Dutch, Polish, Italian and German updates
[koha.git] / opac / opac-search.pl
index e48a017..2ed8303 100755 (executable)
@@ -72,6 +72,7 @@ if (C4::Context->preference("marcflavour") eq "UNIMARC" ) {
 elsif (C4::Context->preference("marcflavour") eq "MARC21" ) {
     $template->param('usmarc' => 1);
 }
+$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
 
 if (C4::Context->preference('BakerTaylorEnabled')) {
        $template->param(
@@ -217,10 +218,11 @@ if ( $template_type eq 'advsearch' ) {
                $template->param( expanded_options => C4::Context->preference("expandedSearchOption") );
        }
        # but let the user override it
-       if ( ($cgi->param('expanded_options') == 0) || ($cgi->param('expanded_options') == 1 ) ) {
-       $template->param( expanded_options => $cgi->param('expanded_options'));
-       }
-
+       if (defined $cgi->param('expanded_options')) {
+           if ( ($cgi->param('expanded_options') == 0) || ($cgi->param('expanded_options') == 1 ) ) {
+           $template->param( expanded_options => $cgi->param('expanded_options'));
+           }
+        }
     output_html_with_http_headers $cgi, $cookie, $template->output;
     exit;
 }
@@ -288,12 +290,8 @@ if($params->{'multibranchlimit'}) {
 push @limits, join(" or ", map { "branch: $_ "}  @{GetBranchesInCategory($params->{'multibranchlimit'})}) ;
 }
 
-my $available;
-foreach my $limit(@limits) {
-    if ($limit =~/available/) {
-        $available = 1;
-    }
-}
+my $available = $params->{'available'};
+
 $template->param(available => $available);
 
 # append year limits if they exist
@@ -346,11 +344,11 @@ $template->param ( QUERY_INPUTS => \@query_inputs );
 my @limit_inputs = $limit_cgi ? _input_cgi_parse($limit_cgi) : ();
 
 # add OPAC 'hidelostitems'
-if (C4::Context->preference('hidelostitems') == 1) {
-    # either lost ge 0 or no value in the lost register
-    $query ="($query) and ( (lost,st-numeric <= 0) or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='') )";
-}
-
+#if (C4::Context->preference('hidelostitems') == 1) {
+#    # either lost ge 0 or no value in the lost register
+#    $query ="($query) and ( (lost,st-numeric <= 0) or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='') )";
+#}
+#
 # add OPAC suppression - requires at least one item indexed with Suppress
 if (C4::Context->preference('OpacSuppression')) {
     $query = "($query) not Suppress=1";
@@ -410,17 +408,18 @@ for (my $i=0;$i<=@servers;$i++) {
                 # 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"} });
+                                                   @{ $group->{"RECORDS"} }, $available, 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,@{$results_hashref->{$server}->{"RECORDS"}});
+        } else { 
+            @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,$scan, $available,C4::Context->preference('hidelostitems'), @{$results_hashref->{$server}->{"RECORDS"}});
         }
                my $tag_quantity;
                if (C4::Context->preference('TagsEnabled') and
                        $tag_quantity = C4::Context->preference('TagsShowOnList')) {
                        foreach (@newresults) {
                                my $bibnum = $_->{biblionumber} or next;
+                               $_->{itemsissued} = CountItemsIssued( $bibnum );
                                $_ ->{'TagLoop'} = get_tags({biblionumber=>$bibnum, approved=>1, 'sort'=>'-weight',
                                                                                limit=>$tag_quantity });
                        }
@@ -456,7 +455,7 @@ for (my $i=0;$i<=@servers;$i++) {
         if ($hits) {
             $template->param(total => $hits);
             my $limit_cgi_not_availablity = $limit_cgi;
-            $limit_cgi_not_availablity =~ s/&limit=available//g if defined $limit_cgi_not_availablity;
+            $limit_cgi_not_availablity =~ s/&available=1//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);
@@ -580,6 +579,6 @@ if (defined $barshelves) {
        $template->param( addbarshelvesloop => $barshelves);
 }
 
-my $content_type = ($format eq 'rss' or $format eq 'atom') ? $format : 'html';
+$content_type = ($format eq 'rss' or $format eq 'atom') ? $format : 'html';
 
 output_html_with_http_headers $cgi, $cookie, $template->output, $content_type;