From d52983cf3d448d18b0b0086968a506522e3cc816 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 --- reserve/request.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/reserve/request.pl b/reserve/request.pl index 4f80b8d5b9..92f75b2c26 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -425,6 +425,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; @@ -571,7 +572,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} ); } @@ -591,7 +592,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