Bug 15400: Display date of birth and age more consistantly
authorJosef Moravec <josef.moravec@gmail.com>
Fri, 2 Nov 2018 08:13:35 +0000 (08:13 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 29 Jun 2020 10:37:02 +0000 (12:37 +0200)
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 <aleishaamohia@hotmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

C4/Utils/DataTables/Members.pm
koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
koha-tmpl/intranet-tmpl/prog/en/includes/circ-patron-search-results.inc
koha-tmpl/intranet-tmpl/prog/en/includes/patron-age.inc [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt
members/moremember.pl

index 580a3ea..a718a96 100644 (file)
@@ -214,6 +214,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);
index 5e020f1..948a95c 100644 (file)
                 <li class="email"> <a href="mailto:[% patron.emailpro | url %]" title="[% patron.emailpro | html %]">[% patron.emailpro | html %]</a></li>
             [% END %]
         [% END %]
+        [% IF ( patron.dateofbirth ) %]
+            <li>
+                <span class="label">Date of birth:</span>
+                [% INCLUDE 'patron-age.inc' %]
+            </li>
+        [% END %]
 
         [% UNLESS ( patron.address or patron.address2 ) %]
             <li><span class="empty" id="noaddressstored">No address stored.</span></li>
         [% UNLESS ( patron.email or patron.emailpro) %]
             <li> <span class="empty">No email stored.</span></li>
         [% END %]
+        [% UNLESS ( patron.dateofbirth ) %]
+            <li> <span class="empty">No date of birth stored.</span></li>
+        [% END %]
+
     [% END %]
 
     [% IF Koha.Preference('ExtendedPatronAttributes') %]
index 50821d1..0c31cbf 100644 (file)
@@ -26,7 +26,7 @@
                     <td><a href="[% data_url | url %]">[% borrower.surname | html %], [% borrower.firstname | html %]</a></td>
             [% END %]
                 <td>[% borrower.cardnumber | html %]</td>
-                <td>[% borrower.dateofbirth | $KohaDates %]</td>
+                <td>[% INCLUDE 'patron-age.inc' patron = borrower %]</td>
                 <td>[% Categories.GetName( borrower.categorycode ) | html %]</td>
                 <td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
                 <td>[% borrower.address | html %]</td>
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 (file)
index 0000000..c89382b
--- /dev/null
@@ -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 -%]
index 0757ae7..b4351f4 100644 (file)
                                             [% IF ( patron.dateofbirth ) %]
                                                 <li>
                                                     <span class="label">Date of birth:</span>
-                                                    [% patron.dateofbirth | $KohaDates %] ([% patron.get_age | html %] years)
+                                                    [% INCLUDE 'patron-age.inc' %]
                                                 </li>
                                             [% END %]
                                             [% IF ( patron.sex ) %]
index a82f0e8..38ec5aa 100644 (file)
@@ -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":
index ae6364d..6bfeb08 100644 (file)
@@ -19,7 +19,7 @@
                 "dt_name":
                     "<a href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=[% data.borrowernumber | html %]\" class=\"patron_preview\" data-borrowernumber=\"[% data.borrowernumber | html %]\" style='white-space:nowrap'>[% INCLUDE 'patron-title.inc' borrowernumber = data.borrowernumber category_type = data.category_type firstname = data.firstname surname = data.surname othernames = data.othernames invert_name = 1 | $To %]</a><br />[% INCLUDE escape_address data = data %][% IF data.email %]<br/>Email: <a href='mailto:[% data.email | html | $To %]'>[% data.email | html | $To %]</a>[% END %]",
     "dt_dateofbirth":
-        "[% data.dateofbirth | $KohaDates %]",
+        "[% INCLUDE 'patron-age.inc' patron = data %]",
                 "dt_category":
                     "[% data.category_description | html | $To %] ([% data.category_type | html | $To %])",
                 "dt_branch":
index 656ee35..93efa7a 100755 (executable)
@@ -122,7 +122,6 @@ if ( !$patron->is_valid_age ) {
     $template->param( age_low => $patron->category->dateofbirthrequired );
     $template->param( age_high => $patron->category->upperagelimit );
 }
-$template->param( age => $patron->get_age );
 
 # Generate CSRF token for upload and delete image buttons
 $template->param(