From 912e329977e17622c68f53463c3da0993d3e93aa 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 b76338e0ea..48feee3fe2 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.11.0