3 # Copyright 2000-2002 Katipo Communications
4 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 2 of the License, or (at your option) any later
11 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along with
16 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
17 # Suite 330, Boston, MA 02111-1307 USA
26 # FIXME - C4::Search uses C4::Reserves2, which uses C4::Search.
27 # So Perl complains that all of the functions here get redefined.
30 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
32 # set the version for version checking
33 $VERSION = do { my @v = '$Revision$' =~ /\d+/g;
34 shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
38 C4::Search - Functions for searching the Koha catalog and other databases
44 my ($count, @results) = catalogsearch4($env, $type, $search, $num, $offset);
48 This module provides the searching facilities for the Koha catalog and
61 &barcodes &ItemInfo &itemcount
62 &getcoverPhoto &add_query_line
63 &FindDuplicate &ZEBRAsearch_kohafields &sqlsearch &cataloguing_search
64 &getMARCnotes &getMARCsubjects &getMARCurls &parsefields);
65 # make all your functions, whether exported or not;
68 ZEBRAsearchkohafields is the underlying API for searching zebra for KOHA internal use
69 its kept similar to earlier version Koha Marc searches. instead of passing marc tags to the routine
70 you pass named kohafields
71 So you give an array of @kohafieldnames,@values, what relation they have @relations (equal, truncation etc) @and_or and
72 you receive an array of XML records.
73 The routine also has a flag $fordisplay and if it is set to 1 it will return the @results as an array of Perl hashes so that your previous
74 search results templates do actually work.
75 However more advanced search frontends will be available and this routine can serve as the connecting API for circulation and serials management
76 See sub FindDuplicates for an example;
82 sub ZEBRAsearch_kohafields{
83 my ($kohafield,$value, $relation,$sort, $and_or, $fordisplay,$reorder,$startfrom,$number_of_results,$searchfrom)=@_;
84 return (0,undef) unless (@$value[0]);
85 my $server="biblioserver";
92 for ( $i=0; $i<=$#{$value}; $i++){
93 last if (@$value[$i] eq "");
95 my $keyattr=MARCfind_attr_from_kohafield(@$kohafield[$i]) if (@$kohafield[$i]);
96 if (!$keyattr){$keyattr=" \@attr 1=any";}
97 @$value[$i]=~ s/(\.|\?|\;|\=|\/|\\|\||\:|\*|\!|\,|\(|\)|\[|\]|\{|\}|\/)/ /g;
98 $query.=@$relation[$i]." ".$keyattr." \"".@$value[$i]."\" " if @$value[$i];
100 for (my $z= 0;$z<=$#{$and_or};$z++){
101 $query=@$and_or[$z]." ".$query if (@$value[$z+1] ne "");
107 ($oConnection[0])=C4::Context->Zconn($server);
112 my (@sortpart)=split /,/,$reorder;
116 my ($sortattr)=MARCfind_attr_from_kohafield($sortpart[0]);
117 my @sortfield=split /@/,$sortattr; ## incase our $sortattr contains type modifiers
118 $query.=" \@attr 7=".$sortpart[1]." \@".$sortfield[1]." 0";##
119 $query= "\@or ".$query;
121 my (@sortpart)=split /,/,$sort;
123 push @sortpart,1; ## Ascending by default
125 my ($sortattr)=MARCfind_attr_from_kohafield($sortpart[0]);
126 my @sortfield=split /@/,$sortattr; ## incase our $sortattr contains type modifiers
127 $query.=" \@attr 7=".$sortpart[1]." \@".$sortfield[1]." 0";## fix to accept secondary sort as well
128 $query= "\@or ".$query;
130 unless($query=~/4=109/){ ###ranked sort not valid for numeric fields
132 $query="\@attr 2=102 ".$query;
143 $oResult= $oConnection[0]->search_pqf($query);
146 while (($i = ZOOM::event(\@oConnection)) != 0) {
147 $event = $oConnection[$i-1]->last_event();
148 last if $event == ZOOM::Event::ZEND;
151 my($error, $errmsg, $addinfo, $diagset) = $oConnection[0]->error_x();
152 if ($error==10007 && $tried<3) {## timeout --another 30 looonng seconds for this update
155 }elsif ($error==2 && $tried<2) {## timeout --temporary zebra error !whatever that means
159 warn "Error-$server /errcode:, $error, /MSG:,$errmsg,$addinfo \n";
161 $oConnection[0]->destroy();
162 return (undef,undef);
164 my $dbh=C4::Context->dbh;
165 $numresults=$oResult->size() ;
171 $ri=$startfrom if $startfrom;
172 for ( $ri; $ri<$numresults ; $ri++){
173 my $xmlrecord=$oResult->record($ri)->raw();
174 $xmlrecord=Encode::decode("utf8",$xmlrecord);
176 ### Turn into hash of xml
177 $xmlrecord=XML_xml2hash($xmlrecord);
180 push @results,$xmlrecord;
181 last if ($number_of_results && $z>=$number_of_results);
186 my (@parsed)=parsefields($dbh,$searchfrom,@results);
187 return ($numresults,@parsed) ;
192 $oConnection[0]->destroy();
193 return ($numresults,@results) ;
197 =item add_bold_fields
198 After a search the searched keyword is <b>boldened</b> in the displayed search results if it exists in the title or author
199 It is now depreceated
201 sub add_html_bold_fields {
202 my ($type, $data, $search) = @_;
203 foreach my $key ('title', 'author') {
206 $new_key = 'bold_' . $key;
207 $data->{$new_key} = $data->{$key};
217 if ($type eq 'keyword') {
218 my $newkey=$search->{'keyword'};
220 @keys = split " ", $newkey;
223 for ($i = 0; $i < $count ; $i++) {
225 if (($data->{$new_key} =~ /($keys[$i])/i) && (lc($keys[$i]) ne 'b') ) {
227 $data->{$new_key} =~ s/$word/<b>$word<\/b>/;
236 ## This searches the SQL database only for biblionumber,itemnumber,barcode
237 ### Not very useful on production but as a debug tool useful during system maturing for ZEBRA operations
239 my ($dbh,$search)=@_;
241 if ($search->{'barcode'} ne '') {
242 $sth=$dbh->prepare("SELECT biblionumber from items where barcode=?");
243 $sth->execute($search->{'barcode'});
244 }elsif ($search->{'itemnumber'} ne '') {
245 $sth=$dbh->prepare("SELECT biblionumber from items where itemnumber=?");
246 $sth->execute($search->{'itemnumber'});
247 }elsif ($search->{'biblionumber'} ne '') {
248 $sth=$dbh->prepare("SELECT biblionumber from biblio where biblionumber=?");
249 $sth->execute($search->{'biblionumber'});
251 return (undef,undef);
254 my $result=$sth->fetchrow_hashref;
255 return (1,$result) if $result;
258 sub cataloguing_search{
259 ## This is an SQL based search designed to be used when adding a new biblio incase library sets
260 ## preference zebraorsql to sql when adding a new biblio
261 my ($search,$num,$offset) = @_;
262 my ($count,@results);
263 my $dbh=C4::Context->dbh;
266 my $condition="select SQL_CALC_FOUND_ROWS marcxml from biblio where ";
267 if ($search->{'isbn'} ne''){
268 $search->{'isbn'}=$search->{'isbn'}."%";
269 $query=$search->{'isbn'};
270 $condition.= " isbn like ? ";
272 return (0,undef) unless $search->{title};
273 $query=$search->{'title'};
274 $condition.= " MATCH (title) AGAINST(? in BOOLEAN MODE ) ";
276 my $sth=$dbh->prepare($condition);
277 $sth->execute($query);
278 my $nbresult=$dbh->prepare("SELECT FOUND_ROWS()");
280 my $count=$nbresult->fetchrow;
281 my $limit = $num + $offset;
282 my $startfrom = $offset;
285 while (my $marc=$sth->fetchrow){
286 if (($i >= $startfrom) && ($i < $limit)) {
287 my $record=XML_xml2hash_onerecord($marc);
288 my $data=XMLmarc2koha_onerecord($dbh,$record,"biblios");
294 return ($count,@results);
301 my $dbh=C4::Context->dbh;
302 my ($result) = XMLmarc2koha_onerecord($dbh,$xml,"biblios");
308 # search duplicate on ISBN, easy and fast..
310 if ($result->{isbn}) {
311 push @kohafield,"isbn";
312 ###Temporary fix for ISBN
313 my $isbn=$result->{isbn};
314 $isbn=~ s/(\.|\?|\;|\=|\/|\\|\||\:|\!|\'|,|\-|\"|\*|\(|\)|\[|\]|\{|\}|\/)//g;
317 $result->{title}=~s /\\//g;
318 $result->{title}=~s /\"//g;
319 $result->{title}=~ s/(\.|\?|\;|\=|\/|\\|\||\:|\*|\!|\,|\-|\(|\)|\[|\]|\{|\}|\/)/ /g;
321 push @kohafield,"title";
322 push @value,$result->{title};
323 push @relation,"\@attr 6=3 \@attr 4=1 \@attr 5=1"; ## right truncated,phrase,whole field
326 my ($total,@result)=ZEBRAsearch_kohafields(\@kohafield,\@value,\@relation,"",\@and_or,0,"",0,1);
328 my $title=XML_readline($result[0],"title","biblios") ;
329 my $biblionumber=XML_readline($result[0],"biblionumber","biblios") ;
330 return $biblionumber,$title ;
338 my ($type,$search,$results)=@_;
339 my $dbh = C4::Context->dbh;
342 my $borrowernumber = $search->{'borrowernumber'};
343 my $remote_IP = $search->{'remote_IP'};
344 my $remote_URL= $search->{'remote_URL'};
345 my $searchdesc = $search->{'searchdesc'};
347 my $sth = $dbh->prepare("INSERT INTO phrase_log(phr_phrase,phr_resultcount,phr_ip,user,actual) VALUES(?,?,?,?,?)");
350 $sth->execute($searchdesc,$results,$remote_IP,$borrowernumber,$remote_URL);
358 @results = &ItemInfo($env, $biblionumber, $type);
360 Returns information about books with the given biblionumber.
362 C<$type> may be either C<intra> or anything else. If it is not set to
363 C<intra>, then the search will exclude lost, very overdue, and
368 C<&ItemInfo> returns a list of references-to-hash. Each element
369 contains a number of keys. Most of them are table items from the
370 C<biblio>, C<biblioitems>, C<items>, and C<itemtypes> tables in the
371 Koha database. Other keys include:
375 =item C<$data-E<gt>{branchname}>
377 The name (not the code) of the branch to which the book belongs.
379 =item C<$data-E<gt>{datelastseen}>
381 This is simply C<items.datelastseen>, except that while the date is
382 stored in YYYY-MM-DD format in the database, here it is converted to
383 DD/MM/YYYY format. A NULL date is returned as C<//>.
385 =item C<$data-E<gt>{datedue}>
387 =item C<$data-E<gt>{class}>
389 This is the concatenation of C<biblioitems.classification>, the book's
390 Dewey code, and C<biblioitems.subclass>.
392 =item C<$data-E<gt>{ocount}>
394 I think this is the number of copies of the book available.
396 =item C<$data-E<gt>{order}>
398 If this is set, it is set to C<One Order>.
405 my ($dbh,$data) = @_;
408 my ($date_due, $count_reserves);
410 my $isth=$dbh->prepare("Select issues.*,borrowers.cardnumber from issues,borrowers where itemnumber = ? and returndate is null and issues.borrowernumber=borrowers.borrowernumber");
411 $isth->execute($data->{'itemnumber'});
412 if (my $idata=$isth->fetchrow_hashref){
413 $data->{borrowernumber} = $idata->{borrowernumber};
414 $data->{cardnumber} = $idata->{cardnumber};
415 $datedue = format_date($idata->{'date_due'});
417 if ($datedue eq '' || $datedue eq "0000-00-00"){
419 my ($restype,$reserves)=C4::Reserves2::CheckReserves($data->{'itemnumber'});
421 $count_reserves = $restype;
425 #get branch information.....
426 my $bsth=$dbh->prepare("SELECT * FROM branches WHERE branchcode = ?");
427 $bsth->execute($data->{'holdingbranch'});
428 if (my $bdata=$bsth->fetchrow_hashref){
429 $data->{'branchname'} = $bdata->{'branchname'};
431 my $date=substr($data->{'datelastseen'},0,8);
432 $data->{'datelastseen'}=format_date($date);
433 $data->{'datedue'}=$datedue;
434 $data->{'count_reserves'} = $count_reserves;
435 # get notforloan complete status if applicable
436 my ($tagfield,$tagsub)=MARCfind_marc_from_kohafield("notforloan","holdings");
437 my $sthnflstatus = $dbh->prepare("select authorised_value from holdings_subfield_structure where tagfield='$tagfield' and tagsubfield='$tagsub'");
438 $sthnflstatus->execute;
439 my ($authorised_valuecode) = $sthnflstatus->fetchrow;
440 if ($authorised_valuecode) {
441 $sthnflstatus = $dbh->prepare("select lib from authorised_values where category=? and authorised_value=?");
442 $sthnflstatus->execute($authorised_valuecode,$data->{itemnotforloan});
443 my ($lib) = $sthnflstatus->fetchrow;
444 $data->{notforloan} = $lib;
447 # my shelf procedures
448 my ($tagfield,$tagsubfield)=MARCfind_marc_from_kohafield("shelf","holdings");
450 my $shelfstatus = $dbh->prepare("select authorised_value from holdings_subfield_structure where tagfield='$tagfield' and tagsubfield='$tagsubfield'");
451 $shelfstatus->execute;
452 $authorised_valuecode = $shelfstatus->fetchrow;
453 if ($authorised_valuecode) {
454 $shelfstatus = $dbh->prepare("select lib from authorised_values where category=? and authorised_value=?");
455 $shelfstatus->execute($authorised_valuecode,$data->{shelf});
457 my ($lib) = $shelfstatus->fetchrow;
458 $data->{shelf} = $lib;
472 @barcodes = &barcodes($biblioitemnumber);
474 Given a biblioitemnumber, looks up the corresponding items.
476 Returns an array of references-to-hash; the keys are C<barcode> and
479 The returned items include very overdue items, but not lost ones.
484 #called from request.pl
485 my ($biblionumber)=@_;
487 my $dbh = C4::Context->dbh;
494 push @kohafields, "biblionumber";
495 push @values,$biblionumber;
496 push @relations, " "," \@attr 2=1"; ## selecting wthdrawn less then 1
497 push @and_or, "\@and";
499 my ($count,@results)=ZEBRAsearch_kohafields(\@kohafields,\@values,\@relations,$sort,\@and_or,"","");
500 push @fields,"barcode","itemlost","itemnumber","date_due","wthdrawn","notforloan";
501 my ($biblio,@items)=XMLmarc2koha($dbh,$results[0],"holdings", @fields);
505 sub XML_repeated_read{
506 my ($xml,$kohafield,$recordtype,$tag,$subf)=@_;
507 #$xml represents one record of MARCXML as perlhashed
508 ## returns an array of read fields--useful for readind repeated fields
509 ### $recordtype is needed for mapping the correct field if supplied
511 ($tag,$subf)=MARCfind_marc_from_kohafield($kohafield,$recordtype) if $kohafield;
513 my $biblio=$xml->{'datafield'};
514 my $controlfields=$xml->{'controlfield'};
515 my $leader=$xml->{'leader'};
517 foreach my $data (@$biblio){
518 if ($data->{'tag'} eq $tag){
519 foreach my $subfield ( $data->{'subfield'}){
520 foreach my $code ( @$subfield){
521 if ($code->{'code'} eq $subf || !$subf){
522 push @value, $code->{'content'};
529 if ($tag eq "000" || $tag eq "LDR"){
530 push @value, $leader->[0] if $leader->[0];
532 foreach my $control (@$controlfields){
533 if ($control->{'tag'} eq $tag){
534 push @value, $control->{'content'} if $control->{'content'};
548 ##Requires a MARCXML as $record
549 my ($dbh, $record, $marcflavour) = @_;
551 my ($mintag, $maxtag);
552 if ($marcflavour eq "MARC21") {
555 } else { # assume unimarc if not marc21
560 foreach my $field ($mintag..$maxtag) {
561 my @value=XML_repeated_read($record,"","",$field,"");
562 push @marcnotes, \@value;
567 my $marcnotesarray=\@marcnotes;
568 return $marcnotesarray;
572 sub getMARCsubjects {
574 my ($dbh, $record, $marcflavour) = @_;
575 my ($mintag, $maxtag);
576 if ($marcflavour eq "MARC21") {
579 } else { # assume unimarc if not marc21
588 foreach my $field ($mintag..$maxtag) {
589 my @value =XML_repeated_read($record,"","",$field,"a");
590 foreach my $subject (@value){
591 $marcsubjct = {MARCSUBJCT => $subject,};
592 push @marcsubjcts, $marcsubjct;
596 my $marcsubjctsarray=\@marcsubjcts;
597 return $marcsubjctsarray;
598 } #end getMARCsubjects
602 ### This code is wrong only works with MARC21
603 my ($dbh, $record, $marcflavour) = @_;
604 my ($mintag, $maxtag);
605 if ($marcflavour eq "MARC21") {
608 } else { # assume unimarc if not marc21
618 foreach my $field ($mintag..$maxtag) {
619 my @value =XML_repeated_read($record,"","",$field,"a");
620 foreach my $url (@value){
621 if ( $value ne $url) {
622 $marcurl = {MARCURL => $url,};
623 push @marcurls, $marcurl;
630 my $marcurlsarray=\@marcurls;
631 return $marcurlsarray;
637 #pass this a MARC record and it will parse it for display purposes
638 my ($dbh,$intranet,@marcrecords)=@_;
641 my $retrieve_from=C4::Context->preference('retrieve_from');
642 #Build brancnames hash for displaying in OPAC - more user friendly
644 #get branch information.....
646 my $bsth=$dbh->prepare("SELECT branchcode,branchname FROM branches");
648 while (my $bdata=$bsth->fetchrow_hashref){
649 $branches{$bdata->{'branchcode'}}= $bdata->{'branchname'};
652 #Building shelving hash if library has shelves defined like junior section, non-fiction, audio-visual room etc
655 my ($tagfield,$tagsubfield)=MARCfind_marc_from_kohafield("shelf","holdings");
656 my $shelfstatus = $dbh->prepare("select authorised_value from holdings_subfield_structure where tagfield='$tagfield' and tagsubfield='$tagsubfield'");
657 $shelfstatus->execute;
658 my ($authorised_valuecode) = $shelfstatus->fetchrow;
659 if ($authorised_valuecode) {
660 $shelfstatus = $dbh->prepare("select lib,authorised_value from authorised_values where category=? ");
661 $shelfstatus->execute($authorised_valuecode);
662 while (my $lib = $shelfstatus->fetchrow_hashref){
663 $shelves{$lib->{'authorised_value'}} = $lib->{'lib'};
667 foreach my $xml(@marcrecords){
668 #my $xml=XML_xml2hash($xmlrecord);
669 my @kohafields; ## just name those necessary for the result page
670 push @kohafields, "biblionumber","title","author","publishercode","classification","itemtype","copyrightdate", "holdingbranch","date_due","location","shelf","itemcallnumber","notforloan","itemlost","wthdrawn";
671 my ($oldbiblio,@itemrecords) = XMLmarc2koha($dbh,$xml,"",@kohafields);
679 ##Loop for each item field
681 foreach my $item (@itemrecords) {
682 $norequests = 0 unless $item->{'itemnotforloan'};
685 #renaming some fields according to templates
686 $item->{'branchname'}=$branches{$item->{'holdingbranch'}};
687 $item->{'shelves'}=$shelves{$item->{'shelf'}};
688 $status="Lost" if ($item->{'itemlost'}>0);
689 $status="Withdrawn" if ($item->{'wthdrawn'}>0);
690 if ($intranet eq "intranet"){ ## we give full itemcallnumber detail in intranet
691 $status="Due:".format_date($item->{'date_due'}) if ($item->{'date_due'} gt "0000-00-00");
692 $status = $item->{'holdingbranch'}."-".$item->{'shelf'}."[".$item->{'itemcallnumber'}."]" unless defined $status;
694 $status="On Loan" if ($item->{'date_due'} gt "0000-00-00");
695 $status = $item->{'branchname'}."[".$item->{'shelves'}."]" unless defined $status;
701 $oldbiblio->{'noitems'} = $noitems;
702 $oldbiblio->{'norequests'} = $norequests;
703 $oldbiblio->{'even'} = $even;
706 $oldbiblio->{'toggle'}="#ffffcc";
708 $oldbiblio->{'toggle'}="white";
709 } ; ## some forms seems to use toggle
711 $oldbiblio->{'itemcount'} = $counts{'total'};
712 my $totalitemcounts = 0;
713 foreach my $key (keys %counts){
714 if ($key ne 'total'){
715 $totalitemcounts+= $counts{$key};
716 $oldbiblio->{'locationhash'}->{$key}=$counts{$key};
720 my ($locationtext, $locationtextonly, $notavailabletext) = ('','','');
721 foreach (sort keys %{$oldbiblio->{'locationhash'}}) {
723 if ($_ eq 'notavailable') {
724 $notavailabletext="Not available";
725 my $c=$oldbiblio->{'locationhash'}->{$_};
726 $oldbiblio->{'not-available-p'}=$c;
729 my $c=$oldbiblio->{'locationhash'}->{$_};
731 $oldbiblio->{'lost-p'} = $c;
732 } elsif ($_ eq 'Withdrawn') {
733 $oldbiblio->{'withdrawn-p'} = $c;
734 } elsif ($_ =~/\^Due:/) {
736 $oldbiblio->{'on-loan-p'} = $c;
738 $locationtextonly.= $_;
739 $locationtextonly.= " ($c)<br> " if $totalitemcounts > 1;
741 if ($totalitemcounts>1) {
742 $locationtext.=" ($c)<br> ";
746 if ($notavailabletext) {
747 $locationtext.= $notavailabletext;
749 $locationtext=~s/, $//;
751 $oldbiblio->{'location'} = $locationtext;
752 $oldbiblio->{'location-only'} = $locationtextonly;
753 $oldbiblio->{'use-location-flags-p'} = 1;
754 push @results,$oldbiblio;
756 }## For each record received
761 ## return the address of a cover image if defined otherwise the amazon cover images
764 my $image=XML_readline_onerecord($record,"coverphoto","biblios");
768 # if there is no image put the amazon cover image adress
770 my $isbn=XML_readline_onerecord($record,"isbn","biblios");
771 return "http://images.amazon.com/images/P/".$isbn.".01.MZZZZZZZ.jpg";
776 ($count, $lcount, $nacount, $fcount, $scount, $lostcount,
777 $mending, $transit,$ocount) =
778 &itemcount($env, $biblionumber, $type);
780 Counts the number of items with the given biblionumber, broken down by
785 If C<$type> is not set to C<intra>, lost, very overdue, and withdrawn
786 items will not be counted.
788 C<&itemcount> returns a nine-element list:
790 C<$count> is the total number of items with the given biblionumber.
792 C<$lcount> is the number of items at the Levin branch.
794 C<$nacount> is the number of items that are neither borrowed, lost,
795 nor withdrawn (and are therefore presumably on a shelf somewhere).
797 C<$fcount> is the number of items at the Foxton branch.
799 C<$scount> is the number of items at the Shannon branch.
801 C<$lostcount> is the number of lost and very overdue items.
803 C<$mending> is the number of items at the Mending branch (being
806 C<$transit> is the number of items at the Transit branch (in transit
809 C<$ocount> is the number of items that haven't arrived yet
810 (aqorders.quantity - aqorders.quantityreceived).
818 my ($env,$bibnum,$type)=@_;
819 my $dbh = C4::Context->dbh;
825 my $query="Select * from items where
827 push @kohafield,"biblionumber";
830 my ($total,@result)=ZEBRAsearch_kohafields(\@kohafield,\@value, \@relation,"", \@and_or, 0);## there is only one record no need for $num or $offset
831 my @fields;## extract only the fields required
832 push @fields,"itemnumber","itemlost","wthdrawn","holdingbranch","date_due";
833 my ($biblio,@items)=XMLmarc2koha ($dbh,$result[0],"holdings",\@fields);
843 foreach my $data(@items){
844 if ($type ne "intra"){
845 next if ($data->{itemlost} || $data->{wthdrawn});
846 } ## Probably trying to hide lost item from opac ?
849 ## Now it seems we want to find those which are onloan
852 if ( $data->{date_due} gt "0000-00-00"){
856 ### The rest of this code is hardcoded for Foxtrot Shanon etc. We urgently need a global understanding of these terms--TG
857 if ($data->{'holdingbranch'} eq 'C' || $data->{'holdingbranch'} eq 'LT'){
860 if ($data->{'holdingbranch'} eq 'F' || $data->{'holdingbranch'} eq 'FP'){
863 if ($data->{'holdingbranch'} eq 'S' || $data->{'holdingbranch'} eq 'SP'){
866 if ($data->{'itemlost'} eq '1'){
869 if ($data->{'itemlost'} eq '2'){
872 if ($data->{'holdingbranch'} eq 'FM'){
875 if ($data->{'holdingbranch'} eq 'TR'){
881 my $sth2=$dbh->prepare("Select * from aqorders where biblionumber=?");
882 $sth2->execute($bibnum);
883 if (my $data=$sth2->fetchrow_hashref){
884 $ocount=$data->{'quantity'} - $data->{'quantityreceived'};
888 return ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount);
891 END { } # module clean-up code here (global destructor)
900 Koha Developement team <info@koha.org>
901 # New functions to comply with ZEBRA search and new KOHA 3 API added 2006 Tumer Garip tgarip@neu.edu.tr