From 9f0096cf8eb17df1ec2a02c485c1c6e70eba08c5 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Sat, 13 Jan 2024 21:18:55 +0000 Subject: [PATCH] Bug 33452: Improve display of applied filters and results table This makes various improvements on the display of the results: * Filters didn't display the value that was filtered on * Filter labels were not translatable * Results table showed line/column using untranslatable codes * Results table showed library and patron category codes instead of descriptions To test: * Use the various filters in the form * Use various combinations of row/column * Verify it all works as expected and display is much improved Note: * In the filters, the code for extended patron attributs will be used as label. * In the results table only patron category codes and library codes translate to descriptions. Other values from pull downs haven't been implemented yet. --- .../en/modules/reports/borrowers_stats.tt | 69 ++++++++++++++++--- reports/borrowers_stats.pl | 32 +++++---- 2 files changed, 78 insertions(+), 23 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt index c3be44acf9..009f904e2a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt @@ -1,5 +1,8 @@ [% USE raw %] +[% USE KohaDates %] +[% USE Categories %] [% USE Branches %] +[% USE AuthorisedValues %] [% USE Koha %] [% USE Asset %] [% PROCESS 'i18n.inc' %] @@ -53,18 +56,68 @@

Patrons statistics

[% IF ( do_it ) %] [% FOREACH mainloo IN mainloop %] - [% IF ( mainloo.loopfilter.size>0 ) %] + [% IF ( mainloo.loopfilter.size > 0 ) %]

Filtered on:

- [% FOREACH loopfilte IN mainloo.loopfilter %] -

- [% loopfilte.crit | html %] = [% loopfilte.filter | html %] -

+ [% END %]
- + [%- BLOCK row_column -%] + [%- SWITCH code -%] + [%- CASE 'categorycode' -%]Patron category + [%- CASE 'zipcode' -%]ZIP/Postal code + [%- CASE 'branchcode' -%]Library + [%- CASE 'sex' -%]Gender + [%- CASE 'sort1' -%]Sort 1 + [%- CASE 'sort2' -%]Sort 2 + [%- CASE -%][% code | html %] + [%- END -%] + [%- END -%] + [% FOREACH loopco IN mainloo.loopcol %] diff --git a/reports/borrowers_stats.pl b/reports/borrowers_stats.pl index 4e0f645999..b7136b874e 100755 --- a/reports/borrowers_stats.pl +++ b/reports/borrowers_stats.pl @@ -181,34 +181,35 @@ sub calculate { else { $colfilter = ''; } my @loopfilter; - foreach my $i (0 .. scalar @$filters) { - my %cell; + foreach my $i ( 0 .. scalar @$filters ) { if ( @$filters[$i] ) { - if ( $i == 0) { $cell{crit} = "Cat code"; } - elsif ( $i == 1 ) { $cell{crit} = "ZIP/Postal 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"; } + my %cell = ( filter => @$filters[$i] ); + if ( $i == 0 ) { $cell{crit} = "category"; } + elsif ( $i == 1 ) { $cell{crit} = "zip"; } + elsif ( $i == 2 ) { $cell{crit} = "library"; } + elsif ( $i == 3 ) { $cell{crit} = "dob_from"; } + elsif ( $i == 4 ) { $cell{crit} = "dob_to"; } + elsif ( $i == 5 ) { $cell{crit} = "gender"; } + elsif ( $i == 6 ) { $cell{crit} = "sort1"; } + elsif ( $i == 7 ) { $cell{crit} = "sort2"; } + else { $cell{crit} = "unknown"; } push @loopfilter, \%cell; } } + foreach my $type (keys %$attr_filters) { if($attr_filters->{$type}) { push @loopfilter, { - crit => "Attribute $type", + crit => "attribute_$type", filter => $attr_filters->{$type} } } } my @branchcodes = Koha::Libraries->search->get_column('branchcode'); - ($status ) and push @loopfilter,{crit=>"Status", filter=>$status }; - ($activity) and push @loopfilter,{crit=>"Activity",filter=>$activity}; + ($status) and push @loopfilter, { crit => "status", filter => $status }; + ($activity) and push @loopfilter, { crit => "activity", filter => $activity }; # year of activity my ( $period_year, $period_month, $period_day )=Add_Delta_YM( Today(),-$period, 0); my $newperioddate=$period_year."-".$period_month."-".$period_day; @@ -254,6 +255,7 @@ sub calculate { if ($celvalue) { $cell{rowtitle} = $celvalue; $cell{rowtitle_display} = ($patron_categories->find($celvalue)->description || "$celvalue\*") if ($line eq 'categorycode'); + $cell{rowtitle_display} = (Koha::Libraries->find($celvalue)->branchname || "$celvalue\*") if ($line eq 'branchcode'); } $cell{totalrow} = 0; push @loopline, \%cell; @@ -299,8 +301,8 @@ sub calculate { my %cell; if (defined $celvalue) { $cell{coltitle} = $celvalue; - # $cell{coltitle_display} = ($colfield eq 'branchcode') ? $branches->{$celvalue}->{branchname} : $celvalue; $cell{coltitle_display} = $patron_categories->find($celvalue)->description if ($column eq 'categorycode'); + $cell{coltitle_display} = (Koha::Libraries->find($celvalue)->branchname || "$celvalue\*") if ($column eq 'branchcode'); } push @loopcol, \%cell; } -- 2.30.2
[% mainloo.line | html %] / [% mainloo.column | html %][%- PROCESS row_column code=mainloo.line -%] / [%- PROCESS row_column code=mainloo.column -%] [% IF ( loopco.coltitle_display ) %][% loopco.coltitle_display | html %][% ELSE %][% loopco.coltitle | html %][% END %] @@ -207,7 +260,7 @@ - + [% INCLUDE 'date-format.inc' %] @@ -235,7 +288,7 @@