Bugzilla – Attachment 137829 Details for
Bug 30355
SMS auto renew digest notices are only generated if patron is also set to receive email
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28553: Patrons can be set to receive auto_renew notices as SMS, but Koha does not generate them
Bug-28553-Patrons-can-be-set-to-receive-autorenew-.patch (text/plain), 6.77 KB, created by
Kyle M Hall (khall)
on 2022-07-18 16:40:22 UTC
(
hide
)
Description:
Bug 28553: Patrons can be set to receive auto_renew notices as SMS, but Koha does not generate them
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2022-07-18 16:40:22 UTC
Size:
6.77 KB
patch
obsolete
>From 4d77a9c8f58258bc8ae0280ccf0f9cf0155bc472 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 18 Jul 2022 12:37:48 -0400 >Subject: [PATCH] Bug 28553: Patrons can be set to receive auto_renew notices > as SMS, but Koha does not generate them > >Following bug 18532, one can set a patron's messaging prefs to deliver an auto-renew notice via SMS. >However, the auto_renewals cron only knows how to generate email notices. We should not allow the selection of non-functional transport types. > >Test Plan: >1) Set a patron to recieve auto-renewals via SMS, leave digest mode > disabled. Ensure no other transports are enabled either. >2) Auto-renew some items >3) Note the SMS auto-renewal notice was generated! > >https://bugs.koha-community.org/show_bug.cgi?id=30355 >--- > misc/cronjobs/automatic_renewals.pl | 83 ++++++++++++++++++----------- > 1 file changed, 53 insertions(+), 30 deletions(-) > >diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl >index 1af18c70f5..83a0e0fffc 100755 >--- a/misc/cronjobs/automatic_renewals.pl >+++ b/misc/cronjobs/automatic_renewals.pl >@@ -133,7 +133,16 @@ $verbose = 1 unless $verbose or $confirm; > print "Test run only\n" unless $confirm; > > print "getting auto renewals\n" if $verbose; >-my $auto_renews = Koha::Checkouts->search({ auto_renew => 1, 'patron.autorenew_checkouts' => 1 },{ join => 'patron'}); >+my $auto_renews = Koha::Checkouts->search( >+ { >+ auto_renew => 1, >+ 'patron.autorenew_checkouts' => 1, >+ }, >+ { >+ join => 'patron', >+ join => 'item', >+ } >+); > print "found " . $auto_renews->count . " auto renewals\n" if $verbose; > > my $renew_digest = {}; >@@ -141,7 +150,7 @@ my %report; > while ( my $auto_renew = $auto_renews->next ) { > print "examining item '" . $auto_renew->itemnumber . "' to auto renew\n" if $verbose; > >- my ( $borrower_preferences, $wants_email, $wants_digest ) = ( undef, 0, 0 ); >+ my ( $borrower_preferences, $wants_messages, $wants_digest ) = ( undef, 0, 0 ); > if ( $send_notices_pref eq 'preferences' ){ > $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( > { >@@ -149,15 +158,14 @@ while ( my $auto_renew = $auto_renews->next ) { > message_name => 'auto_renewals' > } > ); >- $wants_email = 1 >+ $wants_messages = 1 > if $borrower_preferences >- && $borrower_preferences->{transports} >- && $borrower_preferences->{transports}->{email}; >+ && $borrower_preferences->{transports}; > $wants_digest = 1 >- if $wants_email >+ if $wants_messages > && $borrower_preferences->{wants_digest}; > } else { # Preference is never or cron >- $wants_email = $send_notices; >+ $wants_messages = $send_notices; > $wants_digest = 0; > } > >@@ -175,7 +183,7 @@ while ( my $auto_renew = $auto_renews->next ) { > $auto_renew->auto_renew_error(undef)->store; > } > push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew >- if ( $wants_email ) && !$wants_digest; >+ if ( $wants_messages ) && !$wants_digest; > } elsif ( $error eq 'too_many' > or $error eq 'on_reserve' > or $error eq 'restriction' >@@ -194,7 +202,7 @@ while ( my $auto_renew = $auto_renews->next ) { > if ( $updated ) { > $auto_renew->auto_renew_error($error)->store if $confirm; > push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew >- if $error ne 'auto_too_soon' && ( $wants_email && !$wants_digest ); # Do not notify if it's too soon >+ if $error ne 'auto_too_soon' && ( $wants_messages && !$wants_digest ); # Do not notify if it's too soon > } > } > >@@ -218,30 +226,45 @@ while ( my $auto_renew = $auto_renews->next ) { > if ( $send_notices && $confirm ) { > for my $borrowernumber ( keys %report ) { > my $patron = Koha::Patrons->find($borrowernumber); >- for my $issue ( @{ $report{$borrowernumber} } ) { >- my $item = Koha::Items->find( $issue->itemnumber ); >- my $letter = C4::Letters::GetPreparedLetter( >- module => 'circulation', >- letter_code => 'AUTO_RENEWALS', >- tables => { >- borrowers => $patron->borrowernumber, >- issues => $issue->itemnumber, >- items => $issue->itemnumber, >- biblio => $item->biblionumber, >- }, >- lang => $patron->lang, >+ my $borrower_preferences = >+ C4::Members::Messaging::GetMessagingPreferences( >+ { >+ borrowernumber => $borrowernumber, >+ message_name => 'auto_renewals' >+ } > ); >+ for my $issue ( @{ $report{$borrowernumber} } ) { >+ my $item = $issue->item; >+ # Force sending of email and only email if pref is set to "cron" >+ my @transports = $send_notices_pref eq 'preferences' ? keys %{ $borrower_preferences->{'transports'} } : 'sms'; >+ foreach my $transport ( @transports ) { >+ my $letter = C4::Letters::GetPreparedLetter ( >+ module => 'circulation', >+ letter_code => 'AUTO_RENEWALS', >+ tables => { >+ borrowers => $patron->borrowernumber, >+ issues => $issue->itemnumber, >+ items => $issue->itemnumber, >+ biblio => $item->biblionumber, >+ }, >+ lang => $patron->lang, >+ message_transport_type => $transport, >+ ); > >- my $library = Koha::Libraries->find( $patron->branchcode ); >- my $admin_email_address = $library->from_email_address; >- >- C4::Letters::EnqueueLetter( >- { letter => $letter, >- borrowernumber => $borrowernumber, >- message_transport_type => 'email', >- from_address => $admin_email_address, >+ if ($letter) { >+ my $library = $patron->library; >+ my $admin_email_address = $library->from_email_address; >+ >+ C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $borrowernumber, >+ from_address => $admin_email_address, >+ message_transport_type => $transport >+ } >+ ); > } >- ); >+ } > } > } > >-- >2.37.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 30355
:
137829