</select>
</li>
- <li>
- <label for="include-all">Include all rows (ignore pagination):</label>
- <input id="include-all" name="chart-include-all" type="checkbox" />
- </li>
+ [% IF allresults.size %]
+ <li>
+ <label for="include-all">Include all rows (ignore pagination):</label>
+ <input id="include-all" name="chart-include-all" type="checkbox" />
+ </li>
+ [% ELSE %]
+ <li>
+ <p>This chart will use only visible rows, click 'Fetch all data' to chart the full report</p>
+ </li>
+ [% END %]
<li>
<label for="exclude-last">Exclude last line (Rollup): </label>
<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>
</div>
<div class="btn-group">
- <a class="btn btn-default" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-bar-chart"></i> Create chart</a>
+ [% IF allresults.size %]
+ <a class="btn btn-default" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-bar-chart"></i> Create chart</a>
+ [% ELSE %]
+ <a class="btn btn-default" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-bar-chart"></i> Create chart</a>
+ <a class="btn btn-default fetch_chart_data" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&phase=Run this report&reportname=[% name |uri %][% PROCESS params %]&want_full_chart=1"><i class="fa fa-bar-chart"></i> Fetch all data for chart</a>
+ [% END %]
+
</div>
[% END %]
}
$(document).ready(function(){
+
+ $("body").on('click',".fetch_chart_data",function(){
+ if( [% unlimited_total %] > 1000 ){
+ if( confirm("Fetching full chart data for reports with many rows can cause performance issues. Are you sure you with to chart this report?") ){
+ return true;
+ } else {
+ return false;
+ }
+ }
+ });
+
var showsql;
hide_bar_element();
headers = [% header_row.json | $raw %];
var results;
- if ($('input[name="chart-include-all"]').prop('checked')) {
- results = [% allresults.json | $raw %]
- }
- else {
- results = [% results.json | $raw %]
- }
+ [% IF allresults.size %]
+ if ($('input[name="chart-include-all"]').prop('checked')) {
+ results = [% allresults.json | $raw %]
+ }
+ else {
+ results = [% results.json | $raw %]
+ }
+ [% ELSE %]
+ results = [% results.json | $raw %];
+ [% END %]
if ($('input[name="chart-exclude-last"]').prop('checked')) {
results.splice(-1, 1);
my $report_id = $input->param('reports');
my @sql_params = $input->multi_param('sql_params');
my @param_names = $input->multi_param('param_name');
+ my $want_full_chart = $input->param('want_full_chart') || 0;
# offset algorithm
if ($input->param('page')) {
my ($sql,$header_types) = get_prepped_report( $sql, \@param_names, \@sql_params);
$template->param(header_types => $header_types);
my ( $sth, $errors ) = execute_query( $sql, $offset, $limit, undef, $report_id );
- my ($sth2, $errors2) = execute_query($sql);
my $total = nb_rows($sql) || 0;
unless ($sth) {
die "execute_query failed to return sth for report $report_id: $sql";
my @cells = map { +{ cell => $_ } } @$row;
push @rows, { cells => \@cells };
}
- while (my $row = $sth2->fetchrow_arrayref()) {
- my @cells = map { +{ cell => $_ } } @$row;
- push @allrows, { cells => \@cells };
+ if( $want_full_chart ){
+ my ($sth2, $errors2) = execute_query($sql);
+ while (my $row = $sth2->fetchrow_arrayref()) {
+ my @cells = map { +{ cell => $_ } } @$row;
+ push @allrows, { cells => \@cells };
+ }
}
}
my $totpages = int($total/$limit) + (($total % $limit) > 0 ? 1 : 0);
- my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report_id&phase=Run%20this%20report&limit=$limit";
+ my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report_id&phase=Run%20this%20report&limit=$limit&want_full_chart=$want_full_chart";
if (@param_names) {
$url = join('&param_name=', $url, map { URI::Escape::uri_escape_utf8($_) } @param_names);
}