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

(-)a/koha-tmpl/intranet-tmpl/prog/en/js/members.js (+52 lines)
Lines 147-152 function Dopopguarantor(link) { Link Here
147
    var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top');
147
    var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top');
148
}
148
}
149
149
150
function CalculateAge() {
151
    var hint = $("#dateofbirth").siblings(".hint").first();
152
    hint.html(dateformat);
153
154
    if (dformat == 'metric' && false === CheckDate(document.form.dateofbirth)) {
155
        return;
156
    }
157
158
    if (!$("#dateofbirth").datepicker( 'getDate' )) {
159
        return;
160
    }
161
162
    var today = new Date();
163
    var dob = new Date($("#dateofbirth").datepicker( 'getDate' ));
164
165
    var nowyear = today.getFullYear();
166
    var nowmonth = today.getMonth();
167
    var nowday = today.getDate();
168
169
    var birthyear = dob.getFullYear();
170
    var birthmonth = dob.getMonth();
171
    var birthday = dob.getDate();
172
173
    var year = nowyear - birthyear;
174
    var month = nowmonth - birthmonth;
175
    var day = nowday - birthday;
176
177
    if(day < 0) {
178
        month = parseInt(month) -1;
179
    }
180
181
    if(month < 0) {
182
        year = parseInt(year) -1;
183
        month = 12 + month;
184
    }
185
186
    var age_string;
187
    if (year || month) {
188
        age_string = _('Age: ');
189
    }
190
    if (year) {
191
        age_string += _(year > 1 ? '%s years ' : '%s year ').format(year);
192
    }
193
194
    if (month) {
195
        age_string += _(month > 1 ? '%s months ' : '%s month ').format(month);
196
    }
197
198
    hint.html(age_string);
199
200
}
201
150
$(document).ready(function(){
202
$(document).ready(function(){
151
    if($("#yesdebarred").is(":checked")){
203
    if($("#yesdebarred").is(":checked")){
152
        $("#debarreduntil").show();
204
        $("#debarreduntil").show();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-8 / +3 lines)
Lines 34-39 Link Here
34
            }
34
            }
35
        [% END %]
35
        [% END %]
36
        $("#dateofbirth").datepicker({ maxDate: "-1D", yearRange: "c-120:" });
36
        $("#dateofbirth").datepicker({ maxDate: "-1D", yearRange: "c-120:" });
37
        dateformat = $("#dateofbirth").siblings(".hint").first().html();
38
        CalculateAge();
37
        $("#entryform").validate({
39
        $("#entryform").validate({
38
            rules: {
40
            rules: {
39
                email: {
41
                email: {
Lines 145-152 Link Here
145
        return 0;
147
        return 0;
146
    }
148
    }
147
149
148
149
150
        var MSG_SEPARATOR = _("Separator must be / in field %s");
150
        var MSG_SEPARATOR = _("Separator must be / in field %s");
151
        var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
151
        var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
152
        var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
152
        var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
Lines 343-353 Link Here
343
                [% END %]
343
                [% END %]
344
                Date of birth: </label>
344
                Date of birth: </label>
345
345
346
        [% IF ( dateformat == "metric" ) %]
346
                <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CalculateAge();" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" />
347
                <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CheckDate(document.form.dateofbirth);" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" />
348
        [% ELSE %]
349
                <input type="text" id="dateofbirth" name="dateofbirth" size="20" value="[% UNLESS opduplicate %][% dateofbirth %][% END %]" />
350
        [% END %]
351
347
352
        [% IF ( mandatorydateofbirth ) %]<span class="required">Required</span>[% END %]
348
        [% IF ( mandatorydateofbirth ) %]<span class="required">Required</span>[% END %]
353
        [% IF ( ERROR_dateofbirth ) %]<span class="required">(Error)</span>[% END %]
349
        [% IF ( ERROR_dateofbirth ) %]<span class="required">(Error)</span>[% END %]
354
- 

Return to bug 15206