From ea147ed292d9d57724b30d0c743c7c78db9ae2ab Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Fri, 2 Nov 2018 08:13:35 +0000 Subject: [PATCH] Bug 15400: Display date of birth and age more consistantly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test plan: 0) Apply the patch 1) Go to all of these pages Patron detail Other patron pages - look on the left side (circ-menu) Patron search Guarantor search ( go to child patron -> edit -> in guarantor section click "Set to patron" Search through "Check out" (in the header) 2) Confirm that does show date of birth and date consistantly, try it on patrons with and without date of birth set to find possible reggressions Signed-off-by: Aleisha Amohia Signed-off-by: Kyle M Hall Signed-off-by: Séverine QUEUNE --- C4/Utils/DataTables/Members.pm | 1 + koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc | 10 ++++++++++ .../prog/en/includes/circ-patron-search-results.inc | 2 +- koha-tmpl/intranet-tmpl/prog/en/includes/patron-age.inc | 8 ++++++++ koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt | 2 +- .../prog/en/modules/members/tables/guarantor_search.tt | 2 +- .../prog/en/modules/members/tables/members_results.tt | 2 +- members/moremember.pl | 5 ----- 8 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/patron-age.inc diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm index caf7a92152..f86f93d2d0 100644 --- a/C4/Utils/DataTables/Members.pm +++ b/C4/Utils/DataTables/Members.pm @@ -180,6 +180,7 @@ sub search { my $patron_object = Koha::Patrons->find( $patron->{borrowernumber} ); $patron->{overdues} = $patron_object->get_overdues->count; $patron->{issues} = $patron_object->checkouts->count; + $patron->{age} = $patron_object->get_age; my $balance = $patron_object->account->balance; # FIXME Should be formatted from the template $patron->{fines} = sprintf("%.2f", $balance); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc index a79a55f38f..e120610f89 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -53,6 +53,12 @@ [% END %] [% END %] + [% IF ( patron.dateofbirth ) %] +
  • + Date of birth: + [% INCLUDE 'patron-age.inc' %] +
  • + [% END %] [% UNLESS ( patron.address or patron.address2 ) %]
  • No address stored.
  • @@ -66,6 +72,10 @@ [% UNLESS ( patron.email or patron.emailpro) %]
  • No email stored.
  • [% END %] + [% UNLESS ( patron.dateofbirth ) %] +
  • No date of birth stored.
  • + [% END %] + [% END %] [% IF Koha.Preference('ExtendedPatronAttributes') %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-patron-search-results.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-patron-search-results.inc index 8b34bd6c59..815ee16258 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-patron-search-results.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-patron-search-results.inc @@ -27,7 +27,7 @@ [% borrower.surname | html %], [% borrower.firstname | html %] [% END %] [% borrower.cardnumber | html %] - [% borrower.dateofbirth | $KohaDates %] + [% INCLUDE 'patron-age.inc' patron = borrower %] [% Categories.GetName( borrower.categorycode ) | html %] [% Branches.GetName( borrower.branchcode ) | html %] [% borrower.address | html %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-age.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-age.inc new file mode 100644 index 0000000000..c89382b641 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-age.inc @@ -0,0 +1,8 @@ +[%- USE KohaDates -%] +[%- IF ( patron ) -%] + [%- IF ( patron.dateofbirth ) -%] + [% patron.dateofbirth | $KohaDates -%] + [%- IF ( patron.get_age ) %] ([% patron.get_age | html %] years) + [%- ELSIF ( patron.age ) %] ([% patron.age | html %] years)[% END -%] + [%- END -%] +[%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index fc93db3b45..25a47eb23b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -232,7 +232,7 @@ [% IF ( patron.dateofbirth ) %]
  • Date of birth: - [% patron.dateofbirth | $KohaDates %] ([% age | html %] years) + [% INCLUDE 'patron-age.inc' %]
  • [% END %] [% IF ( patron.sex ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt index a82f0e8dcb..38ec5aa9e0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt @@ -14,7 +14,7 @@ "dt_name": "[% INCLUDE 'patron-title.inc' borrowernumber = data.borrowernumber category_type = data.category_type firstname = data.firstname surname = data.surname othernames = data.othernames cardnumber = data.cardnumber invert_name = 1%]", "dt_dateofbirth": - "[% data.dateofbirth | $KohaDates %]", + "[% INCLUDE 'patron-age.inc' patron = data %]", "dt_address": "[% INCLUDE escape_address data=data %]", "dt_action": diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt index 607146e269..352559a526 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt @@ -19,7 +19,7 @@ "dt_name": "[% INCLUDE 'patron-title.inc' borrowernumber = data.borrowernumber category_type = data.category_type firstname = To.json(data.firstname) surname = To.json(data.surname) othernames = To.json(data.othernames) invert_name = 1 %]
    [% INCLUDE escape_address data = data %][% IF data.email %]
    Email: [% data.email | html %][% END %]", "dt_dateofbirth": - "[% data.dateofbirth | $KohaDates %]", + "[% INCLUDE 'patron-age.inc' patron = data %]", "dt_category": "[% data.category_description | html %] ([% data.category_type | html %])", "dt_branch": diff --git a/members/moremember.pl b/members/moremember.pl index be365a3c06..25e19d54de 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -223,11 +223,6 @@ $today->truncate(to => 'day'); my $overdues_exist = 0; my $totalprice = 0; -# Calculate and display patron's age -if ( $data->{dateofbirth} ) { - $template->param( age => Koha::Patron->new({ dateofbirth => $data->{dateofbirth} })->get_age ); -} - ### ############################################################################### # BUILD HTML # show all reserves of this borrower, and the position of the reservation .... -- 2.11.0