@@ -, +, @@
memberentry.pl
---
koha-tmpl/intranet-tmpl/prog/en/js/members.js | 52 ++++++++++++++++++++++
.../prog/en/modules/members/memberentrygen.tt | 10 ++---
2 files changed, 55 insertions(+), 7 deletions(-)
--- a/koha-tmpl/intranet-tmpl/prog/en/js/members.js
+++ a/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();
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
+++ a/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:
- [% IF ( dateformat == "metric" ) %]
-
- [% ELSE %]
-
- [% END %]
+
[% IF ( mandatorydateofbirth ) %]Required[% END %]
[% IF ( ERROR_dateofbirth ) %](Error)[% END %]
--