Bug 31306: Allow to pass params and attributes to search_ordered
[srvgit] / reports / guided_reports.pl
index 6106fa9..c497dcc 100755 (executable)
@@ -77,7 +77,8 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
         flagsrequired   => { reports => $flagsrequired },
     }
 );
-my $session = $cookie ? get_session($cookie->value) : undef;
+my $session_id = $input->cookie('CGISESSID');
+my $session = $session_id ? get_session($session_id) : undef;
 
 my $filter;
 if ( $input->param("filter_set") or $input->param('clear_filters') ) {
@@ -181,7 +182,6 @@ elsif ( $phase eq 'Show SQL'){
         'notes'      => $report->notes,
         'sql'     => $report->savedsql,
         'showsql' => 1,
-        'mana_success' => $input->param('mana_success'),
         'mana_success' => scalar $input->param('mana_success'),
         'mana_id' => $report->{mana_id},
         'mana_comments' => $report->{comments}
@@ -846,7 +846,14 @@ elsif ($phase eq 'Run this report'){
         } else {
             my ($sql,$header_types) = $report->prep_report( \@param_names, \@sql_params );
             $template->param(header_types => $header_types);
-            my ( $sth, $errors ) = execute_query( $sql, $offset, $limit, undef, $report_id );
+            my ( $sth, $errors ) = execute_query(
+                {
+                    sql        => $sql,
+                    offset     => $offset,
+                    limit      => $limit,
+                    report_id  => $report_id,
+                }
+            );
             my $total;
             if (!$sth) {
                 die "execute_query failed to return sth for report $report_id: $sql";
@@ -859,7 +866,7 @@ elsif ($phase eq 'Run this report'){
                     push @rows, { cells => \@cells };
                 }
                 if( $want_full_chart ){
-                    my ($sth2, $errors2) = execute_query($sql);
+                    my ( $sth2, $errors2 ) = execute_query( { sql => $sql, report_id => $report_id } );
                     while (my $row = $sth2->fetchrow_arrayref()) {
                         my @cells = map { +{ cell => $_ } } @$row;
                         push @allrows, { cells => \@cells };
@@ -913,7 +920,7 @@ elsif ($phase eq 'Export'){
     my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ;
 
     ($sql, undef) = $report->prep_report( \@param_names, \@sql_params );
-       my ($sth, $q_errors) = execute_query($sql);
+    my ( $sth, $q_errors ) = execute_query( { sql => $sql, report_id => $report_id } );
     unless ($q_errors and @$q_errors) {
         my ( $type, $content );
         if ($format eq 'tab') {