Bugzilla – Attachment 189837 Details for
Bug 41280
Adjust PatronLibrary scope, respect global level for the second patron_maxissueqty rule in C4::Circulation::TooMany
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41280: Add patron library scope to PatronLibrary for branch level rules
Bug-41280-Add-patron-library-scope-to-PatronLibrar.patch (text/plain), 4.44 KB, created by
Marcel de Rooy
on 2025-11-21 10:42:29 UTC
(
hide
)
Description:
Bug 41280: Add patron library scope to PatronLibrary for branch level rules
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2025-11-21 10:42:29 UTC
Size:
4.44 KB
patch
obsolete
>From 72433ac3cb87c5882ddb930ab302a3335b6abef2 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 21 Nov 2025 11:37:01 +0100 >Subject: [PATCH] Bug 41280: Add patron library scope to PatronLibrary for > branch level rules >Content-Type: text/plain; charset=utf-8 > >At the same time bringing both CircControl blocks more in sync by using >$branch and a new $prefetch variable. >--- > C4/Circulation.pm | 41 +++++++++++++++++++---------------------- > 1 file changed, 19 insertions(+), 22 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index c0ff2a6726..488abff1fc 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -435,8 +435,9 @@ sub TooMany { > my $dbh = C4::Context->dbh; > > # Get which branchcode we need >- my $branch = _GetCircControlBranch( $item, $patron ); >- my $type = $item->effective_itemtype; >+ my $branch = _GetCircControlBranch( $item, $patron ); >+ my $type = $item->effective_itemtype; >+ my $branch_type = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch'; > > my ( $type_object, $parent_type, $parent_maxissueqty_rule ); > $type_object = Koha::ItemTypes->find($type); >@@ -484,19 +485,16 @@ sub TooMany { > if ( defined($maxissueqty_rule) and $maxissueqty_rule->rule_value ne "" ) { > > my $checkouts; >- if ( $maxissueqty_rule->branchcode ) { >- if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) { >- $checkouts = $patron->checkouts->search( { '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 >- } else { >- my $branch_type = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch'; >- $checkouts = $patron->checkouts->search( { "item.$branch_type" => $maxissueqty_rule->branchcode } ); >- } >- } else { >- $checkouts = $patron->checkouts; # if rule is not branch specific then count all loans by patron >+ my $prefetch = { prefetch => 'item' }; >+ if ( !$maxissueqty_rule->branchcode ) { # global level: look at all checkouts >+ $checkouts = $patron->checkouts( undef, $prefetch ); >+ } elsif ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) { >+ $checkouts = $patron->checkouts->search( { 'me.branchcode' => $branch }, $prefetch ); >+ } elsif ( C4::Context->preference('CircControl') eq 'PatronLibrary' ) { >+ $checkouts = $patron->checkouts->search( { "item.$branch_type" => $branch }, $prefetch ); >+ } else { # ItemHomeLibrary >+ $checkouts = $patron->checkouts->search( { "item.$branch_type" => $branch }, $prefetch ); > } >- $checkouts = $checkouts->search( undef, { prefetch => 'item' } ); > > my $sum_checkouts; > my $rule_itemtype = $maxissueqty_rule->itemtype; >@@ -591,17 +589,16 @@ sub TooMany { > if ( defined( $branch_borrower_circ_rule->{patron_maxissueqty} ) > and $branch_borrower_circ_rule->{patron_maxissueqty} ne '' ) > { >- my $checkouts = $patron->checkouts; >+ my $checkouts; >+ my $prefetch = { prefetch => 'item' }; > if ( !$branch_borrower_circ_rule->branchcode ) { # global level: look at all checkouts >- } elsif ( C4::Context->preference('CircControl') eq 'PatronLibrary' ) { # do the same >+ $checkouts = $patron->checkouts; > } elsif ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) { > $checkouts = $patron->checkouts->search( { 'me.branchcode' => $branch } ); >- } else { >- my $branch_type = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch'; >- $checkouts = $patron->checkouts->search( >- { "item.$branch_type" => $branch }, >- { prefetch => 'item' } >- ); >+ } elsif ( C4::Context->preference('CircControl') eq 'PatronLibrary' ) { >+ $checkouts = $patron->checkouts->search( { "item.$branch_type" => $branch }, $prefetch ); >+ } else { # ItemHomeLibrary >+ $checkouts = $patron->checkouts->search( { "item.$branch_type" => $branch }, $prefetch ); > } > > my $checkout_count = $checkouts->count; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41280
:
189836
|
189837
|
189838
|
189839