Browse Source

Working on web interface

master
chris 25 years ago
parent
commit
73d1bf7eb0
  1. 48
      C4/Search.pm
  2. 3
      addborrower.pl
  3. 11
      search.pl

48
C4/Search.pm

@ -15,7 +15,7 @@ $VERSION = 0.01;
@ISA = qw(Exporter); @ISA = qw(Exporter);
@EXPORT = qw(&CatSearch &BornameSearch &ItemInfo &KeywordSearch &subsearch @EXPORT = qw(&CatSearch &BornameSearch &ItemInfo &KeywordSearch &subsearch
&itemdata &bibdata &GetItems &borrdata &getacctlist &itemnodata); &itemdata &bibdata &GetItems &borrdata &getacctlist &itemnodata &itemcount);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here, # your exported package globals go here,
@ -55,7 +55,7 @@ sub KeywordSearch {
my ($env,$type,$search,$num,$offset)=@_; my ($env,$type,$search,$num,$offset)=@_;
my $dbh = &C4Connect; my $dbh = &C4Connect;
my $query ="Select count(*) from biblio where author like my $query ="Select count(*) from biblio where author like
'%$search->{'keyword'}%' or '%$search->{'keyword'}%' or
title like '%$search->{'keyword'}%'"; title like '%$search->{'keyword'}%'";
my $sth=$dbh->prepare($query); my $sth=$dbh->prepare($query);
@ -154,14 +154,14 @@ sub CatSearch {
my $i=0; my $i=0;
my $i2=0; my $i2=0;
my $limit=$num+$offset; my $limit=$num+$offset;
# print $query;
if ($search->{'title'} ne '' || $search->{'author'} ne '' ){ if ($search->{'title'} ne '' || $search->{'author'} ne '' ){
while ((my $data=$sth->fetchrow_hashref) && $i < $limit){ while ((my $data=$sth->fetchrow_hashref) && $i < $limit){
if ($i >= $offset){ # if ($i >= $offset){
$results[$i2]="$data->{'biblionumber'}\t$data->{'title'}\t$data->{'author'}"; $results[$i2]="$data->{'biblionumber'}\t$data->{'title'}\t$data->{'author'}";
$i2++; $i2++;
} # }
$i++; # $i++;
} }
} else { } else {
while (my $data=$sth->fetchrow_hashref){ while (my $data=$sth->fetchrow_hashref){
@ -388,7 +388,41 @@ sub getacctlist {
} }
return ($numlines,\@acctlines,$total); return ($numlines,\@acctlines,$total);
} }
sub itemcount {
my ($env,$bibnum)=@_;
my $dbh=C4Connect;
my $query="Select * from items where
biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
my $count=0;
my $lcount=0;
my $nacount=0;
while (my $data=$sth->fetchrow_hashref){
$count++;
my $query2="select * from issues where itemnumber=
'$data->{'itemnumber'}'";
# print $query2;
my $sth2=$dbh->prepare($query2);
$sth2->execute;
if (my $data2=$sth2->fetchrow_hashref){
$nacount++;
} else {
if ($data->{'holdingbranch'}='L'){
$lcount++;
}
}
$sth2->finish;
}
$sth->finish;
print $lcount;
print $nacount;
return $count;
$dbh->disconnect;
}
END { } # module clean-up code here (global destructor) END { } # module clean-up code here (global destructor)

3
addborrower.pl

@ -2,6 +2,7 @@
#script to guide user thru adding/modifying a borrower entry #script to guide user thru adding/modifying a borrower entry
#written 22/11/99 #written 22/11/99
#update 21/12/99 by chris@katipo.co.nz
use strict; use strict;
#use C4::Search; #use C4::Search;
@ -96,7 +97,7 @@ if ($action eq 'S') {
$inputs{'contactname'} ="18\tR\tContact Name\ttext\t40\t$data->{'contactname'}"; $inputs{'contactname'} ="18\tR\tContact Name\ttext\t40\t$data->{'contactname'}";
$inputs{'borrowernotes'}="19\t\tNotes\ttextarea\t40x4\t$data->{'borrowernotes'}"; $inputs{'borrowernotes'}="19\t\tNotes\ttextarea\t40x4\t$data->{'borrowernotes'}";
$inputs{'type'} ="20\t\t\thidden\tborrowers"; $inputs{'type'} ="20\t\t\thidden\tborrowers";
$inputs{'updtype'} ="I"; $inputs{'updtype'} ="21\t\t\thidden\tI";
if ($action eq "M") { if ($action eq "M") {
$inputs{'updtype'} = "\21\t\t\thidden\tM"; $inputs{'updtype'} = "\21\t\t\thidden\tM";
$inputs{'borrowernumber'} ="22\t\t\thidden\t$data->{'borrowernumber'}"; $inputs{'borrowernumber'} ="22\t\t\thidden\t$data->{'borrowernumber'}";

11
search.pl

@ -9,6 +9,7 @@ use C4::Search;
use CGI; use CGI;
use C4::Output; use C4::Output;
my $env;
my $input = new CGI; my $input = new CGI;
print $input->header; print $input->header;
#print $input->dump; #print $input->dump;
@ -72,7 +73,7 @@ print mktablehdr;
if ($subject ne ''){ if ($subject ne ''){
print mktablerow(1,'#cccc99','<b>SUBJECT</b>'); print mktablerow(1,'#cccc99','<b>SUBJECT</b>');
} else { } else {
print mktablerow(2,'#cccc99','<b>TITLE</b>','<b>AUTHOR</b>'); print mktablerow(3,'#cccc99','<b>TITLE</b>','<b>AUTHOR</b>','<b>ITEM COUNT</b>');
} }
my $count2=@results; my $count2=@results;
my $i=0; my $i=0;
@ -89,22 +90,24 @@ while ($i < $count2){
$word=~ s/\n//g; $word=~ s/\n//g;
my $url="/cgi-bin/kumara/search.pl?author=$word&type=a"; my $url="/cgi-bin/kumara/search.pl?author=$word&type=a";
$stuff[2]=mklink($url,$stuff[2]); $stuff[2]=mklink($url,$stuff[2]);
my $count=itemcount($env,$stuff[0]);
$stuff[3]=$count;
} else { } else {
my $word=$stuff[1]; my $word=$stuff[1];
$word=~ s/ /%20/g; $word=~ s/ /%20/g;
$stuff[1]=mklink("/cgi-bin/kumara/subjectsearch.pl?subject=$word",$stuff[1]); $stuff[1]=mklink("/cgi-bin/kumara/subjectsearch.pl?subject=$word",$stuff[1]);
} }
if ($colour == 1){ if ($colour == 1){
print mktablerow(2,'#ffffcc',$stuff[1],$stuff[2]); print mktablerow(3,'#ffffcc',$stuff[1],$stuff[2],$stuff[3]);
$colour=0; $colour=0;
} else{ } else{
print mktablerow(2,'white',$stuff[1],$stuff[2]); print mktablerow(3,'white',$stuff[1],$stuff[2],$stuff[3]);
$colour=1; $colour=1;
} }
$i++; $i++;
} }
$offset=$num+$offset; $offset=$num+$offset;
print mktablerow(2,'#cccc99',' &nbsp; ',' &nbsp; '); print mktablerow(3,'#cccc99',' &nbsp; ',' &nbsp; ',' &nbsp;');
print mktableft(); print mktableft();
if ($offset < $count){ if ($offset < $count){
my $search="num=$num&offset=$offset"; my $search="num=$num&offset=$offset";

Loading…
Cancel
Save