From 8016d2bd0d2d45ee0777469d28d988f2794575fb Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 1 May 2013 14:22:50 -0400 Subject: [PATCH] Bug 10166 - Can't place holds on multiple titles if one or more are un-holdable 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 Signed-off-by: Katrin Fischer All tests and QA script pass. Signed-off-by: Jared Camins-Esakov --- opac/opac-reserve.pl | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index e725d306e7..c6e05f5310 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -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 ); } -- 2.20.1