[Bug 15206] New: Show patron's age when filling date of birth in memberentry.pl
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Bug ID: 15206 Summary: Show patron's age when filling date of birth in memberentry.pl Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Patrons Assignee: koha-bugs@lists.koha-community.org Reporter: alex.arnaud@biblibre.com QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle.m.hall@gmail.com When creating a new patron and filling the "dateofbirth" datepicker element, a message under the element shows the patron's age. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #1 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 44953 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=44953&action=edit Bug 15206 - Show patron's age under date of birth in memberentry.pl Test plan: Create a new patron (members/memberentry.pl), enter a date of birth, patron'a age should be shown under -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |alex.arnaud@biblibre.com |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |veron@veron.ch --- Comment #2 from Marc Véron <veron@veron.ch> --- Hi Alex, I like thsi feature. I played around with a 10 year old kid. Today we have 18/11/2015 This are my results: 18/11/2005 -> Age: 10 year(s) 2 day(s) 18/11/2005 -> Age: 10 year(s) 1 day(s) 20/11/2005 -> Age: 10 year(s) 21/11/2005 -> Age: 9 year(s) 11 month(s) 30 day(s) 22/11/2005 -> Age: 9 year(s) 11 month(s) 29 day(s) There seems to be an offset of some days. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |ASSIGNED --- Comment #3 from Alex Arnaud <alex.arnaud@biblibre.com> --- (In reply to Marc Véron from comment #2)
Hi Alex, I like thsi feature.
I played around with a 10 year old kid.
Today we have 18/11/2015
This are my results: 18/11/2005 -> Age: 10 year(s) 2 day(s) 18/11/2005 -> Age: 10 year(s) 1 day(s) 20/11/2005 -> Age: 10 year(s) 21/11/2005 -> Age: 9 year(s) 11 month(s) 30 day(s) 22/11/2005 -> Age: 9 year(s) 11 month(s) 29 day(s)
There seems to be an offset of some days.
Hello Marc, Tanks for testing. Indeed there's a problem and i understand why. Patch is coming soon... -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #44953|0 |1 is obsolete| | --- Comment #4 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 44978 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=44978&action=edit Bug 15206 - Show patron's age under date of birth in memberentry.pl Test plan: Create a new patron (members/memberentry.pl), enter a date of birth, patron'a age should be shown under -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff --- Comment #5 from Alex Arnaud <alex.arnaud@biblibre.com> --- I removed the number of days because it's quite imprecise since months haven't the same number of days. If anyone can do better or knows a javascript library that can do it with more accurate feel free to tell me. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Frédéric Demians <frederic@tamil.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |frederic@tamil.fr --- Comment #6 from Frédéric Demians <frederic@tamil.fr> --- Code review: You have: function CalculateAge(dateofbirth) { Then, you don't use "dateofbirth". You have: <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CalculateAge(document.form.dateofbirth);" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" /> You rather should use jQuery: $( "#dateofbirth" ).change(CalculateAge);
From an UI point of view, it seems awkward to have displayed firstly "DD/MM/YYYY" under the Date of birth text box, and then having this info replaced by the age. This way, it's not possible to see the age without modifying the date of birth. Wouldn't it be better/simpler to display the age on the detail page (moremember.pl), rather than on the editing page (memberentry.pl)?
Have you seen that there is already a Perl function calculating age in Koha? C4::Members::GetAge(). There is a risk that your javascript code and Perl GetAge() produce a different age. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |In Discussion --- Comment #7 from Alex Arnaud <alex.arnaud@biblibre.com> --- (In reply to Frédéric Demians from comment #6)
Code review:
You have:
function CalculateAge(dateofbirth) {
Then, you don't use "dateofbirth".
You have:
<input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CalculateAge(document.form.dateofbirth);" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" />
You rather should use jQuery:
$( "#dateofbirth" ).change(CalculateAge); You are right. I forgot to remove the function parameter. Using "$("#dateofbirth").datepicker( 'getDate' )" is bettre because it gives me the correct date format
From an UI point of view, it seems awkward to have displayed firstly "DD/MM/YYYY" under the Date of birth text box, and then having this info replaced by the age. This way, it's not possible to see the age without modifying the date of birth. Wouldn't it be better/simpler to display the age on the detail page (moremember.pl), rather than on the editing page (memberentry.pl)? The main goal is to have directly the age under the datepiker while typing the date of birth. This allows librarian, for example, to change the category consequently
Have you seen that there is already a Perl function calculating age in Koha? C4::Members::GetAge(). There is a risk that your javascript code and Perl GetAge() produce a different age. So, i should make an Ajax call to a perl script to use this existing sub. But why not
-- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #8 from Frédéric Demians <frederic@tamil.fr> ---
The main goal is to have directly the age under the datepiker while typing the date of birth. This allows librarian, for example, to change the category consequently
OK. Interesting for librarian, indeed. Would be great to have it also on borrower detail page.
Have you seen that there is already a Perl function calculating age in Koha? C4::Members::GetAge(). There is a risk that your javascript code and Perl GetAge() produce a different age.
So, i should make an Ajax call to a perl script to use this existing sub. But why not
With Koha brand new REST API... Or you can alternatively do it JS but adding some tests to guaranty consistency. I even see in my crystal ball GetAge() modified to delegate to MySQL the age calculation for stability reason. For example: SELECT TIMESTAMPDIFF(YEAR,'2010-09-10',CURDATE()) -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #9 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 45579 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45579&action=edit Bug 15206 - C4::Member::GetAge returns years and months -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #10 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 45580 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45580&action=edit Bug 15206 - CalculateAge in memberentry use C4::Members::GetAge() -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #11 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 45581 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45581&action=edit Bug 15206 - Show patron's age in moremenber page near date of birth -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|In Discussion |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #12 from Alex Arnaud <alex.arnaud@biblibre.com> --- Test plan: Create a new patron (members/memberentry.pl), enter a date of birth, patron'a age should be shown under Got to a patron's detail page and check his age near date of birth. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #13 from Frédéric Demians <frederic@tamil.fr> --- Comment on attachment 45581 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45581 Bug 15206 - Show patron's age in moremenber page near date of birth Review of attachment 45581: --> (http://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=15206&attachment=45581) ----------------------------------------------------------------- ::: koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ +225,4 @@
[% IF ( emailpro ) %]<li><span class="label">Secondary email: </span><a href="mailto:[% emailpro %]">[% emailpro %]</a></li>[% END %] [% END %] [% IF ( initials ) %]<li><span class="label">Initials: </span>[% initials %]</li>[% END %] + [% IF ( dateofbirth ) %]<li><span class="label">Date of birth:</span>[% dateofbirth | $KohaDates %] ([% age %])</li>[% END %]
I don't know how to have something translatable here. ::: members/moremember.pl @@ +140,5 @@
$data->{'IS_ADULT'} = ( $data->{'categorycode'} ne 'I' );
+my @age; +my ($years, $months) = GetAge($data->{dateofbirth}); +push @age, "$years year(s)" if $years;
This line, and the next one, will not be translatable. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #14 from Frédéric Demians <frederic@tamil.fr> --- Comment on attachment 45580 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45580 Bug 15206 - CalculateAge in memberentry use C4::Members::GetAge() Review of attachment 45580: --> (http://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=15206&attachment=45580) ----------------------------------------------------------------- ::: koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ +163,5 @@
+ data: 'dateofbirth=' + year + '-' + month + '-' + day, + dataType: 'json', + success : function(json, statut){ + var age_string = "Age: "; + if (json.years) { age_string += json.years + " year(s) "; }
Translation issue here also. http://wiki.koha-community.org/wiki/Coding_Guidelines#JavaScript -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #15 from Frédéric Demians <frederic@tamil.fr> --- Otherwise, jQuery ajax call seem great :-) -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA --- Comment #16 from Owen Leonard <oleonard@myacpl.org> --- When I try setting a patron's birth date in the patron edit form I get a JavaScript error: "NetworkError: 404 Not Found - /cgi-bin/koha/svc/members/age?dateofbirth=2015-11-9" I also notice that the date I enter isn't the date which is passed in the AJAX call. With MM/DD/YYYY as my system's dateformat preference, I've tried these: Typed 01/03/1990, date passed: 1990-0-3 Typed 12/13/1970, date passed: 1970-11-13 Typed 06/09/2003, date passed: 2003-5-9 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |ASSIGNED --- Comment #17 from Alex Arnaud <alex.arnaud@biblibre.com> --- (In reply to Owen Leonard from comment #16)
When I try setting a patron's birth date in the patron edit form I get a JavaScript error:
"NetworkError: 404 Not Found - /cgi-bin/koha/svc/members/age?dateofbirth=2015-11-9" Oops. Sorry, i forgot to commit the script svc/members/age
I also notice that the date I enter isn't the date which is passed in the AJAX call. With MM/DD/YYYY as my system's dateformat preference, I've tried these:
Typed 01/03/1990, date passed: 1990-0-3 Typed 12/13/1970, date passed: 1970-11-13 Typed 06/09/2003, date passed: 2003-5-9
It's not a pbm. Months start from 0 to 11. But the result is the same. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #18 from Alex Arnaud <alex.arnaud@biblibre.com> --- (In reply to Alex Arnaud from comment #17)
(In reply to Owen Leonard from comment #16)
When I try setting a patron's birth date in the patron edit form I get a JavaScript error:
"NetworkError: 404 Not Found - /cgi-bin/koha/svc/members/age?dateofbirth=2015-11-9" Oops. Sorry, i forgot to commit the script svc/members/age
I also notice that the date I enter isn't the date which is passed in the AJAX call. With MM/DD/YYYY as my system's dateformat preference, I've tried these:
Typed 01/03/1990, date passed: 1990-0-3 Typed 12/13/1970, date passed: 1970-11-13 Typed 06/09/2003, date passed: 2003-5-9
It's not a pbm. Months start from 0 to 11. But the result is the same.
In fact you are right. Since C4::Members::GetAge() use months from 1 to 12 we have an intervall... Fix is coming -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #44978|0 |1 is obsolete| | --- Comment #19 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 45589 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45589&action=edit Bug 15206 - Show patron's age under date of birth in memberentry.pl Test plan: Create a new patron (members/memberentry.pl), enter a date of birth, patron'a age should be shown under -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #45579|0 |1 is obsolete| | --- Comment #20 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 45590 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45590&action=edit Bug 15206 - C4::Member::GetAge returns years and months -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #45580|0 |1 is obsolete| | --- Comment #21 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 45591 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45591&action=edit Bug 15206 - CalculateAge in memberentry use C4::Members::GetAge() -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #45581|0 |1 is obsolete| | --- Comment #22 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 45592 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45592&action=edit Bug 15206 - Show patron's age in moremenber page near date of birth -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #23 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 45593 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45593&action=edit Bug 15206 - Make string translatable and fix months calculation -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #45589|0 |1 is obsolete| | --- Comment #24 from Marc Véron <veron@veron.ch> --- Created attachment 45597 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45597&action=edit Bug 15206 - Show patron's age under date of birth in memberentry.pl Test plan: Create a new patron (members/memberentry.pl), enter a date of birth, patron'a age should be shown under Tested all patches together, works as expected. Signed-off-by: Marc Véron <veron@veron.ch> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #45590|0 |1 is obsolete| | --- Comment #25 from Marc Véron <veron@veron.ch> --- Created attachment 45598 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45598&action=edit Bug 15206 - C4::Member::GetAge returns years and months Tested all patches together, works as expected. Signed-off-by: Marc Véron <veron@veron.ch> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #45591|0 |1 is obsolete| | --- Comment #26 from Marc Véron <veron@veron.ch> --- Created attachment 45599 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45599&action=edit Bug 15206 - CalculateAge in memberentry use C4::Members::GetAge() Tested all patches together, works as expected. Signed-off-by: Marc Véron <veron@veron.ch> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #45592|0 |1 is obsolete| | --- Comment #27 from Marc Véron <veron@veron.ch> --- Created attachment 45600 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45600&action=edit Bug 15206 - Show patron's age in moremenber page near date of birth Tested all patches together, works as expected. Signed-off-by: Marc Véron <veron@veron.ch> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #45593|0 |1 is obsolete| | --- Comment #28 from Marc Véron <veron@veron.ch> --- Created attachment 45601 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45601&action=edit Bug 15206 - Make string translatable and fix months calculation Tested all patches together, works as expected. Signed-off-by: Marc Véron <veron@veron.ch> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org Status|Signed Off |Failed QA --- Comment #29 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Whaou, an ajax request looks like a bit overkill imo... Anyway, now it's done. Quick QA comments: 1/ catch error when retrieving the answer of the ajax request (empty .hint) 2/ CalculateAge should only be done if CheckDate return success (otherwise empty .hint) 3/ Use string_var.format(number) in JS code to display the string 4/ Why do you use gettext? pass age_month and age_year to the template and let it display/translate the string accordingly 5/ I think "year(s)" could be replaced with "year" :) And manage the plural for month/months should not be too difficult. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #30 from Frédéric Demians <frederic@tamil.fr> --- And if you could attach here a single patch rather than a sequence of patches... -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |In Discussion --- Comment #31 from Alex Arnaud <alex.arnaud@biblibre.com> --- (In reply to Jonathan Druart from comment #29)
Whaou, an ajax request looks like a bit overkill imo... Anyway, now it's done.
Quick QA comments: 1/ catch error when retrieving the answer of the ajax request (empty .hint) 2/ CalculateAge should only be done if CheckDate return success (otherwise empty .hint) right
3/ Use string_var.format(number) in JS code to display the string can you be more explicit ?
4/ Why do you use gettext? pass age_month and age_year to the template and let it display/translate the string accordingly I think it's better than use some [% if %]/[% else %] in templates that make them less readable imo. And now we have (thx Julian Maurice) Koha::I18N. Why don't use it ?
5/ I think "year(s)" could be replaced with "year" :) And manage the plural for month/months should not be too difficult. ?
-- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #32 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- (In reply to Alex Arnaud from comment #31)
3/ Use string_var.format(number) in JS code to display the string can you be more explicit ?
git grep '\.format(' will give you some examples.
4/ Why do you use gettext? pass age_month and age_year to the template and let it display/translate the string accordingly I think it's better than use some [% if %]/[% else %] in templates that make them less readable imo. And now we have (thx Julian Maurice) Koha::I18N. Why don't use it ?
You will have to test the plurial/existence of the vars in the pl, it's the same :) There is absolutely no need to use Koha::I18N here. Pass the values to the template and let it displays the strings as it wants.
5/ I think "year(s)" could be replaced with "year" :) And manage the plural for month/months should not be too difficult. ?
if months == 1 then display 'month' elsif months > 1 then display 'months' -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #33 from Frédéric Demians <frederic@tamil.fr> ---
5/ I think "year(s)" could be replaced with "year" :) And manage the plural for month/months should not be too difficult. ?
if months == 1 then display 'month' elsif months > 1 then display 'months'
If possible, it should be avoided. Some languages have more than two nouns forms (one for unit, and one for plural). See: http://www.unicode.org/cldr/charts/27/supplemental/language_plural_rules.htm... Something like that would do it: Age: years: 10 / months: 2 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #34 from Marc Véron <veron@veron.ch> --- (In reply to Frédéric Demians from comment #33) (...)
Something like that would do it:
Age: years: 10 / months: 2
+1 for better translatability -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |http://bugs.koha-community. | |org/bugzilla3/show_bug.cgi? | |id=15395 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |http://bugs.koha-community. | |org/bugzilla3/show_bug.cgi? | |id=14763 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |http://bugs.koha-community. | |org/bugzilla3/show_bug.cgi? | |id=15400 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #45597|0 |1 is obsolete| | Attachment #45598|0 |1 is obsolete| | Attachment #45599|0 |1 is obsolete| | Attachment #45600|0 |1 is obsolete| | Attachment #45601|0 |1 is obsolete| | --- Comment #35 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 46228 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46228&action=edit 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 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|In Discussion |Needs Signoff --- Comment #36 from Alex Arnaud <alex.arnaud@biblibre.com> --- The last patch replace all others. It removes showing of age in patron's detail page (duplicate of bug 14763) and it remove the use of perl sub getAge() via ajax call (bad performances). Also it handles better plural forms. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #46228|0 |1 is obsolete| | --- Comment #37 from Marc Véron <veron@veron.ch> --- Created attachment 46245 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46245&action=edit 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 Followed test plan, works as expected. Signed-off-by: Marc Véron <veron@veron.ch> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #38 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Alex, Could you please: 1/ move the CalculateAge to a js file (to make it reusable) 2/ do not display "Age:" if the calculation fails 3/ Remove the checkdate param, it is not really needed. You should use Date_from_syspref defined in calendar.inc instead -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #46245|0 |1 is obsolete| | --- Comment #39 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 46396 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46396&action=edit 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 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #40 from Alex Arnaud <alex.arnaud@biblibre.com> --- (In reply to Jonathan Druart from comment #38)
Alex, Could you please: 1/ move the CalculateAge to a js file (to make it reusable) 2/ do not display "Age:" if the calculation fails 3/ Remove the checkdate param, it is not really needed. You should use Date_from_syspref defined in calendar.inc instead
I don't need Date_from_syspref since i use datepicker( 'getDate' ) from datepicker component to get the correct format. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #41 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- With "to make it reusable", I meant "Don't hardcode stuff in it"... -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #42 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- And don't call CheckDate, it's obsolete. Date_from_syspref does that for any date format. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #43 from Alex Arnaud <alex.arnaud@biblibre.com> --- (In reply to Jonathan Druart from comment #41)
With "to make it reusable", I meant "Don't hardcode stuff in it"...
oops... -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #44 from Alex Arnaud <alex.arnaud@biblibre.com> --- (In reply to Jonathan Druart from comment #41)
With "to make it reusable", I meant "Don't hardcode stuff in it"...
This means i could not reset the description (div .hint) under the datepicker with date format when datepicker is emptied. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #45 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- I don't understand your issue, what about something like: function CalculateAge(date) { // Caculate age return (years, months); } onchange( age = CalculateAge(date); add_age_string_to_the_div ); -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |ASSIGNED -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Aleisha Amohia <aleishaamohia@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aleishaamohia@hotmail.com --- Comment #46 from Aleisha Amohia <aleishaamohia@hotmail.com> --- There is a GetAge function already in C4::Members which I used to write a patch for Bug 14763. I am not saying this is a duplicate of that bug, because I feel this is slightly different to what my patch does, but is it possible to use that function for this? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #47 from Alex Arnaud <alex.arnaud@biblibre.com> --- Created attachment 47301 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=47301&action=edit Bug 15206 - Make CalculateAge a reusable function -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 Alex Arnaud <alex.arnaud@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15206 --- Comment #48 from Alex Arnaud <alex.arnaud@biblibre.com> --- (In reply to Aleisha Amohia from comment #46)
There is a GetAge function already in C4::Members which I used to write a patch for Bug 14763. I am not saying this is a duplicate of that bug, because I feel this is slightly different to what my patch does, but is it possible to use that function for this?
I tried to use it by making an ajax call to a perl script but response times are too long. Now CalculateAge function is quite simple and reusable. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org