From 60fc079cfb771a83e15ec095046ceb9305d48a50 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Sun, 19 Apr 2009 09:44:30 +1200 Subject: [PATCH] Update for bug 1545 allowing for the title to be edited Signed-off-by: Galen Charlton --- C4/Reports/Guided.pm | 7 ++++--- .../modules/reports/guided_reports_start.tmpl | 9 ++++++--- reports/guided_reports.pl | 20 ++++++++++--------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index 86c5ccbb23..ff51ecbb1e 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -39,7 +39,7 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw( get_report_types get_report_areas get_columns build_query get_criteria - save_report get_saved_reports execute_query get_saved_report create_compound run_compound + save_report get_saved_reports execute_query get_saved_report create_compound run_compound get_column_type get_distinct_values save_dictionary get_from_dictionary delete_definition delete_report format_results get_sql select_2_select_count_value update_sql @@ -449,11 +449,12 @@ sub save_report { sub update_sql { my $id = shift || croak "No Id given"; my $sql = shift; + my $reportname = shift; my $dbh = C4::Context->dbh(); $sql =~ s/(\s*\;\s*)$//; # removes trailing whitespace and /;/ - my $query = "UPDATE saved_sql SET savedsql = ?, last_modified = now() WHERE id = ? "; + my $query = "UPDATE saved_sql SET savedsql = ?, last_modified = now(), report_name = ? WHERE id = ? "; my $sth = $dbh->prepare($query); - $sth->execute( $sql, $id ); + $sth->execute( $sql, $reportname, $id ); $sth->finish(); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl index eb93a891fb..2d0687e5ef 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl @@ -112,8 +112,8 @@ canned reports and writing custom SQL reports.

&phase=Show%20SQL">Show SQL   &phase=Edit%20SQL">Edit SQL -&phase=Run%20this%20report">Run this Report -">Schedule this Report +&phase=Run%20this%20report">Run +">Schedule &phase=Delete%20Saved">Delete @@ -461,7 +461,10 @@ Sub report:">
Edit SQL - +
    +
  1. " >
  2. +
  3. +
diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index e06d9d1810..bf20310884 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -91,18 +91,20 @@ elsif ( $phase eq 'Show SQL'){ elsif ( $phase eq 'Edit SQL'){ - my $id = $input->param('reports'); - my $sql = get_sql($id); - $template->param( - 'sql' => $sql, - 'id' => $id, - 'editsql' => 1, + my $id = $input->param('reports'); + my ($sql,$type,$reportname,$notes) = get_saved_report($id); + $template->param( + 'sql' => $sql, + 'reportname' => $reportname, + 'id' => $id, + 'editsql' => 1, ); } elsif ( $phase eq 'Update SQL'){ - my $id = $input->param('id'); - my $sql = $input->param('sql'); + my $id = $input->param('id'); + my $sql = $input->param('sql'); + my $reportname = $input->param('reportname'); my @errors; if ($sql =~ /;?\W?(UPDATE|DELETE|DROP|INSERT|SHOW|CREATE)\W/i) { push @errors, {sqlerr => $1}; @@ -117,7 +119,7 @@ elsif ( $phase eq 'Update SQL'){ ); } else { - update_sql( $id, $sql ); + update_sql( $id, $sql, $reportname ); $template->param( 'save_successful' => 1, );