Bug 16631: Bring back template. Fix test syntax.

RM amended: Add bug number to commit title

Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Casey Conlin 2026-06-30 15:24:31 +00:00 committed by Pedro Amorim
parent 67a37a07c3
commit ba448064e2
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
2 changed files with 19 additions and 20 deletions

View File

@ -107,6 +107,8 @@ my $logged_in_user = Koha::Patrons->find($borrowernumber);
my $limit_reports_by_library = C4::Context->preference('LimitReportsByLibrary');
my $can_manage_report_limits = $logged_in_user && Koha::Report->can_manage_limits($logged_in_user);
$template->param( templates => Koha::Notice::Templates->search( { module => 'report' } ) );
my $filter;
if ( $input->param("filter_set") or $input->param('clear_filters') ) {
$filter = {};
@ -799,24 +801,16 @@ if ( !$op ) {
print $_ while <$ods_fh>;
unlink $ods_filepath;
} elsif ( $format eq 'template' ) {
my $template_id = $input->param('template');
my $notice_template = Koha::Notice::Templates->find($template_id);
my $data = $sth->fetchall_arrayref( {} );
$content = process_tt(
$notice_template->content,
{
data => $data,
report_id => $report_id,
for_download => 1,
}
);
$reportfilename = process_tt(
$notice_template->title,
{
data => $data,
report_id => $report_id,
}
my $template_code = $input->param('template_code');
my $data = $sth->fetchall_arrayref( {} );
my $rendered = GetPreparedLetter(
module => 'report',
letter_code => $template_code,
objects => { data => $data, report_id => $report_id, for_download => 1 }
);
$content = $rendered->{content};
$reportfilename = $rendered->{title};
}
}

View File

@ -20,7 +20,7 @@ use Modern::Perl;
use Test::Exception;
use Test::MockModule;
use Test::NoWarnings;
use Test::More tests => 13;
use Test::More tests => 16;
use Koha::Report;
use Koha::Reports;
@ -287,6 +287,9 @@ subtest 'apply_execution_time_limit' => sub {
Koha::Report->apply_execution_time_limit($sql),
qr!^(?i:select) /\*\+ MAX_EXECUTION_TIME\(1500\) \*/ \* FROM biblio$!,
'MySQL max execution time hint applied'
);
};
subtest 'reports_branches are added and removed from report_branches table' => sub {
plan tests => 4;
@ -333,8 +336,10 @@ subtest 'can_manage_limits and can_access' => sub {
my $super_patron =
$builder->build_object( { class => 'Koha::Patrons', value => { flags => 1, branchcode => $branchA } } );
my $mgr_patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $branchA } } );
my $basic_patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $branchA } } );
my $mgr_patron =
$builder->build_object( { class => 'Koha::Patrons', value => { flags => 0, branchcode => $branchA } } );
my $basic_patron =
$builder->build_object( { class => 'Koha::Patrons', value => { flags => 0, branchcode => $branchA } } );
# Grant reports => manage_report_limits to manager patron (create permission if missing)
my $perm = $schema->resultset('Permission')->find( { module_bit => 16, code => 'manage_report_limits' } )