# 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;
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});
# item is withdrawn, lost or damaged
if ( $item->{wthdrawn}
- || ($item->{itemlost} and not $hidelostitems)
+ || $item->{itemlost}
|| $item->{damaged}
|| $item->{notforloan}
|| $item->{reserved}
( 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;
(++$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(
$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));
}
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
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) {
<div id="search-facets">
<h4>Refine your search</h4>
<ul>
- <li>Availability<ul><li><!-- TMPL_IF NAME="available" -->Showing only <strong>available</strong> items. <a href="/cgi-bin/koha/catalogue/search.pl?<!-- TMPL_VAR NAME="query_cgi" --><!-- TMPL_VAR NAME="limit_cgi_not_availablity" --><!-- TMPL_IF NAME="sort_by" -->&sort_by=<!-- TMPL_VAR NAME="sort_by" --><!-- /TMPL_IF -->">Show all items</a><!-- TMPL_ELSE -->Limit to <a href="/cgi-bin/koha/catalogue/search.pl?<!-- TMPL_VAR NAME="query_cgi" --><!-- TMPL_VAR NAME="limit_cgi" --><!-- TMPL_IF NAME="sort_by" -->&sort_by=<!-- TMPL_VAR NAME="sort_by" --><!-- /TMPL_IF -->&available=1">currently available items.</a><!-- /TMPL_IF --></li></ul>
+ <li>Availability<ul><li><!-- TMPL_IF NAME="available" -->Showing only <strong>available</strong> items. <a href="/cgi-bin/koha/catalogue/search.pl?<!-- TMPL_VAR NAME="query_cgi" --><!-- TMPL_VAR NAME="limit_cgi_not_availablity" --><!-- TMPL_IF NAME="sort_by" -->&sort_by=<!-- TMPL_VAR NAME="sort_by" --><!-- /TMPL_IF -->">Show all items</a><!-- TMPL_ELSE -->Limit to <a href="/cgi-bin/koha/catalogue/search.pl?<!-- TMPL_VAR NAME="query_cgi" --><!-- TMPL_VAR NAME="limit_cgi" --><!-- TMPL_IF NAME="sort_by" -->&sort_by=<!-- TMPL_VAR NAME="sort_by" --><!-- /TMPL_IF -->&limit=available">currently available items.</a><!-- /TMPL_IF --></li></ul>
<!-- TMPL_IF NAME="related" --> <li>(related searches: <!-- TMPL_LOOP NAME="related" --><!-- TMPL_VAR NAME="related_search" --><!-- /TMPL_LOOP -->)</li><!-- /TMPL_IF -->
</li>
<div id="search-facets">
<h4>Refine your search</h4>
<ul>
- <li>Availability<ul><li><!-- TMPL_IF NAME="available" -->Showing only <strong>available</strong> items. <a href="/cgi-bin/koha/opac-search.pl?<!-- TMPL_VAR NAME="query_cgi" --><!-- TMPL_VAR NAME="limit_cgi_not_availablity" --><!-- TMPL_IF NAME="sort_by" -->&sort_by=<!-- TMPL_VAR NAME="sort_by" --><!-- /TMPL_IF -->">Show all items</a><!-- TMPL_ELSE -->Limit to <a href="/cgi-bin/koha/opac-search.pl?<!-- TMPL_VAR NAME="query_cgi" --><!-- TMPL_VAR NAME="limit_cgi" --><!-- TMPL_IF NAME="sort_by" -->&sort_by=<!-- TMPL_VAR NAME="sort_by" --><!-- /TMPL_IF -->&available=1">currently available items.</a><!-- /TMPL_IF --></li></ul>
+ <li>Availability<ul><li><!-- TMPL_IF NAME="available" -->Showing only <strong>available</strong> items. <a href="/cgi-bin/koha/opac-search.pl?<!-- TMPL_VAR NAME="query_cgi" --><!-- TMPL_VAR NAME="limit_cgi_not_availablity" --><!-- TMPL_IF NAME="sort_by" -->&sort_by=<!-- TMPL_VAR NAME="sort_by" --><!-- /TMPL_IF -->">Show all items</a><!-- TMPL_ELSE -->Limit to <a href="/cgi-bin/koha/opac-search.pl?<!-- TMPL_VAR NAME="query_cgi" --><!-- TMPL_VAR NAME="limit_cgi" --><!-- TMPL_IF NAME="sort_by" -->&sort_by=<!-- TMPL_VAR NAME="sort_by" --><!-- /TMPL_IF -->&limit=available">currently available items.</a><!-- /TMPL_IF --></li></ul>
<!-- TMPL_IF NAME="related" --> <li>(related searches: <!-- TMPL_LOOP NAME="related" --><!-- TMPL_VAR NAME="related_search" --><!-- /TMPL_LOOP -->)</li><!-- /TMPL_IF -->
</li>
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
# we want as specified by $offset and $results_per_page,
# we need to set the offset parameter of searchResults to 0
my @group_results = searchResults( $query_desc, $group->{'group_count'},$results_per_page, 0, $scan,
- @{ $group->{"RECORDS"} }, $available, C4::Context->preference('hidelostitems'));
+ @{ $group->{"RECORDS"} }, C4::Context->preference('hidelostitems'));
push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results };
}
- } else {
- @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,$scan, $available,C4::Context->preference('hidelostitems'), @{$results_hashref->{$server}->{"RECORDS"}});
+ } else {
+ @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,$scan,@{$results_hashref->{$server}->{"RECORDS"}},, C4::Context->preference('hidelostitems'));
}
my $tag_quantity;
if (C4::Context->preference('TagsEnabled') and
if ($hits) {
$template->param(total => $hits);
my $limit_cgi_not_availablity = $limit_cgi;
- $limit_cgi_not_availablity =~ s/&available=1//g if defined $limit_cgi_not_availablity;
+ $limit_cgi_not_availablity =~ s/&limit=available//g if defined $limit_cgi_not_availablity;
$template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity);
$template->param(limit_cgi => $limit_cgi);
$template->param(query_cgi => $query_cgi);
$template->param( addbarshelvesloop => $barshelves);
}
-$content_type = ($format eq 'rss' or $format eq 'atom') ? $format : 'html';
+my $content_type = ($format eq 'rss' or $format eq 'atom') ? $format : 'html';
output_html_with_http_headers $cgi, $cookie, $template->output, $content_type;