From 8a9ddc1b1ca2f63e9129e1381493b60a18db2cce Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 28 Nov 2023 14:57:55 +0000 Subject: [PATCH] Bug 18139: Display the rule critera used to determin the checkout limits to the template MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The too many checked out message can be very confusing for librarians when the limit specified is more or less than the number of checkouts the patron already has. We should make it clear to the librarian that his is only counting certain types of checkouts by giving them the issuing rule criteria used. Test Plan: 1) Apply this patch 2) Try to check out more items than the circ rules allow for regular and on-site checkouts Signed-off-by: Eric Gosselin Signed-off-by: Marc Véron Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi Signed-off-by: Katrin Fischer --- C4/Circulation.pm | 41 ++++++++++++------- .../prog/en/modules/circ/circulation.tt | 41 +++++++++++++++++++ 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index ac28b2e74b..13ca90e9f2 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -541,6 +541,8 @@ sub TooMany { max_checkouts_allowed => $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef, max_onsite_checkouts_allowed => $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef, switch_onsite_checkout => $switch_onsite_checkout, + circulation_rule => $maxissueqty_rule, + onsite_circulation_rule => $maxonsiteissueqty_rule, }; # If parent rules exists if ( defined($parent_maxissueqty_rule) and defined($parent_maxissueqty_rule->rule_value) ){ @@ -589,7 +591,8 @@ sub TooMany { onsite_checkout => $onsite_checkout, max_checkouts_allowed => $max_checkouts_allowed, max_onsite_checkouts_allowed => $max_onsite_checkouts_allowed, - switch_onsite_checkout => $switch_onsite_checkout + switch_onsite_checkout => $switch_onsite_checkout, + circulation_rule => $branch_borrower_circ_rule, } ); return $qty_over if defined $qty_over; @@ -611,14 +614,17 @@ sub _check_max_qty { my $max_checkouts_allowed = $params->{max_checkouts_allowed}; my $max_onsite_checkouts_allowed = $params->{max_onsite_checkouts_allowed}; my $switch_onsite_checkout = $params->{switch_onsite_checkout}; + my $circulation_rule = $params->{circulation_rule}; + my $onsite_circulation_rule = $params->{onsite_circulation_rule}; if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) { if ( $max_onsite_checkouts_allowed eq '' ) { return; } if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) { return { - reason => 'TOO_MANY_ONSITE_CHECKOUTS', - count => $onsite_checkout_count, - max_allowed => $max_onsite_checkouts_allowed, + reason => 'TOO_MANY_ONSITE_CHECKOUTS', + count => $onsite_checkout_count, + max_allowed => $max_onsite_checkouts_allowed, + circulation_rule => $onsite_circulation_rule, }; } } @@ -627,9 +633,10 @@ sub _check_max_qty { my $delta = $switch_onsite_checkout ? 1 : 0; if ( $checkout_count >= $max_checkouts_allowed + $delta ) { return { - reason => 'TOO_MANY_CHECKOUTS', - count => $checkout_count, - max_allowed => $max_checkouts_allowed, + reason => 'TOO_MANY_CHECKOUTS', + count => $checkout_count, + max_allowed => $max_checkouts_allowed, + circulation_rule => $circulation_rule, }; } } @@ -639,9 +646,10 @@ sub _check_max_qty { $checkout_count - $onsite_checkout_count >= $max_checkouts_allowed ) { return { - reason => 'TOO_MANY_CHECKOUTS', - count => $checkout_count - $onsite_checkout_count, - max_allowed => $max_checkouts_allowed, + reason => 'TOO_MANY_CHECKOUTS', + count => $checkout_count - $onsite_checkout_count, + max_allowed => $max_checkouts_allowed, + circulation_rule => $circulation_rule, }; } } @@ -1019,16 +1027,19 @@ sub CanBookBeIssued { # if TooMany max_allowed returns 0 the user doesn't have permission to check out this book if ( $toomany && not exists $needsconfirmation{RENEW_ISSUE} ) { if ( $toomany->{max_allowed} == 0 ) { - $needsconfirmation{PATRON_CANT} = 1; + $needsconfirmation{PATRON_CANT} = 1; + $needsconfirmation{circulation_rule_PATRON_CANT} = $toomany->{circulation_rule}; } if ( C4::Context->preference("AllowTooManyOverride") ) { - $needsconfirmation{TOO_MANY} = $toomany->{reason}; + $needsconfirmation{TOO_MANY} = $toomany->{reason}; $needsconfirmation{current_loan_count} = $toomany->{count}; - $needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; + $needsconfirmation{max_loans_allowed} = $toomany->{max_allowed}; + $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; } else { - $issuingimpossible{TOO_MANY} = $toomany->{reason}; + $issuingimpossible{TOO_MANY} = $toomany->{reason}; $issuingimpossible{current_loan_count} = $toomany->{count}; - $issuingimpossible{max_loans_allowed} = $toomany->{max_allowed}; + $issuingimpossible{max_loans_allowed} = $toomany->{max_allowed}; + $needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule}; } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 91a77187d5..94dcaf6dbc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -171,10 +171,18 @@ [% IF TOO_MANY and TOO_MANY == 'TOO_MANY_CHECKOUTS' %]
  • Too many checked out. [% current_loan_count | html %] checked out, only [% max_loans_allowed | html %] are allowed.
  • +
  • + Maximum checkouts calculated from the circulation rule for + [% INCLUDE circulation_rule_criteria rule=circulation_rule_TOO_MANY %] +
  • [% END %] [% IF TOO_MANY and TOO_MANY == 'TOO_MANY_ONSITE_CHECKOUTS' %]
  • Too many on-site checked out. [% current_loan_count | html %] on-site checked out, only [% max_loans_allowed | html %] are allowed.
  • +
  • + Maximum checkouts calculated from the circulation rule for + [% INCLUDE circulation_rule_criteria rule=circulation_rule_TOO_MANY %] +
  • [% END %] [% IF ( BORRNOTSAMEBRANCH ) %] @@ -557,6 +565,10 @@ [% IF ( TOO_MANY ) %]
  • Too many checked out. [% current_loan_count | html %] checked out, only [% max_loans_allowed | html %] are allowed.
  • +
  • + Maximum checkouts calculated from the circulation rule for + [% INCLUDE circulation_rule_criteria rule=circulation_rule_TOO_MANY %] +
  • [% END %] [% IF ( ITEMNOTSAMEBRANCH ) %] @@ -1055,3 +1067,32 @@ [% END %] [% INCLUDE 'intranet-bottom.inc' %] + +[% BLOCK circulation_rule_criteria %] +
      +
    • + Item type: + [% IF rule.itemtype %] + [% ItemTypes.GetDescription( rule.itemtype ) | html %] + [% ELSE %] + All + [% END %] +
    • +
    • + Patron category: + [% IF rule.categorycode %] + [% Categories.GetName( rule.categorycode ) | html %] + [% ELSE %] + All + [% END %] +
    • +
    • + Library: + [% IF rule.branchcode %] + [% Branches.GetName( rule.branchcode ) | html %] + [% ELSE %] + All libraries + [% END %] +
    • +
    +[% END %] -- 2.39.5