From 83729f038ad67b79e9d6631e924789120ba708d8 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Tue, 17 Sep 2024 10:54:32 +0300 Subject: [PATCH 1/6] Bug 23415: Notify patron fines when renewing It is possible to renew items for patron who has fines over accepted limit on renew page or from checkout list. This patch adds confirmation alerts to these renew actions when patron has fines over "noissuescharge" syspref. Test plan: 1. Have patron with checkouts and fines over allowed limit 2. Renew checkouts either from renew page or checkout list => renew is successful 3. Apply patch 4. Repeat steps 1 and 2 => On renew page an alert is displayed and user has to confirm renew => When renew is done from checkout list confirmation pop-up is displayed Sponsored-by: Koha-Suomi Oy Signed-off-by: Shi Yao Wang Signed-off-by: Martin Renvoize --- circ/circulation.pl | 2 +- circ/renew.pl | 18 +++++++++++++++++- .../en/modules/admin/preferences/opac.pref | 1 + .../prog/en/modules/circ/circulation.tt | 4 ++++ .../prog/en/modules/circ/renew.tt | 10 ++++++++++ .../prog/en/modules/members/moremember.tt | 4 ++++ koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 15 +++++++++++++++ 7 files changed, 52 insertions(+), 2 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index 0a9906028e..16993a994e 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -292,7 +292,7 @@ if ($patron) { $template->param( overduecount => $overdues->count, issuecount => $issues->count, - finetotal => $balance, + fines => $balance, ); if ( $patron and $patron->is_debarred ) { diff --git a/circ/renew.pl b/circ/renew.pl index c27881a494..539b0eddeb 100755 --- a/circ/renew.pl +++ b/circ/renew.pl @@ -27,6 +27,7 @@ use C4::Circulation qw( barcodedecode CanBookBeRenewed GetLatestAutoRenewDate Ad use Koha::DateUtils qw( dt_from_string ); use Koha::Database; use Koha::BiblioFrameworks; +use Koha::Patrons; my $cgi = CGI->new; @@ -47,11 +48,12 @@ my $unseen = $cgi->param('unseen') || 0; $barcode = barcodedecode($barcode) if $barcode; my $override_limit = $cgi->param('override_limit'); my $override_holds = $cgi->param('override_holds'); +my $override_debt = $cgi->param('override_debt'); my $hard_due_date = $cgi->param('hard_due_date'); my ( $item, $checkout, $patron ); my $error = q{}; -my ( $soonest_renew_date, $latest_auto_renew_date ); +my ( $soonest_renew_date, $latest_auto_renew_date, $balance ); if ( $op eq 'cud-renew' && $barcode ) { $barcode = barcodedecode($barcode) if $barcode; @@ -65,6 +67,9 @@ if ( $op eq 'cud-renew' && $barcode ) { $patron = $checkout->patron; + $balance = $patron->account->balance; + my $amountlimit = C4::Context->preference("OPACFineNoRenewals"); + if ( ( $patron->is_debarred || q{} ) lt dt_from_string()->ymd() ) { my $can_renew; my $info; @@ -88,6 +93,16 @@ if ( $op eq 'cud-renew' && $barcode ) { $checkout, ); } + + if ( $balance > $amountlimit ) { + $error = "too_much_debt"; + $can_renew = 0; + if ($override_debt) { + $can_renew = 1; + $error = undef; + } + } + if ($can_renew) { my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; my $date_due = @@ -122,6 +137,7 @@ if ( $op eq 'cud-renew' && $barcode ) { error => $error, soonestrenewdate => $soonest_renew_date, latestautorenewdate => $latest_auto_renew_date, + balance => $balance, ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index f15aad0b93..5944febf80 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -657,6 +657,7 @@ OPAC: - pref: OPACFineNoRenewals class: currency - '[% local_currency %] in charges (leave blank to disable).' + -
NOTE: If set, confirmation dialog is shown when renewing for patron with charges from staff interface.' - - pref: OPACFineNoRenewalsIncludeCredits choices: 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 1ca767f729..4cd08600b9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -1135,6 +1135,10 @@ [% UNLESS ( patron.borrowernumber ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %] + var amountlimit = "[% Koha.Preference('OPACFineNoRenewals') | html %]"; + var fines = "[% fines | $Price %]"; + var MSG_CONFIRM_RENEW = _("The patron has a debt of %s\nAre you sure you want to renew checkout(s)?").format(fines); + // On-site checkout function toggle_onsite_checkout(){ const duedatespec = document.querySelector("#duedatespec"); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt index ad65329134..d74f1ea834 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt @@ -2,6 +2,7 @@ [% USE Asset %] [% USE Koha %] [% USE KohaDates %] +[% USE Price %] [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] @@ -137,6 +138,14 @@ [% END %] + [% ELSIF error == "too_much_debt" %] + +
  • The patron has a debt of [% balance | $Price %].
  • +
    + + + +
    [% ELSIF error == "on_reserve" %]

    [% INCLUDE 'biblio-title.inc' biblio=item.biblio link = 1 %] ( [% item.barcode | html %] ): This item is on hold for another patron.

    @@ -163,6 +172,7 @@

    Item cannot be renewed because it's an onsite checkout

    [% ELSIF error == 'recalled' %]

    This item has been recalled.

    + [% ELSE %] [% error | html %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index cdb10f8e48..1c0b34dd04 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -807,6 +807,10 @@ CAN_user_circulate_manage_bookings = [% CAN_user_circulate_manage_bookings | $raw %] patron_borrowernumber = [% patron.borrowernumber | $raw %] + var amountlimit = "[% Koha.Preference('OPACFineNoRenewals') | html %]"; + var fines = "[% fines | $Price %]"; + var MSG_CONFIRM_RENEW = _("The patron has a debt of %s\n Are you sure you want to renew checkout(s)?").format(fines); + function uncheck_sibling(me){ nodename=me.getAttribute("name"); if (nodename =="barcodes[]"){ diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 185a5488db..67881a0253 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -754,6 +754,8 @@ if (AlwaysLoadCheckoutsTable) { $(document).ready(function () { var onHoldDueDateSet = false; + var show_confirm = true; + var onHoldChecked = function () { var isChecked = false; $("input[data-on-reserve]").each(function () { @@ -943,6 +945,16 @@ $(document).ready(function () { $("#RenewChecked").on("click", function (e) { e.preventDefault(); let refresh_table = true; + + if(show_confirm && parseFloat(fines) > parseFloat(amountlimit) ) { + var result = confirm(MSG_CONFIRM_RENEW); + if(!result){ + return false; + } + // Prevent displaying confirm box again + show_confirm = false; + } + function renew(item_id) { var override_limit = $("#override_limit").is(":checked") ? 1 : 0; @@ -978,6 +990,9 @@ $(document).ready(function () { params.date_due = dueDate; } + + $(this).parent().parent().replaceWith(""); + const client = APIClient.circulation; return client.checkouts.renew(params).then( success => { -- 2.34.1