Bug 10166 - Can't place holds on multiple titles if one or more are un-holdable
authorOwen Leonard <oleonard@myacpl.org>
Wed, 1 May 2013 18:22:50 +0000 (14:22 -0400)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Mon, 6 May 2013 12:33:35 +0000 (08:33 -0400)
opac-reserve.pl tries to check whether all selected titles in a
multiple-hold batch are unavailable to be placed on hold. However, the
logic is flawed in such a way that if the last item in the batch cannot
be placed on hold the script assumes none can be placed on hold.

This patch modifies the way the script tracks the "no titles available
for holds" variable in order to correct the error.

To test, place multiple holds by selecting titles from a list of search
results. Test three conditions:

- All titles are available to be placed on hold

  You should see no onscreen warnings, and all titles should be
  selectable on the place hold screen. A "Place hold" button should
  appear at the bottom.

- Some titles can be placed on hold, some cannot

  The titles which can be placed on hold should be selectable.
  Titles which cannot be placed on hold should show a warning
  message. A "Place hold" button should appear at the bottom.

- No titles can be placed on hold

  "Sorry, none of these items can be placed on hold." should appear at
  the top of the page. All titles should appear with warning messages.
  There should be no "Place hold" button.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
All tests and QA script pass.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
opac/opac-reserve.pl

index e725d30..c6e05f5 100755 (executable)
@@ -349,7 +349,7 @@ my $notforloan_label_of = get_notforloan_label_of();
 my $biblioLoop = [];
 my $numBibsAvailable = 0;
 my $itemdata_enumchron = 0;
-my $anyholdable;
+my $anyholdable = 0;
 my $itemLevelTypes = C4::Context->preference('item-level_itypes');
 $template->param('item_level_itypes' => $itemLevelTypes);
 
@@ -526,26 +526,24 @@ foreach my $biblioNum (@biblionumbers) {
         $numBibsAvailable++;
         $biblioLoopIter{bib_available} = 1;
         $biblioLoopIter{holdable} = 1;
-        $anyholdable = 1;
     }
     if ($biblioLoopIter{already_reserved}) {
         $biblioLoopIter{holdable} = undef;
-        $anyholdable = undef;
     }
     if(not CanBookBeReserved($borrowernumber,$biblioNum)){
         $biblioLoopIter{holdable} = undef;
-        $anyholdable = undef;
     }
     if(not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowernumber,$biblioNum)) {
         $biblioLoopIter{holdable} = undef;
         $biblioLoopIter{already_patron_possession} = 1;
-        $anyholdable = undef;
     }
 
+    if( $biblioLoopIter{holdable} ){ $anyholdable = 1; }
+
     push @$biblioLoop, \%biblioLoopIter;
 }
 
-if ( $numBibsAvailable == 0 || !$anyholdable) {
+if ( $numBibsAvailable == 0 || $anyholdable == 0) {
     $template->param( none_available => 1 );
 }