Bug 23773: Send membership expiry notices by sms too

Test plan:
1. Verify in "About" page that SMS::Send is installed.
   If not, install it.
2. Set system preferences:
   - SMSSendDriver = 'Test'
   - MembershipExpiryDaysNotice = 30
3. In "Notices and Slips" tool, edit the 'MEMBERSHIP_EXPIRY' letter and
   verify that both email and sms parts are filled. Use a different
   title and body for the sms part
4. Create a new borrower with an email address and an SMS number. Set
   their expiry date to a date next week
5. Run misc/cronjobs/membership_expiry.pl --confirm
6. Verify in the patron "Notices" tab that two notices are pending, one
   for email, one for sms

Sponsored-by: Médiathèque de Montauban
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Julian Maurice 2022-07-21 11:39:07 +02:00 committed by Tomas Cohen Arazi
parent 409891ed50
commit ac86c2ab6d
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -34,7 +34,7 @@ Options:
--man full documentation
--where <conditions> where clause to add to the query
-v -verbose verbose mode
-n --nomail if supplied messages will be output to STDOUT and not sent
-n --nomail if supplied, messages will be output to STDOUT and no email or sms will be sent
-c --confirm commit changes to db, no action will be taken unless this switch is included
-b --branch <branchname> only deal with patrons from this library/branch
--before=X include patrons expiring a number of days BEFORE the date set by the preference
@ -43,7 +43,7 @@ Options:
=head1 DESCRIPTION
This script sends membership expiry reminder notices to patrons.
This script sends membership expiry reminder notices to patrons, by email and sms.
It queues them in the message queue, which is processed by
the process_message_queue.pl cronjob.
@ -218,13 +218,35 @@ while ( my $recent = $upcoming_mem_expires->next ) {
last if !$letter; # Letters.pm already warned, just exit
if( $nomail ) {
print $letter->{'content'}."\n";
} else {
C4::Letters::EnqueueLetter({
letter => $letter,
borrowernumber => $recent->borrowernumber,
from_address => $from_address,
message_transport_type => 'email',
});
next;
}
C4::Letters::EnqueueLetter({
letter => $letter,
borrowernumber => $recent->borrowernumber,
from_address => $from_address,
message_transport_type => 'email',
});
if ($recent->smsalertnumber) {
my $smsletter = C4::Letters::GetPreparedLetter(
module => 'members',
letter_code => $letter_type,
branchcode => $recent->branchcode,
lang => $recent->lang,
tables => {
borrowers => $recent->borrowernumber,
branches => $recent->branchcode,
},
message_transport_type => 'sms',
);
if ($smsletter) {
C4::Letters::EnqueueLetter({
letter => $smsletter,
borrowernumber => $recent->borrowernumber,
message_transport_type => 'sms',
});
}
}
}