From da2eaf0a6256c00bc6cd0d0db4a792aa2e0d6062 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Mon, 7 Dec 2009 11:17:32 +0100 Subject: [PATCH] Revert "(MT #2298) Rewrite "only available items"" This reverts commit dfa44a90d4005a034bc2186e0d48ce4d5cb1992e. --- C4/Search.pm | 42 +++++++------------ catalogue/search.pl | 10 +++-- .../intranet-tmpl/prog/en/includes/facets.inc | 2 +- .../prog/en/includes/opac-facets.inc | 2 +- opac/opac-search.pl | 18 ++++---- 5 files changed, 35 insertions(+), 39 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index a709c648bf..202f6d5ac9 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1336,9 +1336,7 @@ Format results in a form suitable for passing to the template # IMO this subroutine is pretty messy still -- it's responsible for # building the HTML output for the template sub searchResults { - my ( $searchdesc, $hits, $results_per_page, $offset, $scan, - $limit_available, $hidelostitems, @marcresults) = @_; - + my ( $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults, $hidelostitems ) = @_; my $dbh = C4::Context->dbh; my @newresults; @@ -1543,7 +1541,7 @@ sub searchResults { my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber}; # For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item - if ( ($item->{onloan} or $item->{reserved} ) and not $limit_available) { + if ( $item->{onloan} or $item->{reserved} ) { $onloan_count++; my $key = $prefix . $item->{onloan} . $item->{barcode}; $onloan_items->{$key}->{due_date} = format_date($item->{onloan}); @@ -1598,7 +1596,7 @@ sub searchResults { # item is withdrawn, lost or damaged if ( $item->{wthdrawn} - || ($item->{itemlost} and not $hidelostitems) + || $item->{itemlost} || $item->{damaged} || $item->{notforloan} || $item->{reserved} @@ -1658,17 +1656,13 @@ sub searchResults { ( C4::Context->preference('maxItemsinSearchResults') ) ? C4::Context->preference('maxItemsinSearchResults') - 1 : 1; - - if(! $limit_available){ - for my $key ( sort keys %$onloan_items) { - (++$onloanitemscount > $maxitems) and last; - push @onloan_items_loop, $onloan_items->{$key}; - } - - for my $key ( sort keys %$other_items ) { - (++$otheritemscount > $maxitems) and last; - push @other_items_loop, $other_items->{$key}; - } + for my $key ( sort keys %$onloan_items ) { + (++$onloanitemscount > $maxitems) and last; + push @onloan_items_loop, $onloan_items->{$key}; + } + for my $key ( sort keys %$other_items ) { + (++$otheritemscount > $maxitems) and last; + push @other_items_loop, $other_items->{$key}; } for my $key ( sort keys %$notforloan_items ) { (++$notforloanitemscount > $maxitems) and last; @@ -1678,6 +1672,7 @@ sub searchResults { (++$availableitemscount > $maxitems) and last; push @available_items_loop, $available_items->{$key} } + # XSLT processing of some stuff if (C4::Context->preference("XSLTResultsDisplay") && !$scan) { $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display( @@ -1707,17 +1702,10 @@ sub searchResults { $oldbiblio->{orderedcount} = $ordered_count; $oldbiblio->{isbn} =~ s/-//g; # deleting - in isbn to enable amazon content - push( @newresults, $oldbiblio ) if ((not $limit_available and ($items_count)) - or ($limit_available and $available_count)); - - #if((not $hidelostitems and not $limit_available ) - #or ($items_count > $itemlost_count and $available_count )); - #($items_count > $itemlost_count) ) - #or (or ($available_count and $limit_available)) - #); - #+ $onloan_count ) ) - # && ( $hidelostitems or $limit_available )) - # ); + push( @newresults, $oldbiblio ) + if(not $hidelostitems + or (($items_count > $itemlost_count ) + && $hidelostitems)); } diff --git a/catalogue/search.pl b/catalogue/search.pl index 6f4ec63fb9..49942dbc3a 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -378,8 +378,12 @@ if($params->{'multibranchlimit'}) { push @limits, join(" or ", map { "branch: $_ "} @{GetBranchesInCategory($params->{'multibranchlimit'})}) ; } -my $available = $params->{'available'}; - +my $available; +foreach my $limit(@limits) { + if ($limit =~/available/) { + $available = 1; + } +} $template->param(available => $available); # append year limits if they exist @@ -503,7 +507,7 @@ for (my $i=0;$i<@servers;$i++) { if ($server =~/biblioserver/) { # this is the local bibliographic server $hits = $results_hashref->{$server}->{"hits"}; my $page = $cgi->param('page') || 0; - my @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,$scan,$available, 0, @{$results_hashref->{$server}->{"RECORDS"}}); + my @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,$scan,@{$results_hashref->{$server}->{"RECORDS"}}); $total = $total + $results_hashref->{$server}->{"hits"}; ## If there's just one result, redirect to the detail page if ($total == 1) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc index 377ca87f57..6855411c26 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc @@ -3,7 +3,7 @@

Refine your search