Bug 32282: Fixed capitalisation of ID in User ID
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / modborrowers.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% USE Categories %]
7 [% USE TablesSettings %]
8 [% SET footerjs = 1 %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Batch patron modification &rsaquo; Tools &rsaquo; Koha</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 </head>
13
14 <body id="tools_modborrowers" class="tools">
15 [% WRAPPER 'header.inc' %]
16     [% INCLUDE 'cat-search.inc' %]
17 [% END %]
18
19 [% WRAPPER 'sub-header.inc' %]
20 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
21     <ol>
22         <li>
23             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
24         </li>
25         <li>
26             <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
27         </li>
28         <li>
29             <a href="#" aria-current="page">Batch patron modification</a>
30         </li>
31     </ol>
32 </nav>
33 [% END %]
34
35 <div class="main container-fluid">
36     <div class="row">
37         <div class="col-sm-10 col-sm-push-2">
38             <main>
39
40                 [% IF ( op == 'show_form' ) %]
41                 <h1>Batch patron modification</h1>
42                 <form id="patron_batchmod_form" method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
43                     <input type="hidden" name="op" value="show" />
44                     <div id="batch_patron_options" class="toptabs">
45                         <ul class="nav nav-tabs" role="tablist">
46                             <li role="presentation" class="active">
47                                 <a href="#usecardnumber" aria-controls="usecardnumber" role="tab" data-toggle="tab">By card number</a>
48                             </li>
49                             <li role="presentation">
50                                 <a href="#useborrowernumber" aria-controls="useborrowernumber" role="tab" data-toggle="tab">By borrowernumber</a>
51                             </li>
52                             [% IF patron_lists %]
53                                 <li role="presentation">
54                                     <a href="#uselist" aria-controls="uselist" role="tab" data-toggle="tab">By patron list</a>
55                                 </li>
56                             [% END %]
57                         </ul>
58                         <div class="tab-content">
59                             <div id="usecardnumber" role="tabpanel" class="tab-pane active">
60                                 <fieldset class="rows">
61                                     <legend>Use a file of card numbers</legend>
62                                     <ol>
63                                         <li>
64                                             <label for="cardnumberuploadfile">File: </label> <input type="file"
65                                                 id="cardnumberuploadfile" name="cardnumberuploadfile" />
66                                             <div class="hint">File must contain one card number per line.</div>
67                                         </li>
68                                     </ol>
69                                 </fieldset>
70                                 <fieldset class="rows">
71                                     <legend>Or list card numbers one by one</legend>
72                                     <ol>
73                                         <li>
74                                             <label for="cardnumberlist">Card number list (one card number per line):
75                                             </label>
76                                             <textarea rows="10" cols="30" id="cardnumberlist"
77                                                 name="cardnumberlist">[% cardnumberlist | html %]</textarea>
78                                         </li>
79                                     </ol>
80                                 </fieldset>
81                                 <fieldset class="action">
82                                     <input type="submit" class="btn btn-primary" value="Continue" />
83                                     <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
84                                 </fieldset>
85                             </div>
86                             <div id="useborrowernumber" role="tabpanel" class="tab-pane">
87                                 <fieldset class="rows">
88                                     <legend>Use a file of borrowernumbers</legend>
89                                     <ol>
90                                         <li>
91                                             <label for="borrowernumberuploadfile">File: </label> <input type="file"
92                                                 id="borrowernumberuploadfile" name="borrowernumberuploadfile" />
93                                             <div class="hint">File must contain one borrowernumber per line.</div>
94                                         </li>
95                                     </ol>
96                                 </fieldset>
97                                 <fieldset class="rows">
98                                     <legend>List borrowernumbers one by one</legend>
99                                     <ol>
100                                         <li>
101                                             <label for="borrowernumberlist">Borrowernumber list (one number per line):
102                                             </label>
103                                             <textarea rows="10" cols="30" id="borrowernumberlist"
104                                                 name="borrowernumberlist">[% borrowernumberlist | html %]</textarea>
105                                         </li>
106                                     </ol>
107                                 </fieldset>
108                                 <fieldset class="action">
109                                     <input type="submit" class="btn btn-primary" value="Continue" />
110                                     <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
111                                 </fieldset>
112                             </div>
113                             [% IF patron_lists %]
114                                 <div id="uselist" role="tabpanel" class="tab-pane">
115                                     <fieldset class="rows">
116                                         <legend>Use a patron list</legend>
117                                         <ol>
118                                             <li>
119                                                 <label for="patron_list_id">Patron list: </label>
120                                                 <select id="patron_list_id" name="patron_list_id">
121                                                     <option value=""> -- Choose a patron list -- </option>
122                                                     [% FOREACH pl IN patron_lists %]
123                                                     <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
124                                                     [% END %]
125                                                 </select>
126                                             </li>
127                                         </ol>
128                                     </fieldset>
129                                     <fieldset class="action">
130                                         <input type="submit" class="btn btn-primary" value="Continue" />
131                                         <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
132                                     </fieldset>
133                                 </div>
134                             [% END %]
135                         </div> <!-- /.tab-content -->
136                     </div><!-- /#batch_patron_options -->
137                 </form>
138                 [% END %]
139
140                 [% IF ( op == 'show') && (!borrowers) && (!notfoundcardnumbers) # Alert if no patrons given%]
141                     [% op = 'noshow' # Change op to prevent display in code below %]
142                     <h1>Batch patrons modification</h1>
143                     <div class="dialog alert">
144                         <p>No patron card numbers or borrowernumbers given.</p>
145                         <form action="/cgi-bin/koha/tools/modborrowers.pl" method="get">
146                          <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
147                         </form>
148                     </div>
149                 [% END #Alert if no patrons %]
150
151                 [% IF ( op == 'show' or op == 'show_results' ) %]
152                     [% IF ( op == 'show' ) %]
153                         <h1>Batch patrons modification</h1>
154                     [% ELSE %]
155                         <h1>Batch patrons results</h1>
156                     [% END %]
157                     [% IF ( notfoundcardnumbers ) %]
158                         [% IF ( useborrowernumbers ) -%]
159                             <div class="dialog alert"><p>Warning, the following borrowernumbers were not found:</p></div>
160                         [% ELSE -%]
161                             <div class="dialog alert"><p>Warning, the following card numbers were not found:</p></div>
162                         [% END %]
163
164                         <div class="page-section">
165                             <table style="margin:auto;">
166                                 <thead>
167                                     [% IF ( useborrowernumbers ) -%]
168                                         <tr><th>Borrowernumbers not found</th></tr>
169                                     [% ELSE -%]
170                                         <tr><th>Card numbers not found</th></tr>
171                                     [% END %]
172                                 </thead>
173                                 <tbody>
174                                     [% FOREACH notfoundcardnumber IN notfoundcardnumbers %]
175                                         <tr><td>[% notfoundcardnumber.cardnumber | html %]</td></tr>
176                                     [% END %]
177                                 </tbody>
178                             </table>
179                         </div> <!-- /.page-section -->
180                     [% END %]
181
182                     [% IF ( op == 'show_results' ) %]
183                         [% IF ( errors ) %]
184                             <div class="dialog alert">
185                             <h4>Errors occurred:</h4>
186                             <ul class="warnings">
187                             [% FOREACH error IN errors %]
188                                 [% IF ( error.error == 'can_not_update' ) %]
189                                     <li>Can not update patron.
190                                     [% IF ( error.cardnumber ) %] Card number:  [% error.cardnumber | html %] [% END %]
191                                     (Borrowernumber: [% error.borrowernumber | html %])
192                                     </li>
193                                 [% ELSE %]
194                                     <li>[% error.error | html %]</li>
195                                 [% END %]
196                             [% END %]
197                             </ul>
198                             </div>
199                         [% END %]
200                     [% END %]
201
202                     [% IF ( op == 'show' ) %]
203                     <form name="f" action="modborrowers.pl" method="post">
204                         <input type="hidden" name="op" value="do" />
205                         [% IF ( borrowers ) %]
206                             <div class="btn-toolbar selections-toolbar"><a id="selectallbutton" href="#"><i class="fa fa-check"></i> Select all</a> | <a id="clearallbutton" href="#"><i class="fa fa-remove"></i> Clear all</a></div>
207                         [% END %]
208                     [% END %]
209                         [% IF borrowers %]
210                             <div id="cataloguing_additem_itemlist" class="page-section">
211                                 <div style="overflow:auto">
212                                     <table id="borrowerst">
213                                         <thead>
214                                             <tr>
215                                                 [% IF ( op == 'show' ) %]
216                                                     <th class="NoSort">&nbsp;</th>
217                                                 [% ELSE %]
218                                                     <th class="NoVisible">&nbsp;</th>
219                                                 [% END %]
220                                                 <th>Card number</th>
221                                                 <th>Surname</th>
222                                                 <th>First name</th>
223                                                 <th>Library</th>
224                                                 <th>Patron category</th>
225                                                 <th>Street number</th>
226                                                 <th>Address</th>
227                                                 <th>Address 2</th>
228                                                 <th>City</th>
229                                                 <th>State</th>
230                                                 <th>ZIP/Postal code</th>
231                                                 <th>Country</th>
232                                                 <th>Primary email</th>
233                                                 <th>Phone</th>
234                                                 <th>Mobile</th>
235                                                 <th>Registration date</th>
236                                                 <th>Expiry date</th>
237                                                 [% IF CanUpdatePasswordExpiration %]
238                                                     <th>Password expiration date</th>
239                                                 [% END %]
240                                                 <th>Circulation note</th>
241                                                 <th>OPAC note</th>
242                                                 <th>Restriction expiration</th>
243                                                 <th>Restriction comment</th>
244                                                 [% FOREACH attrh IN attributes_header %]
245                                                     <th>[% attrh.attribute | html %]</th>
246                                                 [% END %]
247                                             </tr>
248                                         </thead>
249                                         <tbody>
250                                             [% FOREACH borrower IN borrowers %]
251                                                 <tr>
252                                                     [% IF ( op == 'show' ) %]
253                                                         <td>
254                                                     [% ELSE %]
255                                                         <td class="NoVisible">
256                                                     [% END %]
257                                                         <input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber | html %]" checked="checked" />
258                                                     </td>
259                                                     <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | uri %]">[% borrower.cardnumber | html %]</a></td>
260                                                     <td>[% borrower.surname | html %]</td>
261                                                     <td>[% borrower.firstname | html %]</td>
262                                                     <td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
263                                                     <td>[% Categories.GetName(borrower.categorycode) | html %]</td>
264                                                     <td>[% borrower.streetnumber | html %]</td>
265                                                     <td>[% borrower.address | html %]</td>
266                                                     <td>[% borrower.address2 | html %]</td>
267                                                     <td>[% borrower.city | html %]</td>
268                                                     <td>[% borrower.state | html %]</td>
269                                                     <td>[% borrower.zipcode | html %]</td>
270                                                     <td>[% borrower.country | html %]</td>
271                                                     <td>[% borrower.email | html %]</td>
272                                                     <td>[% borrower.phone | html %]</td>
273                                                     <td>[% borrower.mobile | html %]</td>
274                                                     <td data-order="[% borrower.dateenrolled | html %]">[% borrower.dateenrolled | $KohaDates %]</td>
275                                                     <td data-order="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</td>
276                                                     [% IF CanUpdatePasswordExpiration %]
277                                                         [% IF borrower.password_expiration_date  %]
278                                                             <td data-order="[% borrower.password_expiration_date | html %]">
279                                                                 [% borrower.password_expiration_date | $KohaDates %]
280                                                             </td>
281                                                         [% ELSE %]
282                                                             <td data-order="9999-99-99">Never</td>
283                                                         [% END %]
284                                                     [% END %]
285                                                     <td>[% borrower.borrowernotes | html %]</td>
286                                                     <td>[% borrower.opacnote | html %]</td>
287                                                     <td data-order="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</td>
288                                                     <td>[% borrower.debarredcomment | html %]</td>
289                                                     [% FOREACH pa IN borrower.patron_attributes %]
290                                                         [% IF ( pa.code ) %]
291                                                         [%# Replace pa.attribute with pa.description if we prefer to display the description %]
292                                                             <td>[% pa.code | html %]=[% pa.attribute | html %]</td>
293                                                         [% ELSE %]
294                                                             <td></td>
295                                                         [% END %]
296                                                     [% END %]
297                                                 </tr>
298                                             [% END %]
299                                         </tbody>
300                                     </table>
301                                 </div>
302                             </div>
303
304                             [% IF ( op == 'show' ) %]
305                             <div id="cataloguing_additem_newitem">
306                                 <h2>Edit patrons</h2>
307                                 <div class="hint">Checking the box right next to the label will disable the entry and delete the values of that field on all selected patrons</div>
308                                 <fieldset class="rows" id="fields_list">
309                                     <ol>
310                                         [% FOREACH field IN fields %]
311                                         <li>
312                                             [% IF ( field.mandatory ) %]
313                                             <label for="[% field.name | html %]" class="required">
314                                             [% ELSE %]
315                                             <label for="[% field.name | html %]">
316                                             [% END %]
317                                             [% SWITCH ( field.name ) %]
318                                                 [% CASE 'surname' %]<span>Surname:</span>
319                                                 [% CASE 'firstname' %]<span>First name:</span>
320                                                 [% CASE 'branchcode' %]<span>Library:</span>
321                                                 [% CASE 'categorycode' %]<span>Patron category:</span>
322                                                 [% CASE 'streetnumber' %]<span>Street number:</span>
323                                                 [% CASE 'address' %]<span>Address:</span>
324                                                 [% CASE 'address2' %]<span>Address 2:</span>
325                                                 [% CASE 'city' %]<span>City:</span>
326                                                 [% CASE 'state' %]<span>State:</span>
327                                                 [% CASE 'zipcode' %]<span>ZIP/Postal code:</span>
328                                                 [% CASE 'country' %]<span>Country:</span>
329                                                 [% CASE 'email' %]<span>Primary email:</span>
330                                                 [% CASE 'phone' %]<span>Phone:</span>
331                                                 [% CASE 'mobile' %]<span>Mobile:</span>
332                                                 [% CASE 'sort1' %]<span>Sort 1:</span>
333                                                 [% CASE 'sort2' %]<span>Sort 2:</span>
334                                                 [% CASE 'dateenrolled' %]<span>Registration date:</span>
335                                                 [% CASE 'dateexpiry' %]<span>Expiry date:</span>
336                                                 [% CASE 'borrowernotes' %]<span>Circulation note:</span>
337                                                 [% CASE 'opacnote' %]<span>OPAC note:</span>
338                                                 [% CASE 'debarred' %]<span>Restriction expiration:</span>
339                                                 [% CASE 'debarredcomment' %]<span>Restriction comment:</span>
340                                                 [% CASE 'password_expiration_date' %]<span>Password expiration date:</span>
341                                             [% END %]
342                                             </label>
343                                             [% IF ( field.type == 'text' ) %]
344                                                 <input type="text" name="[% field.name | html %]" value="" />
345                                             [% END %]
346                                             [% IF ( field.type == 'select' ) %]
347                                                 [% IF field.option.size %]
348                                                     <select name="[% field.name | html %]" >
349                                                         [% FOREACH opt IN field.option %]
350                                                             <option value="[% opt.value | html %]">[% opt.lib | html %]</option>
351                                                         [% END %]
352                                                     </select>
353                                                 [% ELSE %]
354                                                     There is no value defined for [% field.name | html %]
355                                                 [% END %]
356                                             [% END %]
357                                             [% IF ( field.type == 'date' ) %]
358                                                 <input type="text" name="[% field.name | html %]" id="[% field.name | html %]" value="" size="10" maxlength="10" class="flatpickr" />
359                                                 <a href="#"  class="clear-date" id="clear-date-[% field.name | html %]" ><i class="fa fa-fw fa-trash"></i> Clear</a>
360                                             [% END %]
361                                             [% IF field.mandatory %]
362                                                 <input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name | html %]" disabled="disabled" readonly="readonly" />
363                                                 <span class="required">Required fields cannot be cleared</span>
364                                             [% ELSE %]
365                                                 <input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name | html %]" />
366                                             [% END %]
367                                         </li>
368                                         [% END %]
369                                         [% IF ( patron_attributes_codes ) %]
370                                             <li class="attributes">
371                                                 <label style="width:auto;">Patron attribute:
372                                                     <select name="patron_attributes">
373                                                         <option value=""></option>
374                                                         [% FOREACH pac IN patron_attributes_codes %]
375                                                             <option value="[% pac.attribute_code | html %]" data-type="[% pac.type | html %]" data-category="[% pac.category_lib | html %]">[% pac.attribute_lib | html %]</option>
376                                                         [% END %]
377                                                     </select>
378                                                 </label>
379                                                 <input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
380                                                 <span class="patron_attributes_value"><input type"hidden" name="patron_attributes_value" /></span>
381                                                 <a href="#" class="add_attributes" title="Add an attribute"><i class="fa fa-fw fa-plus"></i> New</a>
382                                                 <span class="information_category hint" style="width:25%;float:right;"></span>
383                                             </li>
384                                         [% END %]
385                                     </ol>
386                                 </fieldset>
387                                 <fieldset class="action">
388                                     <input type="submit" name="mainformsubmit" class="btn btn-primary" value="Save" />
389                                     <a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
390                                 </fieldset>
391                             </div>
392                         </form>
393                         [% END %]
394                     [% END %]
395                 [% END %]
396                 [% IF ( op == 'show_results' ) %]
397                 <p>
398                     <a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
399                 </p>
400                 [% END %]
401
402             </main>
403         </div> <!-- /.col-sm-10.col-sm-push-2 -->
404
405         <div class="col-sm-2 col-sm-pull-10">
406             <aside>
407                 [% INCLUDE 'tools-menu.inc' %]
408             </aside>
409         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
410      </div> <!-- /.row -->
411
412 [% MACRO jsinclude BLOCK %]
413     [% INCLUDE 'calendar.inc' %]
414     [% INCLUDE 'datatables.inc' %]
415     [% INCLUDE 'columns_settings.inc' %]
416     [% Asset.js("js/tools-menu.js") | $raw %]
417     <script>
418         var patron_attributes_lib = new Array();
419         var patron_attributes_values = new Array();
420         var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'batch_patron_modification', 'borrowerst', 'json' ) | $raw %];
421         [% FOREACH attrh IN attributes_header %]
422             table_settings.push({
423                 columname: "[% attrh.attribute | html %]",
424                 cannot_be_modified: 0,
425                 cannot_be_toggled: 0,
426                 is_hidden: 0
427             });
428         [% END %]
429         $(document).ready(function() {
430             [% IF borrowers %]
431                 let patron_table = KohaTable("borrowerst", {
432                     "order": [[ 1, "asc" ]],
433                     "autoWidth": false,
434                 }, table_settings);
435
436                 $("#selectallbutton").click(function() {
437                     $("#borrowerst").find("input:checkbox").each(function() {
438                         $(this).prop("checked", true);
439                     });
440                     return false;
441                 });
442                 $("#clearallbutton").click(function() {
443                     $("#borrowerst").find("input:checkbox").each(function() {
444                         $(this).prop("checked", false);
445                     });
446                     return false;
447                 });
448             [% END %]
449
450             var values = new Array();
451             var lib = new Array();
452             [% FOREACH pav IN patron_attributes_values %]
453                 values = new Array();
454                 lib = new Array();
455                 [% FOREACH option IN pav.options %]
456                     values.push("[% option.lib | html %]");
457                     lib.push("[% option.authorised_value | html %]");
458                 [% END %]
459                 patron_attributes_lib["[% pav.attribute_code | html %]"] = values;
460                 patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
461             [% END %]
462
463             $('select[name="patron_attributes"]').change(function() {
464                 updateAttrValues(this);
465             } );
466
467             $('select[name="patron_attributes"]').change();
468
469             $(".clear-date").on("click",function(e){
470                 e.preventDefault();
471                 var fieldID = this.id.replace("clear-date-","");
472                 $("#" + fieldID).val("");
473             });
474             $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
475                 e.preventDefault();
476                 add_attributes();
477             });
478             $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
479                 e.preventDefault();
480                 del_attributes(this);
481             });
482             $("#patron_batchmod_form").on("submit", function(){
483                 /* Reset form fields on inactive tabs */
484                 var tab = $(this).find('ul.nav-tabs li.active a').attr('href');
485                 if ( tab == '#usecardnumber' ) {
486                     $("#borrowernumberuploadfile, #patron_list_id, #borrowernumberlist").val("");
487                 } else if ( tab == '#useborrowernumber' ) {
488                     $("#cardnumberuploadfile, #cardnumberlist, #patron_list_id").val("");
489                 } else { // uselist
490                     $("#borrowernumberuploadfile, #cardnumberuploadfile, #borrowernumberlist, #cardnumberlist").val("");
491                 }
492             });
493
494             $('form[name="f"]').on("submit", function(){
495                 // Add the checkboxes to the DOM before we submit the form
496                 var form = this;
497                 var checkboxes = patron_table.$('input:checkbox:checked').serializeArray();
498                 $.each(checkboxes, function(){
499                     let borrowernumber = this.value;
500                     if(!$(form).find('input[name="borrowernumber"][value="'+borrowernumber+'"]').length){
501                         $(form).append(
502                             $('<input>')
503                                 .attr('type', 'hidden')
504                                 .attr('name', 'borrowernumber')
505                                 .val(borrowernumber)
506                         );
507                     }
508                 });
509             });
510         });
511
512         function updateAttrValues (select_attr) {
513             var attr_code = $(select_attr).val();
514             var selected_option = $(select_attr).find("option:selected");
515             var type = $(selected_option).attr('data-type');
516             var category = $(selected_option).attr('data-category');
517             var li_node = $(select_attr).parent().parent();
518             var span = $(li_node).find('span.patron_attributes_value');
519             var information_category_node = $(li_node).find('span.information_category');
520             information_category_node.html("");
521
522             if ( category && category.length > 0 ) {
523                 information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
524             }
525             var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
526             if ( type == 'select' ) {
527                 var options = '<option value = ""></option>';
528                 for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
529                     options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
530                 }
531                 span.html('<select name="patron_attributes_value">' + options + '</select>');
532                 $(disable_input_node).show();
533             } else if ( $(selected_option).val() != "" ) {
534                 span.html('<input type="text" name="patron_attributes_value"/>');
535                 $(disable_input_node).show();
536             } else {
537                 span.html('<input type="hidden" name="patron_attributes_value" />');
538                 $(disable_input_node).hide();
539             }
540         }
541
542         function add_attributes() {
543             var li_node = $("li.attributes:last");
544             var li_clone = $(li_node).clone();
545             if ( $(li_clone).find("a.del_attributes").length == 0 ) {
546                 $(li_clone).append('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash"></i> ' + _("Delete") + '</a>');
547             }
548             $(li_clone).find('select[name="patron_attributes"]').change(function() {
549                 updateAttrValues(this);
550             } );
551
552             $(li_clone).find('select[name="patron_attributes"]').change();
553
554             $("#fields_list>ol").append(li_clone);
555             update_attr_values();
556         }
557
558         function del_attributes(a_node) {
559             $(a_node).parent('li').remove();
560             update_attr_values();
561         }
562
563         function update_attr_values() {
564             $("li.attributes").each(function(i) {
565                 $(this).find("input:checkbox").val("attr"+i+"_value");
566             });
567         }
568         function clearDate(nodeid) {
569             $("#"+nodeid).val("");
570         }
571     </script>
572 [% END %]
573
574 [% INCLUDE 'intranet-bottom.inc' %]