Bug 6024 : add "Run report" link on the new report creation success page
[koha_gimpoz] / reports / guided_reports.pl
index dbda180..f60a37b 100755 (executable)
@@ -36,19 +36,17 @@ guided_reports.pl
 
 Script to control the guided report creation
 
-=over2
-
 =cut
 
 my $input = new CGI;
 
 my $phase = $input->param('phase');
 my $flagsrequired;
-if ( $phase eq 'Build new' ) {
-    $flagsrequired = 'create_report';
+if ( $phase eq 'Build new' or $phase eq 'Delete Saved' ) {
+    $flagsrequired = 'create_reports';
 }
 elsif ( $phase eq 'Use saved' ) {
-    $flagsrequired = 'execute_report';
+    $flagsrequired = 'execute_reports';
 } else {
     $flagsrequired = '*';
 }
@@ -369,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,
         );
     }
 }
@@ -486,7 +485,7 @@ elsif ($phase eq 'Run this report'){
             $sql =~ s/<<$split[$i*2+1]>>/$quoted/;
         }
         my ($sth, $errors) = execute_query($sql, $offset, $limit);
-        my $total = select_2_select_count_value($sql) || 0;
+        my $total = nb_rows($sql) || 0;
         unless ($sth) {
             die "execute_query failed to return sth for report $report: $sql";
         } else {
@@ -500,7 +499,7 @@ elsif ($phase eq 'Run this report'){
         }
 
         my $totpages = int($total/$limit) + (($total % $limit) > 0 ? 1 : 0);
-        my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report&phase=Run%20this%20report";
+        my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report&amp;phase=Run%20this%20report";
         $template->param(
             'results' => \@rows,
             'sql'     => $sql,