From e17b98f29ad41389daba2dccae72985db79eb7d3 Mon Sep 17 00:00:00 2001
From: Nick Clemens
Date: Thu, 23 Oct 2025 15:47:01 +0000
Subject: [PATCH] Bug 41090: Handle auto_renew_final message on renew.pl
This patch removes the error and adds a variable mentioning the last renewal so we can note for the patron
To test:
1 - Set a circ rule for:
Renewals Allowed: 1
Renewal period: 5
No renewal before: 6
No automatic renewal before: 6
Auto renewal: Yes
2 - Issue an item that matches that rule
3 - Use the 'Renew' tab in the toolbar or browse to Circulation->Renew
4 - Enter the item barcode
5 - You see 2 messages:
Cannot renew: auto_renew_final "Continue without renewing"
Item renewed..
6 - Apply patch
7 - Check in item, and repeat 2-4
8 - Now you get a single success message and a note that this is the last renewal
9 - Sign off!
---
circ/renew.pl | 11 ++++++++++-
koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt | 3 +++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/circ/renew.pl b/circ/renew.pl
index 523070ad528..bea1219d7e2 100755
--- a/circ/renew.pl
+++ b/circ/renew.pl
@@ -50,7 +50,8 @@ my $override_holds = $cgi->param('override_holds');
my $hard_due_date = $cgi->param('hard_due_date');
my ( $item, $checkout, $patron );
-my $error = q{};
+my $error = q{};
+my $final_renewal = 0;
my ( $soonest_renew_date, $latest_auto_renew_date );
if ( $op eq 'cud-renew' && $barcode ) {
@@ -73,6 +74,13 @@ if ( $op eq 'cud-renew' && $barcode ) {
( $can_renew, $error, $info ) = CanBookBeRenewed( $patron, $checkout, $override_limit );
push @{$confirmations}, 'RENEWAL_LIMIT' if $override_limit;
+ if ( $error && ( $error eq 'auto_renew_final' ) ) {
+
+ # This error implies it can be renewed - but not again after this, so no error
+ $error = undef;
+ $final_renewal = 1;
+ }
+
if ( $error && ( $error eq 'on_reserve' ) ) {
if ($override_holds) {
$can_renew = 1;
@@ -125,6 +133,7 @@ if ( $op eq 'cud-renew' && $barcode ) {
issue => $checkout,
borrower => $patron,
error => $error,
+ final_renewal => $final_renewal,
soonestrenewdate => $soonest_renew_date,
latestautorenewdate => $latest_auto_renew_date,
);
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 ffd2bd911cd..5a8a43d70a9 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt
@@ -188,6 +188,9 @@
) renewed for [% borrower.firstname | html %] [% borrower.surname | html %] ( [% borrower.cardnumber | html %] ) now due
on [% date_due | $KohaDates as_due_date => 1 %]
+ [% IF final_renewal %]
+ NOTE: This is the last allowed renewal on this item
+ [% END %]
[% END %]
--
2.39.5