From 64fd6936b1895c3b4f03baf5754761a81f76eb5a 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 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 --- 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 1e3f642..4fa647b 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 a16ca2b..2395be3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -44,6 +44,12 @@
  • [% patron.emailpro | html %]
  • [% END %] [% END %] + [% IF ( patron.dateofbirth ) %] +
  • + Date of birth: + [% INCLUDE 'patron-age.inc' %] +
  • + [% END %] [% UNLESS ( patron.address or patron.address2 ) %]
  • No address stored.
  • @@ -57,6 +63,10 @@ [% UNLESS ( patron.email or patron.emailpro) %]
  • No email stored.
  • [% END %] + [% UNLESS ( patron.dateofbirth ) %] +
  • No date of birth stored.
  • + [% END %] + [% END %] [% IF ( ExtendedPatronAttributes ) %][% FOREACH extendedattribute IN extendedattributes %] 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 8e8845b..fff7f75 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 @@ -26,7 +26,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 0000000..c89382b --- /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 6e15e3c..659fd67 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -216,7 +216,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 a82f0e8..38ec5aa 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 607146e..352559a 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 9f06882..8e0ce6b 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.1.4