Bug 22284: (QA follow-up) Make pickup locations be Koha::Library objects
[koha-ffzg.git] / opac / opac-reserve.pl
index eb017b6..4d7cf13 100755 (executable)
@@ -90,6 +90,7 @@ if ( $patron->category->effective_BlockExpiredPatronOpacActions ) {
         # cannot reserve, their card has expired and the rules set mean this is not allowed
         $template->param( message => 1, expired_patron => 1 );
         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
+        exit;
     }
 }
 
@@ -116,6 +117,7 @@ if (! $biblionumbers) {
 if ((! $biblionumbers) && (! $query->param('place_reserve'))) {
     $template->param(message=>1, no_biblionumber=>1);
     output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
+    exit;
 }
 
 # Pass the numbers to the page so they can be fed back
@@ -128,6 +130,7 @@ if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
     # TODO: New message?
     $template->param(message=>1, no_biblionumber=>1);
     output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
+    exit;
 }
 
 
@@ -220,6 +223,7 @@ if ( $query->param('place_reserve') ) {
     if (($selectionCount == 0) || (($selectionCount % 3) != 0)) {
         $template->param(message=>1, bad_data=>1);
         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
+        exit;
     }
 
     my $failed_holds = 0;
@@ -274,10 +278,10 @@ if ( $query->param('place_reserve') ) {
 
         my $rank = $biblioData->{rank};
         if ( $itemNum ne '' ) {
-            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
+            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum, $branch )->{status} eq 'OK';
         }
         else {
-            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum )->{status} eq 'OK';
+            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum, $branch )->{status} eq 'OK';
 
             # Inserts a null into the 'itemnumber' field of 'reserves' table.
             $itemNum = undef;
@@ -400,7 +404,6 @@ $template->param('item_level_itypes' => $itemLevelTypes);
 
 foreach my $biblioNum (@biblionumbers) {
 
-    my $record = GetMarcBiblio({ biblionumber => $biblioNum });
     # Init the bib item with the choices for branch pickup
     my %biblioLoopIter;
 
@@ -409,6 +412,7 @@ foreach my $biblioNum (@biblionumbers) {
     if (! $biblioData) {
         $template->param(message=>1, bad_biblionumber=>$biblioNum);
         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
+        exit;
     }
 
     my @not_available_at = ();
@@ -420,7 +424,10 @@ foreach my $biblioNum (@biblionumbers) {
     my $frameworkcode = GetFrameworkCode( $biblioData->{biblionumber} );
     $biblioLoopIter{biblionumber} = $biblioData->{biblionumber};
     $biblioLoopIter{title} = $biblioData->{title};
-    $biblioLoopIter{subtitle} = GetRecordValue('subtitle', $record, $frameworkcode);
+    $biblioLoopIter{subtitle} = $biblioData->{'subtitle'};
+    $biblioLoopIter{medium} = $biblioData->{medium};
+    $biblioLoopIter{part_number} = $biblioData->{part_number};
+    $biblioLoopIter{part_name} = $biblioData->{part_name};
     $biblioLoopIter{author} = $biblioData->{author};
     $biblioLoopIter{rank} = $biblioData->{rank};
     $biblioLoopIter{reservecount} = $biblioData->{reservecount};
@@ -537,7 +544,7 @@ foreach my $biblioNum (@biblionumbers) {
 
         my $policy_holdallowed = !$itemLoopIter->{already_reserved};
         $policy_holdallowed &&=
-            IsAvailableForItemLevelRequest($itemInfo,$patron_unblessed) &&
+            IsAvailableForItemLevelRequest($item, $patron) &&
             CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
 
         if ($policy_holdallowed) {