Update for bug 1545 allowing for the title to be edited
authorChris Cormack <chris@bigballofwax.co.nz>
Sat, 18 Apr 2009 21:44:30 +0000 (09:44 +1200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Tue, 26 May 2009 19:15:13 +0000 (21:15 +0200)
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
C4/Reports/Guided.pm
koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl
reports/guided_reports.pl

index d7480a5..6e34b95 100644 (file)
@@ -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
@@ -448,11 +448,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();
 }
 
index c119839..44b600a 100644 (file)
@@ -112,8 +112,8 @@ canned reports and writing custom SQL reports.</p>
 </td>
 <td><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=<!-- TMPL_VAR NAME="id" -->&amp;phase=Show%20SQL">Show SQL</a> 
 &nbsp; <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=<!-- TMPL_VAR NAME="id" -->&amp;phase=Edit%20SQL">Edit SQL</a></td>
-<td><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=<!-- TMPL_VAR NAME="id" -->&amp;phase=Run%20this%20report">Run this Report</a></td>
-<td><a href="/cgi-bin/koha/tools/scheduler.pl?id=<!-- TMPL_VAR NAME="id" -->">Schedule this Report</a></td>
+<td><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=<!-- TMPL_VAR NAME="id" -->&amp;phase=Run%20this%20report">Run</a></td>
+<td><a href="/cgi-bin/koha/tools/scheduler.pl?id=<!-- TMPL_VAR NAME="id" -->">Schedule</a></td>
 <td><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=<!-- TMPL_VAR NAME="id" -->&amp;phase=Delete%20Saved">Delete</a></td></tr>
 <!-- /TMPL_LOOP -->
 </table>
@@ -461,7 +461,10 @@ Sub report:<select name="subreport">
 <input type="hidden" name="id" value="<!-- TMPL_VAR NAME="id" -->">
 <fieldset class="rows">
 <legend>Edit SQL</legend>
-<textarea id="sql" name="sql"><!-- TMPL_VAR NAME="sql" --></textarea>
+<ol>
+<li><label for="reportname">Report Name:</label><input type="text" id="reportname" name="reportname" value="<!-- TMPL_VAR NAME="reportname" -->" ></li>
+<li><textarea id="sql" name="sql"><!-- TMPL_VAR NAME="sql" --></textarea></li>
+</ol>
 </fieldset>
 
 <fieldset class="action">
index 38e185e..8dbe1a2 100755 (executable)
@@ -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,
         );