From 1c56b7a488c96ed8f62d8a4b2471110dd1da61f4 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 25 Jan 2021 15:34:31 +0000 Subject: [PATCH] Bug 27529: Choose patron's branch or item's homebranch if following group rules and patron cannot choose branch This patch defaults the holds pickup location to the items homebranch or the patron's branch when a group option is selected for the hold fulfillment policy and the patron is not allowed to choose the branch on the OPAC To test: 1 - Set 'Default checkout, hold and return policy' -> 'Hold pickup library match' to item's hold group or patron's hold group 2 - Set OPACAllowUserToChooseBranch to 'Don't allow' 3 - Try to place an item level hold on the opac 4 - Ka-boom, etiher: The method Koha::Item->patrongroup is not covered by tests! The method Koha::Item->itemgroup is not covered by tests! 5 - Apply patch 6 - Repeat 7 - Note the pickup location is set to either the patron's branch or the items homebranch 8 - Repeat plan with the other group setting --- opac/opac-reserve.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index b90a2061b2..d0d2c4680d 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -246,8 +246,10 @@ if ( $query->param('place_reserve') ) { my $type = $item->effective_itemtype; my $rule = GetBranchItemRule( $patron->branchcode, $type ); - if ( $rule->{hold_fulfillment_policy} eq 'any' ) { + if ( $rule->{hold_fulfillment_policy} eq 'any' || $rule->{hold_fulfillment_policy} eq 'patrongroup' ) { $branch = $patron->branchcode; + } elsif ( $rule->{hold_fulfillment_policy} eq 'itemgroup' ){ + $branch = $item->homebranch; } else { my $policy = $rule->{hold_fulfillment_policy}; $branch = $item->$policy; -- 2.11.0