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

(-)a/koha-tmpl/intranet-tmpl/prog/en/js/members.js (-2 / +34 lines)
Lines 219-226 function select_user(borrowernumber, borrower) { Link Here
219
219
220
function CalculateAge(dateofbirth) {
220
function CalculateAge(dateofbirth) {
221
    var today = new Date();
221
    var today = new Date();
222
    var dob = Date_from_syspref(dateofbirth)
222
    var dob = Date_from_syspref(dateofbirth);
223
    var age = new Object();
223
    var age = {};
224
224
225
    age.year = today.getFullYear() - dob.getFullYear();
225
    age.year = today.getFullYear() - dob.getFullYear();
226
    age.month = today.getMonth() - dob.getMonth();
226
    age.month = today.getMonth() - dob.getMonth();
Lines 238-243 function CalculateAge(dateofbirth) { Link Here
238
    return age;
238
    return age;
239
}
239
}
240
240
241
function write_age() {
242
    var hint = $("#dateofbirth").siblings(".hint").first();
243
    hint.html(dateformat);
244
245
    var age = CalculateAge(document.form.dateofbirth.value);
246
247
    if (!age.year && !age.month) {
248
        return;
249
    }
250
251
    var age_string;
252
    if (age.year || age.month) {
253
        age_string = LABEL_AGE + ": ";
254
    }
255
256
    if (age.year) {
257
        age_string += age.year > 1 ? MSG_YEARS.format(age.year) : MSG_YEAR.format(age.year);
258
        age_string += " ";
259
    }
260
261
    if (age.month) {
262
        age_string += age.month > 1 ? MSG_MONTHS.format(age.month) : MSG_MONTH.format(age.month);
263
    }
264
265
    hint.html(age_string);
266
}
267
241
$(document).ready(function(){
268
$(document).ready(function(){
242
    if($("#yesdebarred").is(":checked")){
269
    if($("#yesdebarred").is(":checked")){
243
        $("#debarreduntil").show();
270
        $("#debarreduntil").show();
Lines 278-283 $(document).ready(function(){ Link Here
278
    });
305
    });
279
306
280
    $("#dateofbirth").datepicker({ maxDate: "-1D", yearRange: "c-120:" });
307
    $("#dateofbirth").datepicker({ maxDate: "-1D", yearRange: "c-120:" });
308
    dateformat = $("#dateofbirth").siblings(".hint").first().html();
309
310
    if( $('#dateofbirth').length ) {
311
        write_age();
312
    }
281
313
282
    $("#entryform").validate({
314
    $("#entryform").validate({
283
        rules: {
315
        rules: {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-142 / +6 lines)
Lines 7-13 Link Here
7
<script type="text/javascript">
7
<script type="text/javascript">
8
//<![CDATA[
8
//<![CDATA[
9
$(document).ready(function() {
9
$(document).ready(function() {
10
11
	[% IF categorycode %]
10
	[% IF categorycode %]
12
		update_category_code( "[% categorycode %]" );
11
		update_category_code( "[% categorycode %]" );
13
	[% ELSE %]
12
	[% ELSE %]
Lines 16-163 $(document).ready(function() { Link Here
16
			update_category_code( category_code );
15
			update_category_code( category_code );
17
		}
16
		}
18
	[% END %]
17
	[% END %]
19
	$("#dateofbirth").datepicker({ maxDate: "-1D", yearRange: "c-120:" });
20
	dateformat = $("#dateofbirth").siblings(".hint").first().html();
21
    if( $('#dateofbirth').length ) {
22
        write_age();
23
    }
24
	$("#entryform").validate({
25
		rules: {
26
			email: {
27
				email: true
28
			},
29
			emailpro: {
30
				email: true
31
			},
32
			B_email: {
33
				email: true
34
			}
35
		},
36
		submitHandler: function(form) {
37
			$("body, form input[type='submit'], form button[type='submit'], form a").addClass('waiting');
38
			if (form.beenSubmitted)
39
				return false;
40
			else
41
				form.beenSubmitted = true;
42
				form.submit();
43
			}
44
	});
45
46
	var mrform = $("#manual_restriction_form");
47
	var mrlink = $("#add_manual_restriction");
48
	mrform.hide();
49
	mrlink.on("click",function(e){
50
		$(this).hide();
51
		mrform.show();
52
		e.preventDefault();
53
	});
54
	$("#cancel_manual_restriction").on("click",function(e){
55
		$('#debarred_expiration').val('');
56
		$('#add_debarment').val(0);
57
		$('#debarred_comment').val('');
58
		mrlink.show();
59
		mrform.hide();
60
		e.preventDefault();
61
	});
62
});
18
});
63
19
64
function clear_entry(node) {
65
	var original = $(node).parent();
66
	$("textarea", original).attr('value', '');
67
	$("select", original).attr('value', '');
68
}
69
70
function clone_entry(node) {
71
	var original = $(node).parent();
72
	var clone = original.clone();
73
74
	var newId = 50 + parseInt(Math.random() * 100000);
75
	$("input,select,textarea", clone).attr('id', function() {
76
		return this.id.replace(/patron_attr_\d+/, 'patron_attr_' + newId);
77
	});
78
	$("input,select,textarea", clone).attr('name', function() {
79
		return this.name.replace(/patron_attr_\d+/, 'patron_attr_' + newId);
80
	});
81
	$("label", clone).attr('for', function() {
82
		return $(this).attr("for").replace(/patron_attr_\d+/, 'patron_attr_' + newId);
83
	});
84
	$("input#patron_attr_" + newId, clone).attr('value','');
85
	$("select#patron_attr_" + newId, clone).attr('value','');
86
	$(original).after(clone);
87
	return false;
88
}
89
90
function update_category_code(category_code) {
91
	if ( $(category_code).is("select") ) {
92
		category_code = $("#categorycode_entry").find("option:selected").val();
93
	}
94
	var mytables = $(".attributes_table");
95
	$(mytables).find("li").hide();
96
	$(mytables).find(" li[data-category_code='"+category_code+"']").show();
97
	$(mytables).find(" li[data-category_code='']").show();
98
}
99
100
function select_user(borrowernumber, borrower) {
101
	var form = $('#entryform').get(0);
102
	if (form.guarantorid.value) {
103
		$("#contact-details").find('a').remove();
104
		$("#contactname, #contactfirstname").parent().find('span').remove();
105
	}
106
107
	var id = borrower.borrowernumber;
108
	form.guarantorid.value = id;
109
	$('#contact-details')
110
		.show()
111
		.find('span')
112
		.after('<a target="blank" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=' + id + '">' + id + '</a>');
113
114
	$(form.contactname)
115
		.val(borrower.surname)
116
		.before('<span>' + borrower.surname + '</span>').get(0).type = 'hidden';
117
	$(form.contactfirstname)
118
		.val(borrower.firstname)
119
		.before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden';
120
121
	form.streetnumber.value = borrower.streetnumber;
122
	form.address.value = borrower.address;
123
	form.address2.value = borrower.address2;
124
	form.city.value = borrower.city;
125
	form.state.value = borrower.state;
126
	form.zipcode.value = borrower.zipcode;
127
	form.country.value = borrower.country;
128
	form.branchcode.value = borrower.branchcode;
129
130
	form.guarantorsearch.value = _("Change");
131
132
	return 0;
133
}
134
135
    function write_age() {
136
        var hint = $("#dateofbirth").siblings(".hint").first();
137
        hint.html(dateformat);
138
139
        var age = CalculateAge(document.form.dateofbirth.value);
140
141
        if (!age.year && !age.month) {
142
            return;
143
        }
144
145
        var age_string;
146
        if (age.year || age.month) {
147
            age_string = _("Age: ");
148
        }
149
150
        if (age.year) {
151
            age_string += age.year > 1 ? _("%s years ").format(age.year) : _("%s year ").format(age.year);
152
        }
153
154
        if (age.month) {
155
            age_string += age.month > 1 ? _("%s months ").format(age.month) : _("%s month ").format(age.month);
156
        }
157
158
        hint.html(age_string);
159
    }
160
161
        var MSG_SEPARATOR = _("Separator must be / in field %s");
20
        var MSG_SEPARATOR = _("Separator must be / in field %s");
162
        var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
21
        var MSG_INCORRECT_DAY = _("Invalid day entered in field %s");
163
        var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
22
        var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s");
Lines 168-175 function select_user(borrowernumber, borrower) { Link Here
168
        var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron");
27
        var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron");
169
        var MSG_PASSWORD_MISMATCH = _("The passwords entered do not match");
28
        var MSG_PASSWORD_MISMATCH = _("The passwords entered do not match");
170
        var MSG_PASSWORD_CONTAINS_TRAILING_SPACES = _("Password contains leading and/or trailing spaces.");
29
        var MSG_PASSWORD_CONTAINS_TRAILING_SPACES = _("Password contains leading and/or trailing spaces.");
30
        var MSG_MONTH = _("%s month")
31
        var MSG_MONTHS = _("%s months")
32
        var MSG_YEAR = _("%s year")
33
        var MSG_YEARS = _("%s years")
171
        var LABEL_CHANGE = _("Change");
34
        var LABEL_CHANGE = _("Change");
172
        var LABEL_SET_TO_PATRON = _("Set to patron");
35
        var LABEL_SET_TO_PATRON = _("Set to patron");
36
        var LABEL_AGE = _("Age");
37
173
//]]>
38
//]]>
174
</script>
39
</script>
175
<script type="text/javascript" src="[% themelang %]/js/members.js"></script>
40
<script type="text/javascript" src="[% themelang %]/js/members.js"></script>
176
- 

Return to bug 16228