Bug 27668: Improve validation of patron entry form in the OPAC
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-memberentry.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE AuthorisedValues %]
4 [% USE Categories %]
5 [% USE Koha %]
6 [% USE Branches %]
7 [% USE KohaDates %]
8 [% USE Math %]
9 [% SET userupdateview = 1 %]
10 [% BLOCK streetnumber %]
11     [% UNLESS hidden.defined('streetnumber') %]
12         <li>
13             <label for="borrower_streetnumber" class="[% required.streetnumber | html %]">Street number:</label>
14
15             <input type="text" id="borrower_streetnumber" name="borrower_streetnumber" value="[% borrower.streetnumber | html %]" class="[% required.streetnumber | html %]" />
16             <div class="required_label [% required.streetnumber | html %]">Required</div>
17         </li>
18     [% END %]
19 [% END %]
20
21 [% INCLUDE 'doc-head-open.inc' %]
22     <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; [% IF action == 'edit' %]Update your personal details[% ELSE %]Register a new account[% END %]</title>
23 [% INCLUDE 'doc-head-close.inc' %]
24 [% BLOCK cssinclude %][% END %]
25 </head>
26
27 [% IF action == 'edit' %]
28 [% INCLUDE 'bodytag.inc' bodyid='opac-patron-update' %]
29 [% ELSE %]
30 <body id="opac-patron-registration" class="opac">
31 [% END %]
32 [% INCLUDE 'masthead.inc' %]
33
34 <div class="main">
35     <nav aria-label="breadcrumb">
36         <ul class="breadcrumb">
37             <li class="breadcrumb-item">
38                 <a href="/cgi-bin/koha/opac-main.pl">Home</a>
39             </li>
40             [% IF action == 'edit' %]
41                 <li class="breadcrumb-item">
42                     <a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a>
43                 </li>
44                 <li class="breadcrumb-item active">
45                     <a href="#">Your personal details</a>
46                 </li>
47             [% ELSE %]
48                 <li class="breadcrumb-item active">
49                     <a href="#">Register a new account</a>
50                 </li>
51             [% END %]
52         </ul>
53     </nav>
54
55     <div class="container-fluid">
56         <div class="row">
57             <div class="col col-lg-2 order-2 order-lg-1">
58                 <div id="navigation">
59                     [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
60                 </div>
61             </div>
62             <div class="col-md-12 col-lg-10 order-1">
63                 [% IF action == 'edit' %]
64                     <div id="update-account" class="maincontent">
65                 [% ELSE %]
66                     <div id="add-account" class="maincontent">
67                 [% END %]
68
69                 [% IF action == 'edit' %]
70                     [% UNLESS OPACPatronDetails %]
71                         <div class="alert alert-info">To make changes to your record please contact the library.</div>
72                     [% END %]
73                     [% IF nochanges %]
74                         <div class="alert alert-error">No changes were made.</div>
75                     [% END %]
76                 [% END %]
77
78                 [% IF empty_mandatory_fields %]
79                     <div class="alert alert-warning">You have not filled out all required fields. Please fill in all missing fields and resubmit.</div>
80                 [% END %]
81
82                 [% IF invalid_form_fields %]
83                     <div class="alert alert-error"><strong>The following fields contain invalid information:</strong>
84                         <ul>
85                             [% FOREACH field IN invalid_form_fields %]
86                                 [% IF field == "email" %]<li>Contact information: <a href="#borrower_email">primary email address</a></li>[% END %]
87                                 [% IF field == "emailpro" %]<li>Contact information: <a href="#borrower_emailpro">secondary email address</a></li>[% END %]
88                                 [% IF field == "B_email" %]<li>Alternate address information: <a href="#borrower_B_email">email address</a></li>[% END %]
89                                 [% IF field == "password_match" %]<li>Passwords do not match! <a href="#password">password</a></li>[% END %]
90                                 [% IF field == "password_too_short" %]
91                                     <li>Password must be at least [% patron.category.effective_min_password_length | html %] characters long.</li>
92                                 [% END %]
93                                 [% IF field == "password_too_weak" %]
94                                     <li>Password must contain at least one digit, one lowercase and one uppercase.</li>
95                                 [% END %]
96                                 [% IF field == "password_has_whitespaces" %]
97                                     <li>Password must not contain leading or trailing whitespaces.</li>
98                                 [% END %]
99                                 [% IF field == "duplicate_email" %]
100                                     <li>This email address already exists in our database.</li>
101                                 [% END %]
102                                 [% IF field == "email_match" %]
103                                     <li>Emails do not match! <a href="#borrower_repeat_email">confirm email address</a></li>
104                                 [% END %]
105                             [% END %]
106                         </ul>
107                         <span>Please correct and resubmit.</span>
108                     </div>
109                 [% END %]
110
111                 [% IF cardnumber_wrong_length || cardnumber_already_exists %]
112                     <div class="alert alert-error">
113                         [% IF cardnumber_wrong_length %]
114                         <a href="#borrower_cardnumber"><strong>The entered card number is the wrong length.</strong></a>
115                         [% ELSIF cardnumber_already_exists %]
116                         <a href="#borrower_cardnumber"><strong>The entered card number is already in use.</strong></a>
117                         [% END %]
118                         <span>Please correct and resubmit.</span>
119                     </div>
120                 [% END %]
121
122                 [% IF failed_captcha %]
123                     <div class="alert alert-warning">You typed in the wrong characters in the box before submitting. Please try again.</div>
124                 [% END %]
125
126                 [% IF has_guarantor_flag && !Koha.Preference('OPACPrivacy') && ( Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') || Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor') ) %]
127                     <div class="row">
128                         <div class="col">
129                             <fieldset class="rows" id="memberentry_privacy">
130                                 <legend id="privacy_legend">Privacy</legend>
131                                 <ol>
132                                     [% IF Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
133                                     <li>
134                                         <label>Allow your guarantor to view your current checkouts?</label>
135                                         <select id="privacy_guarantor_checkouts">
136                                             <option value="0">No</option>
137                                             [% IF borrower.privacy_guarantor_checkouts %]
138                                                 <option value="1" selected="selected">Yes</option>
139                                             [% ELSE %]
140                                                 <option value="1">Yes</option>
141                                             [% END %]
142                                         </select>
143                                         <span class="hint">
144                                             <a id="update_privacy_guarantor_checkouts" href="#" class="btn btn-primary">Update</a>
145                                             <span id="update_privacy_guarantor_checkouts_message" class="alert" style="display:none"></span>
146                                         </span>
147                                     </li>
148                                     [% END %]
149
150                                     [% IF Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor') %]
151                                     <li>
152                                         <label>Allow your guarantor to view your current fines?</label>
153                                         <select id="privacy_guarantor_fines">
154                                             <option value="0">No</option>
155                                             [% IF borrower.privacy_guarantor_fines %]
156                                                 <option value="1" selected="selected">Yes</option>
157                                             [% ELSE %]
158                                                 <option value="1">Yes</option>
159                                             [% END %]
160                                         </select>
161                                         <span class="hint">
162                                             <a id="update_privacy_guarantor_fines" href="#" class="btn btn-primary">Update</a>
163                                             <span id="update_privacy_guarantor_fines_message" class="alert" style="display:none"></span>
164                                         </span>
165                                     </li>
166                                     [% END %]
167
168                                     <li>
169                                         <span class="hint">
170                                             Guaranteed by
171                                             [% FOREACH gr IN patron.guarantor_relationships %]
172                                                 [% SET g = gr.guarantor %]
173                                                 [% g.firstname | html %] [% g.surname | html %]
174                                                 [%- IF ! loop.last %], [% END %]
175                                             [% END %]
176                                         </span>
177                                     </li>
178                                 </ol>
179                             </fieldset>
180                         </div>
181                     </div>
182                 [% END %]
183
184                 [% IF ( extended_unique_id_failed_code ) %]
185                     <div class="alert" id="extended_unique_id_failed"><a href="#patron-attr-start-[% extended_unique_id_failed_code | uri %]">[% extended_unique_id_failed_description _ ': ' | html %]</a> Value is already in use ([% extended_unique_id_failed_value | html %])</div>
186                 [% END %]
187
188                 <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off">
189
190                 [% FOREACH field = ['streetnumber' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'dateofbirth' 'initials' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' ] %]
191                     [% IF mandatory.defined( field ) %]
192                         [% SET required.$field = 'required' %]
193                     [% END %]
194                 [% END %]
195
196                     [%# Following on one line for translatability %]
197                     [% UNLESS ( hidden.defined('cardnumber') || ( !borrower && Koha.Preference('autoMemberNum') ) ) && hidden.defined('dateexpiry') && hidden.defined('branchcode') && hidden.defined('categorycode') %]
198                         <div class="row">
199                             <div class="col">
200                                 <fieldset class="rows" id="memberentry_library">
201
202                                     <legend id="library_legend">Library</legend>
203                                         <ol>
204                                             [% UNLESS hidden.defined('cardnumber') || ( !borrower && Koha.Preference('autoMemberNum') ) %]
205                                             <li>
206
207                                                 <label for="borrower_cardnumber" class="[% required.cardnumber | html %]">Library card number:</label>
208
209                                                 [% IF borrower && !(cardnumber_wrong_length || cardnumber_already_exists) %]
210                                                     [% borrower.cardnumber | html %]
211                                                 [% ELSE %]
212                                                     [% IF minlength_cardnumber == maxlength_cardnumber %]
213                                                         <input type="text" id="borrower_cardnumber" name="borrower_cardnumber" size="20" value="[% borrower.cardnumber | html %]" minlength="[% minlength_cardnumber | html %]" maxlength="[% maxlength_cardnumber | html %]" class="[% required.cardnumber | html %]" />
214                                                         <div class="required_label [% required.cardnumber | html %]">Required</div>
215                                                         <div class="hint">Card number must be exactly [% minlength_cardnumber | html %] characters.</div>
216                                                     [% ELSIF minlength_cardnumber && maxlength_cardnumber %]
217                                                         <input type="text" id="borrower_cardnumber" name="borrower_cardnumber" size="20" value="[% borrower.cardnumber | html %]" minlength="[% minlength_cardnumber | html %]" maxlength="[% maxlength_cardnumber | html %]" class="[% required.cardnumber | html %]" />
218                                                         <div class="required_label [% required.cardnumber | html %]">Required</div>
219                                                         <div class="hint">Card number must be between [% minlength_cardnumber | html %] and [% maxlength_cardnumber | html %] characters.</div>
220                                                     [% ELSIF maxlength_cardnumber %]
221                                                         <input type="text" id="borrower_cardnumber" name="borrower_cardnumber" size="20" value="[% borrower.cardnumber | html %]" maxlength="[% maxlength_cardnumber | html %]" class="[% required.cardnumber | html %]" />
222                                                         <div class="required_label [% required.cardnumber | html %]">Required</div>
223                                                         <div class="hint">Card number can be up to [% maxlength_cardnumber | html %] characters.</div>
224                                                     [% ELSE %]
225                                                         <input type="text" id="borrower_cardnumber" name="borrower_cardnumber" size="20" value="[% borrower.cardnumber | html %]" class="[% required.cardnumber | html %]" />
226                                                         <div class="required_label [% required.cardnumber | html %]">Required</div>
227                                                         <div class="hint">There is no minimum or maximum character length.</div>
228                                                     [% END %]
229                                                 [% END %]
230                                             </li>
231                                             [% END %]
232
233                                             [% UNLESS hidden.defined('dateexpiry') %]
234                                             <li>
235                                                 <label>Expiration date:</label>
236                                                 [% borrower.dateexpiry | $KohaDates  %]
237                                             </li>
238                                             [% END %]
239
240                                             [% UNLESS hidden.defined('branchcode') %]
241                                                 <li>
242                                                     [% IF ( libraries.size > 1 ) %]
243                                                         <label for="borrower_branchcode" class="[% required.branchcode | html %]">Home library:</label>
244
245                                                         <select id="borrower_branchcode" name="borrower_branchcode" class="[% required.branchcode | html %]">
246                                                             [% FOREACH l IN libraries %]
247                                                                 [% IF l.branchcode == borrower.branchcode %]
248                                                                     <option value="[% l.branchcode | html %]" selected="selected">[% l.branchname | html %]</option>
249                                                                 [% ELSE %]
250                                                                     <option value="[% l.branchcode | html %]">[% l.branchname | html %]</option>
251                                                                 [% END %]
252                                                             [% END %]
253                                                         </select>
254                                                         <div class="required_label [% required.branchcode | html %]">Required</div>
255                                                     [% ELSE %]
256                                                         <span class="label">Home library:</span>
257                                                         [% FOREACH l IN libraries %]
258                                                             [% l.branchname | html %]
259                                                             <input type="hidden" name="borrower_branchcode" value="[% l.branchcode | html %]" />
260                                                         [% END %]
261                                                     [% END %]
262                                                 </li>
263                                             [% END %]
264
265                                             [% UNLESS hidden.defined('categorycode') %]
266                                                 <li>
267                                                     <label for="borrower_categorycode" class="[% required.categorycode | html %]">
268                                                     Category:</label>
269
270                                                     [% IF borrower %]
271                                                         [% Categories.GetName( borrower.categorycode ) | html %]
272                                                         <input type="hidden" name="borrower_categorycode" value="[% borrower.categorycode | html %]" />
273                                                     [% ELSE %]
274                                                         <select id="borrower_categorycode" name="borrower_categorycode" class="[% required.categorycode | html %]">
275                                                             [% FOREACH c IN Categories.all() %]
276                                                                 [% IF c.categorycode == Koha.Preference('PatronSelfRegistrationDefaultCategory') %]
277                                                                     <option value="[% c.categorycode | html %]" data-pwd-length="[% c.effective_min_password_length | html %]" data-pwd-strong="[% c.effective_require_strong_password | html %]" selected="selected">[% c.description | html %]</option>
278                                                                 [% ELSE %]
279                                                                     <option value="[% c.categorycode | html %]" data-pwd-length="[% c.effective_min_password_length | html %]" data-pwd-strong="[% c.effective_require_strong_password | html %]">[% c.description | html %]</option>
280                                                                 [% END %]
281                                                             [% END %]
282                                                         </select>
283                                                         <div class="required_label [% required.categorycode | html %]">Required</div>
284                                                     [% END %]
285                                                 </li>
286                                             [% END %]
287                                         </ol>
288                                     </fieldset>
289                                 </div> <!-- /.col -->
290                             </div> <!-- /.row -->
291                     [% END # / defined 'branchcode' %]
292
293                     [%# Following on one line for translatability %]
294                     [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('othernames') && hidden.defined('sex') %]
295                         <div class="row">
296                             <div class="col">
297                                 <fieldset class="rows" id="memberentry_identity">
298                                     <legend id="identity_legend">Identity</legend>
299
300                                     <ol>
301                                         [% UNLESS hidden.defined('title') || !Koha.Preference('BorrowersTitles') %]
302                                             <li>
303                                                 <label for="borrower_title" class="[% required.title | html %]">Salutation:</label>
304
305                                                 <select id="borrower_title" name="borrower_title" class="[% required.title | html %]">
306                                                     <option value=""></option>
307                                                     [% FOREACH mt IN Koha.Preference('BorrowersTitles').split('\|') %]
308                                                         [% IF mt == borrower.title %]
309                                                             <option value="[% mt | html %]" selected="selected">[% mt | html %]</option>
310                                                         [% ELSE %]
311                                                             <option value="[% mt | html %]">[% mt | html %]</option>
312                                                         [% END %]
313                                                     [% END %]
314                                                 </select>
315                                                 <div class="required_label [% required.title | html %]">Required</div>
316                                             </li>
317                                         [% END %]
318
319                                         [% UNLESS hidden.defined('surname') %]
320                                             <li>
321                                                 <label for="borrower_surname" class="[% required.surname | html %]">Surname:</label>
322
323                                                 <input type="text" id="borrower_surname" name="borrower_surname" value="[% borrower.surname | html %]" class="[% required.surname | html %]" />
324                                                 <div class="required_label [% required.surname | html %]">Required</div>
325                                             </li>
326                                         [% END %]
327
328                                         [% UNLESS hidden.defined('firstname') %]
329                                             <li>
330                                                 <label for="borrower_firstname" class="[% required.firstname | html %]">First name:</label>
331
332                                                 <input type="text" id="borrower_firstname" name="borrower_firstname" value="[% borrower.firstname | html %]" class="[% required.firstname | html %]" />
333                                                 <div class="required_label [% required.firstname | html %]">Required</div>
334                                             </li>
335                                         [% END %]
336
337                                         [% UNLESS hidden.defined('dateofbirth') %]
338                                             <li>
339                                                 <label for="borrower_dateofbirth" class="[% required.dateofbirth | html %]">Date of birth:</label>
340
341                                                 <input type="text" id="borrower_dateofbirth" name="borrower_dateofbirth" value="[% borrower.dateofbirth | $KohaDates %]" size="10" class="[% required.dateofbirth | html %]" />
342
343                                                 [% UNLESS action == 'edit' && !OPACPatronDetails %]
344                                                     [% UNLESS ( mandatory.defined('dateofbirth') ) %]
345                                                         <a href="#" style="font-size:85%;text-decoration:none;" class="cleardate">Clear date</a>
346                                                     [% END %]
347                                                 [% END %]
348
349                                                 <div class="required_label [% required.dateofbirth | html %]">Required</div>
350                                             </li>
351                                         [% END %]
352
353                                         [% UNLESS hidden.defined('initials') %]
354                                             <li>
355                                                 <label for="borrower_initials" class="[% required.initials | html %]">Initials:</label>
356
357                                                 <input type="text" id="borrower_initials" name="borrower_initials" value="[% borrower.initials | html %]" class="[% required.initials | html %]" />
358                                                 <div class="required_label [% required.initials | html %]">Required</div>
359                                             </li>
360                                         [% END %]
361
362                                         [% UNLESS hidden.defined('othernames') %]
363                                             <li>
364                                                 <label for="borrower_othernames" class="[% required.othernames | html %]">Other names:</label>
365
366                                                 <input type="text" id="borrower_othernames" name="borrower_othernames" value="[% borrower.othernames | html %]" class="[% required.othernames | html %]" />
367                                                 <div class="required_label [% required.initials | html %]">Required</div>
368                                             </li>
369                                         [% END %]
370
371                                         [% UNLESS hidden.defined('sex') %]
372                                             <li class="lradio">
373                                                 <label for="sex-female" class="radio inline"><span class="patronsex-female">Female:</span></label>
374                                                 [% IF borrower.sex == 'F' %]
375                                                     <input type="radio" name="borrower_sex" id="sex-female" value="F" checked="checked" />
376                                                 [% ELSE %]
377                                                     <input type="radio" name="borrower_sex" id="sex-female" value="F" />
378                                                 [% END %]
379
380                                                 <label for="sex-male" class="radio inline"><span class="patronsex-male">Male:</span></label>
381                                                 [% IF borrower.sex == 'M' %]
382                                                     <input type="radio" name="borrower_sex" id="sex-male" value="M" checked="checked" />
383                                                 [% ELSE %]
384                                                     <input type="radio" name="borrower_sex" id="sex-male" value="M" />
385                                                 [% END %]
386
387                                                 <label for="sex-other" class="radio inline"><span class="patronsex-other">Other:</span></label>
388                                                 [% IF borrower.sex == 'O' %]
389                                                     <input type="radio" name="borrower_sex" id="sex-other" value="O" checked="checked" />
390                                                 [% ELSE %]
391                                                     <input type="radio" name="borrower_sex" id="sex-other" value="O" />
392                                                 [% END %]
393
394                                                 <label for="sex-none" class="radio inline"><span class="patronsex-none">None specified:</span></label>
395                                                 [% IF borrower.sex == '' %]
396                                                     <input type="radio" name="borrower_sex" id="sex-none" value="" checked="checked" />
397                                                 [% ELSE %]
398                                                     <input type="radio" name="borrower_sex" id="sex-none" value="" />
399                                                 [% END %]
400                                             </li>
401                                         [% END %]
402                                     </ol>
403                                 </fieldset>
404                             </div> <!-- /.col -->
405                             [% IF ( display_patron_image ) %]
406                                 <div class="col-sm-2">
407                                     <p class="patronimage">
408                                        <img src="/cgi-bin/koha/opac-patron-image.pl" alt="" />
409                                     </p>
410                                 </div>
411                             [% END %]
412                         </div> <!-- /.row -->
413                     [% END # /UNLESS fields hidden %]
414
415                     [%# Following on one line for translatability %]
416                     [% UNLESS hidden.defined('streetnumber') && hidden.defined('address') && hidden.defined('address2') && hidden.defined('city') && hidden.defined('state') && hidden.defined('zipcode') && hidden.defined('country') %]
417                         <div class="row">
418                             <div class="col">
419                                 <fieldset class="rows" id="memberentry_mainaddress">
420                                     <legend id="mainaddress_legend">Main address</legend>
421
422                                     <ol>
423                                         [% IF Koha.Preference('AddressFormat') != 'de' %][% INCLUDE streetnumber %][% END %]
424
425                                         [% UNLESS hidden.defined('address') %]
426                                             <li>
427                                                 <label for="borrower_address" class="[% required.address | html %]">Address:</label>
428
429                                                 <input type="text" id="borrower_address" name="borrower_address" value="[% borrower.address | html %]" class="[% required.address | html %]" />
430                                                 <div class="required_label [% required.address | html %]">Required</div>
431                                             </li>
432                                         [% END %]
433
434                                         [% IF Koha.Preference('AddressFormat') == 'de' %][% INCLUDE streetnumber %][% END %]
435
436                                         [% UNLESS hidden.defined('address2') %]
437                                             <li>
438                                                 <label for="borrower_address2" class="[% required.address2 | html %]">Address 2:</label>
439
440                                                 <input type="text" id="borrower_address2" name="borrower_address2" value="[% borrower.address2 | html %]" class="[% required.address2 | html %]" />
441                                                 <div class="required_label [% required.address2 | html %]">Required</div>
442                                             </li>
443                                         [% END %]
444
445                                         [% UNLESS hidden.defined('city') %]
446                                             <li>
447                                                 <label for="borrower_city" class="[% required.city | html %]">City:</label>
448
449                                                 <input type="text" id="borrower_city" name="borrower_city" value="[% borrower.city | html %]" class="[% required.city | html %]" />
450                                                 <div class="required_label [% required.city | html %]">Required</div>
451                                             </li>
452                                         [% END %]
453
454                                         [% UNLESS hidden.defined('state') %]
455                                             <li>
456                                                 <label for="borrower_state" class="[% required.state | html %]">State:</label>
457
458                                                 <input type="text" id="borrower_state" name="borrower_state" value="[% borrower.state | html %]" class="[% required.state | html %]" />
459                                                 <div class="required_label [% required.state | html %]">Required</div>
460                                             </li>
461                                         [% END %]
462
463                                         [% UNLESS hidden.defined('zipcode') %]
464                                             <li>
465                                                 <label for="borrower_zipcode" class="[% required.zipcode | html %]">ZIP/Postal code:</label>
466
467                                                 <input type="text" id="borrower_zipcode" name="borrower_zipcode" value="[% borrower.zipcode | html %]" class="[% required.zipcode | html %]" />
468                                                 <div class="required_label [% required.zipcode | html %]">Required</div>
469                                             </li>
470                                         [% END %]
471
472                                         [% UNLESS hidden.defined('country') %]
473                                             <li>
474                                                 <label for="borrower_country" class="[% required.country | html %]">Country:</label>
475
476                                                 <input type="text" id="borrower_country" name="borrower_country" value="[% borrower.country | html %]" class="[% required.country | html %]" />
477                                                 <div class="required_label [% required.country | html %]">Required</div>
478                                             </li>
479                                         [% END %]
480
481                                     </ol>
482                                 </fieldset>
483                             </div> <!-- /.col -->
484                         </div> <!-- /.row -->
485                     [% END %]
486
487                     [%# Following on one line for translatability %]
488                     [% UNLESS hidden.defined('phone') && hidden.defined('phonepro') && hidden.defined('mobile') && hidden.defined('email') && hidden.defined('emailpro') && hidden.defined('fax') %]
489                         <div class="row">
490                             <div class="col">
491                                 <fieldset class="rows" id="memberentry_contact">
492                                     <legend id="contact_legend">Contact information</legend>
493
494                                     <ol>
495                                         [% UNLESS hidden.defined('phone') %]
496                                             <li>
497                                                 <label for="borrower_phone" class="[% required.phone | html %]">Primary phone:</label>
498
499                                                 <input type="text" id="borrower_phone" name="borrower_phone" value="[% borrower.phone | html %]" class="[% required.phone | html %]" />
500                                                 <div class="required_label [% required.phone | html %]">Required</div>
501                                             </li>
502                                         [% END %]
503
504                                         [% UNLESS hidden.defined('phonepro') %]
505                                             <li>
506                                                 <label for="borrower_phonepro" class="[% required.phonepro | html %]">Secondary phone:</label>
507
508                                                 <input type="text" id="borrower_phonepro" name="borrower_phonepro" value="[% borrower.phonepro | html %]" class="[% required.phonepro | html %]" />
509                                                 <div class="required_label [% required.phonepro | html %]">Required</div>
510                                             </li>
511                                         [% END %]
512
513                                         [% UNLESS hidden.defined('mobile') %]
514                                             <li>
515                                                 <label for="borrower_mobile" class="[% required.mobile | html %]">Other phone:</label>
516
517                                                 <input type="text" id="borrower_mobile" name="borrower_mobile" value="[% borrower.mobile | html %]" class="[% required.mobile | html %]" />
518                                                 <div class="required_label [% required.mobile | html %]">Required</div>
519                                             </li>
520                                         [% END %]
521
522                                         [% UNLESS hidden.defined('email') %]
523                                             <li>
524                                                 <label for="borrower_email" class="[% required.email | html %]">Primary email:</label>
525
526                                                 <input type="text" id="borrower_email" name="borrower_email" value="[% borrower.email | html %]" class="[% required.email | html %]" />
527                                                 <div class="required_label [% required.email | html %]">Required</div>
528                                             </li>
529
530                                             [% IF action != 'edit' and Koha.Preference('PatronSelfRegistrationConfirmEmail') %]
531                                                 <li>
532                                                     <label for="borrower_repeat_email" class="[% required.email | html %]">Confirm primary email:</label>
533
534                                                     <input type="text" id="borrower_repeat_email" name="borrower_repeat_email" autocomplete="off" class="[% required.email | html %]">
535                                                     <div class="required_label [% required.email | html %]">Required</div>
536                                                 </li>
537                                             [% END %]
538                                         [% END %]
539
540                                         [% UNLESS hidden.defined('emailpro') %]
541                                             <li>
542                                                 <label for="borrower_emailpro" class="[% required.emailpro | html %]">Secondary email:</label>
543
544                                                 <input type="text" id="borrower_emailpro" name="borrower_emailpro" value="[% borrower.emailpro | html %]" class="[% required.emailpro | html %]" />
545                                                 <div class="required_label [% required.emailpro | html %]">Required</div>
546                                             </li>
547                                         [% END %]
548
549                                         [% UNLESS hidden.defined('fax') %]
550                                             <li>
551                                                 <label for="borrower_fax" class="[% required.fax | html %]">Fax:</label>
552
553                                                 <input type="text" id="borrower_fax" name="borrower_fax" value="[% borrower.fax | html %]" class="[% required.fax | html %]" />
554                                                 <div class="required_label [% required.fax | html %]">Required</div>
555                                             </li>
556                                         [% END %]
557                                     </ol>
558                                 </fieldset>
559                             </div> <!-- /.col -->
560                         </div> <!-- /.row -->
561                     [% END %]
562
563                     [%# Following on one line for translatability %]
564                     [% UNLESS hidden.defined('B_address') && hidden.defined('B_address2') && hidden.defined('B_city') && hidden.defined('B_state') && hidden.defined('B_zipcode') && hidden.defined('B_country') && hidden.defined('B_phone') && hidden.defined('B_email') && hidden.defined('contactnote') %]
565                         <div class="row">
566                             <div class="col">
567                                 <fieldset class="rows" id="memberentry_alternateaddress">
568                                     <legend id="alternateaddress_legend">Alternate address</legend>
569
570                                     <ol>
571                                         [% UNLESS hidden.defined('B_address') %]
572                                             <li>
573                                                 <label for="borrower_B_address" class="[% required.B_address | html %]">Address:</label>
574
575                                                 <input type="text" id="borrower_B_address" name="borrower_B_address" value="[% borrower.B_address | html %]" class="[% required.B_address | html %]" />
576                                                 <div class="required_label [% required.B_address | html %]">Required</div>
577                                             </li>
578                                         [% END %]
579
580                                         [% UNLESS hidden.defined('B_address2') %]
581                                             <li>
582                                                 <label for="borrower_B_address2" class="[% required.B_address | html %]">Address 2:</label>
583
584                                                 <input type="text" id="borrower_B_address2" name="borrower_B_address2" value="[% borrower.B_address2 | html %]" class="[% required.B_address | html %]" />
585                                                 <div class="required_label [% required.B_address2 | html %]">Required</div>
586                                             </li>
587                                         [% END %]
588
589                                         [% UNLESS hidden.defined('B_city') %]
590                                             <li>
591                                                 <label for="borrower_B_city" class="[% required.B_city | html %]">City:</label>
592
593                                                 <input type="text" id="borrower_B_city" name="borrower_B_city" value="[% borrower.B_city | html %]" class="[% required.B_city | html %]" />
594                                                 <div class="required_label [% required.B_city | html %]">Required</div>
595                                             </li>
596                                         [% END %]
597
598                                         [% UNLESS hidden.defined('B_state') %]
599                                             <li>
600                                                 <label for="borrower_B_state" class="[% required.B_state | html %]">State:</label>
601
602                                                 <input type="text" id="borrower_B_state" name="borrower_B_state" value="[% borrower.B_state | html %]" class="[% required.B_state | html %]" />
603                                                 <div class="required_label [% required.B_state | html %]">Required</div>
604                                             </li>
605                                         [% END %]
606
607                                         [% UNLESS hidden.defined('B_zipcode') %]
608                                             <li>
609                                                 <label for="borrower_B_zipcode" class="[% required.B_zipcode | html %]">ZIP/Postal code:</label>
610
611                                                 <input type="text" id="borrower_B_zipcode" name="borrower_B_zipcode" value="[% borrower.B_zipcode | html %]" class="[% required.B_zipcode | html %]" />
612                                                 <div class="required_label [% required.B_zipcode | html %]">Required</div>
613                                             </li>
614                                         [% END %]
615
616                                         [% UNLESS hidden.defined('B_country') %]
617                                             <li>
618                                                 <label for="borrower_B_country" class="[% required.B_country | html %]">Country:</label>
619
620                                                 <input type="text" id="borrower_B_country" name="borrower_B_country" value="[% borrower.B_country | html %]" class="[% required.B_country | html %]" />
621                                                 <div class="required_label [% required.B_country | html %]">Required</div>
622                                             </li>
623                                         [% END %]
624
625                                         [% UNLESS hidden.defined('B_phone') %]
626                                             <li>
627                                                 <label for="borrower_B_phone" class="[% required.B_phone | html %]">Phone:</label>
628
629                                                 <input type="text" id="borrower_B_phone" name="borrower_B_phone" value="[% borrower.B_phone | html %]" class="[% required.B_phone | html %]" />
630                                                 <div class="required_label [% required.B_phone | html %]">Required</div>
631                                             </li>
632                                         [% END %]
633
634                                         [% UNLESS hidden.defined('B_email') %]
635                                             <li>
636                                                 <label for="borrower_B_email" class="[% required.B_email | html %]">Email:</label>
637
638                                                 <input type="text" id="borrower_B_email" name="borrower_B_email" value="[% borrower.B_email | html %]" class="[% required.B_email | html %]" />
639                                                 <div class="required_label [% required.B_email | html %]">Required</div>
640                                             </li>
641                                         [% END %]
642
643                                         [% UNLESS hidden.defined('contactnote') %]
644                                             <li>
645                                                 <label for="borrower_contactnote" class="[% required.contactnote | html %]">Contact note:</label>
646
647                                                 <textarea id="borrower_contactnote" name="borrower_contactnote" cols="30" rows="2" class="[% required.contactnote | html %]">[% borrower.contactnote | html %]</textarea>
648                                                 <div class="required_label [% required.contactnote | html %]">Required</div>
649                                             </li>
650                                         [% END %]
651
652                                     </ol>
653                                 </fieldset>
654                             </div> <!-- /.col -->
655                         </div> <!-- /.row -->
656                     [% END %]
657
658                     [%# Following on one line for translatability %]
659                     [% UNLESS hidden.defined('altcontactsurname') && hidden.defined('altcontactfirstname') && hidden.defined('altcontactaddress1') && hidden.defined('altcontactaddress2') && hidden.defined('altcontactaddress3') && hidden.defined('altcontactstate') && hidden.defined('altcontactzipcode') && hidden.defined('altcontactcountry') && hidden.defined('altcontactphone') %]
660                         <div class="row">
661                             <div class="col">
662                                 <fieldset class="rows" id="memberentry_alternatecontact">
663                                     <legend id="alternatecontact_legend">Alternate contact</legend>
664
665                                     <ol>
666                                         [% UNLESS hidden.defined('altcontactsurname') %]
667                                             <li>
668                                                 <label for="borrower_altcontactsurname" class="[% required.altcontactsurname | html %]">Surname:</label>
669
670                                                 <input type="text" id="borrower_altcontactsurname" name="borrower_altcontactsurname" value="[% borrower.altcontactsurname | html %]" class="[% required.altcontactsurname | html %]" />
671                                                 <div class="required_label [% required.altcontactsurname | html %]">Required</div>
672                                             </li>
673                                         [% END %]
674
675                                         [% UNLESS hidden.defined('altcontactfirstname') %]
676                                             <li>
677                                                 <label for="borrower_altcontactfirstname" class="[% required.altcontactfirstname | html %]">First name:</label>
678
679                                                 <input type="text" id="borrower_altcontactfirstname" name="borrower_altcontactfirstname" value="[% borrower.altcontactfirstname | html %]" class="[% required.altcontactfirstname | html %]" />
680                                                 <div class="required_label [% required.altcontactfirstname | html %]">Required</div>
681                                             </li>
682                                         [% END %]
683
684                                         [% UNLESS hidden.defined('altcontactaddress1') %]
685                                             <li>
686                                                 <label for="borrower_altcontactaddress1" class="[% required.altcontactaddress1 | html %]">Address:</label>
687
688                                                 <input type="text" id="borrower_altcontactaddress1" name="borrower_altcontactaddress1" value="[% borrower.altcontactaddress1 | html %]" class="[% required.altcontactaddress1 | html %]" />
689                                                 <div class="required_label [% required.altcontactaddress1 | html %]">Required</div>
690                                             </li>
691                                         [% END %]
692
693                                         [% UNLESS hidden.defined('altcontactaddress2') %]
694                                             <li>
695                                                 <label for="borrower_altcontactaddress2" class="[% required.altcontactaddress2 | html %]">Address 2:</label>
696
697                                                 <input type="text" id="borrower_altcontactaddress2" name="borrower_altcontactaddress2" value="[% borrower.altcontactaddress2 | html %]" class="[% required.altcontactaddress2 | html %]" />
698                                                 <div class="required_label [% required.altcontactaddress2 | html %]">Required</div>
699                                             </li>
700                                         [% END %]
701
702                                         [% UNLESS hidden.defined('altcontactaddress3') %]
703                                             <li>
704                                                 <label for="borrower_altcontactaddress3" class="[% required.altcontactaddress3 | html %]">City:</label>
705
706                                                 <input type="text" id="borrower_altcontactaddress3" name="borrower_altcontactaddress3" value="[% borrower.altcontactaddress3 | html %]" class="[% required.altcontactaddress3 | html %]" />
707                                                 <div class="required_label [% required.altcontactaddress3 | html %]">Required</div>
708                                             </li>
709                                         [% END %]
710
711                                         [% UNLESS hidden.defined('altcontactstate') %]
712                                             <li>
713                                                 <label for="borrower_altcontactstate" class="[% required.altcontactstate | html %]">State:</label>
714
715                                                 <input type="text" id="borrower_altcontactstate" name="borrower_altcontactstate" value="[% borrower.altcontactstate | html %]" class="[% required.altcontactstate | html %]" />
716                                                 <div class="required_label [% required.altcontactstate | html %]">Required</div>
717                                             </li>
718                                         [% END %]
719
720                                         [% UNLESS hidden.defined('altcontactzipcode') %]
721                                             <li>
722                                                 <label for="borrower_altcontactzipcode" class="[% required.altcontactzipcode | html %]">ZIP/Postal code:</label>
723
724                                                 <input type="text" id="borrower_altcontactzipcode" name="borrower_altcontactzipcode" value="[% borrower.altcontactzipcode | html %]" class="[% required.altcontactzipcode | html %]" />
725                                                 <div class="required_label [% required.altcontactzipcode | html %]">Required</div>
726                                             </li>
727                                         [% END %]
728
729                                         [% UNLESS hidden.defined('altcontactcountry') %]
730                                             <li>
731                                                 <label for="borrower_altcontactcountry" class="[% required.altcontactcountry | html %]">Country:</label>
732
733                                                 <input type="text" id="borrower_altcontactcountry" name="borrower_altcontactcountry" value="[% borrower.altcontactcountry | html %]" class="[% required.altcontactcountry | html %]" />
734                                                 <div class="required_label [% required.altcontactcountry | html %]">Required</div>
735                                             </li>
736                                         [% END %]
737
738                                         [% UNLESS hidden.defined('altcontactphone') %]
739                                             <li>
740                                                 <label for="borrower_altcontactphone" class="[% required.altcontactphone | html %]">Phone:</label>
741
742                                                 <input type="text" id="borrower_altcontactphone" name="borrower_altcontactphone" value="[% borrower.altcontactphone | html %]" class="[% required.altcontactphone | html %]" />
743                                                 <div class="required_label [% required.altcontactphone | html %]">Required</div>
744                                             </li>
745                                         [% END %]
746                                     </ol>
747                                 </fieldset>
748                             </div> <!-- /.col -->
749                         </div> <!-- /.row -->
750                     [% END %]
751
752                     [% UNLESS action == 'edit' || hidden.defined('password') %]
753                         <div class="row">
754                             <div class="col">
755                                 <fieldset class="rows" id="memberentry_password">
756                                     <legend id="contact_legend">Password</legend>
757                                     <div class="alert alert-info">
758                                         [% IF patron %]
759                                             [% IF ( patron.category.effective_require_strong_password ) %]
760                                                 <p>Your password must contain at least [% patron.category.effective_min_password_length | html %] characters, including UPPERCASE, lowercase and numbers.</p>
761                                             [% ELSE %]
762                                                 <p>Your password must be at least [% patron.category.effective_min_password_length | html %] characters long.</p>
763                                             [% END %]
764                                         [% ELSE %]
765                                             <p id="password_alert"></p>
766                                         [% END %]
767                                         [% UNLESS mandatory.defined('password') %]
768                                             <p>If you do not enter a password a system generated password will be created.</p>
769                                         [% END %]
770                                     </div>
771
772                                     <ol>
773                                         <li><label for="borrower_password" class="[% required.password | html %]">Password</label>
774                                             <input type="password" name="borrower_password" id="password" class="[% required.password | html %]" />
775                                             <div class="required_label [% required.password | html %]">Required</div>
776                                         </li>
777                                         <li><label for="borrower_password2" class="[% required.password | html %]">Confirm password</label>
778                                             <input type="password" name="borrower_password2" id="password2" />
779                                             <div class="required_label [% required.password | html %]">Required</div>
780                                         </li>
781                                     </ol>
782                                 </fieldset>
783                             </div> <!-- /.col -->
784                         </div> <!-- /.row -->
785                    [% END %]
786
787                     [% IF ( Koha.Preference('ExtendedPatronAttributes') && patron_attribute_classes.size && ! ( action == 'new' && Koha.Preference('PatronSelfRegistrationVerifyByEmail') ) ) %]
788                         <div class="row">
789                             <div class="col">
790                                 [% FOREACH pa_class IN patron_attribute_classes %]
791                                     [% IF pa_class.class %]
792                                         <fieldset id="aai_[% pa_loo.class | html %]" class="rows patron-attributes">
793                                             <legend>[% pa_class.lib | html %]</legend>
794                                     [% ELSE %]
795                                         <fieldset class="rows patron-attributes">
796                                             <legend>Additional information</legend>
797                                     [% END %]
798                                         <ol class="attributes_table">
799                                             [% FOREACH pa IN pa_class.items %]
800                                                 [% FOREACH pa_value IN pa.values %]
801                                                     [% IF loop.first %]<a name="patron-attr-start-[% pa.type.code | html %]"></a>[% END %]
802                                                     [% form_id = 'patron-attr-' _ Math.int( Math.rand(1000000) ) %]
803                                                     <li data-category_code="[% pa.type.category_code | html %]">
804                                                         [% IF pa.type.mandatory && pa.type.opac_editable %]
805                                                             <label for="[% form_id | html %]" class="required">[% pa.type.description | html %]: </label>
806                                                         [% ELSE %]
807                                                             <label for="[% form_id | html %]">[% pa.type.description | html %]: </label>
808                                                         [% END %]
809                                                         [% IF pa.type.opac_editable %]
810                                                             <input type="hidden" name="patron_attribute_code" value="[% pa.type.code | html %]" />
811                                                             [% IF ( pa.type.authorised_value_category ) %]
812                                                                 <select id="[% form_id | html %]" name="patron_attribute_value">
813                                                                     <option value=""></option>
814                                                                     [% FOREACH auth_val IN AuthorisedValues.Get( pa.type.authorised_value_category, 1 ) %]
815                                                                         [% IF ( auth_val.authorised_value == pa_value ) %]
816                                                                             <option value="[% auth_val.authorised_value | html %]" selected="selected">
817                                                                                 [% auth_val.lib | html %]
818                                                                             </option>
819                                                                         [% ELSE %]
820                                                                             <option value="[% auth_val.authorised_value | html %]" >
821                                                                                 [% auth_val.lib | html %]
822                                                                             </option>
823                                                                         [% END %]
824                                                                     [% END %]
825                                                                 </select>
826                                                             [% ELSE %]
827                                                                 <textarea rows="2" cols="30" id="[% form_id | html %]" name="patron_attribute_value">[% pa_value | html %]</textarea>
828                                                             [% END %]
829                                                             [% IF pa.type.mandatory %]
830                                                                 <div class="required">Required</div>
831                                                             [% END %]
832                                                             <a href="#" class="clear-attribute">Clear</a>
833                                                             [% IF ( pa.type.repeatable ) %]
834                                                             <a href="#" class="clone-attribute">New</a>
835                                                             [% END %]
836                                                         [% ELSE %]
837                                                             [% IF ( pa.type.authorised_value_category ) %]
838                                                                 [% AuthorisedValues.GetByCode( pa.type.authorised_value_category, pa_value, 1 ) | html_line_break %]
839                                                             [% ELSE %]
840                                                                 [% pa_value | html_line_break %]
841                                                             [% END %]
842                                                         [% END %]
843                                                     </li>
844                                                 [% END %]
845                                             [% END %]
846                                         </ol>
847                                     </fieldset>
848                                 [% END %]
849                             </div> <!-- /.col -->
850                         </div> <!-- /.row -->
851                     [% END %]
852
853                     [% IF Koha.Preference('GDPR_Policy') && action != 'edit' %]
854                         <div class="row">
855                             <div class="col">
856                                 <fieldset class="rows" id="memberentry_gdpr_consent">
857                                     <legend>GDPR consent</legend>
858                                     <ol>
859                                     <li>
860                                         <label></label><span><input type="checkbox" name="borrower_gdpr_proc_consent" value="agreed"> I agree with your processing of my personal data as outlined in the <a target="_blank" href="[% Koha.Preference('PrivacyPolicyURL') | url %]">privacy policy</a>. <div class="required">Required</div></span>
861                                     </li>
862                                     </ol>
863                                 </fieldset>
864                             </div> <!-- /.col -->
865                         </div> <!-- /.row -->
866                    [% END %]
867
868                    [% UNLESS action == 'edit' %]
869                         <div class="row">
870                             <div class="col">
871                                 <fieldset class="rows" id="memberentry_captcha">
872                                     <legend>Verification</legend>
873                                     <ol>
874
875                                         <li>
876                                             <label for="captcha" class="required">Verification:</label>
877
878                                             <input type="text" name="captcha" id="captcha" />
879                                             <div class="required_label required">Required</div>
880                                             <input type="hidden" name="captcha_digest" value="[% captcha_digest | html %]" />
881
882                                             <span class="hint">Please type the following characters into the preceding box: <strong>[% captcha | html %]</strong></span>
883                                         </li>
884                                     </ol>
885                                 </fieldset>
886                             </div> <!-- /.col -->
887                         </div> <!-- /.row -->
888                     [% END %]
889
890                     <div class="row">
891                         <div class="col">
892                             [% IF action == 'edit' %]
893                                 [% IF OPACPatronDetails %]
894                                     <fieldset class="action">
895                                         <input type="hidden" name="action" value="update" />
896                                         <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
897                                         <input type="submit" class="btn btn-primary" value="Submit update request" />
898                                     </fieldset>
899                                 [% END %]
900                             [% ELSE %]
901                                 <fieldset class="action">
902                                     <input type="hidden" name="action" value="create" />
903                                     <input type="submit" class="btn btn-primary" value="Submit" />
904                                 </fieldset>
905                             [% END %]
906                         </div> <!-- /.col -->
907                     </div> <!-- /.row -->
908
909                 </form>
910
911                     </div><!--/div#update-account -->
912                 </div>
913             </div>
914         </div>
915     </div>
916
917 [% INCLUDE 'opac-bottom.inc' %]
918 [% BLOCK jsinclude %]
919     [% INCLUDE 'validator-strings.inc' %]
920     [% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %]
921     [% INCLUDE 'calendar.inc' %]
922
923     <script>
924
925         $(document).ready(function() {
926             [% IF action == 'edit' && !OPACPatronDetails %]
927                 $("#memberentry-form :input").attr('readonly', true);
928                 $("#borrower_branchcode").attr('disabled',true);
929                 $("#borrower_title").attr('disabled',true);
930                 $('#memberentry-form :radio').attr('disabled',true);
931                 $('span.required').remove();
932                 $('label.required').removeClass('required');
933             [% END %]
934
935             $("#memberentry-form").validate({
936                 rules: {
937                     borrower_email: {
938                         email: true
939                     },
940                     borrower_repeat_email: {
941                         equalTo: '#borrower_email'
942                     },
943                     borrower_emailpro: {
944                         email: true
945                     },
946                     borrower_B_email: {
947                         email: true
948                     },
949                     borrower_password: {
950                         password_strong: true,
951                         password_no_spaces: true
952                     },
953                     borrower_password2: {
954                         password_match: true
955                     },
956                     captcha: {
957                         required: true,
958                     }
959                 },
960                 submitHandler: function(form) {
961                     if (form.beenSubmitted) {
962                         return false;
963                     }
964                     else {
965                         form.beenSubmitted = true;
966                         form.submit();
967                     }
968                 }
969             });
970
971             $("input.required,select.required,textarea.required").rules("add", {
972                 required: true
973             });
974
975             [% IF patron.guarantor_relationships && !Koha.Preference('OPACPrivacy') %]
976
977                 [% IF Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
978                     $('#update_privacy_guarantor_checkouts').click( function() {
979                         var can_see_checkouts = $('#privacy_guarantor_checkouts').val() == 1;
980                         $.ajax({
981                             url: "/api/v1/public/patrons/[% logged_in_user.borrowernumber | uri %]/guarantors/can_see_checkouts",
982                             type: "PUT",
983                             data: JSON.stringify({
984                                 allowed: can_see_checkouts
985                             }),
986                             contentType: "application/json",
987                             success: function () {
988                                 $('#update_privacy_guarantor_checkouts_message')
989                                     .fadeIn("slow")
990                                     .text(_("Your setting has been updated!"))
991                                     .delay(5000)
992                                     .fadeOut("slow");
993                             },
994                             error: function () {
995                                 $('#update_privacy_guarantor_checkouts_message')
996                                     .fadeIn("slow")
997                                     .text(_("Unable to update your setting!"))
998                                     .delay(5000)
999                                     .fadeOut("slow");
1000                             }
1001                         });
1002                     });
1003                 [% END %]
1004
1005                 [% IF Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor') %]
1006                     $('#update_privacy_guarantor_fines').click( function() {
1007                         var can_see_charges = $('#privacy_guarantor_fines').val() == 1;
1008                         $.ajax({
1009                             url: "/api/v1/public/patrons/[% logged_in_user.borrowernumber | uri %]/guarantors/can_see_charges",
1010                             type: 'PUT',
1011                             data: JSON.stringify({ 
1012                                 allowed: can_see_charges
1013                             }),
1014                             contentType: 'application/json',
1015                             success: function() {
1016                                 $('#update_privacy_guarantor_fines_message')
1017                                     .fadeIn("slow")
1018                                     .text( _("Your setting has been updated!") )
1019                                     .delay( 5000 )
1020                                     .fadeOut("slow");
1021                             },
1022                             error: function() {
1023                                 $('#update_privacy_guarantor_fines_message')
1024                                     .fadeIn("slow")
1025                                     .text( _("Unable to update your setting!") )
1026                                     .delay( 5000 )
1027                                     .fadeOut("slow");
1028                             }
1029                         });
1030                     });
1031                 [% END %]
1032             [% END %]
1033
1034             $(".patron-attributes").on( 'click', '.clear-attribute', function() {
1035                 $(this).parent()
1036                     .find('textarea').attr('value', '').end()
1037                     .find('select').attr('value', '').end();
1038
1039                 return false;
1040             } );
1041
1042             $(".patron-attributes").on( 'click', '.clone-attribute', function() {
1043                 var clone = $(this).parent().clone().insertAfter( $(this).parent() );
1044
1045                 var newId = 50 + parseInt(Math.random() * 100000);
1046                 $('input[type!="hidden"],select,textarea', clone).attr('id', 'patron-attr-' + newId).attr('value', '');
1047                 $("label", clone).attr('for', 'patron-attr-' + newId).attr('value', '');
1048
1049                 return false;
1050             } );
1051         });
1052
1053     $(".cleardate").on("click", function(){
1054         $('#borrower_dateofbirth').val('');
1055         return false;
1056     });
1057
1058     [% IF action != 'edit' and Koha.Preference('PatronSelfRegistrationConfirmEmail') %]
1059         $("#borrower_email").bind("cut copy paste", function(e){
1060             e.preventDefault();
1061             $("#borrower_email").bind("contextmenu", function(e){
1062                 e.preventDefault();
1063             });
1064         });
1065         $("#borrower_repeat_email").bind("cut copy paste", function(e){
1066             e.preventDefault();
1067             $("#borrower_repeat_email").bind("contextmenu", function(e){
1068                 e.preventDefault();
1069             });
1070         });
1071     [% END %]
1072
1073     [% UNLESS patron %]
1074         var PWD_STRONG_MSG = _("Password must contain at least %s characters, including UPPERCASE, lowercase and numbers");
1075         var PWD_WEAK_MSG = _("Password must contain at least %s characters");
1076         var default_password_length = [% defaultCategory.effective_min_password_length | html %];
1077         var default_strong_password = [% defaultCategory.effective_require_strong_password ? defaultCategory.effective_require_strong_password : 0 | html %];
1078         $(document).ready(function() {
1079             var setPwdMessage = function() {
1080                 var require_strong = $('select#borrower_categorycode option:selected').length ? $('select#borrower_categorycode option:selected').data('pwdStrong') : default_strong_password;
1081                 var min_length = $('select#borrower_categorycode option:selected').length ? $('select#borrower_categorycode option:selected').data('pwdLength') : default_password_length;
1082                 $('#password_alert').html((require_strong?PWD_STRONG_MSG:PWD_WEAK_MSG).format(min_length));
1083             };
1084             setPwdMessage();
1085             $('select#borrower_categorycode').change(setPwdMessage);
1086         });
1087     [% END %]
1088
1089     </script>
1090     [% PROCESS 'password_check.inc' new_password => 'borrower_password', category_selector => '#borrower_categorycode', RequireStrongPassword => patron ? patron.category.effective_require_strong_password : defaultCategory.effective_require_strong_password, minPasswordLength => patron ? patron.category.effective_min_password_length : defaultCategory.effective_min_password_length %]
1091
1092 [% END %]