View | Details | Raw Unified | Return to bug 23626
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_23626.perl (-1 / +1 lines)
Lines 1-7 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{
3
    $dbh->do(q{
4
        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('ReportsMaxRowsInChart','',NULL,'If greater than 0, sets the maximum number of rows that will be used when charting results of guided reports','Integer')
4
        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('ReportsMaxRowsReturned','',NULL,'If greater than 0, sets the maximum number of rows that will be used when charting results of guided reports','Integer')
5
    });
5
    });
6
6
7
    SetVersion( $DBversion );
7
    SetVersion( $DBversion );
(-)a/installer/data/mysql/sysprefs.sql (-1 / +1 lines)
Lines 508-514 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
508
('RentalsInNoissuesCharge','1',NULL,'Rental charges block checkouts (added to noissuescharge).','YesNo'),
508
('RentalsInNoissuesCharge','1',NULL,'Rental charges block checkouts (added to noissuescharge).','YesNo'),
509
('ReplyToDefault','',NULL,'Use this email address as the replyto in emails','Free'),
509
('ReplyToDefault','',NULL,'Use this email address as the replyto in emails','Free'),
510
('ReportsLog','0',NULL,'If ON, log information about reports.','YesNo'),
510
('ReportsLog','0',NULL,'If ON, log information about reports.','YesNo'),
511
('ReportsMaxRowsInChart','0',NULL,'If greater than 0, sets the maximum number of rows that will be used when charting results of guided reports','Integer'),
511
('ReportsMaxRowsReturned','0',NULL,'If greater than 0, sets the maximum number of rows that will be included in the results of guided reports','Integer'),
512
('RequestOnOpac','1',NULL,'If ON, globally enables patron holds on OPAC','YesNo'),
512
('RequestOnOpac','1',NULL,'If ON, globally enables patron holds on OPAC','YesNo'),
513
('RequireStrongPassword','1','','Require a strong login password for staff and patrons','YesNo'),
513
('RequireStrongPassword','1','','Require a strong login password for staff and patrons','YesNo'),
514
('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice'),
514
('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc (-2 / +2 lines)
Lines 35-42 Link Here
35
                        </li>
35
                        </li>
36
36
37
                        <li>
37
                        <li>
38
                            [% IF Koha.Preference("ReportsMaxRowsInChart") %]
38
                            [% IF Koha.Preference("ReportsMaxRowsReturned") %]
39
                                <label for="include-all">Include first [% Koha.Preference("ReportsMaxRowsInChart") %] rows of full report (ignore pagination):</label>
39
                                <label for="include-all">Include first [% Koha.Preference("ReportsMaxRowsReturned") %] rows of full report (ignore pagination):</label>
40
                            [% ELSE %]
40
                            [% ELSE %]
41
                                <label for="include-all">Include all rows (ignore pagination):</label>
41
                                <label for="include-all">Include all rows (ignore pagination):</label>
42
                            [% END %]
42
                            [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref (-2 / +2 lines)
Lines 99-107 Web services: Link Here
99
            - rows of a report requested via the reports web service.
99
            - rows of a report requested via the reports web service.
100
        -
100
        -
101
            - Allow at most
101
            - Allow at most
102
            - pref: ReportsMaxRowsInChart
102
            - pref: ReportsMaxRowsReturned
103
              class: integer
103
              class: integer
104
            - rows of a report to be used when charting results of guided reports
104
            - rows of a report to be returned in the results of guided reports
105
    IdRef:
105
    IdRef:
106
        -
106
        -
107
            - pref: IdRef
107
            - pref: IdRef
(-)a/reports/guided_reports.pl (-12 / +19 lines)
Lines 829-835 elsif ($phase eq 'Run this report'){ Link Here
829
            $template->param(header_types => $header_types);
829
            $template->param(header_types => $header_types);
830
            my ( $sth, $errors ) = execute_query( $sql, $offset, $limit, undef, $report_id );
830
            my ( $sth, $errors ) = execute_query( $sql, $offset, $limit, undef, $report_id );
831
            my ($sth2, $errors2) = execute_query($sql);
831
            my ($sth2, $errors2) = execute_query($sql);
832
            my $max_rows = C4::Context->preference('ReportsMaxRowsInChart');
832
            my $max_rows = C4::Context->preference('ReportsMaxRowsReturned');
833
            my $total = nb_rows($sql) || 0;
833
            my $total = nb_rows($sql) || 0;
834
            unless ($sth) {
834
            unless ($sth) {
835
                die "execute_query failed to return sth for report $report_id: $sql";
835
                die "execute_query failed to return sth for report $report_id: $sql";
Lines 890-895 elsif ($phase eq 'Export'){ Link Here
890
    my $format         = $input->param('format');
890
    my $format         = $input->param('format');
891
    my $reportname     = $input->param('reportname');
891
    my $reportname     = $input->param('reportname');
892
    my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ;
892
    my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ;
893
    my $max_rows = C4::Context->preference('ReportsMaxRowsReturned');
893
894
894
    $sql = get_prepped_report( $sql, \@param_names, \@sql_params );
895
    $sql = get_prepped_report( $sql, \@param_names, \@sql_params );
895
	my ($sth, $q_errors) = execute_query($sql);
896
	my ($sth, $q_errors) = execute_query($sql);
Lines 899-907 elsif ($phase eq 'Export'){ Link Here
899
            $type = 'application/octet-stream';
900
            $type = 'application/octet-stream';
900
            $content .= join("\t", header_cell_values($sth)) . "\n";
901
            $content .= join("\t", header_cell_values($sth)) . "\n";
901
            $content = Encode::decode('UTF-8', $content);
902
            $content = Encode::decode('UTF-8', $content);
903
            my $n = 0;
902
            while (my $row = $sth->fetchrow_arrayref()) {
904
            while (my $row = $sth->fetchrow_arrayref()) {
905
                $n++;
903
                $content .= join("\t", @$row) . "\n";
906
                $content .= join("\t", @$row) . "\n";
907
                last if $max_rows && $n >= $max_rows;
904
            }
908
            }
909
            $sth->finish();
905
        } else {
910
        } else {
906
            my $delimiter = C4::Context->preference('delimiter') || ',';
911
            my $delimiter = C4::Context->preference('delimiter') || ',';
907
            if ( $format eq 'csv' ) {
912
            if ( $format eq 'csv' ) {
Lines 914-949 elsif ($phase eq 'Export'){ Link Here
914
                } else {
919
                } else {
915
                    push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ;
920
                    push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ;
916
                }
921
                }
922
                my $n = 0;
917
                while (my $row = $sth->fetchrow_arrayref()) {
923
                while (my $row = $sth->fetchrow_arrayref()) {
924
                    $n++;
918
                    if ($csv->combine(@$row)) {
925
                    if ($csv->combine(@$row)) {
919
                        $content .= $csv->string() . "\n";
926
                        $content .= $csv->string() . "\n";
927
                        last if $max_rows && $n >= $max_rows;
920
                    } else {
928
                    } else {
921
                        push @$q_errors, { combine => $csv->error_diag() } ;
929
                        push @$q_errors, { combine => $csv->error_diag() } ;
922
                    }
930
                    }
923
                }
931
                }
932
                $sth->finish();
924
            }
933
            }
925
            elsif ( $format eq 'ods' ) {
934
            elsif ( $format eq 'ods' ) {
926
                $type = 'application/vnd.oasis.opendocument.spreadsheet';
935
                $type = 'application/vnd.oasis.opendocument.spreadsheet';
927
                my $ods_fh = File::Temp->new( UNLINK => 0 );
936
                my $ods_fh = File::Temp->new( UNLINK => 0 );
928
                my $ods_filepath = $ods_fh->filename;
937
                my $ods_filepath = $ods_fh->filename;
929
                my $ods_content;
938
                my @ods_content;
930
939
931
                # First line is headers
940
                # First line is headers
932
                my @headers = header_cell_values($sth);
941
                my @headers = header_cell_values($sth);
933
                push @$ods_content, \@headers;
942
                push @ods_content, \@headers;
934
943
935
                # Other line in Unicode
944
                # Other line in Unicode
936
                my $sql_rows = $sth->fetchall_arrayref();
945
                my $n = 0;
937
                foreach my $sql_row ( @$sql_rows ) {
946
                while (my $row = $sth->fetchrow_arrayref()) {
938
                    my @content_row;
947
                    $n++;
939
                    foreach my $sql_cell ( @$sql_row ) {
948
                    push @ods_content, [ map { Encode::encode( 'UTF8', $_ ) } @$row ];
940
                        push @content_row, Encode::encode( 'UTF8', $sql_cell );
949
                    last if $max_rows && $n >= $max_rows;
941
                    }
942
                    push @$ods_content, \@content_row;
943
                }
950
                }
951
                $sth->finish();
944
952
945
                # Process
953
                # Process
946
                generate_ods($ods_filepath, $ods_content);
954
                generate_ods($ods_filepath, \@ods_content);
947
955
948
                # Output
956
                # Output
949
                binmode(STDOUT);
957
                binmode(STDOUT);
950
- 

Return to bug 23626