Bugzilla – Attachment 47540 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]
Bug 15206 - Show patron's age under date of birth in memberentry.pl
Bug-15206---Show-patrons-age-under-date-of-birth-i.patch (text/plain), 4.14 KB, created by
Jonathan Druart
on 2016-02-02 10:24:45 UTC
(
hide
)
Description:
Bug 15206 - Show patron's age under date of birth in memberentry.pl
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-02-02 10:24:45 UTC
Size:
4.14 KB
patch
obsolete
>From 3825baa26dc74ebbcb0b1add11abb2e488c6332f Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Mon, 4 Jan 2016 14:49:04 +0100 >Subject: [PATCH] Bug 15206 - Show patron's age under date of birth in > memberentry.pl > >Test plan: > >Create or edit a patron (members/memberentry.pl), enter a date of birth >(for a new patron), patron'a age should be shown under > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > koha-tmpl/intranet-tmpl/prog/en/js/members.js | 52 ++++++++++++++++++++++ > .../prog/en/modules/members/memberentrygen.tt | 10 ++--- > 2 files changed, 55 insertions(+), 7 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/members.js b/koha-tmpl/intranet-tmpl/prog/en/js/members.js >index 75e230b..10fc154 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/members.js >@@ -147,6 +147,58 @@ 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; >+ } >+ >+ var today = new Date(); >+ var dob = new Date($("#dateofbirth").datepicker( 'getDate' )); >+ >+ var nowyear = today.getFullYear(); >+ var nowmonth = today.getMonth(); >+ var nowday = today.getDate(); >+ >+ var birthyear = dob.getFullYear(); >+ var birthmonth = dob.getMonth(); >+ var birthday = dob.getDate(); >+ >+ var year = nowyear - birthyear; >+ var month = nowmonth - birthmonth; >+ var day = nowday - birthday; >+ >+ if(day < 0) { >+ month = parseInt(month) -1; >+ } >+ >+ if(month < 0) { >+ year = parseInt(year) -1; >+ month = 12 + month; >+ } >+ >+ var age_string; >+ if (year || month) { >+ age_string = _('Age: '); >+ } >+ if (year) { >+ age_string += _(year > 1 ? '%s years ' : '%s year ').format(year); >+ } >+ >+ if (month) { >+ age_string += _(month > 1 ? '%s months ' : '%s month ').format(month); >+ } >+ >+ hint.html(age_string); >+ >+} >+ > $(document).ready(function(){ > if($("#yesdebarred").is(":checked")){ > $("#debarreduntil").show(); >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 d66357f..0210613 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -34,6 +34,8 @@ > } > [% END %] > $("#dateofbirth").datepicker({ maxDate: "-1D", yearRange: "c-120:" }); >+ dateformat = $("#dateofbirth").siblings(".hint").first().html(); >+ CalculateAge(); > $("#entryform").validate({ > rules: { > email: { >@@ -145,8 +147,6 @@ > return 0; > } > >- >- > 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,11 +343,7 @@ > [% END %] > Date of birth: </label> > >- [% IF ( dateformat == "metric" ) %] >- <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CheckDate(document.form.dateofbirth);" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" /> >- [% ELSE %] >- <input type="text" id="dateofbirth" name="dateofbirth" size="20" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" /> >- [% END %] >+ <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CalculateAge();" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" /> > > [% IF ( mandatorydateofbirth ) %]<span class="required">Required</span>[% END %] > [% IF ( ERROR_dateofbirth ) %]<span class="required">(Error)</span>[% END %] >-- >2.1.0
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