From 4f222a0048e5219e34a0f55ef093de0782650530 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 --- C4/Letters.pm | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 8c6fe85..464fcc0 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -685,18 +685,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.10.2