From 3ef4c1b8dde340075cc0056dd61ee8a50ca4a65b Mon Sep 17 00:00:00 2001
From: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Date: Tue, 10 Mar 2020 01:10:26 +0000
Subject: [PATCH] Bug 24378: atomicupdate for new wording

Signed-off-by: David Nind <david@davidnind.com>
---
 .../mysql/atomicupdate/reword_auto_renewals.perl   | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 installer/data/mysql/atomicupdate/reword_auto_renewals.perl

diff --git a/installer/data/mysql/atomicupdate/reword_auto_renewals.perl b/installer/data/mysql/atomicupdate/reword_auto_renewals.perl
new file mode 100644
index 0000000000..4ed5eca4ef
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/reword_auto_renewals.perl
@@ -0,0 +1,35 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    # you can use $dbh here like:
+    $dbh->do( q{
+        INSERT INTO letter (module, code, name, title, content, message_transport_type) VALUES ('circulation', 'AUTO_RENEWALS', 'Notification of automatic renewal', 'Automatic renewal notice',
+"Dear [% borrower.firstname %] [% borrower.surname %],
+[% IF checkout.auto_renew_error %]
+The following item, [% biblio.title %], has not been renewed because:
+[% IF checkout.auto_renew_error == 'too_many' %]
+You have reached the maximum of checkouts possible.
+[% ELSIF checkout.auto_renew_error == 'on_reserve' %]
+This item is on hold for another patron.
+[% ELSIF checkout.auto_renew_error == 'restriction' %]
+You are currently restricted.
+[% ELSIF checkout.auto_renew_error == 'overdue' %]
+You have overdue items.
+[% ELSIF checkout.auto_renew_error == 'auto_too_late' %]
+It\'s too late to renew this item.
+[% ELSIF checkout.auto_renew_error == 'auto_too_much_oweing' %]
+Your total unpaid fines are too high.
+[% END %]
+[% ELSE %]
+The following item, [% biblio.title %], has correctly been renewed and is now due on [% checkout.date_due %]
+[% END %]", 'email');
+    });
+
+    # or perform some test and warn
+    # if( !column_exists( 'biblio', 'biblionumber' ) ) {
+    #    warn "There is something wrong";
+    # }
+
+    # Always end with this (adjust the bug info)
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 24378 - Change wording on AUTO_RENEWALS notice in updatedatabase)\n";
+}
-- 
2.11.0