From eed055c2918cb6f28af07b5af038d3c77d03bba9 Mon Sep 17 00:00:00 2001 From: Maryse Simard Date: Thu, 7 Feb 2019 08:24:03 -0500 Subject: [PATCH] Bug 21263: Pickup library not set correctly when using Default holds policy In the case of a specific item hold, it can only be fulfilled if the pickup library matches the hold fulfillment policy. Therefore, if OPACAllowUserToChooseBranch is set to don't allow, the pickup library should correspond to the policy. In case of hold that does not specify an item, the homebranch or holdingbranch can't be determined at this time, so the pickup library still defaults to the homebranch of the borrower. Same if there is no policy or it states 'any'. To test: - Make sure OPACAllowUserToChooseBranch is set to don't allow - Make sure you have two branches A and B - Have one item whose homebranch is B - Have one user whose homebranch is A - Make sure the circulation rules allow the user to reserve the item's item type 1. Go to Administration > Circulation and fines rules 2. Create a Default holds policy by item type for that item type - Item type = item's item type - Hold policy = From any library - Hold pickup library match = item's home library - Return policy = item returns home 3. Go to the OPAC and log in with the user's credentials 4. Search for the item 5. Click on "Place hold" 6. Select a specific item and confirm hold 7. In the user's file on the OPAC and check the reservation's pickup library. It should be the item's homebranch You can then repeat the steps for 'item's holding library' or 'any library' as the Hold pickup library match. It should also work the same way if there is no 'Default holds policy by item type' for this item type but a 'Default checkout, hold and return policy' set. Finally, check that placing a hold without selecting a specific item still defaults the pickup library to the borrower's homebranch. Signed-off-by: Hayley Mapley Signed-off-by: Martin Renvoize --- opac/opac-reserve.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index aeb88ca036..725b31d07b 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -241,6 +241,20 @@ if ( $query->param('place_reserve') ) { $branch = $patron->branchcode; } + # When choosing a specific item, the default pickup library should be dictated by the default hold policy + if ( ! C4::Context->preference("OPACAllowUserToChooseBranch") && $itemNum ) { + my $item = Koha::Items->find( $itemNum ); + my $type = $item->effective_itemtype; + my $rule = GetBranchItemRule( $patron->branchcode, $type ); + + if ( $rule->{hold_fulfillment_policy} eq 'any' ) { + $branch = $patron->branchcode; + } else { + my $policy = $rule->{hold_fulfillment_policy}; + $branch = $item->$policy; + } + } + #item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber if ( $itemNum ne '' ) { my $item = Koha::Items->find( $itemNum ); -- 2.20.1