From f49bd9a5449b22f02867caa5dd7c0d70fb52b419 Mon Sep 17 00:00:00 2001 From: tipaul Date: Wed, 24 Mar 2004 10:44:48 +0000 Subject: [PATCH] bugfixes for newsearches --- C4/Search.pm | 91 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 753ab91d50..ecc7a0d774 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -85,13 +85,72 @@ sub newsearch { $sth->execute($duration,$itemtype); my $i=0; my @result; - while (my $line = $sth->fetchrow_hashref) { - if ($i>=$offset && $i+$offset<$num) { - push @result,$line; + while (my $data = $sth->fetchrow_hashref) { + if ($i>=$offset && $i<$num+$offset) { + my ($counts) = itemcount2("", $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'){ # FIXME - Should ignore 'order', too. + #$data->{'location'}.="$key $counts->{$key} "; + $totalitemcounts+=$counts->{$key}; + $data->{'locationhash'}->{$key}=$counts->{$key}; + } + } + my $locationtext=''; + my $locationtextonly=''; + my $notavailabletext=''; + foreach (sort keys %{$data->{'locationhash'}}) { + if ($_ eq 'notavailable') { + $notavailabletext="Not available"; + my $c=$data->{'locationhash'}->{$_}; + $data->{'not-available-p'}=$totalitemcounts; + if ($totalitemcounts>1) { + $notavailabletext.=" ($c)"; + $data->{'not-available-plural-p'}=1; + } + } else { + $locationtext.="$_ "; + my $c=$data->{'locationhash'}->{$_}; + if ($_ eq 'Item Lost') { + $data->{'lost-p'}=$totalitemcounts; + $data->{'lost-plural-p'}=1 + if $totalitemcounts > 1; + } elsif ($_ eq 'Withdrawn') { + $data->{'withdrawn-p'}=$totalitemcounts; + $data->{'withdrawn-plural-p'}=1 + if $totalitemcounts > 1; + } elsif ($_ eq 'On Loan') { + $data->{'on-loan-p'}=$totalitemcounts; + $data->{'on-loan-plural-p'}=1 + if $totalitemcounts > 1; + } else { + $locationtextonly.=$_; + $locationtextonly.=" ($c), " + if $totalitemcounts>1; + } + if ($totalitemcounts>1) { + $locationtext.=" ($c), "; + } + } + } + if ($notavailabletext) { + $locationtext.=$notavailabletext; + } else { + $locationtext=~s/, $//; + } + $data->{'location'}=$locationtext; + $data->{'location-only'}=$locationtextonly; + $data->{'subject2'}=$subject2; + $data->{'use-location-flags-p'}=1; # XXX + + push @result,$data; } $i++ } - return(@result); + return($i,@result); } @@ -251,17 +310,37 @@ sub catalogsearch { } } my $locationtext=''; + my $locationtextonly=''; my $notavailabletext=''; foreach (sort keys %{$data->{'locationhash'}}) { if ($_ eq 'notavailable') { $notavailabletext="Not available"; my $c=$data->{'locationhash'}->{$_}; + $data->{'not-available-p'}=$totalitemcounts; if ($totalitemcounts>1) { $notavailabletext.=" ($c)"; + $data->{'not-available-plural-p'}=1; } } else { $locationtext.="$_"; my $c=$data->{'locationhash'}->{$_}; + if ($_ eq 'Item Lost') { + $data->{'lost-p'}=$totalitemcounts; + $data->{'lost-plural-p'}=1 + if $totalitemcounts > 1; + } elsif ($_ eq 'Withdrawn') { + $data->{'withdrawn-p'}=$totalitemcounts; + $data->{'withdrawn-plural-p'}=1 + if $totalitemcounts > 1; + } elsif ($_ eq 'On Loan') { + $data->{'on-loan-p'}=$totalitemcounts; + $data->{'on-loan-plural-p'}=1 + if $totalitemcounts > 1; + } else { + $locationtextonly.=$_; + $locationtextonly.=" ($c), " + if $totalitemcounts>1; + } if ($totalitemcounts>1) { $locationtext.=" ($c), "; } @@ -273,7 +352,9 @@ sub catalogsearch { $locationtext=~s/, $//; } $data->{'location'}=$locationtext; + $data->{'location-only'}=$locationtextonly; $data->{'subject2'}=$subject2; + $data->{'use-location-flags-p'}=1; # XXX } } return ($count,@results); @@ -1335,7 +1416,7 @@ sub ItemInfo { } if ($datedue eq ''){ # $datedue="Available"; - my ($restype,$reserves)=CheckReserves($data->{'itemnumber'}); + my ($restype,$reserves)=C4::Reserves2::CheckReserves($data->{'itemnumber'}); if ($restype){ $datedue=$restype; } -- 2.39.2