X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=reports%2Fissues_avg_stats.pl;h=93fe04676ff227cca5ae13aaa197008d68f8fd8e;hb=6def929de4a72fb8d6a9cac59419daa87807c500;hp=f0f1dd578094692ce52ecac35be11f8791f0d773;hpb=c190d93a12c2741b8d4539b7bee175257da815c8;p=koha.git diff --git a/reports/issues_avg_stats.pl b/reports/issues_avg_stats.pl index f0f1dd5780..93fe04676f 100755 --- a/reports/issues_avg_stats.pl +++ b/reports/issues_avg_stats.pl @@ -21,7 +21,7 @@ use strict; #use warnings; FIXME - Bug 2505 use C4::Auth; -use CGI; +use CGI qw ( -utf8 ); use C4::Context; use C4::Branch; # GetBranches use C4::Output; @@ -43,7 +43,7 @@ plugin that shows a stats on borrowers my $input = new CGI; my $do_it=$input->param('do_it'); -my $fullreportname = "reports/issues_avg_stats.tmpl"; +my $fullreportname = "reports/issues_avg_stats.tt"; my $line = $input->param("Line"); my $column = $input->param("Column"); my @filters = $input->param("Filter"); @@ -68,7 +68,6 @@ my ($template, $borrowernumber, $cookie) our $sep = $input->param("sep"); $sep = "\t" if ($sep eq 'tabulation'); $template->param(do_it => $do_it, - DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), ); if ($do_it) { # Displaying results @@ -77,7 +76,7 @@ if ($do_it) { # Printing results to screen $template->param(mainloop => $results); output_html_with_http_headers $input, $cookie, $template->output; - exit(1); + exit; } else { # Printing to a csv file print $input->header(-type => 'application/vnd.sun.xml.calc', @@ -110,7 +109,7 @@ if ($do_it) { print $sep.$col->{totalcol}; } print $sep.@$results[0]->{total}; - exit(1); + exit; } # Displaying choices } else { @@ -161,21 +160,6 @@ if ($do_it) { $hassort1 =1 if ($value); push @select, $value; } - my $branches=GetBranches(); - my @select_branch; - my %select_branches; - push @select_branch,""; - $select_branches{""} = ""; - foreach my $branch (keys %$branches) { - push @select_branch, $branch; - $select_branches{$branch} = $branches->{$branch}->{'branchname'}; - } - my $CGIBranch=CGI::scrolling_list( -name => 'Filter', - -id => 'branch', - -values => \@select_branch, - -labels => \%select_branches, - -size => 1, - -multiple => 0 ); my $CGISort1=CGI::scrolling_list( -name => 'Filter', -id => 'sort1', @@ -210,14 +194,14 @@ if ($do_it) { my $CGIsepChoice=GetDelimiterChoices; $template->param( - CGIBorCat => $CGIBorCat, - CGIItemType => $CGIItemTypes, - CGIBranch => $CGIBranch, - hassort1=> $hassort1, - hassort2=> $hassort2, - HlghtSort2 => $hglghtsort2, - CGISort1 => $CGISort1, - CGISort2 => $CGISort2, + CGIBorCat => $CGIBorCat, + CGIItemType => $CGIItemTypes, + branchloop => GetBranchesLoop(), + hassort1 => $hassort1, + hassort2 => $hassort2, + HlghtSort2 => $hglghtsort2, + CGISort1 => $CGISort1, + CGISort2 => $CGISort2, CGIextChoice => $CGIextChoice, CGIsepChoice => $CGIsepChoice ); @@ -554,8 +538,23 @@ sub calculate { # and the number matches the number of columns my $colcount=0; foreach my $col ( @loopcol ) { - my $value =$table{$row}->{(($col->{coltitle} eq "NULL")or ($col->{coltitle} eq ""))?"zzEMPTY":$col->{coltitle}} / $wgttable{$row}->{(($col->{coltitle} eq "NULL")or ($col->{coltitle} eq ""))?"zzEMPTY":$col->{coltitle}} if ($table{$row}->{(($col->{coltitle} eq "NULL")or ($col->{coltitle} eq ""))?"zzEMPTY":$col->{coltitle}}); - + my $value; + if ($table{$row}->{ + ( ( $col->{coltitle} eq 'NULL' ) + or ( $col->{coltitle} eq q{} ) + ) ? 'zzEMPTY' : $col->{coltitle} + } + ) { + $value = $table{$row}->{ + ( ( $col->{coltitle} eq 'NULL' ) + or ( $col->{coltitle} eq q{} ) + ) ? 'zzEMPTY' : $col->{coltitle} + } / $wgttable{$row}->{ + ( ( $col->{coltitle} eq 'NULL' ) + or ( $col->{coltitle} eq q{} ) + ) ? 'zzEMPTY' : $col->{coltitle} + }; + } $table{$row}->{(($col->{coltitle} eq "NULL")or ($col->{coltitle} eq ""))?"zzEMPTY":$col->{coltitle}} = $value; $table{$row}->{totalrow}+=$value; #warn "row : $row col:$col $cnttable{$row}->{(($col->{coltitle} eq \"NULL\")or ($col->{coltitle} eq \"\"))?\"zzEMPTY\":$col->{coltitle}}"; @@ -563,12 +562,16 @@ sub calculate { push @loopcell, {value => ($value)?sprintf("%.2f",$value):0 } ; } #warn "row : $row colcount:$colcount"; - my $total = $table{$row}->{totalrow}/$colcount if ($colcount>0); - push @looprow,{ 'rowtitle' => ($row eq "zzEMPTY")?"NULL":$row, - 'loopcell' => \@loopcell, - 'hilighted' => ($hilighted >0), - 'totalrow' => ($total)?sprintf("%.2f",$total):0 - }; + my $total; + if ( $colcount > 0 ) { + $total = $table{$row}->{totalrow} / $colcount; + } + push @looprow, + { 'rowtitle' => ( $row eq "zzEMPTY" ) ? "NULL" : $row, + 'loopcell' => \@loopcell, + 'hilighted' => ( $hilighted > 0 ), + 'totalrow' => ($total) ? sprintf( "%.2f", $total ) : 0 + }; $hilighted = -$hilighted; } #