View | Details | Raw Unified | Return to bug 15206
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-3 / +19 lines)
Lines 145-150 Link Here
145
        return 0;
145
        return 0;
146
    }
146
    }
147
147
148
    function CalculateAge(dateofbirth) {
149
        //var dob = $("#dateofbirth").datepicker( 'getDate' );
150
        //var today = new Date();
151
        var dob = new Date($("#dateofbirth").datepicker( 'getDate' ));
152
153
        var ageDifS = (Date.now() - dob.getTime()) / 1000;
154
        var year = Math.floor(ageDifS / 31536000);
155
        var month = Math.floor((ageDifS % 31536000) / 2628000);
156
        var day = Math.floor(((ageDifS % 31536000) % 2628000) / 86400);
157
158
        var age_string = "Age: ";
159
        if (year) { age_string += year + " year(s) "; }
160
        if (month) { age_string += month + " month(s) "; }
161
        if (day) { age_string += day + " day(s) "; }
162
163
        var elem = $("#dateofbirth").siblings(".hint").first().html(age_string);
164
    }
148
165
149
166
150
        var MSG_SEPARATOR = _("Separator must be / in field %s");
167
        var MSG_SEPARATOR = _("Separator must be / in field %s");
Lines 344-352 Link Here
344
                Date of birth: </label>
361
                Date of birth: </label>
345
362
346
        [% IF ( dateformat == "metric" ) %]
363
        [% IF ( dateformat == "metric" ) %]
347
                <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CheckDate(document.form.dateofbirth);" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" />
364
                <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CheckDate(document.form.dateofbirth); CalculateAge(document.form.dateofbirth);" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" />
348
        [% ELSE %]
365
        [% ELSE %]
349
                <input type="text" id="dateofbirth" name="dateofbirth" size="20" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" />
366
                <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CalculateAge(document.form.dateofbirth);" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" />
350
        [% END %]
367
        [% END %]
351
368
352
        [% IF ( mandatorydateofbirth ) %]<span class="required">Required</span>[% END %]
369
        [% IF ( mandatorydateofbirth ) %]<span class="required">Required</span>[% END %]
353
- 

Return to bug 15206