From 1eb2c4bfbea6d55a29b33d0e66a7fcd886226de8 Mon Sep 17 00:00:00 2001 From: Casey Conlin <101153261+CaseyConlin@users.noreply.github.com> Date: Sat, 12 Jul 2025 15:23:38 -0400 Subject: [PATCH 11/16] Add library limits info to duplicate section and fix limit info not showing after saving. --- .../modules/reports/guided_reports_start.tt | 13 +++++++- reports/guided_reports.pl | 33 ++++++++++++++----- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index 8e6a4fd042..ade44dd2c7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -1436,7 +1436,18 @@ Required - + [% IF ( Koha.Preference('EnableFilteringReports') ) %] +
+ Library limitation: +
+ +
Limits the use of this report to the selected libraries.
+
+
+ [% END %]
diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index e3c34532e6..00d2e0ccb0 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -58,6 +58,7 @@ my $input = CGI->new; my $usecache = Koha::Caches->get_instance->memcached_cache; my $op = $input->param('op') // ''; +print STDERR "DEBUG op: $op\n"; # my @branches = grep { $_ ne q{} } $input->multi_param('branches'); my $flagsrequired; @@ -130,7 +131,7 @@ if ( !$op ) { 'showsql' => 1, 'mana_success' => scalar $input->param('mana_success'), 'mana_id' => $report->{mana_id}, - 'mana_comments' => $report->{comments} + 'mana_comments' => $report->{comments}, ); } elsif ( $op eq 'edit_form' ) { @@ -228,9 +229,8 @@ if ( !$op ) { 'problematic_authvals' => $problematic_authvals, 'warn_authval_problem' => 1, 'phase_update' => 1, - - # 'branches' => @branches, - 'report' => $report, + 'branches' => @branches, + 'report' => $report, ); } else { @@ -246,6 +246,8 @@ if ( !$op ) { notes => $notes, public => $public, cache_expiry => $cache_expiry, + + # report => $report, } ); @@ -269,7 +271,9 @@ if ( !$op ) { 'public' => $public, 'usecache' => $usecache, 'tables' => $tables, - 'branches' => @branches, + + # 'branches' => @branches, + 'report' => $report, ); logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog"); } @@ -513,6 +517,7 @@ if ( !$op ) { my $area = $input->param('area'); my $sql = $input->param('sql'); my $type = $input->param('type'); + $template->param( 'save' => 1, 'area' => $area, @@ -538,6 +543,7 @@ if ( !$op ) { my $public = $input->param('public'); my $save_anyway = $input->param('save_anyway'); my $tables = get_tables(); + my @branches = grep { $_ ne q{} } $input->multi_param('branches'); # if we have the units, then we came from creating a report from SQL and thus need to handle converting units if ($cache_expiry_units) { @@ -615,6 +621,9 @@ if ( !$op ) { public => $public, } ); + my $report = Koha::Reports->find($id); + $report->replace_library_limits( \@branches ); + logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog"); $template->param( 'save_successful' => 1, @@ -627,7 +636,8 @@ if ( !$op ) { 'cache_expiry' => $cache_expiry, 'public' => $public, 'usecache' => $usecache, - 'tables' => $tables + 'tables' => $tables, + 'report' => $report, ); } } @@ -770,20 +780,24 @@ if ( !$op ) { } elsif ( $op eq 'add_form_sql' || $op eq 'duplicate' ) { - my ( $group, $subgroup, $sql, $reportname, $notes ); + my ( $group, $subgroup, $sql, $reportname, $notes, @branches, $report ); if ( $input->param('sql') ) { $group = $input->param('report_group'); $subgroup = $input->param('report_subgroup'); $sql = $input->param('sql') // ''; $reportname = $input->param('reportname') // ''; $notes = $input->param('notes') // ''; + @branches = grep { $_ ne q{} } $input->multi_param('branches'); + } elsif ( my $report_id = $input->param('id') ) { - my $report = Koha::Reports->find($report_id); + $report = Koha::Reports->find($report_id); $group = $report->report_group; $subgroup = $report->report_subgroup; $sql = $report->savedsql // ''; $reportname = $report->report_name // ''; $notes = $report->notes // ''; + @branches = grep { $_ ne q{} } $input->multi_param('branches'); + } my $tables = get_tables(); @@ -799,6 +813,9 @@ if ( !$op ) { 'usecache' => $usecache, 'tables' => $tables, + # 'branches' => \@branches, + 'report' => $report, + ); } -- 2.39.5