From 2405a21d6ec3841e51644a682f0620acf21e4878 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Wed, 28 Apr 2021 08:55:02 +0300 Subject: [PATCH] Bug 14723: Add error codes and replace strings with them in template This patch adds error codes for delivery notes and replaces English strings with them in template. To test confirm everything works as intended. Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- C4/Letters.pm | 15 ++++++++++----- .../prog/en/modules/members/notices.tt | 14 +++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index d9a7ea8d8b..c80b328f1d 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1335,7 +1335,8 @@ sub _send_message_by_email { warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; _set_message_status( { message_id => $message->{'message_id'}, status => 'failed', - delivery_note => 'Invalid borrowernumber '.$message->{borrowernumber} } ); + delivery_note => 'Invalid borrowernumber '.$message->{borrowernumber}, + error_code => 'INVALID_BORNUMBER' } ); return; } $to_address = $patron->notice_email_address; @@ -1344,7 +1345,8 @@ sub _send_message_by_email { # warning too verbose for this more common case? _set_message_status( { message_id => $message->{'message_id'}, status => 'failed', - delivery_note => 'Unable to find an email address for this borrower' } ); + delivery_note => 'Unable to find an email address for this borrower', + error_code => 'NO_EMAIL' } ); return; } } @@ -1483,14 +1485,16 @@ sub _send_message_by_sms { unless ( $patron and $patron->smsalertnumber ) { _set_message_status( { message_id => $message->{'message_id'}, status => 'failed', - delivery_note => 'Missing SMS number' } ); + delivery_note => 'Missing SMS number', + error_code => 'MISSING_SMS' } ); return; } if ( _is_duplicate( $message ) ) { _set_message_status( { message_id => $message->{'message_id'}, status => 'failed', - delivery_note => 'Message is duplicate' } ); + delivery_note => 'Message is duplicate', + error_code => 'DUPLICATE_MESSAGE' } ); return; } @@ -1499,7 +1503,8 @@ sub _send_message_by_sms { } ); _set_message_status( { message_id => $message->{'message_id'}, status => ($success ? 'sent' : 'failed'), - delivery_note => ($success ? '' : 'No notes from SMS driver') } ); + delivery_note => ($success ? '' : 'No notes from SMS driver'), + error_code => 'NO_NOTES' } ); return $success; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt index e6db22d3c3..d0ff7c9f37 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt @@ -91,13 +91,13 @@ [% QUEUED_MESSAGE.updated_on | $KohaDates with_hours => 1 %] [% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %] - - [% IF ( QUEUED_MESSAGE.delivery_note ) %] - [% IF ( QUEUED_MESSAGE.delivery_note == "Invalid borrowernumber $borrowernumber" ) %]Invalid borrowernumber [% borrowernumber | html %] - [% ELSIF ( QUEUED_MESSAGE.delivery_note == 'Unable to find an email address for this borrower' ) %]Unable to find an email address for this borrower - [% ELSIF ( QUEUED_MESSAGE.delivery_note == 'Missing SMS number' ) %]Missing SMS number - [% ELSIF ( QUEUED_MESSAGE.delivery_note == 'Message is duplicate' ) %]Message is duplicate - [% ELSIF ( QUEUED_MESSAGE.delivery_note == 'No notes from SMS driver' ) %]No notes from SMS driver + + [% IF ( QUEUED_MESSAGE.error_code ) %] + [% IF ( QUEUED_MESSAGE.error_code == "INVALID_BORNUMBER" ) %]Invalid borrowernumber [% borrowernumber | html %] + [% ELSIF ( QUEUED_MESSAGE.error_code == 'NO_EMAIL' ) %]Unable to find an email address for this borrower + [% ELSIF ( QUEUED_MESSAGE.error_code == 'MISSING_SMS' ) %]Missing SMS number + [% ELSIF ( QUEUED_MESSAGE.error_code == 'DUPLICATE_MESSAGE' ) %]Message is duplicate + [% ELSIF ( QUEUED_MESSAGE.error_code == 'NO_NOTES' ) %]No notes from SMS driver [% ELSE %]Error occured while sending email. [% END %] [% END %] -- 2.39.5