From f6155d98e0cf6193efd8224ace68e0755f678df6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 24 Jan 2017 11:18:46 +0100 Subject: [PATCH] Bug 17981: Add a 'letter' param to GetPreparedLetter This will allow us to call GetPreparedLetter with a letter content that does not exist in the DB Signed-off-by: Kyle M Hall Signed-off-by: Josef Moravec Signed-off-by: Jonathan Druart --- C4/Letters.pm | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index d4664d0309..79eae47716 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -688,18 +688,22 @@ sub SendAlerts { sub GetPreparedLetter { my %params = @_; - my $module = $params{module} or croak "No module"; - my $letter_code = $params{letter_code} or croak "No letter_code"; - my $branchcode = $params{branchcode} || ''; - my $mtt = $params{message_transport_type} || 'email'; - my $lang = $params{lang} || 'default'; - - my $letter = getletter( $module, $letter_code, $branchcode, $mtt, $lang ); + my $letter = $params{letter}; unless ( $letter ) { - $letter = getletter( $module, $letter_code, $branchcode, $mtt, 'default' ) - or warn( "No $module $letter_code letter transported by " . $mtt ), - return; + my $module = $params{module} or croak "No module"; + my $letter_code = $params{letter_code} or croak "No letter_code"; + my $branchcode = $params{branchcode} || ''; + my $mtt = $params{message_transport_type} || 'email'; + my $lang = $params{lang} || 'default'; + + $letter = getletter( $module, $letter_code, $branchcode, $mtt, $lang ); + + unless ( $letter ) { + $letter = getletter( $module, $letter_code, $branchcode, $mtt, 'default' ) + or warn( "No $module $letter_code letter transported by " . $mtt ), + return; + } } my $tables = $params{tables} || {}; -- 2.39.5