From a5fb9569c4971c40df570f64c402a71b81c7c77c Mon Sep 17 00:00:00 2001
From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com>
Date: Wed, 5 Jun 2019 14:38:07 +0100
Subject: [PATCH] Bug 23051: Add RenewAccruingItemWhenPaid syspref

This patch adds the new syspref "RenewAccruingItemWhenPaid"
---
 .../bug_23051_add_RenewAccruingItemWhenPaid_syspref.perl          | 8 ++++++++
 installer/data/mysql/sysprefs.sql                                 | 1 +
 .../prog/en/modules/admin/preferences/circulation.pref            | 7 +++++++
 3 files changed, 16 insertions(+)
 create mode 100644 installer/data/mysql/atomicupdate/bug_23051_add_RenewAccruingItemWhenPaid_syspref.perl

diff --git a/installer/data/mysql/atomicupdate/bug_23051_add_RenewAccruingItemWhenPaid_syspref.perl b/installer/data/mysql/atomicupdate/bug_23051_add_RenewAccruingItemWhenPaid_syspref.perl
new file mode 100644
index 0000000000..223e244a7b
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_23051_add_RenewAccruingItemWhenPaid_syspref.perl
@@ -0,0 +1,8 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+
+    $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('RenewAccruingItemWhenPaid', '0', 'If enabled, when the fines on an item accruing is paid off, attempt to renew that item', '', 'YesNo'); | );
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 23051 - Add RenewAccruingItemWhenPaid syspref)\n";
+}
diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index a0d1132d25..367374e528 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -494,6 +494,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'),
 ('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'),
 ('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'),
+('RenewAccruingItemWhenPaid','0','','If enabled, when the fines on an item accruing is paid off, attempt to renew that item','YesNo'),
 ('RenewalLog','0','','If ON, log information about renewals','YesNo'),
 ('RenewalPeriodBase','date_due','date_due|now','Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','Choice'),
 ('RenewalSendNotice','0','',NULL,'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 15085b6b3d..1434f405b0 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
@@ -487,6 +487,13 @@ Circulation:
                   no: Allow
             - their auto renewals.
         -
+            - If a patron pays off all fines on an overdue item that is accruing fines
+            - pref: RenewAccruingItemWhenPaid
+              choices:
+                  yes: Renew
+                  no: "Don't renew"
+            - the item automatically.
+        -
             - pref: ItemsDeniedRenewal
               type: textarea
               syntax: text/x-yaml
-- 
2.11.0