From 78062cb4e833748c03dcec72381775318adf7b18 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 4 Nov 2020 16:52:14 +0000 Subject: [PATCH] Bug 26132: (GOLF EXAMPLE) --- C4/Circulation.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 6880a8288c..bc77eba6cd 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -450,20 +450,20 @@ sub TooMany { if (defined($maxissueqty_rule) and $maxissueqty_rule->rule_value ne "") { my $checkouts; + my $where = {}; + my $attr = { prefetch => 'item' }; if ( $maxissueqty_rule->branchcode ) { if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) { - $checkouts = $patron->checkouts->search( - { 'me.branchcode' => $maxissueqty_rule->branchcode } ); + $where = { 'me.branchcode' => $maxissueqty_rule->branchcode }; } elsif (C4::Context->preference('CircControl') eq 'PatronLibrary') { - $checkouts = $patron->checkouts; # if branch is the patron's home branch, then count all loans by patron + # if branch is the patron's home branch, then count all loans by patron } else { - $checkouts = $patron->checkouts->search( - { 'item.homebranch' => $maxissueqty_rule->branchcode }, - { prefetch => 'item' } ); + $where = { 'item.homebranch' => $maxissueqty_rule->branchcode }; } } else { - $checkouts = $patron->checkouts; # if rule is not branch specific then count all loans by patron + # if rule is not branch specific then count all loans by patron } + $checkouts = $patron->checkouts->search( $where, $attr ); my $sum_checkouts; my $rule_itemtype = $maxissueqty_rule->itemtype; while ( my $c = $checkouts->next ) { -- 2.20.1