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 1158-1163 canned reports and writing custom SQL reports.</p> Link Here
1158
        }
1158
        }
1159
1159
1160
        $(document).ready(function(){
1160
        $(document).ready(function(){
1161
1162
            $("body").on('click',".fetch_chart_data",function(){
1163
                if( [% unlimited_total %] > 1000 ){
1164
                    if( confirm("Fetching full chart data for reports with many rows can cause performance issues. Are you sure you with to chart this report?") ){
1165
                        return true;
1166
                    } else {
1167
                        return false;
1168
                    }
1169
                }
1170
            });
1171
1161
            var showsql;
1172
            var showsql;
1162
            hide_bar_element();
1173
            hide_bar_element();
1163
1174
Lines 1200-1211 canned reports and writing custom SQL reports.</p> Link Here
1200
                    headers = [% header_row.json | $raw %];
1211
                    headers = [% header_row.json | $raw %];
1201
1212
1202
                    var results;
1213
                    var results;
1203
                    if ($('input[name="chart-include-all"]').prop('checked')) {
1214
                    [% IF allresults.size %]
1204
                        results = [% allresults.json | $raw %]
1215
                        if ($('input[name="chart-include-all"]').prop('checked')) {
1205
                    }
1216
                            results = [% allresults.json | $raw %]
1206
                    else {
1217
                        }
1207
                        results = [% results.json | $raw %]
1218
                        else {
1208
                    }
1219
                            results = [% results.json | $raw %]
1220
                        }
1221
                    [% ELSE %]
1222
                        results = [% results.json | $raw %];
1223
                    [% END %]
1209
1224
1210
                    if ($('input[name="chart-exclude-last"]').prop('checked')) {
1225
                    if ($('input[name="chart-exclude-last"]').prop('checked')) {
1211
                        results.splice(-1, 1);
1226
                        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 828-834 elsif ($phase eq 'Run this report'){ Link Here
828
            my ($sql,$header_types) = get_prepped_report( $sql, \@param_names, \@sql_params);
829
            my ($sql,$header_types) = get_prepped_report( $sql, \@param_names, \@sql_params);
829
            $template->param(header_types => $header_types);
830
            $template->param(header_types => $header_types);
830
            my ( $sth, $errors ) = execute_query( $sql, $offset, $limit, undef, $report_id );
831
            my ( $sth, $errors ) = execute_query( $sql, $offset, $limit, undef, $report_id );
831
            my ($sth2, $errors2) = execute_query($sql);
832
            my $total = nb_rows($sql) || 0;
832
            my $total = nb_rows($sql) || 0;
833
            unless ($sth) {
833
            unless ($sth) {
834
                die "execute_query failed to return sth for report $report_id: $sql";
834
                die "execute_query failed to return sth for report $report_id: $sql";
Lines 839-852 elsif ($phase eq 'Run this report'){ Link Here
839
                    my @cells = map { +{ cell => $_ } } @$row;
839
                    my @cells = map { +{ cell => $_ } } @$row;
840
                    push @rows, { cells => \@cells };
840
                    push @rows, { cells => \@cells };
841
                }
841
                }
842
                while (my $row = $sth2->fetchrow_arrayref()) {
842
                if( $want_full_chart ){
843
                    my @cells = map { +{ cell => $_ } } @$row;
843
                    my ($sth2, $errors2) = execute_query($sql);
844
                    push @allrows, { cells => \@cells };
844
                    while (my $row = $sth2->fetchrow_arrayref()) {
845
                        my @cells = map { +{ cell => $_ } } @$row;
846
                        push @allrows, { cells => \@cells };
847
                    }
845
                }
848
                }
846
            }
849
            }
847
850
848
            my $totpages = int($total/$limit) + (($total % $limit) > 0 ? 1 : 0);
851
            my $totpages = int($total/$limit) + (($total % $limit) > 0 ? 1 : 0);
849
            my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report_id&amp;phase=Run%20this%20report&amp;limit=$limit";
852
            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";
850
            if (@param_names) {
853
            if (@param_names) {
851
                $url = join('&amp;param_name=', $url, map { URI::Escape::uri_escape_utf8($_) } @param_names);
854
                $url = join('&amp;param_name=', $url, map { URI::Escape::uri_escape_utf8($_) } @param_names);
852
            }
855
            }
853
- 

Return to bug 23626