From 6cc7510fc57279c3dd2a5c9db1ecde82a55b5385 Mon Sep 17 00:00:00 2001 From: Michal Urban Date: Tue, 12 Jul 2022 18:31:47 -0400 Subject: [PATCH] Bug 23824: Add a Save and Run button to exports Added a setting within the Guided SQL Reports create and edit report interfaces. This allows admins to bypass the need to go to the Edit SQL page to run reports and run a report after saving. To test: 1. Navigate to the reports screen in Koha admin, and create a SQL report 2. Create a report with "Run report after saving" switched to "Yes", save the report (Easy query for testing: "SELECT NOW();") 3. Notice that the report runs after saving 4. Navigate to the edit page for the report, edit the query, set "Run report after saving" to yes and update SQL 5. Notice that the report runs after updating in the Edit SQL page 6. Create a new report with "Run report after saving" set to "No", and save 7. Notice that you are redirected to the Edit SQL page 8. Edit the query with "Run report after saving" set to "No" and update SQL 9. Notice that the SQL updates and does not run --- .../modules/reports/guided_reports_start.tt | 36 +++++++++++++++++++ reports/guided_reports.pl | 4 +++ 2 files changed, 40 insertions(+) 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 9551980fb2..13f2274b0b 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 @@ -1248,6 +1248,24 @@ + + [% IF (save_and_run) %] +
  • + + +
  • + [% ELSE %] +
  • + + +
  • + [% END # /IF (save_and_run) %] @@ -1360,6 +1378,24 @@ + + [% IF (save_and_run) %] +
  • + + +
  • + [% ELSE %] +
  • + + +
  • + [% END # /IF (save_and_run) %] diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index c497dcc0a7..d27ad7b696 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -219,6 +219,7 @@ elsif ( $phase eq 'Update SQL'){ my $cache_expiry_units = $input->param('cache_expiry_units'); my $public = $input->param('public'); my $save_anyway = $input->param('save_anyway'); + my $save_and_run = $input->param('save_and_run'); my @errors; # if we have the units, then we came from creating a report from SQL and thus need to handle converting units @@ -291,6 +292,7 @@ elsif ( $phase eq 'Update SQL'){ 'usecache' => $usecache, ); logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog"); + print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?reports=".$id."phase=Run%20this%20report") if $save_and_run; } if ( $usecache ) { $template->param( @@ -576,6 +578,7 @@ elsif ( $phase eq 'Save Report' ) { my $cache_expiry_units = $input->param('cache_expiry_units'); my $public = $input->param('public'); my $save_anyway = $input->param('save_anyway'); + my $save_and_run = $input->param('save_and_run'); # if we have the units, then we came from creating a report from SQL and thus need to handle converting units @@ -661,6 +664,7 @@ elsif ( $phase eq 'Save Report' ) { 'public' => $public, 'usecache' => $usecache, ); + print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?reports=".$id."phase=Run%20this%20report") if $save_and_run; } } } -- 2.25.1