Committing changes to add authentication and opac templating to rel-1-2 branch

This commit is contained in:
tonnesen 2002-07-11 18:05:28 +00:00
parent 47c2a429b1
commit 9ed1964576
23 changed files with 1881 additions and 938 deletions

186
C4/Auth.pm Normal file
View File

@ -0,0 +1,186 @@
package C4::Auth;
use strict;
use Digest::MD5 qw(md5_base64);
require Exporter;
use C4::Database;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(
&checkauth
);
sub checkauth {
my $query=shift;
# $authnotrequired will be set for scripts which will run without authentication
my $authnotrequired=shift;
if (my $userid=$ENV{'REMOTE_USERNAME'}) {
# Using Basic Authentication, no cookies required
my $cookie=$query->cookie(-name => 'sessionID',
-value => '',
-expires => '+1y');
return ($userid, $cookie, '');
}
my $sessionID=$query->cookie('sessionID');
my $message='';
my $dbh=C4Connect();
my $sth=$dbh->prepare("select userid,ip,lasttime from sessions where sessionid=?");
$sth->execute($sessionID);
if ($sth->rows) {
my ($userid, $ip, $lasttime) = $sth->fetchrow;
if ($lasttime<time()-45 && $userid ne 'tonnesen') {
# timed logout
$message="You have been logged out due to inactivity.";
my $sti=$dbh->prepare("delete from sessions where sessionID=?");
$sti->execute($sessionID);
my $scriptname=$ENV{'SCRIPT_NAME'};
my $selfurl=$query->self_url();
$sti=$dbh->prepare("insert into sessionqueries (sessionID, userid, value) values (?, ?, ?)");
$sti->execute($sessionID, $userid, $selfurl);
open L, ">>/tmp/sessionlog";
my $time=localtime(time());
printf L "%20s from %16s logged out at %30s (inactivity).\n", $userid, $ip, $time;
close L;
} elsif ($ip ne $ENV{'REMOTE_ADDR'}) {
# Different ip than originally logged in from
my $newip=$ENV{'REMOTE_ADDR'};
$message="ERROR ERROR ERROR ERROR<br>Attempt to re-use a cookie from a different ip address.<br>(authenticated from $ip, this request from $newip)";
} else {
my $cookie=$query->cookie(-name => 'sessionID',
-value => $sessionID,
-expires => '+1y');
my $sti=$dbh->prepare("update sessions set lasttime=? where sessionID=?");
$sti->execute(time(), $sessionID);
return ($userid, $cookie, $sessionID);
}
}
if ($authnotrequired) {
my $cookie=$query->cookie(-name => 'sessionID',
-value => '',
-expires => '+1y');
return('', $cookie, '');
} else {
($sessionID) || ($sessionID=int(rand()*100000).'-'.time());
my $userid=$query->param('userid');
my $password=$query->param('password');
if (checkpw($dbh, $userid, $password)) {
my $sti=$dbh->prepare("delete from sessions where sessionID=? and userid=?");
$sti->execute($sessionID, $userid);
$sti=$dbh->prepare("insert into sessions (sessionID, userid, ip,lasttime) values (?, ?, ?, ?)");
$sti->execute($sessionID, $userid, $ENV{'REMOTE_ADDR'}, time());
$sti=$dbh->prepare("select value from sessionqueries where sessionID=? and userid=?");
$sti->execute($sessionID, $userid);
if ($sti->rows) {
my $stj=$dbh->prepare("delete from sessionqueries where sessionID=?");
$stj->execute($sessionID);
my ($selfurl) = $sti->fetchrow;
print $query->redirect($selfurl);
exit;
}
open L, ">>/tmp/sessionlog";
my $time=localtime(time());
printf L "%20s from %16s logged in at %30s.\n", $userid, $ENV{'REMOTE_ADDR'}, $time;
close L;
my $cookie=$query->cookie(-name => 'sessionID',
-value => $sessionID,
-expires => '+1y');
return ($userid, $cookie, $sessionID);
} else {
if ($userid) {
$message="Invalid userid or password entered.";
}
my $parameters;
foreach (param $query) {
$parameters->{$_}=$query->{$_};
}
my $cookie=$query->cookie(-name => 'sessionID',
-value => $sessionID,
-expires => '+1y');
print $query->header(-cookie=>$cookie);
print qq|
<html>
<body background=/images/kohaback.jpg>
<center>
<h2>$message</h2>
<form method=post>
<table border=0 cellpadding=10 cellspacing=0 width=60%>
<tr><td align=center valign=top>
<table border=0 bgcolor=#dddddd cellpadding=10 cellspacing=0>
<tr><th colspan=2 background=/images/background-mem.gif><font size=+2>Koha Login</font></th></tr>
<tr><td>Name:</td><td><input name=userid></td></tr>
<tr><td>Password:</td><td><input type=password name=password></td></tr>
<tr><td colspan=2 align=center><input type=submit value=login></td></tr>
</table>
</td><td align=center valign=top>
<table border=0 bgcolor=#dddddd cellpadding=10 cellspacing=0>
<tr><th background=/images/background-mem.gif><font size=+2>Demo Information</font></th></tr>
<td>
Log in as librarian/koha or patron/koha. The timeout is set to 40 seconds of
inactivity for the purposes of this demo. You can navigate to the Circulation
or Acquisitions modules and you should see an indicator in the upper left of
the screen saying who you are logged in as. If you want to try it out with
a longer timout period, log in as tonnesen/koha and there will be no
timeout period.
<p>
You can also log in using a patron cardnumber. Try V10000008 and
V1000002X with password koha.
</td>
</tr>
</table>
</td></tr>
</table>
</form>
</body>
</html>
|;
exit;
}
}
}
sub checkpw {
# This should be modified to allow a select of authentication schemes (ie LDAP)
# as well as local authentication through the borrowers tables passwd field
#
my ($dbh, $userid, $password) = @_;
my $sth=$dbh->prepare("select password from borrowers where userid=?");
$sth->execute($userid);
if ($sth->rows) {
my ($md5password) = $sth->fetchrow;
if (md5_base64($password) eq $md5password) {
return 1;
}
}
my $sth=$dbh->prepare("select password from borrowers where cardnumber=?");
$sth->execute($userid);
if ($sth->rows) {
my ($md5password) = $sth->fetchrow;
if (md5_base64($password) eq $md5password) {
return 1;
}
}
return 0;
}
END { } # module clean-up code here (global destructor)

View File

@ -24,6 +24,7 @@ $VERSION = 0.01;
&mkform &mkform2 &bold
&gotopage &mkformnotable &mkform3
&getkeytableselectoptions
&picktemplate
);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
@ -74,6 +75,32 @@ my $path=$configfile{'includes'};
($path) || ($path="/usr/local/www/hdl/htdocs/includes");
# make all your functions, whether exported or not;
sub picktemplate {
my ($includes, $base) = @_;
my $dbh=C4Connect;
my $templates;
opendir (D, "$includes/templates");
my @dirlist=readdir D;
foreach (@dirlist) {
(next) if (/^\./);
#(next) unless (/\.tmpl$/);
(next) unless (-e "$includes/templates/$_/$base");
$templates->{$_}=1;
}
my $sth=$dbh->prepare("select value from systempreferences where
variable='template'");
$sth->execute;
my ($preftemplate) = $sth->fetchrow;
$sth->finish;
$dbh->disconnect;
if ($templates->{$preftemplate}) {
return $preftemplate;
} else {
return 'default';
}
}
sub startpage() {
return("<html>\n");

View File

@ -12,8 +12,8 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&FindReserves &CreateReserve &updatereserves &getreservetitle &Findgroupreserve);
@EXPORT = qw(&FindReserves &CheckReserves &CheckWaiting &CancelReserve &FillReserve &ReserveWaiting &CreateReserve &updatereserves &getreservetitle &Findgroupreserve);
# make all your functions, whether exported or not;
sub FindReserves {
@ -22,7 +22,9 @@ sub FindReserves {
my $query="SELECT *,reserves.branchcode,biblio.title AS btitle
FROM reserves,borrowers,biblio ";
if ($bib ne ''){
if ($bor ne ''){
$bib = $dbh->quote($bib);
if ($bor ne ''){
$bor = $dbh->quote($bor);
$query .= " where reserves.biblionumber = $bib
and borrowers.borrowernumber = $bor
and reserves.borrowernumber = borrowers.borrowernumber
@ -58,6 +60,188 @@ sub FindReserves {
return($i,\@results);
}
sub CheckReserves {
my ($item) = @_;
my $dbh=C4Connect;
my $qitem=$dbh->quote($item);
# get the biblionumber...
my $sth=$dbh->prepare("select biblionumber, biblioitemnumber from items where itemnumber=$qitem");
$sth->execute;
my ($biblio, $bibitem) = $sth->fetchrow_array;
$sth->finish;
$dbh->disconnect;
# get the reserves...
my ($count, @reserves) = Findgroupreserve($bibitem, $biblio);
my $priority = 10000000;
my $highest;
if ($count) {
foreach my $res (@reserves) {
if ($res->{'itemnumber'} == $item) {
return ("Waiting", $res);
} else {
if ($res->{'priority'} < $priority) {
$priority = $res->{'priority'};
$highest = $res;
}
}
}
$highest->{'itemnumber'} = $item;
return ("Reserved", $highest);
} else {
return (0, 0);
}
}
sub CancelReserve {
my ($biblio, $item, $borr) = @_;
my $dbh=C4Connect;
warn "In CancelReserve";
if (($item and $borr) and (not $biblio)) {
# removing a waiting reserve record....
$item = $dbh->quote($item);
$borr = $dbh->quote($borr);
# update the database...
my $query = "update reserves set cancellationdate = now(),
found = Null,
priority = 0
where itemnumber = $item
and borrowernumber = $borr";
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
}
if (($biblio and $borr) and (not $item)) {
# removing a reserve record....
my $q_biblio = $dbh->quote($biblio);
$borr = $dbh->quote($borr);
# fix up the priorities on the other records....
my $query = "SELECT priority FROM reserves
WHERE biblionumber = $q_biblio
AND borrowernumber = $borr
AND cancellationdate is NULL
AND (found <> 'F' or found is NULL)";
my $sth=$dbh->prepare($query);
$sth->execute;
my ($priority) = $sth->fetchrow_array;
$sth->finish;
# update the database, removing the record...
my $query = "update reserves set cancellationdate = now(),
found = Null,
priority = 0
where biblionumber = $q_biblio
and borrowernumber = $borr
and cancellationdate is NULL
and (found <> 'F' or found is NULL)";
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
# now fix the priority on the others....
fixpriority($priority, $biblio);
}
$dbh->disconnect;
}
sub FillReserve {
my ($res) = @_;
my $dbh=C4Connect;
# removing a waiting reserve record....
my $biblio = $res->{'biblionumber'}; my $qbiblio = $dbh->quote($biblio);
my $borr = $res->{'borrowernumber'}; $borr = $dbh->quote($borr);
my $resdate = $res->{'reservedate'}; $resdate = $dbh->quote($resdate);
# update the database...
my $query = "UPDATE reserves SET found = 'F',
priority = 0
WHERE biblionumber = $qbiblio
AND reservedate = $resdate
AND borrowernumber = $borr";
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
# now fix the priority on the others....
fixpriority($res->{'priority'}, $biblio);
}
sub fixpriority {
my ($priority, $biblio) = @_;
my $dbh = C4Connect;
my ($count, $reserves) = FindReserves($biblio);
foreach my $rec (@$reserves) {
if ($rec->{'priority'} > $priority) {
my $newpr = $rec->{'priority'}; $newpr = $dbh->quote($newpr - 1);
my $nbib = $rec->{'biblionumber'}; $nbib = $dbh->quote($nbib);
my $nbor = $rec->{'borrowernumber'}; $nbor = $dbh->quote($nbor);
my $nresd = $rec->{'reservedate'}; $nresd = $dbh->quote($nresd);
my $query = "UPDATE reserves SET priority = $newpr
WHERE biblionumber = $nbib
AND borrowernumber = $nbor
AND reservedate = $nresd";
warn $query;
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
}
}
$dbh->disconnect;
}
sub ReserveWaiting {
my ($item, $borr) = @_;
my $dbh = C4Connect;
$item = $dbh->quote($item);
$borr = $dbh->quote($borr);
# get priority and biblionumber....
my $query = "SELECT reserves.priority as priority,
reserves.biblionumber as biblionumber,
reserves.branchcode as branchcode
FROM reserves,items
WHERE reserves.biblionumber = items.biblionumber
AND items.itemnumber = $item
AND reserves.borrowernumber = $borr
AND reserves.cancellationdate is NULL
AND (reserves.found <> 'F' or reserves.found is NULL)";
my $sth = $dbh->prepare($query);
$sth->execute;
my $data = $sth->fetchrow_hashref;
$sth->finish;
my $biblio = $data->{'biblionumber'};
my $q_biblio = $dbh->quote($biblio);
# update reserves record....
$query = "UPDATE reserves SET priority = 0, found = 'W', itemnumber = $item
WHERE borrowernumber = $borr AND biblionumber = $q_biblio";
$sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
# now fix up the remaining priorities....
fixpriority($data->{'priority'}, $biblio);
my $branchcode = $data->{'branchcode'};
return $branchcode;
}
sub CheckWaiting {
my ($borr)=@_;
my $dbh = C4Connect;
$borr = $dbh->quote($borr);
my @itemswaiting;
my $query = "SELECT * FROM reserves
WHERE borrowernumber = $borr
AND reserves.found = 'W'
AND cancellationdate is NULL";
my $sth = $dbh->prepare($query);
$sth->execute();
my $cnt=0;
if (my $data=$sth->fetchrow_hashref) {
@itemswaiting[$cnt] =$data;
$cnt ++;
}
$sth->finish;
return ($cnt,\@itemswaiting);
}
sub Findgroupreserve {
my ($bibitem,$biblio)=@_;
my $dbh=C4Connect;
@ -82,7 +266,6 @@ sub Findgroupreserve {
OR reserves.constrainttype='a' )
AND reserves.cancellationdate is NULL
AND (reserves.found <> 'F' or reserves.found is NULL)";
# print $query;
my $sth=$dbh->prepare($query);
$sth->execute;
my $i=0;

View File

@ -18,8 +18,8 @@ $VERSION = 0.02;
&borrdata2 &NewBorrowerNumber &bibitemdata &borrissues
&getboracctrecord &ItemType &itemissues &subject &subtitle
&addauthor &bibitems &barcodes &findguarantees &allissues &systemprefs
&findguarantor &branchname);
&findguarantor &getwebsites &getwebbiblioitems &catalogsearch &itemcount2 &branchname);
# make all your functions, whether exported or not;
sub findguarantees{
my ($bornum)=@_;
my $dbh=C4Connect;
@ -80,6 +80,73 @@ sub NewBorrowerNumber {
return($data->{'max(borrowernumber)'});
}
sub catalogsearch {
my ($env,$type,$search,$num,$offset)=@_;
my $dbh = C4Connect();
# foreach my $key (%$search){
# $search->{$key}=$dbh->quote($search->{$key});
# }
my ($count,@results);
# print STDERR "Doing a search \n";
if ($search->{'itemnumber'} ne '' || $search->{'isbn'} ne ''){
print STDERR "Doing a precise search\n";
($count,@results)=CatSearch($env,'precise',$search,$num,$offset);
} else {
if ($search->{'subject'} ne ''){
($count,@results)=CatSearch($env,'subject',$search,$num,$offset);
} else {
if ($search->{'keyword'} ne ''){
($count,@results)=&KeywordSearch($env,'keyword',$search,$num,$offset);
} else {
($count,@results)=CatSearch($env,'loose',$search,$num,$offset);
}
}
}
if ($env->{itemcount}) {
foreach my $data (@results){
my ($counts) = itemcount2($env, $data->{'biblionumber'}, 'intra');
my $subject2=$data->{'subject'};
$subject2=~ s/ /%20/g;
$data->{'itemcount'}=$counts->{'total'};
my $totalitemcounts=0;
foreach my $key (keys %$counts){
if ($key ne 'total'){
#$data->{'location'}.="$key $counts->{$key} ";
$totalitemcounts+=$counts->{$key};
$data->{'locationhash'}->{$key}=$counts->{$key};
}
}
my $locationtext='';
my $notavailabletext='';
foreach (sort keys %{$data->{'locationhash'}}) {
if ($_ eq 'notavailable') {
$notavailabletext="Not available";
my $c=$data->{'locationhash'}->{$_};
if ($totalitemcounts>1) {
$notavailabletext.=" ($c)";
}
} else {
$locationtext.="$_";
my $c=$data->{'locationhash'}->{$_};
if ($totalitemcounts>1) {
$locationtext.=" ($c), ";
}
}
}
if ($notavailabletext) {
$locationtext.=$notavailabletext;
} else {
$locationtext=~s/, $//;
}
$data->{'location'}=$locationtext;
$data->{'subject2'}=$subject2;
}
}
return ($count,@results);
}
sub KeywordSearch {
my ($env,$type,$search,$num,$offset)=@_;
@ -206,7 +273,10 @@ sub KeywordSearch {
}
# print $i4;
if ($i4 <=$end && $i4 > $offset){
$res2[$i3]="$data2->{'author'}\t$data2->{'title'}\t$data2->{'biblionumber'}\t$data2->{'copyrightdate'}\t$dewey";
$data2->{'dewey'}=$dewey;
$res2[$i3]=$data2;
# $res2[$i3]="$data2->{'author'}\t$data2->{'title'}\t$data2->{'biblionumber'}\t$data2->{'copyrightdate'}\t$dewey";
$i3++;
$i4++;
# print "in here $i3<br>";
@ -246,8 +316,10 @@ sub KeywordSearch {
$dewey=~s/\.*0*$//;
($dewey == 0) && ($dewey='');
($dewey) && ($dewey.=" $subclass") ;
$sth->finish;
$res2[$i]="$data2->{'author'}\t$data2->{'title'}\t$data2->{'biblionumber'}\t$data2->{'copyrightdate'}\t$dewey";
$sth->finish;
$data2->{'dewey'}=$dewey;
$res2[$i]=$data2;
# $res2[$i]="$data2->{'author'}\t$data2->{'title'}\t$data2->{'biblionumber'}\t$data2->{'copyrightdate'}\t$dewey";
$i++;
}
$i2++;
@ -467,7 +539,11 @@ sub CatSearch {
#$query=$query. " and (title like '%$search->{'title'}%'
#or seriestitle like '%$search->{'title'}%')";
}
if ($search->{'abstract'} ne ''){
$query.= " and (abstract like '%$search->{'abstract'}%')";
}
$query.=" group by biblio.biblionumber";
} else {
if ($search->{'title'} ne '') {
@ -510,6 +586,9 @@ sub CatSearch {
}
$query=$query."))";
}
if ($search->{'abstract'} ne ''){
$query.= " and (abstract like '%$search->{'abstract'}%')";
}
} elsif ($search->{'class'} ne ''){
$query="select * from biblioitems,biblio where biblio.biblionumber=biblioitems.biblionumber";
my @temp=split(/\|/,$search->{'class'});
@ -530,10 +609,15 @@ sub CatSearch {
where biblio.biblionumber=biblioitems.biblionumber
and biblioitems.dewey like '$search->{'dewey'}%'";
} elsif ($search->{'illustrator'} ne '') {
$query="select * from biblioitems,biblio
$query="select * from biblioitems,biblio
where biblio.biblionumber=biblioitems.biblionumber
and biblioitems.illus like '%".$search->{'illustrator'}."%'";
}
} elsif ($search->{'publisher'} ne ''){
$query.= "Select * from biblio,biblioitems where biblio.biblionumber
=biblioitems.biblionumber and (publishercode like '%$search->{'publisher'}%')";
} elsif ($search->{'abstract'} ne ''){
$query.= "Select * from biblio where abstract like '%$search->{'abstract'}%'";
}
$query .=" group by biblio.biblionumber";
}
}
@ -559,8 +643,9 @@ sub CatSearch {
}
}
if ($type eq 'precise'){
$query="select * from items,biblio ";
if ($search->{'item'} ne ''){
$query="select * from items,biblio ";
my $search2=uc $search->{'item'};
$query=$query." where
items.biblionumber=biblio.biblionumber
@ -584,7 +669,9 @@ sub CatSearch {
$dewey=~s/\.*0*$//;
($dewey == 0) && ($dewey='');
($dewey) && ($dewey.=" $subclass");
$results[$i2]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey\t$data->{'isbn'}\t$data->{'itemtype'}";
$data->{'dewey'}=$dewey;
$results[$i2]=$data;
# $results[$i2]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey\t$data->{'isbn'}\t$data->{'itemtype'}";
$i2++;
$sth->finish;
}
@ -626,7 +713,10 @@ while (my $data=$sth->fetchrow_hashref){
if ($search->{'illustrator'} ne ''){
$query.=" and illus like '%".$search->{'illustrator'}."%' ";
}
#print $query;
if ($search->{'publisher'} ne ''){
$query.= " and (publishercode like '%$search->{'publisher'}%')";
}
#print STDERR "$query\n";
my $sti=$dbh->prepare($query);
$sti->execute;
my $dewey;
@ -638,19 +728,14 @@ while (my $data=$sth->fetchrow_hashref){
$dewey=~s/\.*0*$//;
($dewey == 0) && ($dewey='');
($dewey) && ($dewey.=" $subclass");
$data->{'dewey'}=$dewey;
$sti->finish;
if ($true == 1){
if ($count > $offset && $count <= $limit){
if ($type ne 'subject' && $type ne 'precise'){
$results[$i]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey\t$data->{'illus'}";
} elsif ($search->{'isbn'} ne '' || $search->{'item'} ne ''){
$results[$i]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey\t$data->{'illus'}";
} else {
$results[$i]="$data->{'author'}\t$data->{'subject'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey\t$data->{'illus'}";
if ($count > $offset && $count <= $limit){
$results[$i]=$data;
$i++;
}
$i++;
}
$count++;
$count++;
}
}
$sth->finish;
@ -670,17 +755,56 @@ sub subsearch {
my ($env,$subject)=@_;
my $dbh=C4Connect();
$subject=$dbh->quote($subject);
my $query="Select * from biblio,bibliosubject where
biblio.biblionumber=bibliosubject.biblionumber and
my $query="Select * from biblio,biblioitems,bibliosubject where
biblio.biblionumber=bibliosubject.biblionumber and biblio.biblionumber=biblioitems.biblionumber and
bibliosubject.subject=$subject group by biblio.biblionumber
order by biblio.title";
my $sth=$dbh->prepare($query);
$sth->execute;
my $i=0;
# print $query;
my @results;
while (my $data=$sth->fetchrow_hashref){
$results[$i]="$data->{'title'}\t$data->{'author'}\t$data->{'biblionumber'}";
#$results[$i]="$data->{'title'}\t$data->{'author'}\t$data->{'biblionumber'}";
my $dewey= $data->{'dewey'};
my $subclass=$data->{'subclass'};
$dewey=~s/\.*0*$//;
($dewey == 0) && ($dewey='');
($dewey) && ($dewey.=" $subclass") ;
$data->{'dewey'}=$dewey;
my ($counts) = itemcount2($env, $data->{'biblionumber'}, 'intra');
$data->{'itemcount'}=$counts->{'total'};
my $totalitemcounts=0;
foreach my $key (keys %$counts){
if ($key ne 'total'){
#$data->{'location'}.="$key $counts->{$key} ";
$totalitemcounts+=$counts->{$key};
$data->{'locationhash'}->{$key}=$counts->{$key};
}
}
my $locationtext='';
my $notavailabletext='';
foreach (sort keys %{$data->{'locationhash'}}) {
if ($_ eq 'notavailable') {
$notavailabletext="Not available";
my $c=$data->{'locationhash'}->{$_};
if ($totalitemcounts>1) {
$notavailabletext.=" ($c)";
}
} else {
$locationtext.="$_";
my $c=$data->{'locationhash'}->{$_};
if ($totalitemcounts>1) {
$locationtext.=" ($c), ";
}
}
}
if ($notavailabletext) {
$locationtext.=$notavailabletext;
} else {
$locationtext=~s/, $//;
}
$data->{'location'}=$locationtext;
$results[$i]=$data;
$i++;
}
$sth->finish;
@ -690,19 +814,18 @@ sub subsearch {
sub ItemInfo {
my ($env,$biblionumber,$type)=@_;
my $dbh = &C4Connect;
my $query="Select * from items,biblio,biblioitems,branches
where (items.biblioitemnumber = biblioitems.biblioitemnumber)
and biblioitems.biblionumber=biblio.biblionumber
and biblio.biblionumber='$biblionumber' and branches.branchcode=
items.holdingbranch ";
# print $type;
my ($env,$biblionumber,$type) = @_;
my $dbh = &C4Connect;
my $query = "SELECT * FROM items, biblio, biblioitems
WHERE items.biblionumber = '$biblionumber'
AND biblioitems.biblioitemnumber = items.biblioitemnumber
AND biblio.biblionumber = items.biblionumber";
if ($type ne 'intra'){
$query.=" and (items.itemlost<>1 or items.itemlost is NULL)
$query .= " and ((items.itemlost<>1 and items.itemlost <> 2)
or items.itemlost is NULL)
and (wthdrawn <> 1 or wthdrawn is NULL)";
}
$query=$query."order by items.dateaccessioned desc";
$query .= " order by items.dateaccessioned desc";
my $sth=$dbh->prepare($query);
$sth->execute;
my $i=0;
@ -719,20 +842,29 @@ sub ItemInfo {
my @temp=split('-',$idata->{'date_due'});
$datedue = "$temp[2]/$temp[1]/$temp[0]";
}
if ($data->{'itemlost'} eq '1'){
if ($data->{'itemlost'} eq '1' || $data->{'itemlost'} eq '2'){
$datedue='Itemlost';
}
if ($data->{'wthdrawn'} eq '1'){
$datedue="Cancelled";
}
if ($datedue eq ''){
my ($rescount,$reserves)=Findgroupreserve($data->{'biblioitemnumber'},$biblionumber);
if ($rescount >0){
$datedue='Request';
$datedue="Available";
my ($restype,$reserves)=CheckReserves($data->{'itemnumber'});
if ($restype){
$datedue=$restype;
}
}
$isth->finish;
#get branch information.....
my $bquery = "SELECT * FROM branches
WHERE branchcode = '$data->{'holdingbranch'}'";
my $bsth=$dbh->prepare($bquery);
$bsth->execute;
if (my $bdata=$bsth->fetchrow_hashref){
$data->{'branchname'} = $bdata->{'branchname'};
}
my $class = $data->{'classification'};
my $dewey = $data->{'dewey'};
$dewey =~ s/0+$//;
@ -750,8 +882,10 @@ sub ItemInfo {
# $results[$i]="$data->{'title'}\t$data->{'barcode'}\t$datedue\t$data->{'branchname'}\t$data->{'dewey'}";
my @temp=split('-',$data->{'datelastseen'});
my $date="$temp[2]/$temp[1]/$temp[0]";
$results[$i]="$data->{'title'}\t$data->{'barcode'}\t$datedue\t$data->{'branchname'}\t$class\t$data->{'itemnumber'}\t$data->{'itemtype'}\t$date\t$data->{'biblioitemnumber'}\t$data->{'volumeddesc'}";
# print "$results[$i] <br>";
$data->{'datelastseen'}=$date;
$data->{'datedue'}=$datedue;
$data->{'class'}=$class;
$results[$i]=$data;
$i++;
}
$sth->finish;
@ -763,7 +897,9 @@ sub ItemInfo {
if ($data=$sth2->fetchrow_hashref){
$ocount=$data->{'quantity'} - $data->{'quantityreceived'};
if ($ocount > 0){
$results[$i]="$data->{'title'}\t$data->{'barcode'}\t$ocount\tOn Order\t\t$data->{'itemnumber'}\t$data->{'itemtype'}\t\t$data->{'biblioitemnumber'}\t$data->{'volumeddesc'}";
$data->{'ocount'}=$ocount;
$data->{'order'}="One Order";
$results[$i]=$data;
}
}
$sth2->finish;
@ -826,48 +962,55 @@ sub itemdata {
return($data);
}
sub bibdata {
my ($bibnum,$type)=@_;
my $dbh=C4Connect;
my $query="Select *,biblio.notes
from biblio,biblioitems
left join bibliosubtitle on
biblio.biblionumber=bibliosubtitle.biblionumber
where biblio.biblionumber=$bibnum
and biblioitems.biblionumber=$bibnum";
# print $query;
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$query="Select * from bibliosubject where biblionumber='$bibnum'";
$sth=$dbh->prepare($query);
$sth->execute;
while (my $dat=$sth->fetchrow_hashref){
$data->{'subject'}.=" | $dat->{'subject'}";
}
#print $query;
$sth->finish;
$dbh->disconnect;
return($data);
}
sub bibdata {
my ($bibnum, $type) = @_;
my $dbh = C4Connect;
my $query = "Select *, biblio.notes
from biblio, biblioitems
left join bibliosubtitle on
biblio.biblionumber = bibliosubtitle.biblionumber
where biblio.biblionumber = $bibnum
and biblioitems.biblionumber = $bibnum";
my $sth = $dbh->prepare($query);
my $data;
$sth->execute;
$data = $sth->fetchrow_hashref;
$sth->finish;
$query = "Select * from bibliosubject where biblionumber = '$bibnum'";
$sth = $dbh->prepare($query);
$sth->execute;
while (my $dat = $sth->fetchrow_hashref){
$data->{'subject'} .= " | $dat->{'subject'}";
} # while
$sth->finish;
$dbh->disconnect;
return($data);
} # sub bibdata
sub bibitemdata {
my ($bibitem)=@_;
my $dbh=C4Connect;
my $query="Select *,biblioitems.notes as bnotes from biblio,biblioitems,itemtypes where biblio.biblionumber=
biblioitems.biblionumber and biblioitemnumber=$bibitem and
biblioitems.itemtype=itemtypes.itemtype";
# print $query;
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
my ($bibitem) = @_;
my $dbh = C4Connect;
my $query = "Select *,biblioitems.notes as bnotes from biblio, biblioitems,itemtypes
where biblio.biblionumber = biblioitems.biblionumber
and biblioitemnumber = $bibitem
and biblioitems.itemtype = itemtypes.itemtype";
my $sth = $dbh->prepare($query);
my $data;
$sth->execute;
$data = $sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
} # sub bibitemdata
sub subject {
my ($bibnum)=@_;
@ -889,9 +1032,9 @@ sub subject {
sub addauthor {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $query="Select * from additionalauthors where biblionumber=?";
my $query="Select * from additionalauthors where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
$sth->execute($bibnum);
$sth->execute;
my @results;
my $i=0;
while (my $data=$sth->fetchrow_hashref){
@ -906,9 +1049,9 @@ sub addauthor {
sub subtitle {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $query="Select * from bibliosubtitle where biblionumber=?";
my $query="Select * from bibliosubtitle where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
$sth->execute($bibnum);
$sth->execute;
my @results;
my $i=0;
while (my $data=$sth->fetchrow_hashref){
@ -923,51 +1066,66 @@ sub subtitle {
sub itemissues {
my ($bibitem,$biblio)=@_;
my $dbh=C4Connect;
my $query="Select * from items where
items.biblioitemnumber='$bibitem'";
my $sth=$dbh->prepare($query) || die $dbh->errstr;
$sth->execute || die $sth->errstr;
my $i=0;
my @results;
while (my $data=$sth->fetchrow_hashref) {
my $query2="select * from issues,borrowers where itemnumber=$data->{'itemnumber'}
and returndate is NULL and issues.borrowernumber=borrowers.borrowernumber";
my $sth2=$dbh->prepare($query2);
$sth2->execute;
if (my $data2=$sth2->fetchrow_hashref) {
$data->{'date_due'}=$data2->{'date_due'};
$data->{'card'}=$data2->{'cardnumber'};
} else {
if ($data->{'wthdrawn'} eq '1') {
$data->{'date_due'}='Cancelled';
} else {
$data->{'date_due'}='Available';
}
my ($bibitem, $biblio)=@_;
my $dbh = C4Connect;
my $query = "Select * from items where
items.biblioitemnumber = '$bibitem'";
my $sth = $dbh->prepare($query)
|| die $dbh->errstr;
my $i = 0;
my @results;
$sth->execute
|| die $sth->errstr;
while (my $data = $sth->fetchrow_hashref) {
my $query2 = "select * from issues,borrowers
where itemnumber = $data->{'itemnumber'}
and returndate is NULL
and issues.borrowernumber = borrowers.borrowernumber";
my $sth2 = $dbh->prepare($query2);
$sth2->execute;
if (my $data2 = $sth2->fetchrow_hashref) {
$data->{'date_due'} = $data2->{'date_due'};
$data->{'card'} = $data2->{'cardnumber'};
} else {
if ($data->{'wthdrawn'} eq '1') {
$data->{'date_due'} = 'Cancelled';
} else {
$data->{'date_due'} = 'Available';
} # else
} # else
$sth2->finish;
$query2 = "select * from issues, borrowers
where itemnumber = '$data->{'itemnumber'}'
and issues.borrowernumber = borrowers.borrowernumber
order by date_due desc";
$sth2 = $dbh->prepare($query2)
|| die $dbh->errstr;
$sth2->execute
|| die $sth2->errstr;
for (my $i2 = 0; $i2 < 2; $i2++) {
if (my $data2 = $sth2->fetchrow_hashref) {
$data->{"timestamp$i2"} = $data2->{'timestamp'};
$data->{"card$i2"} = $data2->{'cardnumber'};
$data->{"borrower$i2"} = $data2->{'borrowernumber'};
} # if
} # for
$sth2->finish;
$results[$i] = $data;
$i++;
}
$sth2->finish;
$query2="select * from issues,borrowers where itemnumber='$data->{'itemnumber'}'
and issues.borrowernumber=borrowers.borrowernumber
order by date_due desc";
$sth2=$dbh->prepare($query2) || die $dbh->errstr;
$sth2->execute || die $sth2->errstr;
for (my $i2=0;$i2<2;$i2++){
if (my $data2=$sth2->fetchrow_hashref){
$data->{"timestamp$i2"}=$data2->{'timestamp'};
$data->{"card$i2"}=$data2->{'cardnumber'};
$data->{"borrower$i2"}=$data2->{'borrowernumber'};
}
}
$sth2->finish;
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return(@results);
$sth->finish;
$dbh->disconnect;
return(@results);
}
sub itemnodata {
my ($env,$dbh,$itemnumber) = @_;
$dbh=C4Connect;
@ -1143,13 +1301,14 @@ borrowernumber=$params->{'borrowernumber'} order by date desc,timestamp desc";
return ($numlines,\@acctlines,$total);
}
sub itemcount {
my ($env,$bibnum,$type)=@_;
my $dbh=C4Connect;
my $query="Select * from items where
biblionumber=$bibnum ";
if ($type ne 'intra'){
$query.=" and (itemlost <>1 or itemlost is NULL) and
$query.=" and ((itemlost <>1 and itemlost <> 2) or itemlost is NULL) and
(wthdrawn <> 1 or wthdrawn is NULL)";
}
my $sth=$dbh->prepare($query);
@ -1164,13 +1323,14 @@ sub itemcount {
my $mending=0;
my $transit=0;
my $ocount=0;
my $branchcount;
while (my $data=$sth->fetchrow_hashref) {
while (my $data=$sth->fetchrow_hashref){
$count++;
my $query2="select * from issues,items where issues.itemnumber=
'$data->{'itemnumber'}' and returndate is NULL
and items.itemnumber=issues.itemnumber and (items.itemlost <>1 or
items.itemlost is NULL)";
and items.itemnumber=issues.itemnumber and ((items.itemlost <>1 and
items.itemlost <> 2) or items.itemlost is NULL)
and (wthdrawn <> 1 or wthdrawn is NULL)";
my $sth2=$dbh->prepare($query2);
$sth2->execute;
if (my $data2=$sth2->fetchrow_hashref){
@ -1188,30 +1348,78 @@ sub itemcount {
if ($data->{'itemlost'} eq '1'){
$lostcount++;
}
if ($data->{'itemlost'} eq '2'){
$lostcount++;
}
if ($data->{'holdingbranch'} eq 'FM'){
$mending++;
}
if ($data->{'holdingbranch'} eq 'TR'){
$transit++;
}
unless ($data->{'itemlost'} || $data->{'holdingbranch'} eq 'FM' || $data->{'holdingbranch'} eq 'TR') {
$branchcount->{$data->{'holdingbranch'}}++;
}
}
$sth2->finish;
}
# if ($count == 0){
my $query2="Select * from aqorders where biblionumber=$bibnum";
my $sth2=$dbh->prepare($query2);
$sth2->execute;
if (my $data=$sth2->fetchrow_hashref){
$ocount=$data->{'quantity'} - $data->{'quantityreceived'};
}
# $count+=$ocount;
$sth2->finish;
$sth->finish;
$dbh->disconnect;
return ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount, $branchcount);
return ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount);
}
sub itemcount2 {
my ($env,$bibnum,$type)=@_;
my $dbh=C4Connect;
my $query="Select * from items,branches where
biblionumber=$bibnum and items.holdingbranch=branches.branchcode";
if ($type ne 'intra'){
$query.=" and ((itemlost <>1 and itemlost <> 2) or itemlost is NULL) and
(wthdrawn <> 1 or wthdrawn is NULL)";
}
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
my %counts;
$counts{'total'}=0;
while (my $data=$sth->fetchrow_hashref){
$counts{'total'}++;
my $query2="select * from issues,items where issues.itemnumber=
'$data->{'itemnumber'}' and returndate is NULL
and items.itemnumber=issues.itemnumber and ((items.itemlost <>1 and
items.itemlost <> 2) or items.itemlost is NULL)
and (wthdrawn <> 1 or wthdrawn is NULL)";
my $sth2=$dbh->prepare($query2);
$sth2->execute;
if (my $data2=$sth2->fetchrow_hashref){
$counts{'notavailable'}++;
} else {
$counts{$data->{'branchname'}}++;
}
$sth2->finish;
}
my $query2="Select * from aqorders where biblionumber=$bibnum and
datecancellationprinted is NULL and quantity > quantityreceived";
my $sth2=$dbh->prepare($query2);
$sth2->execute;
if (my $data=$sth2->fetchrow_hashref){
$counts{'order'}=$data->{'quantity'} - $data->{'quantityreceived'};
}
$sth2->finish;
$sth->finish;
$dbh->disconnect;
return (\%counts);
}
sub ItemType {
my ($type)=@_;
my $dbh=C4Connect;
@ -1224,31 +1432,41 @@ sub ItemType {
return ($dat->{'description'});
}
sub bibitems {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $query="Select * from biblioitems,itemtypes,items where
biblioitems.biblionumber='$bibnum' and biblioitems.itemtype=itemtypes.itemtype and
biblioitems.biblioitemnumber=items.biblioitemnumber group by
items.biblioitemnumber";
my $sth=$dbh->prepare($query);
$sth->execute;
my $i=0;
my @results;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
my ($bibnum) = @_;
my $dbh = C4Connect;
my $query = "Select * from biblioitems, itemtypes, items
where biblioitems.biblionumber = '$bibnum'
and biblioitems.itemtype = itemtypes.itemtype
and biblioitems.biblioitemnumber = items.biblioitemnumber
group by items.biblioitemnumber";
my $sth = $dbh->prepare($query);
my $count = 0;
my @results;
$sth->execute;
while (my $data = $sth->fetchrow_hashref) {
$results[$count] = $data;
$count++;
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub bibitems
sub barcodes{
#called from request.pl
my ($biblioitemnumber)=@_;
my $dbh=C4Connect;
my $query="Select barcode from items where
biblioitemnumber='$biblioitemnumber'";
biblioitemnumber='$biblioitemnumber'
and ((itemlost <> 1 and itemlost <> 2) or itemlost is NULL) and
(wthdrawn <> 1 or wthdrawn is NULL)";
my $sth=$dbh->prepare($query);
$sth->execute;
my @barcodes;
@ -1260,8 +1478,52 @@ sub barcodes{
$sth->finish;
$dbh->disconnect;
return(@barcodes);
}
sub getwebsites {
my ($biblionumber) = @_;
my $dbh = C4Connect;
my $query = "Select * from websites where biblionumber = $biblionumber";
my $sth = $dbh->prepare($query);
my $count = 0;
my @results;
$sth->execute;
while (my $data = $sth->fetchrow_hashref) {
$data->{'url'} =~ s/^http:\/\///;
$results[$count] = $data;
$count++;
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getwebsites
sub getwebbiblioitems {
my ($biblionumber) = @_;
my $dbh = C4Connect;
my $query = "Select * from biblioitems where biblionumber = $biblionumber
and itemtype = 'WEB'";
my $sth = $dbh->prepare($query);
my $count = 0;
my @results;
$sth->execute;
while (my $data = $sth->fetchrow_hashref) {
$data->{'url'} =~ s/^http:\/\///;
$results[$count] = $data;
$count++;
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getwebbiblioitems
sub branchname {
my ($branchcode)=@_;
my $dbh=C4Connect;
@ -1277,8 +1539,34 @@ sub branchname {
END { } # module clean-up code here (global destructor)
=head1 NAME
C4::Search - Module that provides Catalog searching for Koha
=head1 SYNOPSIS
use C4::Search;
my ($count,@results)=catalogsearch($env,$type,$search,$num,$offset);
=head1 DESCRIPTION
This module provides the searching facilities for the Catalog.
Here I should go through and document each function thats exported and what it does. But I havent yet.
my ($count,@results)=catalogsearch($env,$type,$search,$num,$offset);
This is a front end to all the other searches, depending on what is passed
to it, it calls the appropriate search
=head2 EXPORT
catalogsearch
=head1 AUTHOR
Koha Developement team <info@koha.org>
=head1 SEE ALSO
L<perl>.
=cut

View File

@ -20,17 +20,23 @@ use C4::Acquisitions;
use C4::Biblio;
use C4::Output;
use C4::Circulation::Circ2;
use C4::Auth;
my $input = new CGI;
my ($loggedinuser, $sessioncookie, $sessionID) = checkauth($input);
my $dbh=C4Connect;
my $isbn=$input->param('isbn');
my $q_isbn=$dbh->quote($isbn);
my $biblioitemnumber;
print $input->header;
print $input->header(-cookie=>$sessioncookie);
print startpage();
print startmenu('acquisitions');
print "<p align=left>Logged in as: $loggedinuser [<a href=/cgi-bin/koha/logout.pl>Log Out</a>]</p>\n";
($input->param('checkforbiblio')) && (checkforbiblio());
($input->param('newbiblioitem')) && (newbiblioitem());

View File

@ -23,8 +23,10 @@ use C4::Input;
use C4::Biblio;
use C4::SimpleMarc;
use C4::Z3950;
use C4::Auth;
my $input = new CGI;
my ($loggedinuser, $cookie, $sessionID) = checkauth($input);
#------------------
# Constants
@ -43,10 +45,11 @@ my $dbh=C4Connect;
#-------------
# Display output
print $input->header();
print $input->header(-cookie => $cookie);
print startpage();
print startmenu('acquisitions');
print "<p align=left>Logged in as: $loggedinuser [<a href=/cgi-bin/koha/logout.pl>Log Out</a>]</p>\n";
#-------------
# Process input parameters
@ -1146,6 +1149,9 @@ sub FormatMarcText {
#---------------
# $Log$
# Revision 1.6.2.35 2002/07/11 18:05:29 tonnesen
# Committing changes to add authentication and opac templating to rel-1-2 branch
#
# Revision 1.6.2.34 2002/07/05 19:30:14 amillar
# Second arg of requireDBI is calling subroutine name
#

27
admin-home.pl Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Auth;
use C4::Output;
my $query = new CGI;
my ($loggedinuser, $cookie, $sessionID) = checkauth($query);
print $query->header(-cookie => $cookie);
print startpage();
print startmenu('catalogue');
print "<p align=left>Logged in as: $loggedinuser [<a href=/cgi-bin/koha/logout.pl>Log Out</a>]</p>\n";
open H, "/usr/local/koha/intranet/htdocs/admin/index.html";
while (<H>) {
print $_;
}
close H;
print endpage();
print endmenu('catalogue');

58
admin/templates.pl Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/perl
#script to administer the systempref table
#written 20/02/2002 by paul.poulain@free.fr
# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
use strict;
use C4::Output;
use CGI;
use C4::Search;
use C4::Database;
use C4::Auth;
my $input = new CGI;
my $dbh=C4Connect();
if ($input->param('settemplate')) {
my $sth=$dbh->prepare("update systempreferences set value=? where variable='template'");
$sth->execute($input->param('settemplate'));
print $input->redirect('/cgi-bin/koha/catalogue-home.pl');
exit;
}
print $input->header();
print startpage();
print startmenu('catalogue');
my $sth=$dbh->prepare("select value from systempreferences where variable='template'");
$sth->execute;
my ($template)=$sth->fetchrow;
my $templateoptions='';
opendir D, "/usr/local/koha/intranet/htdocs/includes/templates";
my @dirlist=readdir D;
foreach (@dirlist) {
(next) if (/^\./);
my $selected='';
($_ eq $template) && ($selected=' selected');
$templateoptions.="<option value=$_$selected> $_\n";
}
print qq|
<form method=get>
Template: <select name=settemplate>
$templateoptions
</select>
<p>
<input type=submit value="Set Template">
</form>
|;
print endmenu('catalogue');
print endpage();

286
admin/z3950servers.pl Executable file
View File

@ -0,0 +1,286 @@
#!/usr/bin/perl
#script to administer the branches table
#written 20/02/2002 by paul.poulain@free.fr
# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
# ALGO :
# this script use an $op to know what to do.
# if $op is empty or none of the above values,
# - the default screen is build (with all records, or filtered datas).
# - the user can clic on add, modify or delete record.
# if $op=add_form
# - if primkey exists, this is a modification,so we read the $primkey record
# - builds the add/modify form
# if $op=add_validate
# - the user has just send datas, so we create/modify the record
# if $op=delete_form
# - we show the record having primkey=$primkey and ask for deletion validation form
# if $op=delete_confirm
# - we delete the record having primkey=$primkey
use strict;
use C4::Output;
use CGI;
use C4::Search;
use C4::Database;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
my $query="Select host,port,db,userid,password,name,id,checked,rank from z3950servers where (name like "$data[0]%\") order by rank,name";
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;
my $cnt=0;
while (my $data=$sth->fetchrow_hashref) {
push(@results,$data);
$cnt ++;
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
my $input = new CGI;
my $searchfield=$input->param('searchfield');
my $reqsel="select host,port,db,userid,password,name,id,checked,rank from z3950servers where (name = '$searchfield') order by rank,name";
my $reqdel="delete from z3950servers where name='$searchfield'";
my $offset=$input->param('offset');
my $script_name="/cgi-bin/koha/admin/z3950servers.pl";
my $pagesize=20;
my $op = $input->param('op');
$searchfield=~ s/\,//g;
print $input->header;
#start the page and read in includes
print startpage();
print startmenu('admin');
################## ADD_FORM ##################################
# called by default. Used to create form to add or modify a record
if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($searchfield) {
my $dbh = &C4Connect;
my $sth=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank from z3950servers where (name = '$searchfield') order by rank,name");
$sth->execute;
$data=$sth->fetchrow_hashref;
$sth->finish;
}
print <<printend
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function isNotNull(f,noalert) {
if (f.value.length ==0) {
return false;
}
return true;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function toUC(f) {
var x=f.value.toUpperCase();
f.value=x;
return true;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function isNum(v,maybenull) {
var n = new Number(v.value);
if (isNaN(n)) {
return false;
}
if (maybenull==0 && v.value=='') {
return false;
}
return true;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function isDate(f) {
var t = Date.parse(f.value);
if (isNaN(t)) {
return false;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function Check(f) {
var ok=1;
var _alertString="";
var alertString2;
if (f.searchfield.value.length==0) {
_alertString += "- branch code missing\\n";
}
if (f.branchname.value.length==0) {
_alertString += "- branch name missing\\n";
}
if (_alertString.length==0) {
document.Aform.submit();
} else {
alertString2 = "Form not submitted because of the following problem(s)\\n";
alertString2 += "------------------------------------------------------------------------------------\\n\\n";
alertString2 += _alertString;
alert(alertString2);
}
}
</SCRIPT>
printend
;#/
if ($searchfield) {
print "<h1>Modify Z39.50 Server</h1>";
} else {
print "<h1>Add Z39.50 Server</h1>";
}
print "<form action='$script_name' name=Aform method=post>";
print "<input type=hidden name=op value='add_validate'>";
print "<table>";
if ($searchfield) {
print "<tr><td>Z39.50 Server</td><td><input type=hidden name=searchfield value=$searchfield>$searchfield</td></tr>";
} else {
print "<tr><td>Z39.50 Server</td><td><input type=text name=searchfield size=5 maxlength=5></td></tr>";
}
print "<tr><td>Hostname</td><td><input type=text name=host size=40 maxlength=80 value='$data->{'host'}'></td></tr>";
print "<tr><td>Port</td><td><input type=text name=port value='$data->{'port'}' onBlur=isNum(this)></td></tr>";
print "<tr><td>Database</td><td><input type=text name=db value='$data->{'db'}'></td></tr>";
print "<tr><td>Userid</td><td><input type=text name=userid value='$data->{'userid'}'></td></tr>";
print "<tr><td>Password</td><td><input type=text name=password value='$data->{'password'}'></td></tr>";
print "<tr><td>Checked (searched by default)</td><td><input type=text name=checked value='$data->{'checked'}' onBlur=isNum(this)></td></tr>";
print "<tr><td>Rank (display order)</td><td><input type=text name=rank value='$data->{'rank'}' onBlur=isNum(this)></td></tr>";
print "<tr><td>&nbsp;</td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>";
print "</table>";
print "</form>";
;
# END $OP eq ADD_FORM
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh=C4Connect;
my $query = "replace branches (branchcode,branchname,branchaddress1,branchaddress2,branchaddress3,branchphone,branchfax,branchemail,issuing) values (";
$query.= $dbh->quote($input->param('searchfield')).",";
$query.= $dbh->quote($input->param('branchname')).",";
$query.= $dbh->quote($input->param('branchaddress1')).",";
$query.= $dbh->quote($input->param('branchaddress2')).",";
$query.= $dbh->quote($input->param('branchaddress3')).",";
$query.= $dbh->quote($input->param('branchphone')).",";
$query.= $dbh->quote($input->param('branchfax')).",";
$query.= $dbh->quote($input->param('branchemail')).",";
$query.= $dbh->quote($input->param('issuing')).")";
my $query="replace z3950servers (host,port,db,userid,password,name,checked,rank) values (?, ?, ?, ?, ?, ?, ?, ?)");
my $sth=$dbh->prepare($query);
$sth->execute($input->param('host'),
$input->param('port'),
$input->param('db'),
$input->param('userid'),
$input->param('password'),
$input->param('searchfield'),
$input->param('checked'),
$input->param('rank'),
);
$sth->finish;
print "data recorded";
print "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# END $OP eq ADD_VALIDATE
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
my $dbh = &C4Connect;
my $sth=$dbh->prepare("select count(*) as total from borrowers where branchcode='$searchfield'");
$sth->execute;
my $total = $sth->fetchrow_hashref;
$sth->finish;
print "$reqsel";
my $sth=$dbh->prepare($reqsel);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
print mktablehdr;
print mktablerow(2,'#99cc33',bold('Branch code'),bold("$searchfield"),'/images/background-mem.gif');
print "<form action='$script_name' method=post><input type=hidden name=op value=delete_confirmed><input type=hidden name=searchfield value='$searchfield'>";
print "<tr><td>Branch code</td><td>$data->{'branchcode'}</td></tr>";
print "<tr><td>&nbsp; name</td><td>$data->{'branchname'}</td></tr>";
print "<tr><td>&nbsp; adress</td><td>$data->{'branchaddress1'}</td></tr>";
print "<tr><td>&nbsp;</td><td>$data->{'branchaddress2'}</td></tr>";
print "<tr><td>&nbsp;</td><td>$data->{'branchaddress3'}</td></tr>";
print "<tr><td>&nbsp;phone</td><td>$data->{'branchphone'}</td></tr>";
print "<tr><td>&nbsp; fax</td><td>$data->{'branchfax'}</td></tr>";
print "<tr><td>&nbsp; e-mail</td><td>$data->{'branchemail'}</td></tr>";
print "<tr><td>&nbsp; issuing</td><td>$data->{'issuing'}</td></tr>";
if ($total->{'total'} >0) {
print "<tr><td colspan=2 align=center><b>This record is used $total->{'total'} times. Deletion not possible</b></td></tr>";
print "<tr><td colspan=2></form><form action='$script_name' method=post><input type=submit value=OK></form></td></tr>";
} else {
print "<tr><td colspan=2 align=center>CONFIRM DELETION</td></tr>";
print "<tr><td><INPUT type=submit value='YES'></form></td><td><form action='$script_name' method=post><input type=submit value=NO></form></td></tr>";
}
# END $OP eq DELETE_CONFIRM
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
my $dbh=C4Connect;
# my $searchfield=$input->param('branchcode');
my $sth=$dbh->prepare($reqdel);
$sth->execute;
$sth->finish;
print "data deleted";
print "<form action='$script_name' method=post>";
print "<input type=submit value=OK>";
print "</form>";
# END $OP eq DELETE_CONFIRMED
################## DEFAULT ##################################
} else { # DEFAULT
my @inputs=(["text","searchfield",$searchfield],
["reset","reset","clr"]);
print mkheadr(2,'branches admin');
print mkformnotable("$script_name",@inputs);
print <<printend
printend
;
if ($searchfield ne '') {
print "You Searched for <b>$searchfield<b><p>";
}
print mktablehdr;
print mktablerow(9,'#99cc33',bold('Branch code'),bold('Name'),bold('Address'),
bold('Phone'),bold('Fax'),bold('E-mail'),bold('Issuing'),
'&nbsp;','&nbsp;','/images/background-mem.gif');
my $env;
my ($count,$results)=StringSearch($env,$searchfield,'web');
my $toggle="white";
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
#find out stats
# my ($od,$issue,$fines)=categdata2($env,$results->[$i]{'borrowernumber'});
# $fines=$fines+0;
if ($toggle eq 'white'){
$toggle="#ffffcc";
} else {
$toggle="white";
}
print mktablerow(9,$toggle,$results->[$i]{'branchcode'},$results->[$i]{'branchname'},
$results->[$i]{'branchaddress1'}.$results->[$i]{'branchaddress2'}.$results->[$i]{'branchaddress3'},
$results->[$i]{'branchphone'},,$results->[$i]{'branchfax'},,$results->[$i]{'branchemail'},,$results->[$i]{'issuing'},
mklink("$script_name?op=add_form&searchfield=".$results->[$i]{'branchcode'},'Edit'),
mklink("$script_name?op=delete_confirm&searchfield=".$results->[$i]{'branchcode'},'Delete'));
}
print mktableft;
print "<form action='$script_name' method=post>";
print "<input type=hidden name=op value=add_form>";
if ($offset>0) {
my $prevpage = $offset-$pagesize;
print mklink("$script_name?offset=".$prevpage,'&lt;&lt; Prev');
}
print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
if ($offset+$pagesize<$count) {
my $nextpage =$offset+$pagesize;
print mklink("$script_name?offset=".$nextpage,'Next &gt;&gt;');
}
print "<br><input type=image src=\"/images/button-add-new.gif\" WIDTH=188 HEIGHT=44 ALT=\"Add budget\" BORDER=0 ></a><br>";
print "</form>";
} #---- END $OP eq DEFAULT
print endmenu('admin');
print endpage();

32
catalogue-home.pl Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Auth;
use C4::Output;
my $query = new CGI;
my ($loggedinuser, $cookie, $sessionID) = checkauth($query);
print $query->header(-cookie => $cookie);
print startpage();
print startmenu('catalogue');
print "<p align=left>Logged in as: $loggedinuser [<a href=/cgi-bin/koha/logout.pl>Log Out</a>]</p>\n";
my $classlist='';
open C, "/usr/local/koha/intranet/htdocs/includes/cat-class-list.inc";
while (<C>) {
$classlist.=$_;
}
open H, "/usr/local/koha/intranet/htdocs/catalogue/index.html";
while (<H>) {
s/<!-- CLASSLIST -->/$classlist/;
print $_;
}
close H;
print endpage();
print endmenu('catalogue');

View File

@ -5,7 +5,10 @@ use C4::Circulation::Circ2;
use C4::Output;
use C4::Print;
use DBI;
use C4::Auth;
my $query=new CGI;
my ($loggedinuser, $sessioncookie, $sessionID) = checkauth($query);
my %env;
my $headerbackgroundcolor='#99cc33';
@ -14,7 +17,6 @@ my $circbackgroundcolor='white';
my $linecolor1='#ffffcc';
my $linecolor2='white';
my $backgroundimage="/images/background-mem.gif";
my $query=new CGI;
my $branches=getbranches(\%env);
my $printers=getprinters(\%env);
my $branch=$query->param('branch');
@ -70,7 +72,7 @@ if ($branch && $printer) {
my $branchcookie=$query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y');
my $printercookie=$query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y');
print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie]);
print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie,$sessioncookie]);
#print $query->dump;
print startpage();
#print startmenu('circulation');
@ -83,6 +85,7 @@ if ($query->param('module') eq 'issues' && $query->param('barcode') eq '' && $qu
}
}
print @inp;
print "<p align=left>Logged in as: $loggedinuser [<a href=/cgi-bin/koha/logout.pl>Log Out</a>]</p>\n";
print <<EOF
<script language="javascript" type="text/javascript">
@ -822,7 +825,7 @@ EOF
<form method=get>
<table border=0 cellpadding=5 cellspacing=0 bgcolor=#dddddd>
<tr><th bgcolor=$headerbackgroundcolor background=$backgroundimage><font color=black><b>Enter borrower card number<br> or partial last name</b></font></td></tr>
<tr><td><input name=findborrower></td></tr>
<tr><td><input name=findborrower> <input type=submit value=Go></td></tr>
</table>
<input type=hidden name=module value=issues>
<input type=hidden name=branch value=$branch>

View File

@ -6,11 +6,15 @@ use C4::Circulation::Circ2;
use C4::Output;
use C4::Print;
use DBI;
use C4::Auth;
# this is a reorganisation of circulation.pl
# dividing it up into three scripts......
# this will be the first one that chooses branch and printer settings....
my $query=new CGI;
my ($loggedinuser, $sessioncookie, $sessionID) = checkauth($query);
my %env;
my $headerbackgroundcolor='#99cc33';
@ -20,7 +24,6 @@ my $linecolor1='#ffffcc';
my $linecolor2='white';
my $backgroundimage="/images/background-mem.gif";
my $query=new CGI;
my $branches=getbranches(\%env);
my $printers=getprinters(\%env);
my $branch=$query->param('branch');
@ -107,11 +110,12 @@ EOF
# set header with cookie....
print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie]);
print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie,$sessioncookie]);
print startpage();
print startmenu('circulation');
print "<p align=left>Logged in as: $loggedinuser [<a href=logout.pl>Log Out</a>]</p>\n";
if ($branch and $printer) {
print << "EOF";

322
detail.pl
View File

@ -1,250 +1,94 @@
#!/usr/bin/perl
#script to display detailed information
#written 8/11/99
use HTML::Template;
use strict;
#use DBI;
use C4::Search;
require Exporter;
use C4::Database;
use C4::Output; # contains picktemplate
use CGI;
use C4::Output;
my $input = new CGI;
print $input->header;
#whether it is called from the opac of the intranet
my $type=$input->param('type');
if ($type eq ''){
$type='intra';
}
#setup colours
my $main;
my $secondary;
if ($type eq 'opac'){
$main='#99cccc';
$secondary='#efe5ef';
} else {
$main='#cccc99';
$secondary='#ffffcc';
}
print startpage();
print startmenu($type);
#print $type;
my $blah;
my $bib=$input->param('bib');
my $title=$input->param('title');
if ($type ne 'opac'){
print "<a href=request.pl?bib=$bib><img height=42 WIDTH=120 BORDER=0 src=\"/images/requests.gif\" align=right border=0></a>";
}
use C4::Search;
use C4::Auth;
my $query=new CGI;
my $type=$query->param('type');
($type) || ($type='intra');
my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') ? (1) : (0));
my @items=ItemInfo(\$blah,$bib,$type);
my $dat=bibdata($bib);
my $count=@items;
my ($count3,$addauthor)=addauthor($bib);
my $additional=$addauthor->[0]->{'author'};
for (my $i=1;$i<$count3;$i++){
$additional=$additional."|".$addauthor->[$i]->{'author'};
}
my @temp=split('\t',$items[0]);
if ($type eq 'catmain'){
print mkheadr(3,"Catalogue Maintenance");
}
if ($dat->{'author'} ne ''){
print mkheadr(3,"$dat->{'title'} ($dat->{'author'}) $temp[4]");
} else {
print mkheadr(3,"$dat->{'title'} $temp[4]");
}
print <<printend
<TABLE CELLSPACING=0 CELLPADDING=5 border=1 align=left width="220">
<!-----------------BIBLIO RECORD TABLE--------->
my $language='french';
<form action=/cgi-bin/koha/modbib.pl method=post>
<input type=hidden name=bibnum value=$bib>
<TR VALIGN=TOP>
<td bgcolor="$main"
printend
;
if ($type ne 'opac'){
print "background=\"/images/background-mem.gif\"";
}
print <<printend
><B>BIBLIO RECORD
printend
;
if ($type ne 'opac'){
print "$bib";
}
print <<printend
</TD></TR>
<tr VALIGN=TOP >
<TD>
printend
;
if ($type ne 'opac'){
print "<INPUT TYPE=\"image\" name=\"submit\" VALUE=\"modify\" height=42 WIDTH=93 BORDER=0 src=\"/images/modify-mem.gif\">
<INPUT TYPE=\"image\" name=\"delete\" VALUE=\"delete\" height=42 WIDTH=93 BORDER=0 src=\"/images/delete-mem.gif\">";
}
print <<printend
<br>
<FONT SIZE=2 face="arial, helvetica">
printend
;
if ($type ne 'opac'){
print <<printend
<b>Subtitle:</b> $dat->{'subtitle'}<br>
<b>Author:</b> $dat->{'author'}<br>
<b>Additional Author:</b> $additional<br>
<b>Series Title:</b> $dat->{'seriestitle'}<br>
<b>Subject:</b> $dat->{'subject'}<br>
<b>Copyright:</b> $dat->{'copyrightdate'}<br>
<b>Notes:</b> $dat->{'notes'}<br>
<b>Unititle:</b> $dat->{'unititle'}<br>
<b>Analytical Author:</b> <br>
<b>Analytical Title:</b> <br>
<b>Serial:</b> $dat->{'serial'}<br>
<b>Total Number of Items:</b> $count
<p>
printend
;
}
else {
if ($dat->{'subtitle'} ne ''){
print "<b>Subtitle:</b> $dat->{'subtitle'}<br>";
}
if ($dat->{'author'} ne ''){
print "<b>Author:</b> $dat->{'author'}<br>";
}
#Additional Author: <br>
if ($dat->{'seriestitle'} ne ''){
print "<b>Seriestitle:</b> $dat->{'seriestitle'}<br>";
}
if ($dat->{'subject'} ne ''){
print "<b>Subject:</b> $dat->{'subject'}<br>";
}
if ($dat->{'copyrightdate'} ne ''){
print "<b>Copyright:</b> $dat->{'copyrightdate'}<br>";
}
if ($dat->{'notes'} ne ''){
print "<b>Notes:</b> $dat->{'notes'}<br>";
}
if ($dat->{'unititle'} ne ''){
print "<b>Unititle:</b> $dat->{'unititle'}<br>";
}
#Analytical Author: <br>
#Analytical Title: <br>
if ($dat->{'serial'} ne '0'){
print "<b>Serial:</b> Yes<br>";
}
print "<b>Total Number of Items:</b> $count
<p>
";
}
print <<printend
</form>
</font></TD>
</TR>
</TABLE>
<img src="/images/holder.gif" width=16 height=300 align=left>
printend
;
#print @items;
my $i=0;
print center();
print mktablehdr;
if ($type eq 'opac'){
print mktablerow(6,$main,'Item Type','Class','Branch','Date Due','Last Seen');
} else {
print mktablerow(6,$main,'Itemtype','Class','Location','Date Due','Last Seen','Barcode',"/images/background-mem.gif");
}
my $colour=1;
while ($i < $count){
# print $items[$i],"<br>";
my @results=split('\t',$items[$i]);
if ($type ne 'opac'){
$results[1]=mklink("/cgi-bin/koha/moredetail.pl?item=$results[5]&bib=$bib&bi=$results[8]&type=$type",$results[1]);
}
if ($results[2] eq ''){
$results[2]='Available';
}
if ($type eq 'catmain'){
$results[10]=mklink("/cgi-bin/koha/maint/catmaintain.pl?type=fixitemtype&bi=$results[8]&item=$results[6]","Fix Itemtype");
}
if ($colour == 1){
if ($type ne 'opac'){
if ($type eq 'catmain'){
print mktablerow(8,$secondary,$results[6],$results[4],$results[3],$results[2],$results[7],$results[1],$results[9],$results[10]);
} else {
print mktablerow(7,$secondary,$results[6],$results[4],$results[3],$results[2],$results[7],$results[1],$results[9]);
}
} else {
$results[6]=ItemType($results[6]);
print mktablerow(6,$secondary,$results[6],$results[4],$results[3],$results[2],$results[7],$results[9]);
}
$colour=0;
} else{
if ($type ne 'opac'){
if ($type eq 'catmain'){
print mktablerow(8,'white',$results[6],$results[4],$results[3],$results[2],$results[7],$results[1],$results[9],$results[10]);
} else {
print mktablerow(7,'white',$results[6],$results[4],$results[3],$results[2],$results[7],$results[1],$results[9]);
}
} else {
$results[6]=ItemType($results[6]);
print mktablerow(6,'white',$results[6],$results[4],$results[3],$results[2],$results[7],$results[9]);
}
$colour=1;
}
$i++;
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
print mktableft();
print "<p>";
print mktablehdr();
if ($type ne 'opac'){
print <<printend
<TR VALIGN=TOP>
<TD bgcolor="99cc33" background="/images/background-mem.gif" colspan=2><p><b>HELP</b><br>
<b>Update Biblio for all Items:</b> Click on the <b>Modify</b> button [left] to amend the biblio. Any changes you make will update the record for <b>all</b> the items listed above. <p>
<b>Updating the Biblio for only ONE or SOME Items:</b>
printend
;
if ($type eq 'catmain'){
print <<printend
If some of the items listed above need a different biblio,
you need to click on the wrong item, then shift the group it belongs to, to the correct biblio.
You will need to know the correct biblio number
<p>
my $biblionumber=$query->param('bib');
</TR>
printend
;
} else {
print <<printend
If some of the items listed above need a different biblio, or are on the wrong biblio, you must use the <a href="/cgi-bin/koha/loadmodules.pl?module=acquisitions">acquisitions</a> process to fix this. You will need to "re-order" the items, and delete them from this biblio.
<p>
</TR>
printend
;
}
}
print mktableft();
print endcenter();
print "<br clear=all>";
print endmenu($type);
print endpage();
# change back when ive fixed request.pl
my @items = ItemInfo(undef, $biblionumber, $type);
my $dat=bibdata($biblionumber);
my ($authorcount, $addauthor)= &addauthor($biblionumber);
my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
my ($websitecount, @websites) = &getwebsites($biblionumber);
$dat->{'count'}=@items;
$dat->{'additional'}=$addauthor->[0]->{'author'};
for (my $i = 1; $i < $authorcount; $i++) {
$dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
} # for
my @results;
$results[0]=$dat;
my $resultsarray=\@results;
my $itemsarray=\@items;
my $webarray=\@webbiblioitems;
my $sitearray=\@websites;
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $templatebase="catalogue/detail.tmpl";
($type eq 'opac') && ($templatebase="catalogue/detail-opac.tmpl");
my $startfrom=$query->param('startfrom');
($startfrom) || ($startfrom=0);
my $theme=picktemplate($includes, $templatebase);
my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
my $count=1;
# now to get the items into a hash we can use and whack that thru
$template->param(startfrom => $startfrom+1);
$template->param(endat => $startfrom+20);
$template->param(numrecords => $count);
my $nextstartfrom=($startfrom+20<$count-20) ? ($startfrom+20) : ($count-20);
my $prevstartfrom=($startfrom-20>0) ? ($startfrom-20) : (0);
$template->param(nextstartfrom => $nextstartfrom);
$template->param(prevstartfrom => $prevstartfrom);
# $template->param(template => $templatename);
# $template->param(search => $search);
$template->param(includesdir => $includes);
$template->param(BIBLIO_RESULTS => $resultsarray);
$template->param(ITEM_RESULTS => $itemsarray);
$template->param(WEB_RESULTS => $webarray);
$template->param(SITE_RESULTS => $sitearray);
$template->param(loggedinuser => $loggedinuser);
print $query->header(-cookie => $cookie), $template->output;

66
logout.pl Executable file
View File

@ -0,0 +1,66 @@
#!/usr/bin/perl
use CGI;
use C4::Database;
my $query=new CGI;
my $sessionID=$query->cookie('sessionID');
my $sessions;
open (S, "/tmp/sessions");
while (my ($sid, $u, $lasttime) = split(/:/, <S>)) {
chomp $lasttime;
(next) unless ($sid);
(next) if ($sid eq $sessionID);
$sessions->{$sid}->{'userid'}=$u;
$sessions->{$sid}->{'lasttime'}=$lasttime;
}
open (S, ">/tmp/sessions");
foreach (keys %$sessions) {
my $userid=$sessions->{$_}->{'userid'};
my $lasttime=$sessions->{$_}->{'lasttime'};
print S "$_:$userid:$lasttime\n";
}
my $dbh=C4Connect;
# Check that this is the ip that created the session before deleting it
my $sth=$dbh->prepare("select userid,ip from sessions where sessionID=?");
$sth->execute($sessionID);
my ($userid, $ip);
if ($sth->rows) {
($userid,$ip) = $sth->fetchrow;
if ($ip ne $ENV{'REMOTE_ADDR'}) {
# attempt to logout from a different ip than cookie was created at
exit;
}
}
$sth=$dbh->prepare("delete from sessions where sessionID=?");
$sth->execute($sessionID);
open L, ">>/tmp/sessionlog";
my $time=localtime(time());
printf L "%20s from %16s logged out at %30s (manual log out).\n", $userid, $ip, $time;
close L;
my $cookie=$query->cookie(-name => 'sessionID',
-value => '',
-expires => '+1y');
# Should redirect to intranet home page after logging out
print $query->redirect("mainpage.pl");
exit;
if ($sessionID) {
print "Logged out of $sessionID<br>\n";
print "<a href=shelves.pl>Login</a>";
} else {
print "Not logged in.<br>\n";
print "<a href=shelves.pl>Login</a>";
}

38
mainpage.pl Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/perl
use HTML::Template;
use strict;
require Exporter;
use C4::Database;
use C4::Output; # contains picktemplate
use CGI;
use C4::Auth;
my $query = new CGI;
my ($loggedinuser, $cookie, $sessionID) = checkauth($query);
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $templatebase="catalogue/intranet-main.tmpl";
my $theme=picktemplate($includes, $templatebase);
my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
#$template->param(SITE_RESULTS => $sitearray);
print "Content-Type: text/html\n\n", $template->output;

72
member-password.pl Executable file
View File

@ -0,0 +1,72 @@
#!/usr/bin/perl
#script to delete items
#written 2/5/00
#by chris@katipo.co.nz
use strict;
use C4::Search;
use CGI;
use Digest::MD5 qw(md5_base64);
use C4::Output;
use C4::Database;
use C4::Circulation::Circ2;
#use C4::Acquisitions;
my $input = new CGI;
#print $input->header;
my $member=$input->param('member');
my %env;
$env{'nottodayissues'}=1;
my %member2;
$member2{'borrowernumber'}=$member;
my $issues=currentissues(\%env,\%member2);
my $i=0;
foreach (sort keys %$issues) {
$i++;
}
if ($input->param('newpassword')) {
my $digest=md5_base64($input->param('newpassword'));
my $dbh=C4Connect();
my $sth=$dbh->prepare("update borrowers set password=? where borrowernumber=?");
$sth->execute($digest, $member);
warn "$member $digest";
print $input->redirect("/members/");
} else {
my ($bor,$flags)=getpatroninformation(\%env, $member,'');
my $chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
my $length=int(rand(2))+4;
my $defaultnewpassword='';
for (my $i=0; $i<$length; $i++) {
$defaultnewpassword.=substr($chars, int(rand(length($chars))),1);
}
my $spellitout=$defaultnewpassword;
$spellitout=~s/l/\001/g;
$spellitout=~s/1/\002/g;
$spellitout=~s/O/\003/g;
$spellitout=~s/o/\004/g;
$spellitout=~s/0/\005/g;
$spellitout=~s/\001/ <b>el<\/b> /g;
$spellitout=~s/\002/ <b>one<\/b> /g;
$spellitout=~s/\003/ <b>Oh<\/b> /g;
$spellitout=~s/\004/ <b>oh<\/b> /g;
$spellitout=~s/\005/ <b>zero<\/b> /g;
print $input->header;
print startpage();
print startmenu('member');
print qq|
<h2>$bor->{'surname'}, $bor->{'firstname'}</h2>
<form method=post>
<input type=hidden name=member value=$member>
New Password: <input name=newpassword size=20 value=$defaultnewpassword> (default is $spellitout)
<p>
<input type=submit value="Set Password">
</form>
|;
print endmenu('member');
print endpage();
}

View File

@ -18,8 +18,11 @@ if ($member eq ''){
my $type=$input->param('type');
my $modify=$input->param('modify.x');
my $delete=$input->param('delete.x');
my $password=$input->param('password.x');
if ($delete){
print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$member");
} elsif ($password) {
print $input->redirect("/cgi-bin/koha/member-password.pl?member=$member");
} else {
print $input->header;
print startpage();

26
members-home.pl Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Auth;
use C4::Output;
my $query = new CGI;
my ($loggedinuser, $cookie, $sessionID) = checkauth($query);
print $query->header(-cookie => $cookie);
print startpage();
print startmenu('member');
print "<p align=left>Logged in as: $loggedinuser [<a href=/cgi-bin/koha/logout.pl>Log Out</a>]</p>\n";
open H, "/usr/local/koha/intranet/htdocs/members/index.html";
while (<H>) {
print $_;
}
close H;
print endpage();
print endmenu('member');

View File

@ -1,199 +1,102 @@
#!/usr/bin/perl
#script to display detailed information
#written 8/11/99
use HTML::Template;
use strict;
#use DBI;
use C4::Search;
require Exporter;
use C4::Koha;
use C4::Output;
use C4::Acquisitions;
use C4::Biblio;
use CGI;
my $input = new CGI;
print $input->header;
#whether it is called from the opac of the intranet
my $type=$input->param('type');
#setup colours
my $main;
my $secondary;
if ($type eq 'opac'){
$main='#99cccc';
$secondary='#efe5ef';
} else {
$main='#cccc99';
$secondary='#ffffcc';
}
print startpage();
print startmenu($type);
my $blah;
use C4::Search;
use C4::Acquisitions;
use C4::Output; # contains picktemplate
my $query=new CGI;
my $language='french';
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $templatebase="catalogue/moredetail.tmpl";
my $startfrom=$query->param('startfrom');
($startfrom) || ($startfrom=0);
my $theme=picktemplate($includes, $templatebase);
my $subject=$query->param('subject');
# if its a subject we need to use the subject.tmpl
if ($subject){
$templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
}
my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
# get variables
my $biblionumber=$query->param('bib');
my $title=$query->param('title');
my $bi=$query->param('bi');
my $bib=$input->param('bib');
my $title=$input->param('title');
my $bi=$input->param('bi');
my $data=bibitemdata($bi);
my $dewey = $data->{'dewey'};
$dewey =~ s/0+$//;
if ($dewey eq "000.") { $dewey = "";};
if ($dewey < 10){$dewey='00'.$dewey;}
if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
if ($dewey <= 0){
$dewey='';
}
$dewey=~ s/\.$//;
$data->{'dewey'}=$dewey;
my @results;
my (@items)=itemissues($bi);
my ($order,$ordernum)=getorder($bi,$bib);
#print @items;
my $count=@items;
$data->{'count'}=$count;
my ($order,$ordernum)=getorder($bi,$biblionumber);
my $i=0;
print center();
my $env;
$env->{itemcount}=1;
my $dewey = $data->{'dewey'};
$dewey =~ s/0+$//;
if ($dewey eq "000.") { $dewey = "";};
if ($dewey < 10){$dewey='00'.$dewey;}
if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
if ($dewey <= 0){
$dewey='';
}
$dewey=~ s/\.$//;
print <<printend
<br>
<a href=/cgi-bin/koha/request.pl?bib=$bib><img src=/images/requests.gif width=120 height=42 border=0 align=right border=0></a>
printend
;
if ($type eq 'catmain'){
print "<FONT SIZE=6><em>Catalogue Maintenance</em></FONT><br>";
$results[0]=$data;
foreach my $item (@items){
$item->{'itemlost'}=~ s/0/No/;
$item->{'itemlost'}=~ s/1/Yes/;
$item->{'withdrawn'}=~ s/0/No/;
$item->{'withdrawn'}=~ s/1/Yes/;
$item->{'replacementprice'}+=0.00;
my $year=substr($item->{'timestamp0'},0,4);
my $mon=substr($item->{'timestamp0'},4,2);
my $day=substr($item->{'timestamp0'},6,2);
$item->{'timestamp0'}="$day/$mon/$year";
$item->{'dateaccessioned'} = slashifyDate($item->{'dateaccessioned'});
$item->{'datelastseen'} = slashifyDate($item->{'datelastseen'});
if ($item->{'date_due'} = 'Available'){
$item->{'issue'}="<b>Currently on issue to:</b><br>";
} else {
$item->{'issue'}="<b>Currently on issue to:</b> <a href=/cgi-bin/koha/moremember.pl?bornum=$item->{'borrower0'}>$item->{'card'}</a><br>";
}
}
print <<printend
<FONT SIZE=6><em><a href=/cgi-bin/koha/detail.pl?bib=$bib&type=intra>$data->{'title'} ($data->{'author'})</a></em></FONT><P>
<p>
<form action=/cgi-bin/koha/modbibitem.pl>
<input type=hidden name=bibitem value=$bi>
<input type=hidden name=biblio value=$bib>
<!-------------------BIBLIO ITEM------------>
<TABLE CELLSPACING=0 CELLPADDING=5 border=1 align=left>
<TR VALIGN=TOP>
<td bgcolor="99cc33" background="/images/background-mem.gif" ><B>$data->{'biblioitemnumber'} GROUP - $data->{'description'} </b> </TD>
</TR>
<tr VALIGN=TOP >
<TD width=210 >
<INPUT TYPE="image" name="submit" VALUE="modify" height=42 WIDTH=93 BORDER=0 src="/images/modify-mem.gif">
<INPUT TYPE="image" name="delete" VALUE="delete" height=42 WIDTH=93 BORDER=0 src="/images/delete-mem.gif">
<br>
<FONT SIZE=2 face="arial, helvetica">
<b>Biblionumber:</b> $bib<br>
<b>Item Type:</b> $data->{'itemtype'}<br>
<b>Loan Length:</b> $data->{'loanlength'}<br>
<b>Rental Charge:</b> $data->{'rentalcharge'}<br>
<b>Classification:</b> $data->{'classification'}$dewey$data->{'subclass'}<br>
<b>ISBN:</b> $data->{'isbn'}<br>
<b>Publisher:</b> $data->{'publishercode'} <br>
<b>Place:</b> $data->{'place'}<br>
<b>Date:</b> $data->{'publicationyear'}<br>
<b>Volume:</b> $data->{'volumeddesc'}<br>
<b>Pages:</b> $data->{'pages'}<br>
<b>Illus:</b> $data->{'illus'}<br>
<b>Size:</b> $data->{'size'}<br>
<b>Notes:</b> $data->{'bnotes'}<br>
<b>No. of Items:</b> $count
printend
;
if ($type eq 'catmain'){
print "<br><a href=/cgi-bin/koha/maint/shiftbib.pl?bi=$data->{'biblioitemnumber'}&bib=$data->{'biblionumber'}>Shift to another biblio</a>";
}
print <<printend
$template->param(includesdir => $includes);
$template->param(BIBITEM_DATA => \@results);
$template->param(ITEM_DATA => \@items);
print "Content-Type: text/html\n\n", $template->output;
</font>
</TD>
</tr>
</table>
</form>
printend
;
for (my $i=0;$i<$count;$i++){
print <<printend
<img src="/images/holder.gif" width=16 height=300 align=left>
<TABLE CELLSPACING=0 CELLPADDING=5 border=1 align=left width=220 >
<TR VALIGN=TOP>
<td bgcolor="99cc33" background="/images/background-mem.gif"><B>BARCODE $items[$i]->{'barcode'}</b></TD>
</TR>
<tr VALIGN=TOP >
<TD width=220 >
<form action=/cgi-bin/koha/moditem.pl method=post>
<input type=hidden name=bibitem value=$bi>
<input type=hidden name=item value=$items[$i]->{'itemnumber'}>
<input type=hidden name=type value=$type>
<INPUT TYPE="image" name="submit" VALUE="modify" height=42 WIDTH=93 BORDER=0 src="/images/modify-mem.gif">
<INPUT TYPE="image" name="delete" VALUE="delete" height=42 WIDTH=93 BORDER=0 src="/images/delete-mem.gif">
<br>
printend
;
$items[$i]->{'itemlost'}=~ s/0/No/;
$items[$i]->{'itemlost'}=~ s/1/Yes/;
$items[$i]->{'withdrawn'}=~ s/0/No/;
$items[$i]->{'withdrawn'}=~ s/1/Yes/;
$items[$i]->{'replacementprice'}+=0.00;
my $year=substr($items[$i]->{'timestamp0'},0,4);
my $mon=substr($items[$i]->{'timestamp0'},4,2);
my $day=substr($items[$i]->{'timestamp0'},6,2);
$items[$i]->{'timestamp0'}="$day/$mon/$year";
$items[$i]->{'dateaccessioned'} = slashifyDate($items[$i]->{'dateaccessioned'});
$items[$i]->{'datelastseen'} = slashifyDate($items[$i]->{'datelastseen'});
print <<printend
<FONT SIZE=2 face="arial, helvetica">
<b>Home Branch:</b> $items[$i]->{'homebranch'}<br>
<b>Last seen:</b> $items[$i]->{'datelastseen'}<br>
<b>Last borrowed:</b> $items[$i]->{'timestamp0'}<br>
printend
;
if ($items[$i] eq 'Available'){
print "<b>Currently on issue to:</b><br>";
} else {
print "<b>Currently on issue to:</b> <a href=/cgi-bin/koha/moremember.pl?bornum=$items[$i]->{'borrower0'}>$items[$i]->{'card'}</a><br>";
}
print <<printend
<b>Last Borrower 1:</b> $items[$i]->{'card0'}<br>
<b>Last Borrower 2:</b> $items[$i]->{'card1'}<br>
<b>Current Branch:</b> $items[$i]->{'holdingbranch'}<br>
<b>Replacement Price:</b> $items[$i]->{'replacementprice'}<br>
<b>Item lost:</b> $items[$i]->{'itemlost'}<br>
<b>Paid for:</b> $items[$i]->{'paidfor'}<br>
<b>Notes:</b> $items[$i]->{'itemnotes'}<br>
<b>Renewals:</b> $items[$i]->{'renewals'}<br>
<b><a href=/cgi-bin/koha/acqui/acquire.pl?recieve=$ordernum&biblio=$bib&invoice=$order->{'booksellerinvoicenumber'}&catview=yes>Accession</a> Date: $items[$i]->{'dateaccessioned'}<br>
printend
;
if ($items[$i]->{'wthdrawn'} eq '1'){
$items[$i]->{'wthdrawn'}="Yes";
} else {
$items[$i]->{'wthdrawn'}="No";
}
print <<printend
<b>Cancelled: $items[$i]->{'wthdrawn'}<br>
<b>Total Issues:</b> $items[$i]->{'issues'}<br>
<b>Group Number:</b> $bi <br>
<b>Biblio number:</b> $bib <br>
</font>
</TD>
</tr>
</table>
</form>
printend
;
}
print <<printend
<p>
</form>
printend
;
print endcenter();
print endmenu($type);
print endpage();

View File

@ -127,6 +127,9 @@ $data->{'borrowernotes'}<!--</a>-->
<INPUT TYPE="image" name="modify" VALUE="modify" height=42 WIDTH=93 BORDER=0 src="/images/modify-mem.gif">
<INPUT TYPE="image" name="delete" VALUE="delete" height=42 WIDTH=93 BORDER=0 src="/images/delete-mem.gif">
<p>
<INPUT TYPE="image" name="password" VALUE="password" height=42 WIDTH=154 BORDER=0 src="/images/password-mem.gif">
</p>
</TD>

26
reports-home.pl Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/perl
use strict;
use CGI;
use C4::Auth;
use C4::Output;
my $query = new CGI;
my ($loggedinuser, $cookie, $sessionID) = checkauth($query);
print $query->header(-cookie => $cookie);
print startpage();
print startmenu('report');
print "<p align=left>Logged in as: $loggedinuser [<a href=/cgi-bin/koha/logout.pl>Log Out</a>]</p>\n";
open H, "/usr/local/koha/intranet/htdocs/reports/index.html";
while (<H>) {
print $_;
}
close H;
print endpage();
print endmenu('report');

534
search.pl
View File

@ -1,359 +1,203 @@
#!/usr/bin/perl
#script to provide intranet (librarian) advanced search facility
use HTML::Template;
use strict;
use C4::Search;
require Exporter;
use C4::Database;
use CGI;
use C4::Output;
use C4::Acquisitions;
use C4::Search;
use C4::Auth;
use C4::Output; # no contains picktemplate
my $query=new CGI;
my $type=$query->param('type');
my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') ? (1) : (0));
my $env;
my $input = new CGI;
print $input->header;
#print $input->dump;
#whether it is called from the opac or the intranet
my $type=$input->param('type');if ($type eq ''){
$type = 'intra';
}
my $language='french';
my $ttype=$input->param('ttype');
#setup colours
my $main;
my $secondary;
if ($type eq 'opac'){
$main='#99cccc';
$secondary='#efe5ef';
} else {
$main='#cccc99';
$secondary='#ffffcc';
}
#print $input->Dump;
my $blah;
my %search;
#build hash of users input
my $title=validate($input->param('title'));
$search{'title'}=$title;
my $keyword=validate($input->param('keyword'));
$search{'keyword'}=$keyword;
$search{'front'}=validate($input->param('front'));
my $author=validate($input->param('author'));
$search{'author'}=$author;
my $illustrator=validate($input->param('illustrator'));
$search{'illustrator'}=$illustrator;
my $subject=validate($input->param('subject'));
$search{'subject'}=$subject;
my $itemnumber=validate($input->param('item'));
$search{'item'}=$itemnumber;
my $isbn=validate($input->param('isbn'));
$search{'isbn'}=$isbn;
my $datebefore=validate($input->param('date-before'));
$search{'date-before'}=$datebefore;
my $class=$input->param('class');
$search{'class'}=$class;
$search{'ttype'}=$ttype;
my $dewey=validate($input->param('dewey'));
$search{'dewey'}=$dewey;
my $branch=validate($input->param('branch'));
$search{'branch'}=$branch;
my @results;
my $offset=$input->param('offset');
if ($offset eq ''){
$offset=0;
}
my $num=$input->param('num');
if ($num eq ''){
$num=10;
}
print startpage();
print startmenu($type);
#print $type;
#print $search{'ttype'};
if ($type eq 'intra'){
print mkheadr(1,'Catalogue Search Results');
} elsif ($type eq 'catmain'){
print mkheadr(1,'Catalogue Maintenance');
} else {
print mkheadr(1,'Opac Search Results');
}
print center();
my $count;
if ($itemnumber ne '' || $isbn ne ''){
($count,@results)=&CatSearch(\$blah,'precise',\%search,$num,$offset);
} else {
if ($subject ne ''){
($count,@results)=&CatSearch(\$blah,'subject',\%search,$num,$offset);
} else {
if ($keyword ne ''){
($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
}elsif ($title ne '' || $author ne '' || $illustrator ne '' || $dewey ne '' || $class ne '') {
($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset);
}
}
}
print "You searched on ";
while ( my ($key, $value) = each %search) {
if ($value ne '' && $key ne 'ttype'){
$value=~ s/\\//g;
print bold("$key $value,");
}
}
print " $count results found";
my $offset2=$num+$offset;
my $dispnum=$offset+1;
print "<br> Results $dispnum to $offset2 displayed";
print mktablehdr;
if ($type ne 'opac'){
if ($subject ne ''){
print mktablerow(1,$main,'<b>SUBJECT</b>','/images/background-mem.gif');
} elsif ($illustrator ne '') {
print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>', '<b>ILLUSTRATOR<b>', bold('&copy;'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
} else {
print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('&copy;'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
}
} else {
if ($subject ne ''){
print mktablerow(6,$main,'<b>SUBJECT</b>',' &nbsp; ',' &nbsp; ');
} elsif ($illustrator ne '') {
print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>','<b>ILLUSTRATOR</b>', bold('&copy;'),'<b>COUNT</b>',bold('LOCATION'),'');
} else {
print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('&copy;'),'<b>COUNT</b>',bold('LOCATION'),'');
}
}
my $count2=@results;
if ($keyword ne '' && $offset > 0){
$count2=$count-$offset;
if ($count2 > 10){
$count2=10;
}
}
#print $count2;
my $i=0;
my $colour=1;
while ($i < $count2){
# print $results[$i]."\n";
my @stuff=split('\t',$results[$i]);
$stuff[1]=~ s/\`/\\\'/g;
my $title2=$stuff[1];
$title2=~ s/ /%20/g;
if ($subject eq ''){
# print $stuff[0];
$stuff[1]=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$stuff[2]&title=$title2",$stuff[1]);
my $word=$stuff[0];
# print $word;
$word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
$word=~ s/ //g;
$word=~ s/ /%20/g;
$word=~ s/\,/\,%20/g;
$word=~ s/\n//g;
my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
$stuff[7]=$stuff[5];
$stuff[5]='';
$stuff[0]=mklink($url,$stuff[0]);
my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount,$branchcount)=itemcount($env,$stuff[2],$type);
$stuff[4]=$count;
if ($nacount > 0){
$stuff[5]=$stuff[5]."On Loan";
if ($nacount >1 ){
$stuff[5]=$stuff[5]." ($nacount)";
}
$stuff[5].=" ";
}
if ($lcount > 0){
$stuff[5]=$stuff[5]."Levin";
if ($lcount >1 ){
$stuff[5]=$stuff[5]." ($lcount)";
}
$stuff[5].=" ";
}
if ($fcount > 0){
$stuff[5]=$stuff[5]."Foxton";
if ($fcount >1 ){
$stuff[5]=$stuff[5]." ($fcount)";
}
$stuff[5].=" ";
}
if ($scount > 0){
$stuff[5]=$stuff[5]."Shannon";
if ($scount >1 ){
$stuff[5]=$stuff[5]." ($scount)";
}
$stuff[5].=" ";
}
$stuff[5]='';
my ($numbranches, @branches) = branches();
my $branchinfo;
foreach (@branches) {
my $branchcode=$_->{'branchcode'};
my $branchname=$_->{'branchname'};
$branchinfo->{$branchcode}=$branchname;
}
if ($numbranches>1) {
foreach my $branchcode (sort keys %$branchcount) {
my $c=$branchcount->{$branchcode};
$stuff[5].=$branchinfo->{$branchcode};
if ($c>1) {
$stuff[5].=" ($c)";
}
$stuff[5].=" ";
}
} else {
my $shelfcount=$count-$nacount-$lostcount-$mending-$transit;
if ($nacount) {
$stuff[5]="On Loan ";
if ($count>1) {
$stuff[5].="($nacount) ";
}
}
if ($shelfcount) {
$stuff[5].="Shelf ";
if ($count>1) {
$stuff[5].="($shelfcount) ";
}
}
}
if ($lostcount > 0) {
$stuff[5]=$stuff[5]."Lost";
if ($count >1 ){
$stuff[5]=$stuff[5]." ($lostcount)";
}
$stuff[5].=" ";
}
if ($mending > 0){
$stuff[5]=$stuff[5]."Mending";
if ($count >1 ){
$stuff[5]=$stuff[5]." ($mending)";
}
$stuff[5].=" ";
}
if ($transit > 0){
$stuff[5]=$stuff[5]."In Transit";
if ($count >1 ){
$stuff[5]=$stuff[5]." ($transit)";
}
$stuff[5].=" ";
}
if ($ocount > 0){
$stuff[5]=$stuff[5]."On Order";
if ($ocount >1 ){
$stuff[5]=$stuff[5]." ($ocount)";
}
$stuff[5].=" ";
}
if ($type ne 'opac'){
$stuff[6]=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
}
} else {
my $word=$stuff[1];
$word=~ s/ /%20/g;
$stuff[1]=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$stuff[1]);
}
if ($colour == 1){
if ($illustrator) {
print mktablerow(7,$secondary,$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
} else {
print mktablerow(6,$secondary,$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
}
$colour=0;
} else {
if ($illustrator) {
print mktablerow(7,'white',$stuff[1],$stuff[0],$stuff[7],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
} else {
print mktablerow(6,'white',$stuff[1],$stuff[0],$stuff[3],$stuff[4],$stuff[5],$stuff[6]);
}
$colour=1;
}
$i++;
}
$offset=$num+$offset;
if ($type ne 'opac'){
if ($illustrator) {
print mktablerow(7,$main,' &nbsp; ',' &nbsp; ',' &nbsp;',' &nbsp;','','','','/images/background-mem.gif');
} else {
print mktablerow(6,$main,' &nbsp; ',' &nbsp; ',' &nbsp;',' &nbsp;','','','/images/background-mem.gif');
}
} else {
if ($illustrator) {
print mktablerow(7,$main,' &nbsp; ',' &nbsp; ',' &nbsp;',' &nbsp; ','', '','');
} else {
print mktablerow(6,$main,' &nbsp; ',' &nbsp; ',' &nbsp;',' &nbsp; ','','');
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
print mktableft();
my $search;
#print $query->header;
$search="num=$num&offset=$offset&type=$type";
if ($subject ne ''){
$subject=~ s/ /%20/g;
$search=$search."&subject=$subject";
}
if ($title ne ''){
$title=~ s/ /%20/g;
$search=$search."&title=$title";
}
if ($author ne ''){
$author=~ s/ /%20/g;
$search=$search."&author=$author";
}
if ($keyword ne ''){
$keyword=~ s/ /%20/g;
$search=$search."&keyword=$keyword";
}
if ($class ne ''){
$keyword=~ s/ /%20/g;
$search=$search."&class=$class";
}
if ($dewey ne ''){
$search=$search."&dewey=$dewey";
}
$search.="&ttype=$ttype";
if ($offset < $count){
my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
print $stuff;
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $templatebase="catalogue/searchresults.tmpl";
my $startfrom=$query->param('startfrom');
($startfrom) || ($startfrom=0);
my $theme=picktemplate($includes, $templatebase);
my $subject=$query->param('subject');
# if its a subject we need to use the subject.tmpl
if ($subject) {
$templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
$theme=picktemplate($includes, $templatebase);
}
print "<br>";
my $pages=$count/10;
$pages++;
for (my $i=1;$i<$pages;$i++){
my $temp=$i*10;
$temp=$temp-10;
$search=~ s/offset=[0-9]+/offset=$temp/;
my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
print "$stuff ";
my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
my $env;
$env->{itemcount}=1;
# get all the search variables
# we assume that C4::Search will validate these values for us
my %search;
my $keyword=$query->param('keyword');
$search{'keyword'}=$keyword;
$search{'subject'}=$subject;
my $author=$query->param('author');
$search{'author'}=$author;
$search{'authoresc'}=$author;
#$search{'authorhtmlescaped'}=~s/ /%20/g;
my $illustrator=$query->param('illustrator');
$search{'param'}=$illustrator;
my $itemnumber=$query->param('itemnumber');
$search{'itemnumber'}=$itemnumber;
my $isbn=$query->param('isbn');
$search{'isbn'}=$isbn;
my $datebefore=$query->param('date-before');
$search{'date-before'}=$datebefore;
my $class=$query->param('class');
$search{'class'}=$class;
my $dewey=$query->param('dewey');
$search{'dewey'};
my $branch=$query->param('branch');
$search{'branch'}=$branch;
my $title=$query->param('title');
$search{'title'}=$title;
my $abstract=$query->param('abstract');
$search{'abstract'}=$abstract;
my $publisher=$query->param('publisher');
$search{'publisher'}=$publisher;
my $ttype=$query->param('ttype');
$search{'ttype'}=$ttype;
my $forminputs;
($keyword) && (push @$forminputs, { line => "keyword=$keyword"});
($subject) && (push @$forminputs, { line => "subject=$subject"});
($author) && (push @$forminputs, { line => "author=$author"});
($illustrator) && (push @$forminputs, { line => "illustrator=$illustrator"});
($itemnumber) && (push @$forminputs, { line => "itemnumber=$itemnumber"});
($isbn) && (push @$forminputs, { line => "isbn=$isbn"});
($datebefore) && (push @$forminputs, { line => "date-before=$datebefore"});
($class) && (push @$forminputs, { line => "class=$class"});
($dewey) && (push @$forminputs, { line => "dewey=$dewey"});
($branch) && (push @$forminputs, { line => "branch=$branch"});
($title) && (push @$forminputs, { line => "title=$title"});
($ttype) && (push @$forminputs, { line => "ttype=$ttype"});
($abstract) && (push @$forminputs, { line => "abstract=$abstract"});
($publisher) && (push @$forminputs, { line => "publisher=$publisher"});
($forminputs) || (@$forminputs=());
$template->param(FORMINPUTS => $forminputs);
# whats this for?
# I think it is (or was) a search from the "front" page... [st]
$search{'front'}=$query->param('front');
my $num=10;
my @results;
my $count;
if (my $subject=$query->param('subjectitems')) {
my $blah;
@results=subsearch(\$blah,$subject);
$count=$#results+1;
} else {
($count,@results)=catalogsearch($env,'',\%search,$num,$startfrom);
}
print endcenter();
print endmenu($type);
print endpage();
#my $resultsarray=\@results;
my $resultsarray;
foreach my $result (@results) {
$result->{'authorhtmlescaped'}=$result->{'author'};
$result->{'authorhtmlescaped'}=~s/ /%20/g;
($result->{'copyrightdate'}==0) && ($result->{'copyrightdate'}='');
($type eq 'opac') ? ($result->{'opac'}=1) : ($result->{'opac'}=0);
push (@$resultsarray, $result);
}
($resultsarray) || (@$resultsarray=());
my $search="num=20";
my $searchdesc='';
if ($keyword){
$search=$search."&keyword=$keyword";
$searchdesc.="keyword $keyword, ";
}
if (my $subjectitems=$query->param('subjectitems')){
$search=$search."&subjectitems=$subjectitems";
$searchdesc.="subject $subjectitems, ";
}
if ($subject){
$search=$search."&subject=$subject";
$searchdesc.="subject $subject, ";
}
if ($author){
$search=$search."&author=$author";
$searchdesc.="author $author, ";
}
if ($class){
$search=$search."&class=$class";
$searchdesc.="class $class, ";
}
if ($title){
$search=$search."&title=$title";
$searchdesc.="title $title, ";
}
if ($dewey){
$search=$search."&dewey=$dewey";
$searchdesc.="dewey $dewey, ";
}
$search.="&ttype=$ttype";
$search=~ s/ /%20/g;
$template->param(startfrom => $startfrom+1);
($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : ($template->param(endat => $count));
$template->param(numrecords => $count);
my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$num) : (-1);
$template->param(nextstartfrom => $nextstartfrom);
my $displaynext=1;
my $displayprev=0;
($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
$template->param(displaynext => $displaynext);
$template->param(displayprev => $displayprev);
($type eq 'opac') ? ($template->param(opac => 1)) : ($template->param(opac => 0));
$template->param(prevstartfrom => $prevstartfrom);
$template->param(search => $search);
$template->param(searchdesc => $searchdesc);
$template->param(SEARCH_RESULTS => $resultsarray);
$template->param(includesdir => $includes);
$template->param(loggedinuser => $loggedinuser);
my $numbers;
@$numbers=();
if ($count>10) {
for (my $i=1; $i<$count/10+1; $i++) {
($title) && (push @$forminputs, { line => "title=$title"});
my $highlight=0;
($startfrom==($i-1)*10) && ($highlight=1);
push @$numbers, { number => $i, highlight => $highlight , FORMINPUTS => $forminputs, startfrom => ($i-1)*10, opac => ($type eq 'opac') ? (1) : (0)};
}
}
$template->param(numbers => $numbers);
sub validate {
my ($input)=@_;
$input=~ s/\<[a-z]+\>//gi;
$input=~ s/\<\/[a-z]+\>//gi;
$input=~ s/\<//g;
$input=~ s/\>//g;
$input=~ s/^%//g;
return($input);
}
print $query->header(-cookie => $cookie), $template->output;

View File

@ -10,10 +10,12 @@ use CGI;
use C4::Output;
use C4::BookShelves;
use C4::Circulation::Circ2;
use C4::Auth;
my $env;
my $query = new CGI;
print $query->header;
my ($loggedinuser, $cookie, $sessionID) = checkauth($query);
print $query->header(-cookie => $cookie);
my $headerbackgroundcolor='#663266';
my $circbackgroundcolor='#555555';
my $circbackgroundcolor='#550000';
@ -24,6 +26,7 @@ print startpage();
print startmenu('catalogue');
print "<p align=left>Logged in as: $loggedinuser [<a href=/cgi-bin/koha/logout.pl>Log Out</a>]</p>\n";
my ($shelflist) = GetShelfList();
@ -157,7 +160,7 @@ EOF
<input type=hidden name=shelfnumber value=$shelfnumber>
<input type=hidden name=modifyshelfcontents value=1>
<input type=hidden name=viewshelf value=$shelfnumber>
<input type=submit value="Modify Shelf List">
<input type=submit value="Remove Selected Items">
</form>
EOF
}
@ -166,6 +169,15 @@ EOF
#
# $Log$
# Revision 1.2.2.2 2002/07/11 18:05:28 tonnesen
# Committing changes to add authentication and opac templating to rel-1-2 branch
#
# Revision 1.5 2002/07/04 19:42:48 tonnesen
# Minor changes
#
# Revision 1.4 2002/07/04 19:21:29 tonnesen
# Beginning of authentication api. Applied to shelves.pl for now as a test case.
#
# Revision 1.2.2.1 2002/06/26 20:28:15 tonnesen
# Some udpates that I made here locally a while ago. Still won't be useful, but
# should be functional