From a044f6365be947f8e97bd10a5ed4c6510f634eab Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 28 Jan 2020 13:57:32 +0000 Subject: [PATCH] Bug 24485: Allow hold when some can be overridden The check to see if we can place a hold counts the number that we can override vs the number of items on the record. We cannot override if we already have a hold on an item, however, we don't count these to see if they plus the number of overrides equal the items on the record. To test: 1 - Set max reserves to 2, allow 2 holds per recrod 2 - Place 2 holds for a patron on some records 3 - Find another record with 2 items 4 - Place a hold on the first item, you will be notified about the limit but you can override 5 - Attempt to place hold on second item, cannot be done, button disabled 6 - Apply patch 7 - Repeat 8 - You can place the second hold Signed-off-by: Kelly McElligott Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit d52983cf3d448d18b0b0086968a506522e3cc816) Signed-off-by: Lucas Gass --- reserve/request.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/reserve/request.pl b/reserve/request.pl index e80e77da4a..36b3ec8420 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -354,6 +354,7 @@ foreach my $biblionumber (@biblionumbers) { my $num_available = 0; my $num_override = 0; my $hiddencount = 0; + my $num_alreadyheld = 0; $biblioitem->{force_hold_level} = $force_hold_level; @@ -500,7 +501,7 @@ foreach my $biblionumber (@biblionumbers) { if ( $can_item_be_reserved ne 'itemAlreadyOnHold' ) { $item->{override} = 1; $num_override++; - } + } else { $num_alreadyheld++ } push( @available_itemtypes, $item->{itype} ); } @@ -520,7 +521,10 @@ foreach my $biblionumber (@biblionumbers) { push @{ $biblioitem->{itemloop} }, $item; } - if ( $num_override == scalar( @{ $biblioitem->{itemloop} } ) ) { # That is, if all items require an override + # While we can't override an alreay held item, we should be able to override the others + # Unless all items are already held + if ( $num_override > 0 && ($num_override + $num_alreadyheld) == scalar( @{ $biblioitem->{itemloop} } ) ) { + # That is, if all items require an override $template->param( override_required => 1 ); } elsif ( $num_available == 0 ) { $template->param( none_available => 1 ); -- 2.39.5