From b41cfcd38d4afc153210a90bc3a638788f799b69 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Wed, 22 Feb 2023 13:23:09 -0500 Subject: [PATCH] Bug 33046: Use process_tt in C4::Reports::Guided::EmailReport Bug 33030 implements a new helper subroutine to standardize processing of Template Toolkit syntax outside slips and notices. We should use this subroutine in EmailReport. Test Plan: 1) Apply this patch 2) prove t/db_dependent/Reports/Guided.t Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- C4/Reports/Guided.pm | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index cbbc1a6f88..a55cd17743 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -23,20 +23,20 @@ use Carp qw( carp croak ); use JSON qw( from_json ); use C4::Context; -use C4::Templates qw/themelanguage/; use C4::Koha qw( GetAuthorisedValues ); -use Koha::DateUtils qw( dt_from_string ); -use Koha::Patrons; -use Koha::Reports; -use C4::Output; use C4::Log qw( logaction ); -use Koha::Notice::Templates; - +use C4::Output; +use C4::Templates qw/themelanguage/; +use Koha::AuthorisedValues; use Koha::Database::Columns; +use Koha::DateUtils qw( dt_from_string ); use Koha::Logger; -use Koha::AuthorisedValues; +use Koha::Notice::Templates; use Koha::Patron::Categories; +use Koha::Patrons; +use Koha::Reports; use Koha::SharedContent; +use Koha::TemplateUtils qw( process_tt ); our (@ISA, @EXPORT_OK); BEGIN { @@ -1061,7 +1061,7 @@ sub EmailReport { my $from_address = $from || $row->{from}; my $to_address = $row->{$email_col}; - push ( @errors, { NOT_PARSE => $counter } ) unless my $content = _process_row_TT( $row, $template ); + push ( @errors, { NOT_PARSE => $counter } ) unless my $content = process_tt( $template, $row ); $counter++; next if scalar @errors > $err_count; #If any problems, try next @@ -1078,29 +1078,6 @@ sub EmailReport { } - - -=head2 ProcessRowTT - - my $content = ProcessRowTT($row_hashref, $template); - -Accepts a hashref containing values and processes them against Template Toolkit -to produce content - -=cut - -sub _process_row_TT { - - my ($row, $template) = @_; - - return 0 unless ($row && $template); - my $content; - my $processor = Template->new(); - $processor->process( \$template, $row, \$content); - return $content; - -} - sub _get_display_value { my ( $original_value, $column ) = @_; if ( $column eq 'periodicity' ) { -- 2.39.5