Bug 15524: (QA follow-up) Change Can[Book|Item]BeReserved to return hashref, pass...
[koha.git] / reserve / request.pl
index 2902de0..2fd36e8 100755 (executable)
@@ -211,24 +211,25 @@ foreach my $biblionumber (@biblionumbers) {
     if ( $patron ) {
         { # CanBookBeReserved
             my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber );
-            $canReserve //= '';
-            if ( $canReserve eq 'OK' ) {
+            $canReserve->{status} //= '';
+            if ( $canReserve->{status} eq 'OK' ) {
 
                 #All is OK and we can continue
             }
-            elsif ( $canReserve eq 'tooManyReserves' ) {
+            elsif ( $canReserve->{status} eq 'tooManyReserves' ) {
                 $exceeded_maxreserves = 1;
+                $template->param( maxreserves => $canReserve->{limit} );
             }
-            elsif ( $canReserve eq 'tooManyHoldsForThisRecord' ) {
+            elsif ( $canReserve->{status} eq 'tooManyHoldsForThisRecord' ) {
                 $exceeded_holds_per_record = 1;
-                $biblioloopiter{$canReserve} = 1;
+                $biblioloopiter{ $canReserve->{status} } = 1;
             }
-            elsif ( $canReserve eq 'ageRestricted' ) {
-                $template->param( $canReserve => 1 );
-                $biblioloopiter{$canReserve} = 1;
+            elsif ( $canReserve->{status} eq 'ageRestricted' ) {
+                $template->param( $canReserve->{status} => 1 );
+                $biblioloopiter{ $canReserve->{status} } = 1;
             }
             else {
-                $biblioloopiter{$canReserve} = 1;
+                $biblioloopiter{ $canReserve->{status} } = 1;
             }
         }
 
@@ -462,7 +463,7 @@ foreach my $biblionumber (@biblionumbers) {
                 $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
 
                 my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber );
-                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
+                $item->{not_holdable} = $can_item_be_reserved->{status} unless ( $can_item_be_reserved->{status} eq 'OK' );
 
                 $item->{item_level_holds} = Koha::IssuingRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );