X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=reports%2Fissues_avg_stats.pl;h=b601a44c550b693e05399e7c418615b6090d28c2;hb=9706908b269ebc068b19a0989ca8af6804b1a540;hp=d37dab0384be4033baf9ef92496333b609f48325;hpb=8ad2c7d7acc3cb0033426bd78928214a22ad9dd1;p=koha.git diff --git a/reports/issues_avg_stats.pl b/reports/issues_avg_stats.pl index d37dab0384..b601a44c55 100755 --- a/reports/issues_avg_stats.pl +++ b/reports/issues_avg_stats.pl @@ -14,11 +14,12 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; +#use warnings; FIXME - Bug 2505 use C4::Auth; use CGI; use C4::Context; @@ -55,7 +56,6 @@ my $rodsp = $input->param("ReturnDisplay"); my $calc = $input->param("Cellvalue"); my $output = $input->param("output"); my $basename = $input->param("basename"); -my $mime = $input->param("MIME"); #warn "calcul : ".$calc; my ($template, $borrowernumber, $cookie) = get_template_and_user({template_name => $fullreportname, @@ -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', @@ -200,29 +184,24 @@ if ($do_it) { -size => 1, -multiple => 0 ); - my @mime = ( C4::Context->preference("MIME") ); -# foreach my $mime (@mime){ -# warn "".$mime; -# } - my $CGIextChoice=CGI::scrolling_list( -name => 'MIME', -id => 'MIME', - -values => \@mime, + -values => ['CSV'], # FIXME translation -size => 1, -multiple => 0 ); 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 ); @@ -450,7 +429,6 @@ sub calculate { } $strsth2 .=" GROUP BY $colfield"; $strsth2 .=" ORDER BY $colorder"; - warn "". $strsth2; my $sth2 = $dbh->prepare( $strsth2 ); if (( @colfilter ) and ($colfilter[1])){ @@ -521,7 +499,6 @@ sub calculate { $strcalc .= " AND monthname(returndate) like '" . @$filters[6] ."'" if ( @$filters[6] ); $strcalc .= " group by $linefield, $colfield, issuedate, returndate order by $linefield, $colfield"; - warn "SQL :". $strcalc; my $dbcalc = $dbh->prepare($strcalc); $dbcalc->execute; @@ -561,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}}"; @@ -570,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; } #