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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc (-4 / +10 lines)
Lines 33-42 Link Here
33
                            </select>
33
                            </select>
34
                        </li>
34
                        </li>
35
35
36
                        <li>
36
                        [% IF allresults.size %]
37
                            <label for="include-all">Include all rows (ignore pagination):</label>
37
                            <li>
38
                            <input id="include-all" name="chart-include-all" type="checkbox" />
38
                                <label for="include-all">Include all rows (ignore pagination):</label>
39
                        </li>
39
                                <input id="include-all" name="chart-include-all" type="checkbox" />
40
                            </li>
41
                        [% ELSE %]
42
                            <li>
43
                                <p>This chart will use only visible rows, click 'Fetch all data' to chart the full report</p>
44
                            </li>
45
                        [% END %]
40
46
41
                        <li>
47
                        <li>
42
                            <label for="exclude-last">Exclude last line (Rollup): </label>
48
                            <label for="exclude-last">Exclude last line (Rollup): </label>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc (-1 / +7 lines)
Lines 107-113 Link Here
107
                <a class="btn btn-default toggle_sql" id="toggle_sql_vis" href="#" style="display:none;"><i class="fa fa-eye-slash"></i> Hide SQL code</a>
107
                <a class="btn btn-default toggle_sql" id="toggle_sql_vis" href="#" style="display:none;"><i class="fa fa-eye-slash"></i> Hide SQL code</a>
108
            </div>
108
            </div>
109
            <div class="btn-group">
109
            <div class="btn-group">
110
                <a class="btn btn-default" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-bar-chart"></i> Create chart</a>
110
                [% IF allresults.size %]
111
                    <a class="btn btn-default" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-bar-chart"></i> Create chart</a>
112
                [% ELSE %]
113
                    <a class="btn btn-default" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-bar-chart"></i> Create chart</a>
114
                    <a class="btn btn-default fetch_chart_data" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&amp;phase=Run this report&amp;reportname=[% name |uri %][% PROCESS params %]&amp;want_full_chart=1"><i class="fa fa-bar-chart"></i> Fetch all data for chart</a>
115
                [% END %]
116
111
            </div>
117
            </div>
112
        [% END %]
118
        [% END %]
113
119
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-6 / +21 lines)
Lines 1159-1164 canned reports and writing custom SQL reports.</p> Link Here
1159
        }
1159
        }
1160
1160
1161
        $(document).ready(function(){
1161
        $(document).ready(function(){
1162
1163
            $("body").on('click',".fetch_chart_data",function(){
1164
                if( [% unlimited_total %] > 1000 ){
1165
                    if( confirm("Fetching full chart data for reports with many rows can cause performance issues. Are you sure you with to chart this report?") ){
1166
                        return true;
1167
                    } else {
1168
                        return false;
1169
                    }
1170
                }
1171
            });
1172
1162
            var showsql;
1173
            var showsql;
1163
            hide_bar_element();
1174
            hide_bar_element();
1164
1175
Lines 1201-1212 canned reports and writing custom SQL reports.</p> Link Here
1201
                    headers = [% header_row.json | $raw %];
1212
                    headers = [% header_row.json | $raw %];
1202
1213
1203
                    var results;
1214
                    var results;
1204
                    if ($('input[name="chart-include-all"]').prop('checked')) {
1215
                    [% IF allresults.size %]
1205
                        results = [% allresults.json | $raw %]
1216
                        if ($('input[name="chart-include-all"]').prop('checked')) {
1206
                    }
1217
                            results = [% allresults.json | $raw %]
1207
                    else {
1218
                        }
1208
                        results = [% results.json | $raw %]
1219
                        else {
1209
                    }
1220
                            results = [% results.json | $raw %]
1221
                        }
1222
                    [% ELSE %]
1223
                        results = [% results.json | $raw %];
1224
                    [% END %]
1210
1225
1211
                    if ($('input[name="chart-exclude-last"]').prop('checked')) {
1226
                    if ($('input[name="chart-exclude-last"]').prop('checked')) {
1212
                        results.splice(-1, 1);
1227
                        results.splice(-1, 1);
(-)a/reports/guided_reports.pl (-6 / +8 lines)
Lines 692-697 elsif ($phase eq 'Run this report'){ Link Here
692
    my $report_id  = $input->param('reports');
692
    my $report_id  = $input->param('reports');
693
    my @sql_params = $input->multi_param('sql_params');
693
    my @sql_params = $input->multi_param('sql_params');
694
    my @param_names = $input->multi_param('param_name');
694
    my @param_names = $input->multi_param('param_name');
695
    my $want_full_chart = $input->param('want_full_chart') || 0;
695
696
696
    # offset algorithm
697
    # offset algorithm
697
    if ($input->param('page')) {
698
    if ($input->param('page')) {
Lines 829-835 elsif ($phase eq 'Run this report'){ Link Here
829
            my ($sql,$header_types) = get_prepped_report( $sql, \@param_names, \@sql_params);
830
            my ($sql,$header_types) = get_prepped_report( $sql, \@param_names, \@sql_params);
830
            $template->param(header_types => $header_types);
831
            $template->param(header_types => $header_types);
831
            my ( $sth, $errors ) = execute_query( $sql, $offset, $limit, undef, $report_id );
832
            my ( $sth, $errors ) = execute_query( $sql, $offset, $limit, undef, $report_id );
832
            my ($sth2, $errors2) = execute_query($sql);
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 840-853 elsif ($phase eq 'Run this report'){ Link Here
840
                    my @cells = map { +{ cell => $_ } } @$row;
840
                    my @cells = map { +{ cell => $_ } } @$row;
841
                    push @rows, { cells => \@cells };
841
                    push @rows, { cells => \@cells };
842
                }
842
                }
843
                while (my $row = $sth2->fetchrow_arrayref()) {
843
                if( $want_full_chart ){
844
                    my @cells = map { +{ cell => $_ } } @$row;
844
                    my ($sth2, $errors2) = execute_query($sql);
845
                    push @allrows, { cells => \@cells };
845
                    while (my $row = $sth2->fetchrow_arrayref()) {
846
                        my @cells = map { +{ cell => $_ } } @$row;
847
                        push @allrows, { cells => \@cells };
848
                    }
846
                }
849
                }
847
            }
850
            }
848
851
849
            my $totpages = int($total/$limit) + (($total % $limit) > 0 ? 1 : 0);
852
            my $totpages = int($total/$limit) + (($total % $limit) > 0 ? 1 : 0);
850
            my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report_id&amp;phase=Run%20this%20report&amp;limit=$limit";
853
            my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report_id&amp;phase=Run%20this%20report&amp;limit=$limit&amp;want_full_chart=$want_full_chart";
851
            if (@param_names) {
854
            if (@param_names) {
852
                $url = join('&amp;param_name=', $url, map { URI::Escape::uri_escape_utf8($_) } @param_names);
855
                $url = join('&amp;param_name=', $url, map { URI::Escape::uri_escape_utf8($_) } @param_names);
853
            }
856
            }
854
- 

Return to bug 23626