From e083f7ae534a5ba3b1796210eb5205f8e01c83e0 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 17 Jul 2025 13:12:34 +0000 Subject: [PATCH] Bug 40287: Fix untranslatable strings in more statistics wizards This patch makes some updates to the acquisitions, patrons, and catalog statistics wizards in order to make more information translatable. To test apply the patch and go to Reports. - Under "Statistics wizards," test the acquisitions, patrons, circulation, and catalog statistics reports: - Test setting some or all options in the "Filter column" and running the report. - At the top of the results there should be a list of the filter options you selected and their values. - All the filter labels should be correct, and the filter values should be in their full/description form rather than in code form (e.g. library, item type, collection code, sorting field, etc.) Sponsored-by: Athens County Public Libraries Signed-off-by: David Nind Signed-off-by: Jonathan Druart --- .../en/modules/reports/acquisitions_stats.tt | 81 ++++++++++-------- .../en/modules/reports/borrowers_stats.tt | 82 +++++++++++++++++-- .../en/modules/reports/catalogue_stats.tt | 50 ++++++++++- .../prog/en/modules/reports/issues_stats.tt | 9 +- reports/borrowers_stats.pl | 21 +++-- reports/issues_stats.pl | 14 +++- 6 files changed, 200 insertions(+), 57 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt index c7a796ed286..c53eabaed6f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt @@ -1,5 +1,9 @@ [% USE raw %] [% USE Koha %] +[% USE Branches %] +[% USE ItemTypes %] +[% USE KohaDates %] +[% USE AuthorisedValues %] [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] @@ -46,38 +50,51 @@ [% IF ( do_it ) %] [% FOREACH mainloo IN mainloop %] [% IF ( mainloo.loopfilter.size ) %] -

Filtered on:

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

- [% SWITCH loopfilte.crit %] - [% CASE '0' %] - Placed on (from) - [% CASE '1' %] - Placed on (to) - [% CASE '2' %] - Received on (from) - [% CASE '3' %] - Received on (to) - [% CASE '4' %] - Vendor - [% CASE '5' %] - Home library - [% CASE '6' %] - Collection - [% CASE '7' %] - Item type - [% CASE '8' %] - Fund - [% CASE '9' %] - Sort1 - [% CASE '10' %] - Sort2 - [% CASE %] - Unknown filter - [% END %] - : [% loopfilte.filter | html %] -

- [% END %] +

Filtered on:

+
    + [% FOREACH loopfilte IN mainloo.loopfilter %] +
  • + [% SWITCH loopfilte.crit %] + [% CASE '0' %] + Placed on (from): + [% loopfilte.filter | $KohaDates %] + [% CASE '1' %] + Placed on (to): + [% loopfilte.filter | $KohaDates %] + [% CASE '2' %] + Received on (from): + [% loopfilte.filter | html %] + [% CASE '3' %] + Received on (to): + [% loopfilte.filter | html %] + [% CASE '4' %] + Vendor: + [% loopfilte.filter | html %] + [% CASE '5' %] + Home library: + [% Branches.GetName( loopfilte.filter ) | html %] + [% CASE '6' %] + Collection: + [% AuthorisedValues.GetByCode( 'CCODE', loopfilte.filter ) | html %] + [% CASE '7' %] + Item type: + [% ItemTypes.GetDescription( loopfilte.filter ) | html %] + [% CASE '8' %] + Fund: + [% loopfilte.filter | html %] + [% CASE '9' %] + Sort1: + [% loopfilte.filter | html %] + [% CASE '10' %] + Sort2: + [% loopfilte.filter | html %] + [% CASE %] + Unknown filter: + [% loopfilte.filter | html %] + [% END %] +
  • + [% END %] +
[% END %]
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 26338d50f67..1c9f4f4e973 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 @@ -2,6 +2,10 @@ [% USE Branches %] [% USE Koha %] [% USE Asset %] +[% USE Categories %] +[% USE KohaDates %] +[% USE AuthorisedValues %] +[% USE ExtendedAttributeTypes %] [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] @@ -56,11 +60,75 @@

Patrons statistics

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

Filtered on:

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

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

- [% END %] + [% IF ( mainloo.loopfilter.size > 0 ) %] +

Filtered on:

+
    + [% FOREACH loopfilte IN mainloo.loopfilter %] +
  • + [% SWITCH loopfilte.crit %] + [% CASE 'Cat code' %] + Patron category: + [% Categories.GetName( loopfilte.filter ) | html %] + [% CASE 'ZIP/Postal code' %] + ZIP/Postal code: + [% loopfilte.filter | html %] + [% CASE 'Branch code' %] + Library: + [% Branches.GetName( loopfilte.filter ) | html %] + [% CASE 'Date of birth1' %] + Date of birth > + [% loopfilte.filter | html %] + [% CASE 'Date of birth2' %] + Date of birth < + [% loopfilte.filter | html %] + [% CASE 'Sex' %] + Gender: + [% SWITCH ( loopfilte.filter ) %] + [% CASE 'F' %] + Female + [% CASE 'M' %] + Male + [% CASE 'O' %] + Other + [% CASE %] + None specified + [% END %] + [% CASE 'Sort1' %] + Patron sort1: [% AuthorisedValues.GetByCode('Bsort1', loopfilte.filter ) | html %] + [% CASE 'Sort2' %] + Patron sort2: [% AuthorisedValues.GetByCode('Bsort2', loopfilte.filter ) | html %] + [% CASE 'Status' %] + Status: + [% SWITCH loopfilte.filter %] + [% CASE 'debarred' %] + Restricted + [% CASE 'gonenoaddress' %] + Gone no address + [% CASE 'lost' %] + Lost card + [% CASE %] + [% loopfilte.filter | html %] + [% END %] + [% CASE 'Activity' %] + Activity: + [% SWITCH loopfilte.filter %] + [% CASE 'active' %] + Active + [% CASE 'nonactive' %] + Inactive + [% CASE %] + [% loopfilte.filter | html %] + [% END %] + [% CASE "PA_CLASS" %] + [% loopfilte.label | html %]: + [% loopfilte.filter | html %] + [% CASE %] + [% loopfilte.crit | html %]: + [% loopfilte.filter | html %] + [% END %] +
  • + [% END %] +
[% END %]
@@ -227,7 +295,7 @@ @@ -244,7 +312,7 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt index d22f295e739..7ba47569aed 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt @@ -1,6 +1,8 @@ [% USE raw %] [% USE Koha %] [% USE Branches %] +[% USE ItemTypes %] +[% USE AuthorisedValues %] [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] @@ -46,12 +48,52 @@

Catalog statistics

[% IF ( do_it ) %] [% FOREACH mainloo IN mainloop %] - [% IF ( mainloo.loopfilter ) %] -

Filtered on:

+

Filtered on:

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

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

    +
  • + [% SWITCH loopfilte.crit %] + [% CASE "Item CallNumber From" %] + Item call number from: [% loopfilte.filter | html %] + [% CASE "Item CallNumber To" %] + Item call number to: [% loopfilte.filter | html %] + [% CASE "Item type" %] + Item type: [% ItemTypes.GetDescription( loopfilte.filter ) | html %] + [% CASE "Publisher" %] + Publisher: [% loopfilte.filter | html %] + [% CASE "Publication year From" %] + Publication year from: [% loopfilte.filter | html %] + [% CASE "Publication year To" %] + Publication year to: [% loopfilte.filter | html %] + [% CASE "Library" %] + Library: [% Branches.GetName( loopfilte.filter ) | html %] + [% CASE "Shelving Location" %] + Location: [% AuthorisedValues.GetByCode( 'LOC', loopfilte.filter ) | html %] + [% CASE "Collection Code" %] + Collection: [% AuthorisedValues.GetByCode( 'CCODE', loopfilte.filter ) | html %] + [% CASE "Status" %] + Not for loan: [% AuthorisedValues.GetByCode( 'NOT_LOAN', loopfilte.filter ) | html %] + [% CASE "Materials" %] + Materials specified: [% loopfilte.filter | html %] + [% CASE "Barcode (not like)" %] + Barcode (not like): [% loopfilte.filter | html %] + [% CASE "Barcode (like)" %] + Barcode (like): [% loopfilte.filter | html %] + [% CASE "Date acquired (item) from" %] + Date acquired (item) from: [% loopfilte.filter | html %] + [% CASE "Date acquired (item) to" %] + Date acquired (item) to: [% loopfilte.filter | html %] + [% CASE "Date deleted (item) from" %] + Date deleted (item) from: [% loopfilte.filter | html %] + [% CASE "Date deleted (item) to" %] + Date deleted (item) to: [% loopfilte.filter | html %] + [% CASE %] + [% loopfilte.crit | html %]: + [% loopfilte.filter | html %] + [% END %] +
  • [% END %] - [% END %] +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt index 0b2de47820b..9267a8dbff5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt @@ -3,7 +3,9 @@ [% USE Branches %] [% USE Categories %] [% USE ItemTypes %] +[% USE KohaDates %] [% USE AuthorisedValues %] +[% USE ExtendedAttributeTypes %] [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] @@ -55,7 +57,7 @@ [% IF ( do_it ) %] [% FOREACH mainloo IN mainloop %] [% IF ( mainloo.loopfilter ) %] -

Filtered on:

+

Filtered on:

    [% FOREACH loopfilte IN mainloo.loopfilter %] [% SET li_class = '' %] @@ -127,8 +129,11 @@ [% CASE "4" %] Hour [% END %] + [% CASE "PA_CLASS" %] + [% loopfilte.label | html %]: + [% loopfilte.filter | html %] [% CASE %] - [% loopfilte.crit | html %]: + [% loopfilte.crit | html %]: [% loopfilte.filter | html %] [% END %] diff --git a/reports/borrowers_stats.pl b/reports/borrowers_stats.pl index b8a237042ab..fc9ac9e46be 100755 --- a/reports/borrowers_stats.pl +++ b/reports/borrowers_stats.pl @@ -193,22 +193,25 @@ sub calculate { foreach my $i ( 0 .. scalar @$filters ) { my %cell; if ( @$filters[$i] ) { - if ( $i == 0 ) { $cell{crit} = "Cat code"; $cell{filter} = @$filters[$i]; } - elsif ( $i == 1 ) { $cell{crit} = "ZIP/Postal code"; $cell{filter} = @$filters[$i]; } - elsif ( $i == 2 ) { $cell{crit} = "Branch code"; $cell{filter} = @$filters[$i]; } - elsif ( $i == 3 || $i == 4 ) { $cell{crit} = "Date of birth"; $cell{filter} = @$filters[$i]; } - elsif ( $i == 5 ) { $cell{crit} = "Sex"; $cell{filter} = @$filters[$i]; } - elsif ( $i == 6 ) { $cell{crit} = "Sort1"; $cell{filter} = @$filters[$i]; } - elsif ( $i == 7 ) { $cell{crit} = "Sort2"; $cell{filter} = @$filters[$i]; } - else { $cell{crit} = "Unknown"; } + if ( $i == 0 ) { $cell{crit} = "Cat code"; $cell{filter} = @$filters[$i]; } + elsif ( $i == 1 ) { $cell{crit} = "ZIP/Postal code"; $cell{filter} = @$filters[$i]; } + elsif ( $i == 2 ) { $cell{crit} = "Branch code"; $cell{filter} = @$filters[$i]; } + elsif ( $i == 3 ) { $cell{crit} = "Date of birth1"; $cell{filter} = @$filters[$i]; } + elsif ( $i == 4 ) { $cell{crit} = "Date of birth2"; $cell{filter} = @$filters[$i]; } + elsif ( $i == 5 ) { $cell{crit} = "Sex"; $cell{filter} = @$filters[$i]; } + elsif ( $i == 6 ) { $cell{crit} = "Sort1"; $cell{filter} = @$filters[$i]; } + elsif ( $i == 7 ) { $cell{crit} = "Sort2"; $cell{filter} = @$filters[$i]; } + else { $cell{crit} = "Unknown"; } push @loopfilter, \%cell; } } foreach my $type ( keys %$attr_filters ) { if ( $attr_filters->{$type} ) { + my $patron_attribute_type = Koha::Patron::Attribute::Types->find($type); push @loopfilter, { - crit => "Attribute $type", + crit => "PA_CLASS", + label => $patron_attribute_type->description, filter => $attr_filters->{$type} }; } diff --git a/reports/issues_stats.pl b/reports/issues_stats.pl index 81517b767f3..9439eb8aedb 100755 --- a/reports/issues_stats.pl +++ b/reports/issues_stats.pl @@ -230,10 +230,18 @@ sub calculate { push @loopfilter, \%cell; } - foreach ( keys %$attribute_filters ) { - next unless $attribute_filters->{$_}; - push @loopfilter, { crit => "$_ =", filter => $attribute_filters->{$_} }; + + foreach my $type ( keys %$attribute_filters ) { + if ( $attribute_filters->{$type} ) { + my $patron_attribute_type = Koha::Patron::Attribute::Types->find($type); + push @loopfilter, { + crit => "PA_CLASS", + label => $patron_attribute_type->description, + filter => $attribute_filters->{$type} + }; + } } + push @loopfilter, { crit => "Event", filter => $type }; push @loopfilter, { crit => "Display by", filter => $dsp } if ($dsp); push @loopfilter, { crit => "Select Day", filter => $daysel } if ($daysel); -- 2.43.0