Bugzilla – Attachment 115832 Details for
Bug 18532
Messaging preferences for auto renewals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18532: Add individual issues to digest notice and hide auto_renewals messaging preference when not needed
Bug-18532-Add-individual-issues-to-digest-notice-a.patch (text/plain), 13.99 KB, created by
Martin Renvoize (ashimema)
on 2021-01-26 17:15:48 UTC
(
hide
)
Description:
Bug 18532: Add individual issues to digest notice and hide auto_renewals messaging preference when not needed
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-01-26 17:15:48 UTC
Size:
13.99 KB
patch
obsolete
>From 296ce853bbe8d458af5958bab965310f9fcd9f44 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >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=UTF-8 >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 <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../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 4bb601dd6e..1c75ca19fc 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 0d95a661ec..cc4c82ee52 100644 >--- a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql >+++ b/installer/data/mysql/pl-PL/mandatory/sample_notices.sql >@@ -411,11 +411,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 <<error>> %] >-There were <<error>> items that where not correctly renewed. >+[% IF error %] >+ There were [% error %] items that were not correctly renewed. > [% END %] >-[% IF <<success>> %] >-There were <<success>> 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 @@ > </tr> > [% 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' %] > <tr> > <td>[% 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 %]</td> > [% IF ( messaging_preference.takes_days ) %] > <td> >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 d6ecb17f6d..e7cabc1f25 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 @@ > <tbody> > [% 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' %] > <tr> > <td>[% 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 %]</td> > [% IF ( messaging_preference.takes_days ) %] > <td><select class="input-mini" name="[% messaging_preference.message_attribute_id | html %]-DAYS"> >diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl >index 3b66381cc2..e407b3f114 100755 >--- a/misc/cronjobs/automatic_renewals.pl >+++ b/misc/cronjobs/automatic_renewals.pl >@@ -98,8 +98,8 @@ GetOptions( > > pod2usage(0) if $help; > >-my $send_notices_pref = C4::Context->preference('AutoRenewalNotices') >-if ( $send_notices_pref = 'cron' ) { >+my $send_notices_pref = C4::Context->preference('AutoRenewalNotices'); >+if ( $send_notices_pref eq 'cron' ) { > warn <<'END_WARN'; > > The "AutoRenewalNotices" syspref is set to 'Follow the cron switch'. >@@ -144,6 +144,8 @@ while ( my $auto_renew = $auto_renews->next ) { > $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $auto_renew->borrowernumber, > message_name => 'auto_renewals' } ) if $send_notices_pref eq 'preferences'; > >+ $send_notices = 1 if !$send_notices && $send_notices_pref eq 'preferences' && $borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email}; >+ > # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script > my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber, undef, 1 ); > if ( $error eq 'auto_renew' ) { >@@ -155,7 +157,7 @@ while ( my $auto_renew = $auto_renews->next ) { > my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode, undef, undef, undef, 0 ); > $auto_renew->auto_renew_error(undef)->store; > } >- push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew unless $borrower_preferences && (!$borrower_preferences->{transports} || !$borrower_preferences->{transports}->{email} || $borrower_preferences->{'wants_digest'}); >+ push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew unless $send_notices_pref ne 'cron' && (!$borrower_preferences || !$borrower_preferences->{transports} || !$borrower_preferences->{transports}->{email} || $borrower_preferences->{'wants_digest'}); > } elsif ( $error eq 'too_many' > or $error eq 'on_reserve' > or $error eq 'restriction' >@@ -173,7 +175,7 @@ while ( my $auto_renew = $auto_renews->next ) { > if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) { > $auto_renew->auto_renew_error($error)->store if $confirm; > push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew >- if $error ne 'auto_too_soon' && (!$borrower_preferences || ($borrower_preferences->{transports} && $borrower_preferences->{transports}->{email} && !$borrower_preferences->{'wants_digest'})); # Do not notify if it's too soon >+ if $error ne 'auto_too_soon' && ($send_notices_pref eq 'cron' || ($borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email} && !$borrower_preferences->{'wants_digest'})); # Do not notify if it's too soon > } > } > >@@ -182,9 +184,11 @@ while ( my $auto_renew = $auto_renews->next ) { > if ($digest_per_branch) { > $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; > $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error == 'auto_too_soon' ; >+ push @{$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; > } else { > $renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $error eq 'auto_renew'; > $renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error eq 'auto_too_soon' ; >+ push @{$renew_digest->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; > } > } > >@@ -293,6 +297,7 @@ sub send_digests { > error => $digest->{error}||0, > success => $digest->{success}||0, > }, >+ loops => { issues => \@{$digest->{issues}} }, > tables => { > borrowers => $patron->borrowernumber, > }, >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18532
:
95030
|
95031
|
95337
|
95338
|
95456
|
96049
|
96050
|
96487
|
96494
|
96495
|
98078
|
98079
|
99193
|
99194
|
104880
|
104881
|
104882
|
104883
|
105500
|
105501
|
105502
|
105503
|
114316
|
115798
|
115799
|
115800
|
115801
|
115802
|
115829
|
115830
|
115831
| 115832 |
115833
|
118198
|
118199
|
118205
|
118318
|
118329
|
118330
|
118331
|
118356