From 8a0facb13b226c3404a86c10d61b96586a467876 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Fri, 8 Aug 2025 15:07:24 +0300 Subject: [PATCH] Bug 23415: Add new syspref AllowFineOverrideRenewing This patch adds new syspref AllowFineOverrideRenewing. It allows staff to renew items for patrons whose fines are over limit set in syspref FineNoRenewals. Otherwise renewing is prevented. If renewing items is allowed staff is still required to confirm if they really want to renew items for the patron. To test: 1. Apply this patch, update database and restart all services. 2. Find patron with fines over limit set in FineNoRenewals and renewable items. => Note that renewing is prevented with message "Cannot renew, the patron has a debt of..." 3. Set syspref AllowFineOverrideRenewing as "Allow". => Note that items can now be renewed and renewing them displays confirmation pop-up. Sponsored-by: Koha-Suomi Oy Signed-off-by: Andrew Fuerste Henry Signed-of-by: Martin Renvoize --- C4/Circulation.pm | 15 ++++++++------- installer/data/mysql/atomicupdate/bug_23415.pl | 13 +++++++++++-- installer/data/mysql/mandatory/sysprefs.sql | 3 ++- .../en/modules/admin/preferences/circulation.pref | 6 ++++++ koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 12 ++++++++++++ 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index e1a388cd1e5..b671d7fd425 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3266,12 +3266,13 @@ sub CanBookBeRenewed { $final_unseen_renewal = ( C4::Context->preference('UnseenRenewals') && $issuing_rule->{unseen_renewals_allowed} == ( $issue->unseen_renewals + 1 ) ) ? 1 : 0; - my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing'); - my $finesblockrenewing = C4::Context->preference("FineNoRenewals"); - my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing'); - my $restricted = $patron->is_debarred; - my $hasoverdues = $patron->has_overdues; - my $balance = $patron->account->balance; + my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing'); + my $finesblockrenewing = C4::Context->preference("FineNoRenewals"); + my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing'); + my $allowfineoverriderenewing = C4::Context->preference("AllowFineOverrideRenewing"); + my $restricted = $patron->is_debarred; + my $hasoverdues = $patron->has_overdues; + my $balance = $patron->account->balance; if ( $restricted and $restrictionblockrenewing ) { return ( 0, 'restriction' ); @@ -3279,7 +3280,7 @@ sub CanBookBeRenewed { || ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) ) { return ( 0, 'overdue' ); - } elsif ( $finesblockrenewing && $balance > $finesblockrenewing ) { + } elsif ( $finesblockrenewing && $balance > $finesblockrenewing && !$allowfineoverriderenewing ) { return ( 0, 'too_much_oweing'); } diff --git a/installer/data/mysql/atomicupdate/bug_23415.pl b/installer/data/mysql/atomicupdate/bug_23415.pl index a4160f16cea..57a3bf96394 100755 --- a/installer/data/mysql/atomicupdate/bug_23415.pl +++ b/installer/data/mysql/atomicupdate/bug_23415.pl @@ -2,17 +2,26 @@ use Modern::Perl; return { bug_number => "23415", - description => "Rename OPACFineNoRenewals", + description => "Rename OPACFineNoRenewals and add new syspref AllowFineOverrideRenewing", up => sub { my ($args) = @_; my ( $dbh, $out ) = @$args{qw(dbh out)}; $dbh->do( q{ - UPDATE systempreferences SET variable = "FineNoRenewals", explanation = "Fine limit above which user or staff cannot renew items" WHERE variable = "OPACFineNoRenewals"; + UPDATE IGNORE systempreferences SET variable = "FineNoRenewals", explanation = "Fine limit above which user or staff cannot renew items" WHERE variable = "OPACFineNoRenewals"; } ); say $out "Updated system preference 'OPACFineNoRenewals'"; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) + VALUES ('AllowFineOverrideRenewing', '0', '0', 'If on, staff will be able to renew items for patrons with fines greater than FineNoRenewals.','YesNo') + } + ); + + say $out "Added new system preference 'AllowFineOverrideRenewing'"; }, }; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 936a54a7583..34a2c2ed39a 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -30,8 +30,9 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AllowAllMessageDeletion','0',NULL,'Allow any Library to delete any message','YesNo'), ('AllowCheckoutNotes', '0', NULL, 'Allow patrons to submit notes about checked out items.','YesNo'), ('AllowFineOverride','0',NULL,'If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','YesNo'), +('AllowFineOverrideRenewing','0',NULL,'If on, staff will be able to renew items for patrons with fines greater than FineNoRenewals.','YesNo'), ('AllowHoldDateInFuture','0',NULL,'If set a date field is displayed on the Hold screen of the Staff Interface, allowing the hold date to be set in the future.','YesNo'), -('AllowHoldItemTypeSelection','0',NULL,'If enabled, patrons and staff will be able to select the itemtype when placing a hold','YesNo'), +('AllowHoldItemTypeSelection','0','','If enabled, patrons and staff will be able to select the itemtype when placing a hold','YesNo'), ('AllowHoldPolicyOverride','0',NULL,'Allow staff to override hold policies when placing holds','YesNo'), ('AllowHoldsOnDamagedItems','1',NULL,'Allow hold requests to be placed on damaged items','YesNo'), ('AllowHoldsOnPatronsPossessions','1',NULL,'Allow holds on records that patron have items of it','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 5d1a7bbb09c..c26f00c3657 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -263,6 +263,12 @@ Circulation: 1: Allow 0: "Don't allow" - staff to manually override and check out items to patrons who have more in fines than set in the noissuescharge system preference. + - + - pref: AllowFineOverrideRenewing + choices: + 1: Allow + 0: "Don't allow" + - staff to manually override and renew items for patrons who have more in fines than set in the FineNoRenewals system preference. - - pref: AutomaticItemReturn choices: diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 001b264df9a..2044bc0d71b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -501,6 +501,18 @@ function LoadIssuesTable() { __("Renewal denied by syspref") + ""; + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( + oObj.can_renew_error == "too_much_oweing" + ) { + msg += + "" + + __( + "Cannot renew, he patron has a debt of " + parseFloat(oObj.fine).format_price() + ) + + ""; + span_style = "display: none"; span_class = "renewals-allowed"; } else { -- 2.53.0