From 73d1bf7eb02b8553c2d02be30dd101497ab5020b Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 21 Dec 1999 03:19:57 +0000 Subject: [PATCH] Working on web interface --- C4/Search.pm | 48 +++++++++++++++++++++++++++++++++++++++++------- addborrower.pl | 3 ++- search.pl | 11 +++++++---- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 4b4da3d..0129c76 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -15,7 +15,7 @@ $VERSION = 0.01; @ISA = qw(Exporter); @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! ], # your exported package globals go here, @@ -55,7 +55,7 @@ sub KeywordSearch { my ($env,$type,$search,$num,$offset)=@_; my $dbh = &C4Connect; my $query ="Select count(*) from biblio where author like -'%$search->{'keyword'}%' or + '%$search->{'keyword'}%' or title like '%$search->{'keyword'}%'"; my $sth=$dbh->prepare($query); @@ -154,14 +154,14 @@ sub CatSearch { my $i=0; my $i2=0; my $limit=$num+$offset; - +# print $query; if ($search->{'title'} ne '' || $search->{'author'} ne '' ){ while ((my $data=$sth->fetchrow_hashref) && $i < $limit){ - if ($i >= $offset){ +# if ($i >= $offset){ $results[$i2]="$data->{'biblionumber'}\t$data->{'title'}\t$data->{'author'}"; $i2++; - } - $i++; +# } +# $i++; } } else { while (my $data=$sth->fetchrow_hashref){ @@ -388,7 +388,41 @@ sub getacctlist { } 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) diff --git a/addborrower.pl b/addborrower.pl index 329582f..a4b78a0 100755 --- a/addborrower.pl +++ b/addborrower.pl @@ -2,6 +2,7 @@ #script to guide user thru adding/modifying a borrower entry #written 22/11/99 +#update 21/12/99 by chris@katipo.co.nz use strict; #use C4::Search; @@ -96,7 +97,7 @@ if ($action eq 'S') { $inputs{'contactname'} ="18\tR\tContact Name\ttext\t40\t$data->{'contactname'}"; $inputs{'borrowernotes'}="19\t\tNotes\ttextarea\t40x4\t$data->{'borrowernotes'}"; $inputs{'type'} ="20\t\t\thidden\tborrowers"; - $inputs{'updtype'} ="I"; + $inputs{'updtype'} ="21\t\t\thidden\tI"; if ($action eq "M") { $inputs{'updtype'} = "\21\t\t\thidden\tM"; $inputs{'borrowernumber'} ="22\t\t\thidden\t$data->{'borrowernumber'}"; diff --git a/search.pl b/search.pl index 722c3d8..fe24357 100755 --- a/search.pl +++ b/search.pl @@ -9,6 +9,7 @@ use C4::Search; use CGI; use C4::Output; +my $env; my $input = new CGI; print $input->header; #print $input->dump; @@ -72,7 +73,7 @@ print mktablehdr; if ($subject ne ''){ print mktablerow(1,'#cccc99','SUBJECT'); } else { - print mktablerow(2,'#cccc99','TITLE','AUTHOR'); + print mktablerow(3,'#cccc99','TITLE','AUTHOR','ITEM COUNT'); } my $count2=@results; my $i=0; @@ -89,22 +90,24 @@ while ($i < $count2){ $word=~ s/\n//g; my $url="/cgi-bin/kumara/search.pl?author=$word&type=a"; $stuff[2]=mklink($url,$stuff[2]); + my $count=itemcount($env,$stuff[0]); + $stuff[3]=$count; } else { my $word=$stuff[1]; $word=~ s/ /%20/g; $stuff[1]=mklink("/cgi-bin/kumara/subjectsearch.pl?subject=$word",$stuff[1]); } if ($colour == 1){ - print mktablerow(2,'#ffffcc',$stuff[1],$stuff[2]); + print mktablerow(3,'#ffffcc',$stuff[1],$stuff[2],$stuff[3]); $colour=0; } else{ - print mktablerow(2,'white',$stuff[1],$stuff[2]); + print mktablerow(3,'white',$stuff[1],$stuff[2],$stuff[3]); $colour=1; } $i++; } $offset=$num+$offset; -print mktablerow(2,'#cccc99','   ','   '); +print mktablerow(3,'#cccc99','   ','   ','  '); print mktableft(); if ($offset < $count){ my $search="num=$num&offset=$offset";