From 32b3f63095d230a12fde89a5efab7c979a1078f0 Mon Sep 17 00:00:00 2001 From: Michael Hafen Date: Thu, 11 Apr 2024 16:33:39 -0600 Subject: [PATCH] Bug 36585: improve bor_issues_top report Content-Type: text/plain; charset="utf-8" Try the following with and without a group by, specifically item type. 1. Generate the report with output to screen with a group by. 2. Observe that the patron name is repeated for each column group. 3. Observe that there is no total column. 4. Generate the report with output to csv. 5. Observe that the total check outs is not in the csv. 6. Apply patch. restart Koha. 7. Generate the report to csv again. 8. Observe that the total checkouts is in the csv. 9. Generate the report to screen again. 10. Observe that there is a total column and the patron name is only in one column. --- .../prog/en/modules/reports/bor_issues_top.tt | 15 +++--- reports/bor_issues_top.pl | 50 +++++++++++-------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt index c867cc5b35..f79f801912 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt @@ -86,13 +86,14 @@ + + [% FOREACH loopco IN mainloo.loopcol %] - + [% END %] [% FOREACH loopco IN mainloo.loopcol %] - [% END %] @@ -100,13 +101,13 @@ [% IF ( loopro.hilighted ) %] + [% IF ( loopro.hilighted ) %] [% FOREACH loopcel IN loopro.loopcell %] [% IF ( loopcel.hilighted ) %] - [% IF ( loopcel.hilighted ) %] [% END %] diff --git a/reports/bor_issues_top.pl b/reports/bor_issues_top.pl index 439db23810..617b3c9703 100755 --- a/reports/bor_issues_top.pl +++ b/reports/bor_issues_top.pl @@ -68,23 +68,25 @@ if ($do_it) { -filename=>"$basename.csv" ); my $cols = @$results[0]->{loopcol}; my $lines = @$results[0]->{looprow}; -# header top-right +# header top-left print @$results[0]->{line} ."/". @$results[0]->{column} .$sep; + print "Patron".$sep; + print "Total".$sep; # Other header print join($sep, map {$_->{coltitle}} @$cols); - print $sep . "Total\n"; + print "\n"; # Table foreach my $line ( @$lines ) { my $x = $line->{loopcell}; print $line->{rowtitle}.$sep; - print join($sep, map {$_->{value}} @$x); - print $sep,$line->{totalrow}; + print '"'.$line->{patron}.'"'.$sep; + print join($sep, map {$_->{count}} @$x); print "\n"; } # footer print "TOTAL"; $cols = @$results[0]->{loopfooter}; - print join($sep, map {$_->{totalcol}} @$cols); + print join($sep, map {$_->{total}} @$cols); print $sep.@$results[0]->{total}; } exit; @@ -148,7 +150,7 @@ sub calculate { my $colorder; if ($column){ $column = "old_issues." .$column if (($column=~/branchcode/) or ($column=~/timestamp/)); - $column = "biblioitems.".$column if $column=~/itemtype/; + $column = "items.itype" if $column=~/itemtype/; $column = "borrowers." .$column if $column=~/categorycode/; my @colfilter ; if ($column =~ /timestamp/) { @@ -245,7 +247,7 @@ sub calculate { 'old_issues.returndate >', 'old_issues.returndate <', 'old_issues.branchcode like', - 'biblioitems.itemtype like', + 'items.itype like', 'borrowers.categorycode like', ); foreach ((@$filters)[0..9]) { @@ -309,24 +311,28 @@ sub calculate { foreach my $id (@ranked_ids) { my @loopcell; - foreach my $key (@cols_in_order) { - if($column){ - push @loopcell, { - value => $patrons{$id}->{name}, - reference => $id, - count => $patrons{$id}->{allcols}->{$key}, - }; - }else{ - push @loopcell, { - value => $patrons{$id}->{name}, - reference => $id, - count => $patrons{$id}->{total}, - }; - } + if($column){ + # Total + push @loopcell, { + count => $patrons{$id}->{total}, + }; + foreach my $key (@cols_in_order) { + push @loopcell, { + count => $patrons{$id}->{allcols}->{$key}, + }; + $grantotal += $patrons{$id}->{allcols}->{$key}; + } + }else{ + push @loopcell, { + count => $patrons{$id}->{total}, + }; + $grantotal += $patrons{$id}->{total}; } push @looprow,{ 'rowtitle' => $i++ , 'loopcell' => \@loopcell, 'hilighted' => ($i%2), + 'patron' => $patrons{$id}->{name}, + 'reference' => $id, }; # use a limit, if a limit is defined last if $i > $limit and $limit @@ -336,7 +342,7 @@ sub calculate { $globalline{loopfilter}=\@loopfilter; # the core of the table $globalline{looprow} = \@looprow; - $globalline{loopcol} = [ map {{coltitle=>$_}} @cols_in_order ]; + $globalline{loopcol} = [ map {{coltitle=>$_}} @cols_in_order ] if ($column); # the foot (totals by borrower type) $globalline{loopfooter} = []; $globalline{total}= $grantotal; # FIXME: useless -- 2.34.1
RankPatronTotal[% loopco.coltitle | html %][% loopco.coltitle | html %]
Patron Checkout count
[% ELSE %][% END %] [% loopro.rowtitle | html %][% ELSE %][% END %] + [% IF ( loopro.reference ) %][% END %] + [% IF ( loopro.patron ) %][% loopro.patron | html %][% END %] + [% IF ( loopro.reference ) %][% END %] + [% ELSE %][% END %] - [% IF ( loopcel.reference ) %][% END %] - [% IF ( loopcel.value ) %][% loopcel.value | html %][% END %] - [% IF ( loopcel.reference ) %][% END %] - [% ELSE %][% END %] [% IF ( loopcel.count ) %][% loopcel.count | html %][% END %]