bugfixes for newsearches
This commit is contained in:
parent
73953baf99
commit
f49bd9a544
91
C4/Search.pm
91
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue