From e176aa787cd13b3ccf3d6d7838c663c9126c2e4d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 4 Apr 2016 11:31:21 +0100 Subject: [PATCH] Bug 15967: Use the email template if the print template does not exist From commit 581759e985c170db0edb4a895cda641930e5ac11 Bug 14133: Print notices should be generated with the print template """ IMPORTANT NOTE: This test plan does not take into account the notices generated for the staff ("These messages were not sent directly to the patrons."). However the behavior will also change, the print template will be used in all cases. Is it what we want? """ Yes, it is what we want. But if the print template does not exist, the notice is not generated, we'd like to get the email template instead. Test plan: - Remove the print template for the letter you use for overdues - Define an overdue rule to send an email - Remove the email address for the patron which has overdues - Execute the overdue_notices script The staff should get an email notice and a print notice (using the email template) should be generated for the patron Signed-off-by: Nick Clemens --- misc/cronjobs/overdue_notices.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 7b5de19..06fec8f 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -675,6 +675,8 @@ END_SQL # email or sms is requested but not exist, do a print. $effective_mtt = 'print'; } + + my $letter_exists = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode, $effective_mtt ) ? 1 : 0; my $letter = parse_overdues_letter( { letter_code => $overdue_rules->{"letter$i"}, borrowernumber => $borrowernumber, @@ -685,7 +687,9 @@ END_SQL 'items.content' => $titles, 'count' => $itemcount, }, - message_transport_type => $effective_mtt, + # If there is no template defined for the requested letter + # Fallback on email + message_transport_type => $letter_exists ? $effective_mtt : 'email', } ); unless ($letter) { -- 2.1.4