Bug 24485: Allow hold when some can be overridden
authorNick Clemens <nick@bywatersolutions.com>
Tue, 28 Jan 2020 13:57:32 +0000 (13:57 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 5 Feb 2020 12:32:31 +0000 (12:32 +0000)
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 <kelly@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

reserve/request.pl

index e63417b..5864b3d 100755 (executable)
@@ -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;
 
@@ -584,7 +585,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} );
                 }
@@ -604,7 +605,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 );