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 194-199 sub calculate { Link Here
194
    my $barcodelike   = @$filters[13];
194
    my $barcodelike   = @$filters[13];
195
    my $barcodefilter = @$filters[14];
195
    my $barcodefilter = @$filters[14];
196
    my $not;
196
    my $not;
197
    my $colors = get_colors();
197
    
198
    
198
# extract parameters
199
# extract parameters
199
	my $dbh = C4::Context->dbh;
200
	my $dbh = C4::Context->dbh;
Lines 493-499 if($barcodefilter){ Link Here
493
# 	my %cell;
494
# 	my %cell;
494
# 	%cell = {coltitle => "zzEMPTY"};
495
# 	%cell = {coltitle => "zzEMPTY"};
495
 	push @loopcol,{coltitle => "NULL"} if ($emptycol);
496
 	push @loopcol,{coltitle => "NULL"} if ($emptycol);
496
	
497
498
    my $loopcount = '0';
497
	foreach my $row ( sort keys %table ) {
499
	foreach my $row ( sort keys %table ) {
498
		my @loopcell;
500
		my @loopcell;
499
		#@loopcol ensures the order for columns is common with column titles
501
		#@loopcol ensures the order for columns is common with column titles
Lines 505-512 if($barcodefilter){ Link Here
505
		push @looprow,{ 'rowtitle' => ($row eq "zzEMPTY")?"NULL":$row,
507
		push @looprow,{ 'rowtitle' => ($row eq "zzEMPTY")?"NULL":$row,
506
						'loopcell' => \@loopcell,
508
						'loopcell' => \@loopcell,
507
						'hilighted' => ($hilighted *= -1 > 0),
509
						'hilighted' => ($hilighted *= -1 > 0),
508
						'totalrow' => $table{$row}->{totalrow}
510
						'totalrow' => $table{$row}->{totalrow},
511
                        'fill' => ${$colors}[$loopcount]->{fill},
512
                        'stroke' => ${$colors}[$loopcount]->{stroke},
513
                        'point' => ${$colors}[$loopcount]->{point},
514
                        'highlight' => ${$colors}[$loopcount]->{highlight},
515
509
					};
516
					};
517
        $loopcount++;
518
        if ( $loopcount == '6' ) {
519
            $loopcount = '0';
520
        }
510
	}
521
	}
511
	
522
	
512
#	warn "footer processing";
523
#	warn "footer processing";
Lines 535-538 if($barcodefilter){ Link Here
535
	return \@mainloop;
546
	return \@mainloop;
536
}
547
}
537
548
549
sub get_colors {
550
    my $colors = [
551
        {
552
            fill                => "rgba(151,187,205,0.2)",
553
            stroke              => "rgba(151,187,205,1)",
554
            point               => "rgba(151,187,205,1)",
555
            highlight           => "rgba(151,187,205,1)",
556
        },
557
        {
558
            fill                => "rgba(216,191,216,0.2)",
559
            stroke              => "rgba(216,191,216,1)",
560
            point               => "rgba(216,191,216,1)",
561
            highlight           => "rgba(216,191,216,1)",
562
        },
563
        {
564
            fill                => "rgba(240,128,128,0.2)",
565
            stroke              => "rgba(240,128,128,1)",
566
            point               => "rgba(240,128,128,1)",
567
            highlight           => "rgba(240,128,128,1)",
568
        },
569
        {
570
            fill                => "rgba(240,230,140,0.2)",
571
            stroke              => "rgba(240,230,140,1)",
572
            point               => "rgba(240,230,140,1)",
573
            highlight           => "rgba(240,230,140,1)",
574
        },
575
        {
576
            fill                => "rgba(152,251,152,0.2)",
577
            stroke              => "rgba(152,251,152,1)",
578
            point               => "rgba(152,251,152,1)",
579
            highlight           => "rgba(152,251,152,1)",
580
        },
581
        {
582
            fill                => "rgba(216,191,216,0.2)",
583
            stroke              => "rgba(216,191,216,1)",
584
            point               => "rgba(216,191,216,1)",
585
            highlight           => "rgba(216,191,216,1)",
586
        },
587
   ];
588
589
    return $colors;
590
}
591
538
1;
592
1;
539
- 

Return to bug 13219