From 6480ce42968c26e2089a5c4c37527fae0f335a7c Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 22 Jul 2019 13:41:21 +0000 Subject: [PATCH] Bug 23357: Check if generating a duplicate print notice before generating notice To test: 1 - Check out an overdue to a patron 2 - Set a notice trigger for the same number of days overdue for the patrons patron type 3 - Set the trigger to send via email and sms You may need to define SMSSendDriver preference to enable SMS, you can put 'Email' 4 - perl misc/cronjobs/overdue_notices.pl -v -t 5 - Check the patrons record, 1 notice generated 6 - Check the db: SELECT * FROM message_queue; 7 - Note the message 'Overdue notices' contains a doulbed content for the notice 8 - DELETE * FROM message_queue; 9 - Apply patch 10 - perl misc/cronjobs/overdue_notices.pl -v -t 11 - Chekc the patron's account, 1 message in 'Notices' 12 - Check the DB SELECT * FROM message_queue; 13 - The 'Overdue notices' notice is not doubled Signed-off-by: Martin Renvoize --- misc/cronjobs/overdue_notices.pl | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 75fd593c77..a134a12ea9 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -741,27 +741,27 @@ END_SQL } ); } else { - if ( ($mtt eq 'email' and not scalar @emails_to_use) or ($mtt eq 'sms' and not $data->{smsalertnumber}) ) { - push @output_chunks, - prepare_letter_for_printing( - { letter => $letter, - borrowernumber => $borrowernumber, - firstname => $data->{'firstname'}, - lastname => $data->{'surname'}, - address1 => $data->{'address'}, - address2 => $data->{'address2'}, - city => $data->{'city'}, - postcode => $data->{'zipcode'}, - country => $data->{'country'}, - email => $notice_email, - itemcount => $itemcount, - titles => $titles, - outputformat => defined $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : defined $text_filename ? 'text' : '', - } - ); - } + # Just send a print only if not already done. unless ( $effective_mtt eq 'print' and $print_sent == 1 ) { - # Just sent a print if not already done. + if ( ($mtt eq 'email' and not scalar @emails_to_use) or ($mtt eq 'sms' and not $data->{smsalertnumber}) ) { + push @output_chunks, + prepare_letter_for_printing( + { letter => $letter, + borrowernumber => $borrowernumber, + firstname => $data->{'firstname'}, + lastname => $data->{'surname'}, + address1 => $data->{'address'}, + address2 => $data->{'address2'}, + city => $data->{'city'}, + postcode => $data->{'zipcode'}, + country => $data->{'country'}, + email => $notice_email, + itemcount => $itemcount, + titles => $titles, + outputformat => defined $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : defined $text_filename ? 'text' : '', + } + ); + } C4::Letters::EnqueueLetter( { letter => $letter, borrowernumber => $borrowernumber, -- 2.20.1