From 6bbbfe0b1805acd7be83731fa7d3b44e2a4381d2 Mon Sep 17 00:00:00 2001 From: hdl Date: Wed, 20 Jul 2005 09:52:31 +0000 Subject: [PATCH] Adding Borrowers count feature. Note : This COULD be reported in 2.2 branch. --- .../default/en/reports/issues_stats.tmpl | 1 + reports/issues_stats.pl | 29 ++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/default/en/reports/issues_stats.tmpl b/koha-tmpl/intranet-tmpl/default/en/reports/issues_stats.tmpl index 2501751f44..34e1103497 100644 --- a/koha-tmpl/intranet-tmpl/default/en/reports/issues_stats.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/reports/issues_stats.tmpl @@ -205,6 +205,7 @@

Cell value

Count issues

+

Count borrowers

Circulation rate

diff --git a/reports/issues_stats.pl b/reports/issues_stats.pl index 56156e4ae9..c7229e9d64 100755 --- a/reports/issues_stats.pl +++ b/reports/issues_stats.pl @@ -307,7 +307,7 @@ sub calculate { my $linefield; if (($line =~/datetime/) and ($dsp == 1)) { #Display by day - $linefield .="concat(weekday($line),' ',dayname($line))"; + $linefield .="dayname($line)"; } elsif (($line=~/datetime/) and ($dsp == 2)) { #Display by Month $linefield .="monthname($line)"; @@ -320,7 +320,9 @@ sub calculate { $linefield .= $line; } my $lineorder = $linefield; - $lineorder = "weekday($line)" if $lineorder =~ "^dayname"; + $lineorder = "weekday($line)" if $linefield =~ /dayname/; + $lineorder = "month($line)" if $linefield =~ "^month"; + $lineorder = $linefield if (not ($linefield =~ "^month") and not($linefield =~ /dayname/)); my $strsth; $strsth .= "select distinctrow $linefield from statistics, borrowers where (statistics.borrowernumber=borrowers.borrowernumber) and $line is not null "; @@ -365,7 +367,8 @@ sub calculate { } # 2nd, loop cols. - my $colfield; + my $colfield; + my $colorder; if (($column =~/datetime/) and ($dsp == 1)) { #Display by day $colfield .="dayname($column)"; @@ -380,6 +383,9 @@ sub calculate { } else { $colfield .= $column; } + $colorder = "weekday($line)" if $colfield =~ "^dayname"; + $colorder = "month($line)" if $colfield =~ "^month"; + $colorder = $colfield if (not ($colfield =~ "^month") and not($colfield =~ "^dayname")); my $strsth2; $strsth2 .= "select distinctrow $colfield from statistics, borrowers where (statistics.borrowernumber=borrowers.borrowernumber) and $column is not null "; @@ -400,7 +406,7 @@ sub calculate { $strsth2 .= " and $column LIKE ? " ; } $strsth2 .=" group by $colfield"; - $strsth2 .=" order by $colfield"; + $strsth2 .=" order by $colorder"; # warn "". $strsth2; my $sth2 = $dbh->prepare( $strsth2 ); @@ -443,6 +449,9 @@ sub calculate { $strcalc .= "SELECT $linefield, $colfield, "; $strcalc .= "COUNT( * ) " if ($process ==1); + if ($process ==2){ + $strcalc .= "(COUNT(DISTINCT borrowers.borrowernumber))" ; + } if ($process ==3){ my $rqbookcount = $dbh->prepare("SELECT count(*) FROM items"); $rqbookcount->execute; @@ -469,14 +478,14 @@ sub calculate { $strcalc .= " AND monthname(datetime) like '" . $monthsel ."'" if ( $monthsel ); $strcalc .= " AND statistics.type like '" . $type ."'" if ( $type ); - $strcalc .= " group by $linefield, $colfield order by $lineorder,$colfield"; + $strcalc .= " group by $linefield, $colfield order by $lineorder,$colorder"; warn "". $strcalc; my $dbcalc = $dbh->prepare($strcalc); $dbcalc->execute; # warn "filling table"; my $emptycol; while (my ($row, $col, $value) = $dbcalc->fetchrow) { -# warn "filling table $row / $col / $value "; + warn "filling table $row / $col / $value "; $emptycol = 1 if ($col eq undef); $col = "zzEMPTY" if ($col eq undef); $row = "zzEMPTY" if ($row eq undef); @@ -487,18 +496,18 @@ sub calculate { } push @loopcol,{coltitle => "NULL"} if ($emptycol); - foreach my $row ( sort keys %table ) { + foreach my $row (@loopline) { my @loopcell; #@loopcol ensures the order for columns is common with column titles # and the number matches the number of columns foreach my $col ( @loopcol ) { - my $value =$table{$row}->{($col->{coltitle} eq "NULL")?"zzEMPTY":$col->{coltitle}}; + my $value =$table{($row->{rowtitle} eq "NULL")?"zzEMPTY":$row->{rowtitle}}->{($col->{coltitle} eq "NULL")?"zzEMPTY":$col->{coltitle}}; push @loopcell, {value => $value } ; } - push @looprow,{ 'rowtitle' => ($row eq "zzEMPTY")?"NULL":$row, + push @looprow,{ 'rowtitle' => ($row->{rowtitle} eq "NULL")?"zzEMPTY":$row->{rowtitle}, 'loopcell' => \@loopcell, 'hilighted' => ($hilighted >0), - 'totalrow' => $table{$row}->{totalrow} + 'totalrow' => $table{($row->{rowtitle} eq "NULL")?"zzEMPTY":$row->{rowtitle}}->{totalrow} }; $hilighted = -$hilighted; } -- 2.20.1