Merge remote-tracking branch 'origin/new/bug_5604'
[koha.git] / reports / guided_reports.pl
index 5abdf17..f5667a2 100755 (executable)
@@ -21,6 +21,7 @@ use strict;
 #use warnings; FIXME - Bug 2505
 use CGI;
 use Text::CSV;
+use URI::Escape;
 use C4::Reports::Guided;
 use C4::Auth qw/:DEFAULT get_session/;
 use C4::Output;
@@ -68,6 +69,7 @@ if ( $input->param("filter_set") ) {
     $filter = {};
     $filter->{$_} = $input->param("filter_$_") foreach qw/date author keyword/;
     $session->param('report_filter', $filter) if $session;
+    $template->param( 'filter_set' => 1 );
 }
 elsif ($session) {
     $filter = $session->param('report_filter');
@@ -520,6 +522,9 @@ 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";
+        if (@sql_params) {
+            $url = join('&sql_params=', $url, map { URI::Escape::uri_escape($_) } @sql_params);
+        }
         $template->param(
             'results' => \@rows,
             'sql'     => $sql,
@@ -620,7 +625,7 @@ sub header_cell_loop {
 }
 
 foreach (1..6) {
-    $template->param('build' . $_) and $template->param(buildx => $_) and last;
+     $template->{VARS}->{'build' . $_} and $template->{VARS}->{'buildx' . $_} and last;
 }
 $template->param(   'referer' => $input->referer(),
                     'DHTMLcalendar_dateformat' => C4::Dates->DHTMLcalendar(),