From 16dd3d114ecd23355aa794fbeaef9c98f580ef04 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 24 Jan 2017 17:13:07 +0100 Subject: [PATCH] Bug 17981: Better error handling Signed-off-by: Kyle M Hall --- .../intranet-tmpl/prog/en/modules/tools/preview_letter.tt | 7 +++++-- svc/letters/preview | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/preview_letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/preview_letter.tt index f7aea70676..4bde77d68d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/preview_letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/preview_letter.tt @@ -12,6 +12,9 @@ [% CASE 'preview_not_available' %]Preview is not available for letters '[% m.letter_code %]'. [% CASE 'not_checked_in_yet' %]Do not forget that the issue has not been checked in yet. [% CASE 'not_checked_out_yet' %]Do not forget that the issue has not been checked out yet. + [% CASE 'no_checkout' %]This item is not checked out. + [% CASE 'no_item_or_no_patron' %]The item or the patron does not exist. + [% CASE 'no_hold' %]No hold is placed by this patron on this bibliographic record. [% CASE %][% m.code %] [% END %] @@ -28,7 +31,7 @@ [% END %] - [% IF tt_content %] + [% IF rendered_tt_message %]
Converted version
[% tt_content | html %]
@@ -41,7 +44,7 @@ [% END %] - [% IF tt_content %] + [% IF rendered_tt_message %] [% IF messages_are_similar %]
The generated notices are exactly the same!
[% ELSE %] diff --git a/svc/letters/preview b/svc/letters/preview index d517398bfb..809ee7269c 100644 --- a/svc/letters/preview +++ b/svc/letters/preview @@ -169,7 +169,8 @@ if ( $code eq 'CHECKIN' ) { push @messages, { code => 'not_checked_in_yet', type => 'message' }; } else { - warn "No checkout"; + push @messages, { code => 'no_checkout', type => 'alert' }; + $letter_params = {}; } } elsif ( $code eq 'CHECKOUT' ) { @@ -193,7 +194,8 @@ elsif ( $code eq 'CHECKOUT' ) { push @messages, { code => 'not_checked_out_yet', type => 'message' }; } else { - warn "No item or no patron"; + push @messages, { code => 'no_item_or_no_patron', type => 'alert' }; + $letter_params = {}; } } elsif ( $code eq 'HOLD_SLIP' ) { @@ -212,11 +214,11 @@ elsif ( $code eq 'HOLD_SLIP' ) { }; } else { - warn "No hold placed by this patron on this bibliographic record."; + push @messages, { code => 'no_hold', type => 'alert' }; + $letter_params = {}; } } else { - warn "Preview for letter code $code is not available"; push @messages, { type => 'alert', code => 'preview_not_available', letter_code => $code, }; } -- 2.11.0