Bug 6024 : add "Run report" link on the new report creation success page
authorSrdjan Jankovic <srdjan@catalyst.net.nz>
Thu, 7 Apr 2011 14:45:41 +0000 (10:45 -0400)
committerChris Cormack <chrisc@catalyst.net.nz>
Fri, 8 Apr 2011 01:29:58 +0000 (13:29 +1200)
Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
C4/Reports/Guided.pm
koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl
reports/guided_reports.pl

index d3b8025..194c623 100644 (file)
@@ -466,7 +466,8 @@ sub execute_query ($;$$$) {
 
 =item save_report($sql,$name,$type,$notes)
 
-Given some sql and a name this will saved it so that it can resued
+Given some sql and a name this will saved it so that it can reused
+Returns id of the newly created report
 
 =cut
 
@@ -476,8 +477,10 @@ sub save_report {
     $sql =~ s/(\s*\;\s*)$//; # removes trailing whitespace and /;/
     my $query =
 "INSERT INTO saved_sql (borrowernumber,date_created,last_modified,savedsql,report_name,type,notes)  VALUES (?,now(),now(),?,?,?,?)";
-    my $sth = $dbh->prepare($query);
-    $sth->execute( $borrowernumber, $sql, $name, $type, $notes );
+    $dbh->do( $query, undef, $borrowernumber, $sql, $name, $type, $notes );
+    my $id = $dbh->selectrow_array("SELECT max(id) FROM saved_sql WHERE borrowernumber=? AND report_name=?", undef,
+                                   $borrowernumber, $name);
+    return $id;
 }
 
 sub update_sql {
index eb8d4fb..705fd6a 100644 (file)
@@ -617,6 +617,9 @@ Sub report:<select name="subreport">
 <h2>Your report has been saved</h2>
 <p>The report you have created has now been saved. You can now</p>
 <ul>
+    <!-- TMPL_IF NAME="id"  -->
+    <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=<!-- TMPL_VAR NAME="id" -->&amp;phase=Run%20this%20report">Run this report</a></li>
+    <!-- /TMPL_IF -->
     <li>Access this report from the: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved Reports Page</a></li>
     <li>Schedule this report to run using the: <a href="/cgi-bin/koha/tools/scheduler.pl">Scheduler Tool</a></li>
     <li>Return to: <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Guided Reports</a></li>
index 746174c..f60a37b 100755 (executable)
@@ -367,9 +367,10 @@ elsif ( $phase eq 'Save Report' ) {
         );
     }
     else {
-        save_report( $borrowernumber, $sql, $name, $type, $notes );
+        my $id = save_report( $borrowernumber, $sql, $name, $type, $notes );
         $template->param(
             'save_successful'       => 1,
+            'id'                    => $id,
         );
     }
 }