From 1e096f22ccf9781fe469ba4ff9e923a248c6d4d5 Mon Sep 17 00:00:00 2001 From: Shi Yao Wang Date: Tue, 5 Jul 2022 12:03:52 -0400 Subject: [PATCH] Bug 31105: Holds to pull counts items from other branches when independentbranches is active Holds to pull should not show items from other branches that shares a record when IndependentBranches is active. Except for superlibrarians. Test plan: 1- Have IndependentBranches set to Yes 2- Have a record with an item from the current branch and another item from a different branch. We will call them branch A and branch B respectively 3- Have a patron from branch A place a hold on that record 4- Have a staff account on branch A and B with the following permissions: - circulate (all) - catalogue 5- Go to circulation > holds to pull 6- Notice under "Libraries" it displays branch A and B. Also, it shows 2 under "Items available" 7- Checkout the item from branch A to another patron 8- Go back to circulation > holds to pull 9- Notice under "Libraries" it displays branch B even though we are in branch A 10- Apply the patch 11- Return the checked out item from step 7 12- Redo step 5 to 9 with superlibrarian privileges and notice nothing changed 13- Redo step 11-12 but using accounts from step 4 and notice Holds to pull only shows information relevant to their branch Signed-off-by: Sally Signed-off-by: Kyle M Hall --- Koha/Items.pm | 1 + circ/pendingreserves.pl | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Koha/Items.pm b/Koha/Items.pm index 3e4eece94e..5e9e808eee 100644 --- a/Koha/Items.pm +++ b/Koha/Items.pm @@ -76,6 +76,7 @@ sub filter_by_for_hold { withdrawn => 0, notforloan => { '<=' => 0 }, # items with negative or zero notforloan value are holdable ( C4::Context->preference('AllowHoldsOnDamagedItems')? (): ( damaged => 0 ) ), + ( C4::Context->only_my_library() ? ( homebranch => C4::Context::mybranch() ) : () ), }; if ( C4::Context->preference("item-level_itypes") ) { diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index a438557ed1..86a18b14f0 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -181,8 +181,8 @@ if ( !C4::Context->preference('AllowHoldsOnDamagedItems') ){ $where{'itembib.damaged'} = 0; } -if ( C4::Context->preference('IndependentBranches') ){ - $where{'itembib.holdingbranch'} = C4::Context->userenv->{'branch'}; +if ( C4::Context->only_my_library() ){ + $where{'me.branchcode'} = C4::Context->userenv->{'branch'}; } # get all distinct unfulfilled reserves -- 2.30.2