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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt (-1 / +49 lines)
Lines 2-7 Link Here
2
<title>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Catalog statistics &rsaquo; Results[% ELSE %]&rsaquo; Catalog statistics[% END %]</title>
2
<title>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Catalog statistics &rsaquo; Results[% ELSE %]&rsaquo; Catalog statistics[% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'calendar.inc' %]
4
[% INCLUDE 'calendar.inc' %]
5
<script src="[% interface %]/lib/charts/Chart.min.js"></script>
5
<script type="text/javascript">
6
<script type="text/javascript">
6
//<![CDATA[
7
//<![CDATA[
7
        $(document).ready(function() {
8
        $(document).ready(function() {
Lines 51-57 Link Here
51
[% IF ( do_it ) %]
52
[% IF ( do_it ) %]
52
	[% FOREACH mainloo IN mainloop %]
53
	[% FOREACH mainloo IN mainloop %]
53
		<h1>Catalog statistics</h1>
54
		<h1>Catalog statistics</h1>
54
		[% IF ( mainloo.loopfilter ) %]
55
	    <canvas id="catChart" width="1000" height="400"></canvas>
56
        <div id="toolbar" class="btn-toolbar"><div class="btn-group"><a id="updateChart" class="btn" href="#">Click to change to <span id="chartType">Line</span> Chart</a></div></div>
57
	[% IF ( mainloo.loopfilter ) %]
55
            <p>Filtered on:</p>
58
            <p>Filtered on:</p>
56
			[% FOREACH loopfilte IN mainloo.loopfilter %]
59
			[% FOREACH loopfilte IN mainloo.loopfilter %]
57
					<p>[% loopfilte.crit %] =[% loopfilte.filter %]</p>
60
					<p>[% loopfilte.crit %] =[% loopfilte.filter %]</p>
Lines 272-275 Link Here
272
[% INCLUDE 'reports-menu.inc' %]
275
[% INCLUDE 'reports-menu.inc' %]
273
</div>
276
</div>
274
</div>
277
</div>
278
[% IF ( do_it ) %]
279
<script type="text/javascript">
280
    var ctx = $("#catChart").get(0).getContext("2d");
281
282
    var chartData = {
283
    labels: [[% FOREACH loopco IN mainloo.loopcol %]"[% loopco.coltitle_display |html %]", [% END %]],
284
    datasets: [
285
        [% FOREACH loopro IN mainloo.looprow %]{
286
            label: "[% loopro.rowtitle_display or "UNKNOWN VALUE" |html %]",
287
            fillColor: "[% loopro.fill %]",
288
            strokeColor: "[% loopro.stroke %]",
289
            pointColor: "[% loopro.point %]",
290
            pointStrokeColor: "#fff",
291
            pointHighlightFill: "#fff",
292
            pointHighlightStroke: "[% loopro.highlight %]",
293
            data: [[% FOREACH loopcel IN loopro.loopcell %]"[% loopcel.value %]", [% END %]]
294
        }, [% END %]]
295
    };
296
297
    var chartType = "Bar";
298
    var catChart = new Chart(ctx).Bar( chartData, {});
299
300
    $("#updateChart").click(function() {
301
        console.log("Updating Chart: ");
302
303
        // Replace the chart canvas element
304
        $('#catChart').replaceWith('<canvas id="catChart" width="1000" height="400"></canvas>');
305
306
        // Draw the chart
307
        ctx = $('#catChart').get(0).getContext("2d");
308
309
        if ( chartType == "Bar" ) {
310
            new Chart(ctx).Line( chartData, {});
311
            $('#chartType').text('Bar');
312
            chartType = "Line";
313
        } else {
314
            new Chart(ctx).Bar( chartData, {});
315
            $('#chartType').text('Line');
316
            chartType = "Bar";
317
        }
318
    });
319
    //circChart.update();
320
</script>
321
[% END %]
322
275
[% INCLUDE 'intranet-bottom.inc' %]
323
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/reports/catalogue_stats.pl (-3 / +56 lines)
Lines 188-193 sub calculate { Link Here
188
    my $barcodelike   = @$filters[13];
188
    my $barcodelike   = @$filters[13];
189
    my $barcodefilter = @$filters[14];
189
    my $barcodefilter = @$filters[14];
190
    my $not;
190
    my $not;
191
    my $colors = get_colors();
191
    
192
    
192
# extract parameters
193
# extract parameters
193
	my $dbh = C4::Context->dbh;
194
	my $dbh = C4::Context->dbh;
Lines 476-482 if($barcodefilter){ Link Here
476
# 	my %cell;
477
# 	my %cell;
477
# 	%cell = {coltitle => "zzEMPTY"};
478
# 	%cell = {coltitle => "zzEMPTY"};
478
 	push @loopcol,{coltitle => "NULL"} if ($emptycol);
479
 	push @loopcol,{coltitle => "NULL"} if ($emptycol);
479
	
480
481
    my $loopcount = '0';
480
	foreach my $row ( sort keys %table ) {
482
	foreach my $row ( sort keys %table ) {
481
		my @loopcell;
483
		my @loopcell;
482
		#@loopcol ensures the order for columns is common with column titles
484
		#@loopcol ensures the order for columns is common with column titles
Lines 488-495 if($barcodefilter){ Link Here
488
		push @looprow,{ 'rowtitle' => ($row eq "zzEMPTY")?"NULL":$row,
490
		push @looprow,{ 'rowtitle' => ($row eq "zzEMPTY")?"NULL":$row,
489
						'loopcell' => \@loopcell,
491
						'loopcell' => \@loopcell,
490
						'hilighted' => ($hilighted *= -1 > 0),
492
						'hilighted' => ($hilighted *= -1 > 0),
491
						'totalrow' => $table{$row}->{totalrow}
493
						'totalrow' => $table{$row}->{totalrow},
494
                        'fill' => ${$colors}[$loopcount]->{fill},
495
                        'stroke' => ${$colors}[$loopcount]->{stroke},
496
                        'point' => ${$colors}[$loopcount]->{point},
497
                        'highlight' => ${$colors}[$loopcount]->{highlight},
498
492
					};
499
					};
500
        $loopcount++;
501
        if ( $loopcount == '6' ) {
502
            $loopcount = '0';
503
        }
493
	}
504
	}
494
	
505
	
495
#	warn "footer processing";
506
#	warn "footer processing";
Lines 518-521 if($barcodefilter){ Link Here
518
	return \@mainloop;
529
	return \@mainloop;
519
}
530
}
520
531
532
sub get_colors {
533
    my $colors = [
534
        {
535
            fill                => "rgba(151,187,205,0.2)",
536
            stroke              => "rgba(151,187,205,1)",
537
            point               => "rgba(151,187,205,1)",
538
            highlight           => "rgba(151,187,205,1)",
539
        },
540
        {
541
            fill                => "rgba(216,191,216,0.2)",
542
            stroke              => "rgba(216,191,216,1)",
543
            point               => "rgba(216,191,216,1)",
544
            highlight           => "rgba(216,191,216,1)",
545
        },
546
        {
547
            fill                => "rgba(240,128,128,0.2)",
548
            stroke              => "rgba(240,128,128,1)",
549
            point               => "rgba(240,128,128,1)",
550
            highlight           => "rgba(240,128,128,1)",
551
        },
552
        {
553
            fill                => "rgba(240,230,140,0.2)",
554
            stroke              => "rgba(240,230,140,1)",
555
            point               => "rgba(240,230,140,1)",
556
            highlight           => "rgba(240,230,140,1)",
557
        },
558
        {
559
            fill                => "rgba(152,251,152,0.2)",
560
            stroke              => "rgba(152,251,152,1)",
561
            point               => "rgba(152,251,152,1)",
562
            highlight           => "rgba(152,251,152,1)",
563
        },
564
        {
565
            fill                => "rgba(216,191,216,0.2)",
566
            stroke              => "rgba(216,191,216,1)",
567
            point               => "rgba(216,191,216,1)",
568
            highlight           => "rgba(216,191,216,1)",
569
        },
570
   ];
571
572
    return $colors;
573
}
574
521
1;
575
1;
522
- 

Return to bug 13219