Bug 18139: Display the rule critera used to determin the checkout limits to the template

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 <eric.gosselin@inlibro.com>
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 8a9ddc1b1c)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Kyle Hall 2023-11-28 14:57:55 +00:00 committed by Fridolin Somers
parent 4fb9fad791
commit e2715eb488
2 changed files with 67 additions and 15 deletions

View file

@ -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};
}
}

View file

@ -171,10 +171,18 @@
[% IF TOO_MANY and TOO_MANY == 'TOO_MANY_CHECKOUTS' %]
<li>Too many checked out. [% current_loan_count | html %] checked out, only [% max_loans_allowed | html %] are allowed.</li>
<li>
Maximum checkouts calculated from the circulation rule for
[% INCLUDE circulation_rule_criteria rule=circulation_rule_TOO_MANY %]
</li>
[% END %]
[% IF TOO_MANY and TOO_MANY == 'TOO_MANY_ONSITE_CHECKOUTS' %]
<li>Too many on-site checked out. [% current_loan_count | html %] on-site checked out, only [% max_loans_allowed | html %] are allowed.</li>
<li>
Maximum checkouts calculated from the circulation rule for
[% INCLUDE circulation_rule_criteria rule=circulation_rule_TOO_MANY %]
</li>
[% END %]
[% IF ( BORRNOTSAMEBRANCH ) %]
@ -557,6 +565,10 @@
[% IF ( TOO_MANY ) %]
<li>Too many checked out. [% current_loan_count | html %] checked out, only [% max_loans_allowed | html %] are allowed.</li>
<li>
Maximum checkouts calculated from the circulation rule for
[% INCLUDE circulation_rule_criteria rule=circulation_rule_TOO_MANY %]
</li>
[% END %]
[% IF ( ITEMNOTSAMEBRANCH ) %]
@ -1055,3 +1067,32 @@
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]
[% BLOCK circulation_rule_criteria %]
<ul>
<li>
Item type:
[% IF rule.itemtype %]
[% ItemTypes.GetDescription( rule.itemtype ) | html %]
[% ELSE %]
<i>All</i>
[% END %]
</li>
<li>
Patron category:
[% IF rule.categorycode %]
[% Categories.GetName( rule.categorycode ) | html %]
[% ELSE %]
<i>All</i>
[% END %]
</li>
<li>
Library:
[% IF rule.branchcode %]
[% Branches.GetName( rule.branchcode ) | html %]
[% ELSE %]
<i>All libraries</i>
[% END %]
</li>
</ul>
[% END %]