Bugzilla – Attachment 47506 Details for
Bug 15206
Show patron's age when filling date of birth in memberentry.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 15206 - Make CalculateAge a reusable function
SIGNED-OFF-Bug-15206---Make-CalculateAge-a-reusabl.patch (text/plain), 4.74 KB, created by
Owen Leonard
on 2016-02-01 13:36:40 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 15206 - Make CalculateAge a reusable function
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2016-02-01 13:36:40 UTC
Size:
4.74 KB
patch
obsolete
>From b14de373f480f7adab2a74061bc5ff54061f03ab Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Tue, 26 Jan 2016 10:45:46 +0100 >Subject: [PATCH] [SIGNED-OFF] Bug 15206 - Make CalculateAge a reusable > function >Content-Type: text/plain; charset="utf-8" > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > koha-tmpl/intranet-tmpl/prog/en/js/members.js | 53 +++++----------------- > .../prog/en/modules/members/memberentrygen.tt | 30 +++++++++++- > 2 files changed, 39 insertions(+), 44 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/members.js b/koha-tmpl/intranet-tmpl/prog/en/js/members.js >index 10fc154..2f712cf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/members.js >@@ -147,56 +147,25 @@ function Dopopguarantor(link) { > var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top'); > } > >-function CalculateAge() { >- var hint = $("#dateofbirth").siblings(".hint").first(); >- hint.html(dateformat); >- >- if (dformat == 'metric' && false === CheckDate(document.form.dateofbirth)) { >- return; >- } >- >- if (!$("#dateofbirth").datepicker( 'getDate' )) { >- return; >- } >- >+function CalculateAge(dateofbirth) { > var today = new Date(); >- var dob = new Date($("#dateofbirth").datepicker( 'getDate' )); >- >- var nowyear = today.getFullYear(); >- var nowmonth = today.getMonth(); >- var nowday = today.getDate(); >+ var dob = Date_from_syspref(dateofbirth) >+ var age = new Object(); > >- var birthyear = dob.getFullYear(); >- var birthmonth = dob.getMonth(); >- var birthday = dob.getDate(); >- >- var year = nowyear - birthyear; >- var month = nowmonth - birthmonth; >- var day = nowday - birthday; >+ age.year = today.getFullYear() - dob.getFullYear(); >+ age.month = today.getMonth() - dob.getMonth(); >+ var day = today.getDate() - dob.getDate(); > > if(day < 0) { >- month = parseInt(month) -1; >- } >- >- if(month < 0) { >- year = parseInt(year) -1; >- month = 12 + month; >+ age.month = parseInt(age.month) -1; > } > >- var age_string; >- if (year || month) { >- age_string = _('Age: '); >- } >- if (year) { >- age_string += _(year > 1 ? '%s years ' : '%s year ').format(year); >+ if(age.month < 0) { >+ age.year = parseInt(age.year) -1; >+ age.month = 12 + age.month; > } > >- if (month) { >- age_string += _(month > 1 ? '%s months ' : '%s month ').format(month); >- } >- >- hint.html(age_string); >- >+ return age; > } > > $(document).ready(function(){ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 0210613..c02379d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -35,7 +35,7 @@ > [% END %] > $("#dateofbirth").datepicker({ maxDate: "-1D", yearRange: "c-120:" }); > dateformat = $("#dateofbirth").siblings(".hint").first().html(); >- CalculateAge(); >+ write_age(); > $("#entryform").validate({ > rules: { > email: { >@@ -147,6 +147,32 @@ > return 0; > } > >+ function write_age() { >+ var hint = $("#dateofbirth").siblings(".hint").first(); >+ hint.html(dateformat); >+ >+ var age = CalculateAge(document.form.dateofbirth.value); >+ >+ if (!age.year && !age.month) { >+ return; >+ } >+ >+ var age_string; >+ if (age.year || age.month) { >+ age_string = _('Age: '); >+ } >+ >+ if (age.year) { >+ age_string += _(age.year > 1 ? '%s years ' : '%s year ').format(age.year); >+ } >+ >+ if (age.month) { >+ age_string += _(age.month > 1 ? '%s months ' : '%s month ').format(age.month); >+ } >+ >+ hint.html(age_string); >+ } >+ > var MSG_SEPARATOR = _("Separator must be / in field %s"); > var MSG_INCORRECT_DAY = _("Invalid day entered in field %s"); > var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s"); >@@ -343,7 +369,7 @@ > [% END %] > Date of birth: </label> > >- <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CalculateAge();" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" /> >+ <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="write_age();" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" /> > > [% IF ( mandatorydateofbirth ) %]<span class="required">Required</span>[% END %] > [% IF ( ERROR_dateofbirth ) %]<span class="required">(Error)</span>[% END %] >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15206
:
44953
|
44978
|
45579
|
45580
|
45581
|
45589
|
45590
|
45591
|
45592
|
45593
|
45597
|
45598
|
45599
|
45600
|
45601
|
46228
|
46245
|
46396
|
47301
|
47505
|
47506
|
47540
|
47541
|
47542
|
49032
|
49033
|
49034