Bug 7534: Check hold availability to desired pickup location in opac-reserve.pl
authorLari Taskula <lari.taskula@jns.fi>
Tue, 7 Feb 2017 15:53:52 +0000 (17:53 +0200)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 6 Sep 2018 17:32:25 +0000 (17:32 +0000)
To test:
-1. Have access to your browser's developer tools in order to modify <select>
    dropdown values
1. Go to cgi-bin/koha/admin/branches.pl
2. Configure one of your libraries to "Pickup location" => "No". Remember the
   branchcode of this library!
3. Go place a hold in OPAC
4. See the provided "Pick up location" list
5. Observe the library that you configured is not present in the list
6. You should see another library selected by default. Right click that and
   in Firefox/Chrome click "Inspect element"
7. You should see a list of <option value="xxxx">blabla</option> elements
8. Double click between value (xxxx in above example) and replace the value
   with the branchcode you remember from step 2.
9. Place the hold
10. Observe that you are taken to cgi-bin/koha/opac-user.pl but your hold
    was not successful.
11. Go back to place a hold and this time do not modify any values.
12. Observe that a hold is now placed.

Signed-off-by: Koha Team AMU <axelle.clarisse@univ-amu.fr>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

opac/opac-reserve.pl

index 92989a2..89af3b0 100755 (executable)
@@ -269,10 +269,10 @@ if ( $query->param('place_reserve') ) {
 
         my $rank = $biblioData->{rank};
         if ( $itemNum ne '' ) {
-            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
+            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum, $branch )->{status} eq 'OK';
         }
         else {
-            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum )->{status} eq 'OK';
+            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum, $branch )->{status} eq 'OK';
 
             # Inserts a null into the 'itemnumber' field of 'reserves' table.
             $itemNum = undef;
@@ -525,7 +525,7 @@ foreach my $biblioNum (@biblionumbers) {
         my $policy_holdallowed = !$itemLoopIter->{already_reserved};
         $policy_holdallowed &&=
             IsAvailableForItemLevelRequest($itemInfo,$patron_unblessed) &&
-            CanItemBeReserved($borrowernumber,$itemNum)->{status} eq 'OK';
+            CanItemBeReserved($borrowernumber,$itemNum, $branch)->{status} eq 'OK';
 
         if ($policy_holdallowed) {
             my $opac_hold_policy = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
@@ -585,7 +585,7 @@ foreach my $biblioNum (@biblionumbers) {
         }
     }
 
-    $biblioLoopIter{holdable} &&= CanBookBeReserved($borrowernumber,$biblioNum)->{status} eq 'OK';
+    $biblioLoopIter{holdable} &&= CanBookBeReserved($borrowernumber,$biblioNum,$branch)->{status} eq 'OK';
 
     # For multiple holds per record, if a patron has previously placed a hold,
     # the patron can only place more holds of the same type. That is, if the