From 67a94f61db47f77f2e06090dad2f997c8d3f7e26 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 9 Feb 2021 12:14:19 -0300 Subject: [PATCH] Bug 27071: Use GetReservesControlBranch to pick the branch Pretty much like the opac-reserve.pl does, this patch makes the staff request.pl script get the branch from the specialized routine from C4::Reserves instead of falling back to userenv. To test: 1. Follow the original test plan: - Create two local hold groups containing distinct lists of libraries. - In default rules for all libraries, set Hold Policy = "From local hold group" and Hold pickup library match to "Patron's hold group" - Make sure AllowHoldPolicyOverride is set to Don't Allow - Make sure you're logged in at a library in Group 1 - Find a bib with only 1 item from Group 1. Confirm you can place a hold on this title for a patron in Group 1 (correct), but not for a patron in Group 2 (correct). - Find a bib with only 1 item from Group 2. Confirm you cannot place a hold for a patron from Group 1 (correct), BUT you also cannot place a hold for a patron from Group 2 (incorrect) -- Koha gives the erroneous message "pickupNotInHoldGroup" - Change your library to a something in Group 2 - Find a bib with only 1 item from Group 1. Confirm you cannot place a hold on this title for a patron in Group 1 (incorrect), and not for a patron in Group 2 (correct). - Find a bib with only 1 item from Group 2. Confirm you cannot place a hold for a patron from Group 1 (correct), but you can place a hold for a patron from Group 2 (correct) => FAIL: Things expected to fail on the plan, fail. 2. Apply this patches 3. Repeat 1 => SUCCESS: It now works! Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind --- reserve/request.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reserve/request.pl b/reserve/request.pl index 38d6f56ed2..13d0879f3f 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -67,7 +67,7 @@ my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( ); my $showallitems = $input->param('showallitems'); -my $pickup = $input->param('pickup') || C4::Context->userenv->{'branch'}; +my $pickup = $input->param('pickup'); my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; @@ -551,7 +551,8 @@ foreach my $biblionumber (@biblionumbers) { $item->{'holdallowed'} = $branchitemrule->{'holdallowed'}; - my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber, $pickup )->{status}; + my $reserves_control_branch = $pickup // C4::Reserves::GetReservesControlBranch( $item, $patron_unblessed ); + my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber, $reserves_control_branch )->{status}; $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' ); $item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } ); -- 2.11.0