From 39faff6606c9eefdf61a1e74182aa4a6b38fb156 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 14 May 2020 13:21:22 +0000 Subject: [PATCH] Bug 18532: Add individual issues to digest notice and hide auto_renewals messaging preference when not needed MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch enhances auto_renewals message, removes auto_renewals messaging preference when AutoRenewalNotices is not set to ‘preferences’ and uses that preference to send notices in automatic_renewals.pl script. To test: 1. Apply patches 2. updatedatabase 3. make sure automatic renewals are allowed in circ rules, have a positive number of allowed renewals and a positive number for renewal period 4. Check AutoRenewalNotices preference SUCCESS => AutoRenewalNotices has the value ‘cron’ (means that It keeps the usual behaviour) 5. Checkout two items for a patron, and set them as automatic renewal and set due date as your current yesterday 6. perl misc/cronjobs/automatic_renewals.pl -c -v SUCCESS => items were renewed, but there is no message in message_queue table in mysql 7. Repeat step 5 8. perl misc/cronjobs/automatic_renewals.pl -c -s -v SUCCESS => items were renewed, and there is one message per item in message_queue table in mysql 9. Change AutoRenewalNotices to ‘never’ 10. Repeat step 5 11. perl misc/cronjobs/automatic_renewals.pl -c -s -v SUCCESS => items were renewed, but there is no message in message_queue table in mysql, even with the -s switch 12. Check any patron’s category, and any detail page in staff or OPAC interface, and in any of them you should find Auto Renewals messaging preference 13. Change AutoRenewalNotices to ‘preferences’ 14. Repeat step 12, but this time all of them shows the Auto Renewals messaging preference. 15. Repeat step 5 with a patron that has no messaging preference setted 16. perl misc/cronjobs/automatic_renewals.pl -c -s -v SUCCESS => items were renewed, but there is no message in message_queue table in mysql, because patron didn’t choose to receive messages 17. Grab a category and modify auto renewals messaging preferences, and save 18. Create a new patron from that category. SUCCESS => created patron has the same messaging preference for auto renewals 19. Grab that patron and change auto renewals messaging preference to email but not digest 20. Repeat step 5 for that last patron. 21. perl misc/cronjobs/automatic_renewals.pl -c -v SUCCESS => Items were renewed, and there is a message for each item in message_queue table in mysql. 22. Change auto renewals messaging preference from the same patron and set to email and digest. 23. Repeat step 5. 24. perl misc/cronjobs/automatic_renewals.pl -c -v SUCCESS => items where renewed, and now there is only one message in message_queue table with the details of both renewed items. 25. Check that any changes to a patron’s auto renewals messaging preference in staff is reflected in OPAC, and the other way arround too. 26. Sign off Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- .../data/mysql/atomicupdate/bug-18532.perl | 16 ++++++++++---- .../mysql/pl-PL/mandatory/sample_notices.sql | 21 +++++++++++++------ .../en/includes/messaging-preference-form.inc | 3 +-- .../bootstrap/en/modules/opac-messaging.tt | 2 +- misc/cronjobs/automatic_renewals.pl | 13 ++++++++---- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug-18532.perl b/installer/data/mysql/atomicupdate/bug-18532.perl index 1308bab19e..9d9aff2697 100644 --- a/installer/data/mysql/atomicupdate/bug-18532.perl +++ b/installer/data/mysql/atomicupdate/bug-18532.perl @@ -4,11 +4,19 @@ if( CheckVersion( $DBversion ) ) { $dbh->do( qq{ INSERT IGNORE INTO letter (module, code, name, title, content, message_transport_type) VALUES ('circulation', 'AUTO_RENEWALS_DGST', 'notification on auto renewing', 'Auto renewals (Digest)', "Dear [% borrower.firstname %] [% borrower.surname %], - [% IF checkout.auto_renew_errors %] - There were [% checkout.auto_renew_errors %] items that where not correctly renewed. + [% IF error %] + There were [% error %] items that were not correctly renewed. [% END %] - [% IF checkout.auto_renew %] - There were [% checkout.auto_renew %] items that where correctly renewed. + [% IF success %] + There were [% success %] items that where correctly renewed. + [% END %] + [% FOREACH checkout IN checkouts %] + [% checkout.item.biblio.title %] : [% checkout.item.barcode %] + [% IF !checkout.auto_renew_error %] + was renewed until [% checkout.date_due %] + [% ELSE %] + was not renewed with error: [% checkout.auto_renew_error %] + [% END %] [% END %] ", 'email'); }); diff --git a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql b/installer/data/mysql/pl-PL/mandatory/sample_notices.sql index 54421cf03a..75e1311d55 100644 --- a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql +++ b/installer/data/mysql/pl-PL/mandatory/sample_notices.sql @@ -427,11 +427,20 @@ This item must be renewed at the library. The following item, [% biblio.title %], has correctly been renewed and is now due on [% checkout.date_due | $KohaDates as_due_date => 1 %] [% END %]", 'email'); -INSERT INTO letter (module, code, name, title, content, message_transport_type) VALUES ('circulation', 'AUTO_RENEWALS_DGST', 'Notification on auto renewing', 'Auto renewals (Digest)', +INSERT IGNORE INTO letter (module, code, name, title, content, message_transport_type) VALUES ('circulation', 'AUTO_RENEWALS_DGST', 'Notification on auto renewing', 'Auto renewals (Digest)', "Dear [% borrower.firstname %] [% borrower.surname %], -[% IF <> %] -There were <> items that where not correctly renewed. +[% IF error %] + There were [% error %] items that were not correctly renewed. [% END %] -[% IF <> %] -There were <> items that where correctly renewed. -[% END %]", 'email'); +[% IF success %] + There were [% success %] items that where correctly renewed. +[% END %] +[% FOREACH checkout IN checkouts %] + [% checkout.item.biblio.title %] : [% checkout.item.barcode %] + [% IF !checkout.auto_renew_error %] + was renewed until [% checkout.date_due | $KohaDates %] + [% ELSE %] + was not renewed with error: [% checkout.auto_renew_error %] + [% END %] +[% END %] +", 'email'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc index bccd846ce2..49dbe1705c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc @@ -14,10 +14,10 @@ [% FOREACH messaging_preference IN messaging_preferences %] [% NEXT IF !Koha.Preference( 'ILLModule' ) && messaging_preference.message_name.match('^Ill_') %] + [% NEXT IF messaging_preference.Auto_Renewals && Koha.Preference('AutoRenewalNotices') != 'preferences' %] [% IF ( messaging_preference.Item_Due ) %]Item due [% ELSIF ( messaging_preference.Advance_Notice ) %]Advance notice - [% ELSIF ( messaging_preference.Upcoming_Events ) %]Upcoming events [% ELSIF ( messaging_preference.Hold_Filled ) %]Hold filled [% ELSIF ( messaging_preference.Item_Check_in ) %]Item check-in [% ELSIF ( messaging_preference.Item_Checkout ) %] @@ -28,7 +28,6 @@ [% END %] [% ELSIF ( messaging_preference.Ill_ready ) %]Interlibrary loan ready [% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable - [% ELSIF ( messaging_preference.Auto_Renewals ) %]Auto renewals [% ELSE %]Unknown [% END %] [% IF ( messaging_preference.takes_days ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt index f8e115895e..62ad2a78dd 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -56,6 +56,7 @@ [% FOREACH messaging_preference IN messaging_preferences %] [% NEXT IF !Koha.Preference( 'ILLModule' ) && messaging_preference.message_name.match('^Ill_') %] + [% NEXT IF messaging_preference.Auto_Renewals && Koha.Preference('AutoRenewalNotices') != 'preferences' %] [% IF ( messaging_preference.Item_Due ) %]Item due [% ELSIF ( messaging_preference.Advance_Notice ) %]Advance notice @@ -69,7 +70,6 @@ [% END %] [% ELSIF ( messaging_preference.Ill_ready ) %]Interlibrary loan ready [% ELSIF ( messaging_preference.Ill_unavailable ) %]Interlibrary loan unavailable - [% ELSIF ( messaging_preference.Auto_Renewals ) %]Auto renewals [% ELSE %]Unknown [% END %] [% IF ( messaging_preference.takes_days ) %]