X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=reports%2Fborrowers_stats.pl;h=82b9002602a00a944c11fece66970dcde2232d57;hb=5d6c092921919526ade501facb1220f8a108a08f;hp=eca9b3abc21aaa4b2ce6cf8e44a4a146b6bcc508;hpb=a08c09884ec8799f2835b6a63ed10833bd927fbf;p=koha_fer diff --git a/reports/borrowers_stats.pl b/reports/borrowers_stats.pl index eca9b3abc2..82b9002602 100755 --- a/reports/borrowers_stats.pl +++ b/reports/borrowers_stats.pl @@ -56,7 +56,7 @@ my @filters = $input->param("Filter"); $filters[3]=format_date_in_iso($filters[3]); $filters[4]=format_date_in_iso($filters[4]); my $digits = $input->param("digits"); -my $period = $input->param("period"); +our $period = $input->param("period"); my $borstat = $input->param("status"); my $borstat1 = $input->param("activity"); my $output = $input->param("output"); @@ -154,12 +154,12 @@ if ($do_it) { } output_html_with_http_headers $input, $cookie, $template->output; -sub catcode_aref() { +sub catcode_aref { my $req = C4::Context->dbh->prepare("SELECT categorycode, description FROM categories ORDER BY description"); $req->execute; return $req->fetchall_arrayref({}); } -sub catcodes_hash() { +sub catcodes_hash { my %cathash; my $catcodes = &catcode_aref; foreach (@$catcodes) { @@ -202,28 +202,24 @@ sub calculate { # Filters my $linefilter; - given ($line) { - when (/categorycode/) { $linefilter = @$filters[0] } - when (/zipcode/) { $linefilter = @$filters[1] } - when (/branchcode/) { $linefilter = @$filters[2] } - when (/sex/) { $linefilter = @$filters[5] } - when (/sort1/) { $linefilter = @$filters[6] } - when (/sort2/) { $linefilter = @$filters[7] } - when (/^patron_attr\.(.*)$/) { $linefilter = $attr_filters->{$1} } - default { $linefilter = '' } - } + if ( $line =~ /categorycode/ ) { $linefilter = @$filters[0]; } + elsif ( $line =~ /zipcode/ ) { $linefilter = @$filters[1]; } + elsif ( $line =~ /branchcode/ ) { $linefilter = @$filters[2]; } + elsif ( $line =~ /sex/ ) { $linefilter = @$filters[5]; } + elsif ( $line =~ /sort1/ ) { $linefilter = @$filters[6]; } + elsif ( $line =~ /sort2/ ) { $linefilter = @$filters[7]; } + elsif ( $line =~ /^patron_attr\.(.*)$/ ) { $linefilter = $attr_filters->{$1}; } + else { $linefilter = ''; } my $colfilter; - given ($column) { - when (/categorycode/) { $colfilter = @$filters[0] } - when (/zipcode/) { $colfilter = @$filters[1] } - when (/branchcode/) { $colfilter = @$filters[2] } - when (/sex/) { $colfilter = @$filters[5] } - when (/sort1/) { $colfilter = @$filters[6] } - when (/sort2/) { $colfilter = @$filters[7] } - when (/^patron_attr\.(.*)$/) { $colfilter = $attr_filters->{$1} } - default { $colfilter = '' } - } + if ( $column =~ /categorycode/ ) { $colfilter = @$filters[0]; } + elsif ( $column =~ /zipcode/ ) { $colfilter = @$filters[1]; } + elsif ( $column =~ /branchcode/) { $colfilter = @$filters[2]; } + elsif ( $column =~ /sex/) { $colfilter = @$filters[5]; } + elsif ( $column =~ /sort1/) { $colfilter = @$filters[6]; } + elsif ( $column =~ /sort2/) { $colfilter = @$filters[7]; } + elsif ( $column =~ /^patron_attr\.(.*)$/) { $colfilter = $attr_filters->{$1}; } + else { $colfilter = ''; } my @loopfilter; foreach my $i (0 .. scalar @$filters) { @@ -235,16 +231,16 @@ sub calculate { $cell{filter} = @$filters[$i]; } - given ($i) { - when (0) { $cell{crit} = "Cat code" } - when (1) { $cell{crit} = "Zip code" } - when (2) { $cell{crit} = "Branch code" } - when ([3,4]) { $cell{crit} = "Date of birth" } - when (5) { $cell{crit} = "Sex" } - when (6) { $cell{crit} = "Sort1" } - when (7) { $cell{crit} = "Sort2" } - default { $cell{crit} = "Unknown" } - } + if ( $i == 0) { $cell{crit} = "Cat code"; } + elsif ( $i == 1 ) { $cell{crit} = "Zip code"; } + elsif ( $i == 2 ) { $cell{crit} = "Branch code"; } + elsif ( $i == 3 || + $i == 4 ) { $cell{crit} = "Date of birth"; } + elsif ( $i == 5 ) { $cell{crit} = "Sex"; } + elsif ( $i == 6 ) { $cell{crit} = "Sort1"; } + elsif ( $i == 7 ) { $cell{crit} = "Sort2"; } + else { $cell{crit} = "Unknown"; } + push @loopfilter, \%cell; } } @@ -354,7 +350,7 @@ sub calculate { $sth2->execute(@strparams2); while (my ($celvalue) = $sth2->fetchrow) { my %cell; - if ($celvalue) { + if (defined $celvalue) { $cell{coltitle} = $celvalue; # $cell{coltitle_display} = ($colfield eq 'branchcode') ? $branches->{$celvalue}->{branchname} : $celvalue; $cell{coltitle_display} = $cathash{$celvalue} if ($column eq 'categorycode'); @@ -372,6 +368,7 @@ sub calculate { my $coltitle = $row->{coltitle} // ''; $table{$rowtitle}->{$coltitle} = 0; } + $row->{rowtitle} ||= ''; $table{$row->{rowtitle}}->{totalrow}=0; $table{$row->{rowtitle}}->{rowtitle_display} = $row->{rowtitle_display}; }