Revert "Fix the guided report export, bad check of errors(bug #2672)"
authorHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Fri, 6 Mar 2009 16:05:25 +0000 (17:05 +0100)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Fri, 6 Mar 2009 16:05:25 +0000 (17:05 +0100)
This reverts commit ae4b02cdc4786bfd87f924f639b416f37c47c631.

reports/guided_reports.pl

index 390243e..eb50d65 100755 (executable)
 
 use strict;
 use CGI;
-use C4::Reports;
+use C4::Reports::Guided;
 use C4::Auth;
 use C4::Output;
-use C4::Dates qw( DHTMLcalendar );
+use C4::Dates;
 use C4::Debug;
 
 =head1 NAME
@@ -45,7 +45,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
         query           => $input,
         type            => "intranet",
         authnotrequired => 0,
-        flagsrequired   => { editcatalogue => 1 },
+        flagsrequired   => { reports => 1 },
         debug           => 1,
     }
 );
@@ -65,7 +65,7 @@ elsif ( $phase eq 'Build new' ) {
     $template->param( 'build1' => 1 );
 
     # get report areas
-    my $areas = C4::Reports::get_report_areas();
+    my $areas = get_report_areas();
     $template->param( 'areas' => $areas );
 
 }
@@ -123,7 +123,7 @@ elsif ( $phase eq 'Report on this Area' ) {
     );
 
     # get report types
-    my $types = C4::Reports::get_report_types();
+    my $types = get_report_types();
     $template->param( 'types' => $types );
 }
 
@@ -397,11 +397,13 @@ elsif ($phase eq 'Run this report'){
 }      
 
 elsif ($phase eq 'Export'){
+    binmode STDOUT, ':utf8';
+
        # export results to tab separated text
        my $sql = $input->param('sql');
         my $format = $input->param('format');
        my ($results, $total, $errors) = execute_query($sql,1,0,0,$format);
-        if (!@$errors) {
+        if ($#$errors == -1) {
             $no_html=1;
             print $input->header(       -type => 'application/octet-stream',
                                         -attachment=>'reportresults.csv'
@@ -430,7 +432,7 @@ elsif ($phase eq 'Create report from SQL') {
             );
         }
        $template->param('create' => 1);
-       my $types = C4::Reports::get_report_types();
+       my $types = get_report_types();
         if (my $type = $input->param('type')) {
             for my $i ( 0 .. $#{@$types}) {
                 @$types[$i]->{'selected'} = 1 if @$types[$i]->{'id'} eq $type;