From 54c4cc5410cae3ee8273b370ce2a1ca6f043ea6c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 14 Oct 2020 11:58:26 +0100 Subject: [PATCH] Bug 24381: Convert printfeercpt to use GetPreparedLetter This patch updates C4::Letters to allow use of existing koha template includes from notices, then updates the printfeercpt slip print option to use GetPreparedLetter rather than calling getletter directly. As part of this work, we also add credits and debits handling to the _parseletter_sth and _get_tt_params routines in C4::Letters to allow for recognisable variable names in the notice template. --- C4/Letters.pm | 9 +++++++++ members/printfeercpt.pl | 21 ++------------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index bde0d2b0dc..2a9dc8c7c5 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -29,6 +29,7 @@ use C4::Members; use C4::Log qw( logaction ); use C4::SMS; use C4::Templates; +use Koha::DateUtils; use Koha::SMS::Providers; use Koha::Email; @@ -1591,6 +1592,14 @@ sub _process_tt { push @includes, "$htdocs/$_/en/includes" unless $lang eq 'en'; } + my $htdocs = C4::Context->config('intrahtdocs'); + my ($theme, $lang, $activethemes)= C4::Templates::themelanguage( $htdocs, 'about.tt', 'intranet'); + my @includes; + foreach (@$activethemes) { + push @includes, "$htdocs/$_/$lang/includes"; + push @includes, "$htdocs/$_/en/includes" unless $lang eq 'en'; + } + my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE}; my $template = Template->new( { diff --git a/members/printfeercpt.pl b/members/printfeercpt.pl index 6c695e469a..de6c8731b2 100755 --- a/members/printfeercpt.pl +++ b/members/printfeercpt.pl @@ -56,22 +56,6 @@ output_and_exit_if_error( ); my $letter = C4::Letters::GetPreparedLetter( - module => 'circulation', - letter_code => 'CREDIT_' . $credit->credit_type_code, - branchcode => C4::Context::mybranch, - message_transport_type => 'print', - lang => $patron->lang, - tables => { - credits => $credit_id, - borrowers => $patron->borrowernumber - }, - substitute => { - tendered => scalar $input->param('tendered'), - change => scalar $input->param('change') - } -); - -$letter //= C4::Letters::GetPreparedLetter( module => 'circulation', letter_code => 'ACCOUNT_CREDIT', branchcode => C4::Context::mybranch, @@ -88,9 +72,8 @@ $letter //= C4::Letters::GetPreparedLetter( ); $template->param( - slip => $letter->{content}, - plain => !$letter->{is_html}, - patron => $patron, + slip => $letter->{content}, + plain => !$letter->{is_html} ); output_html_with_http_headers $input, $cookie, $template->output; -- 2.30.2