Bug 30952: Staff interface redesign (header)
[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"><i class="fa fa-home"></i></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" value="Continue" class="button" />
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" value="Continue" class="button" />
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" value="Continue" class="button" />
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                         <table style="margin:auto;">
165                             <thead>
166                                 [% IF ( useborrowernumbers ) -%]
167                                     <tr><th>Borrowernumbers not found</th></tr>
168                                 [% ELSE -%]
169                                     <tr><th>Card numbers not found</th></tr>
170                                 [% END %]
171                             </thead>
172                             <tbody>
173                                 [% FOREACH notfoundcardnumber IN notfoundcardnumbers %]
174                                     <tr><td>[% notfoundcardnumber.cardnumber | html %]</td></tr>
175                                 [% END %]
176                             </tbody>
177                         </table>
178                     [% END %]
179
180                     [% IF ( op == 'show_results' ) %]
181                         [% IF ( errors ) %]
182                             <div class="dialog alert">
183                             <h4>Errors occurred:</h4>
184                             <ul class="warnings">
185                             [% FOREACH error IN errors %]
186                                 [% IF ( error.error == 'can_not_update' ) %]
187                                     <li>Can not update patron.
188                                     [% IF ( error.cardnumber ) %] Card number:  [% error.cardnumber | html %] [% END %]
189                                     (Borrowernumber: [% error.borrowernumber | html %])
190                                     </li>
191                                 [% ELSE %]
192                                     <li>[% error.error | html %]</li>
193                                 [% END %]
194                             [% END %]
195                             </ul>
196                             </div>
197                         [% END %]
198                     [% END %]
199
200                     [% IF ( op == 'show' ) %]
201                     <form name="f" action="modborrowers.pl" method="post">
202                         <input type="hidden" name="op" value="do" />
203                         [% IF ( borrowers ) %]
204                             <div id="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>
205                         [% END %]
206                     [% END %]
207                         [% IF borrowers %]
208                             <div id="cataloguing_additem_itemlist">
209                                 <div style="overflow:auto">
210                                     <table id="borrowerst">
211                                         <thead>
212                                             <tr>
213                                                 [% IF ( op == 'show' ) %]
214                                                     <th class="NoSort">&nbsp;</th>
215                                                 [% ELSE %]
216                                                     <th class="NoVisible">&nbsp;</th>
217                                                 [% END %]
218                                                 <th>Card number</th>
219                                                 <th>Surname</th>
220                                                 <th>First name</th>
221                                                 <th>Library</th>
222                                                 <th>Patron category</th>
223                                                 <th>Street number</th>
224                                                 <th>Address</th>
225                                                 <th>Address 2</th>
226                                                 <th>City</th>
227                                                 <th>State</th>
228                                                 <th>ZIP/Postal code</th>
229                                                 <th>Country</th>
230                                                 <th>Primary email</th>
231                                                 <th>Phone</th>
232                                                 <th>Mobile</th>
233                                                 <th>Registration date</th>
234                                                 <th>Expiry date</th>
235                                                 [% IF CanUpdatePasswordExpiration %]
236                                                     <th>Password expiration date</th>
237                                                 [% END %]
238                                                 <th>Circulation note</th>
239                                                 <th>OPAC note</th>
240                                                 <th>Restriction expiration</th>
241                                                 <th>Restriction comment</th>
242                                                 [% FOREACH attrh IN attributes_header %]
243                                                     <th>[% attrh.attribute | html %]</th>
244                                                 [% END %]
245                                             </tr>
246                                         </thead>
247                                         <tbody>
248                                             [% FOREACH borrower IN borrowers %]
249                                                 <tr>
250                                                     [% IF ( op == 'show' ) %]
251                                                         <td>
252                                                     [% ELSE %]
253                                                         <td class="NoVisible">
254                                                     [% END %]
255                                                         <input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber | html %]" checked="checked" />
256                                                     </td>
257                                                     <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | uri %]">[% borrower.cardnumber | html %]</a></td>
258                                                     <td>[% borrower.surname | html %]</td>
259                                                     <td>[% borrower.firstname | html %]</td>
260                                                     <td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
261                                                     <td>[% Categories.GetName(borrower.categorycode) | html %]</td>
262                                                     <td>[% borrower.streetnumber | html %]</td>
263                                                     <td>[% borrower.address | html %]</td>
264                                                     <td>[% borrower.address2 | html %]</td>
265                                                     <td>[% borrower.city | html %]</td>
266                                                     <td>[% borrower.state | html %]</td>
267                                                     <td>[% borrower.zipcode | html %]</td>
268                                                     <td>[% borrower.country | html %]</td>
269                                                     <td>[% borrower.email | html %]</td>
270                                                     <td>[% borrower.phone | html %]</td>
271                                                     <td>[% borrower.mobile | html %]</td>
272                                                     <td data-order="[% borrower.dateenrolled | html %]">[% borrower.dateenrolled | $KohaDates %]</td>
273                                                     <td data-order="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</td>
274                                                     [% IF CanUpdatePasswordExpiration %]
275                                                         [% IF borrower.password_expiration_date  %]
276                                                             <td data-order="[% borrower.password_expiration_date | html %]">
277                                                                 [% borrower.password_expiration_date | $KohaDates %]
278                                                             </td>
279                                                         [% ELSE %]
280                                                             <td data-order="9999-99-99">Never</td>
281                                                         [% END %]
282                                                     [% END %]
283                                                     <td>[% borrower.borrowernotes | html %]</td>
284                                                     <td>[% borrower.opacnote | html %]</td>
285                                                     <td data-order="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</td>
286                                                     <td>[% borrower.debarredcomment | html %]</td>
287                                                     [% FOREACH pa IN borrower.patron_attributes %]
288                                                         [% IF ( pa.code ) %]
289                                                         [%# Replace pa.attribute with pa.description if we prefer to display the description %]
290                                                             <td>[% pa.code | html %]=[% pa.attribute | html %]</td>
291                                                         [% ELSE %]
292                                                             <td></td>
293                                                         [% END %]
294                                                     [% END %]
295                                                 </tr>
296                                             [% END %]
297                                         </tbody>
298                                     </table>
299                                 </div>
300                             </div>
301
302                             [% IF ( op == 'show' ) %]
303                             <div id="cataloguing_additem_newitem">
304                                 <h2>Edit patrons</h2>
305                                 <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>
306                                 <fieldset class="rows" id="fields_list">
307                                     <ol>
308                                         [% FOREACH field IN fields %]
309                                         <li>
310                                             [% IF ( field.mandatory ) %]
311                                             <label for="[% field.name | html %]" class="required">
312                                             [% ELSE %]
313                                             <label for="[% field.name | html %]">
314                                             [% END %]
315                                             [% SWITCH ( field.name ) %]
316                                                 [% CASE 'surname' %]<span>Surname:</span>
317                                                 [% CASE 'firstname' %]<span>First name:</span>
318                                                 [% CASE 'branchcode' %]<span>Library:</span>
319                                                 [% CASE 'categorycode' %]<span>Patron category:</span>
320                                                 [% CASE 'streetnumber' %]<span>Street number:</span>
321                                                 [% CASE 'address' %]<span>Address:</span>
322                                                 [% CASE 'address2' %]<span>Address 2:</span>
323                                                 [% CASE 'city' %]<span>City:</span>
324                                                 [% CASE 'state' %]<span>State:</span>
325                                                 [% CASE 'zipcode' %]<span>ZIP/Postal code:</span>
326                                                 [% CASE 'country' %]<span>Country:</span>
327                                                 [% CASE 'email' %]<span>Primary email:</span>
328                                                 [% CASE 'phone' %]<span>Phone:</span>
329                                                 [% CASE 'mobile' %]<span>Mobile:</span>
330                                                 [% CASE 'sort1' %]<span>Sort 1:</span>
331                                                 [% CASE 'sort2' %]<span>Sort 2:</span>
332                                                 [% CASE 'dateenrolled' %]<span>Registration date:</span>
333                                                 [% CASE 'dateexpiry' %]<span>Expiry date:</span>
334                                                 [% CASE 'borrowernotes' %]<span>Circulation note:</span>
335                                                 [% CASE 'opacnote' %]<span>OPAC note:</span>
336                                                 [% CASE 'debarred' %]<span>Restriction expiration:</span>
337                                                 [% CASE 'debarredcomment' %]<span>Restriction comment:</span>
338                                                 [% CASE 'password_expiration_date' %]<span>Password expiration date:</span>
339                                             [% END %]
340                                             </label>
341                                             [% IF ( field.type == 'text' ) %]
342                                                 <input type="text" name="[% field.name | html %]" value="" />
343                                             [% END %]
344                                             [% IF ( field.type == 'select' ) %]
345                                                 [% IF field.option.size %]
346                                                     <select name="[% field.name | html %]" >
347                                                         [% FOREACH opt IN field.option %]
348                                                             <option value="[% opt.value | html %]">[% opt.lib | html %]</option>
349                                                         [% END %]
350                                                     </select>
351                                                 [% ELSE %]
352                                                     There is no value defined for [% field.name | html %]
353                                                 [% END %]
354                                             [% END %]
355                                             [% IF ( field.type == 'date' ) %]
356                                                 <input type="text" name="[% field.name | html %]" id="[% field.name | html %]" value="" size="10" maxlength="10" class="flatpickr" />
357                                                 <a href="#"  class="clear-date" id="clear-date-[% field.name | html %]" ><i class="fa fa-fw fa-trash"></i> Clear</a>
358                                             [% END %]
359                                             [% IF field.mandatory %]
360                                                 <input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name | html %]" disabled="disabled" readonly="readonly" />
361                                                 <span class="required">Required fields cannot be cleared</span>
362                                             [% ELSE %]
363                                                 <input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name | html %]" />
364                                             [% END %]
365                                         </li>
366                                         [% END %]
367                                         [% IF ( patron_attributes_codes ) %]
368                                             <li class="attributes">
369                                                 <label style="width:auto;">Patron attribute:
370                                                     <select name="patron_attributes">
371                                                         <option value=""></option>
372                                                         [% FOREACH pac IN patron_attributes_codes %]
373                                                             <option value="[% pac.attribute_code | html %]" data-type="[% pac.type | html %]" data-category="[% pac.category_lib | html %]">[% pac.attribute_lib | html %]</option>
374                                                         [% END %]
375                                                     </select>
376                                                 </label>
377                                                 <input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
378                                                 <span class="patron_attributes_value"><input type"hidden" name="patron_attributes_value" /></span>
379                                                 <a href="#" class="add_attributes" title="Add an attribute"><i class="fa fa-fw fa-plus"></i> New</a>
380                                                 <span class="information_category hint" style="width:25%;float:right;"></span>
381                                             </li>
382                                         [% END %]
383                                     </ol>
384                                 </fieldset>
385                                 <fieldset class="action">
386                                     <input type="submit" name="mainformsubmit" value="Save" />
387                                     <a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
388                                 </fieldset>
389                             </div>
390                         </form>
391                         [% END %]
392                     [% END %]
393                 [% END %]
394                 [% IF ( op == 'show_results' ) %]
395                 <p>
396                     <a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
397                 </p>
398                 [% END %]
399
400             </main>
401         </div> <!-- /.col-sm-10.col-sm-push-2 -->
402
403         <div class="col-sm-2 col-sm-pull-10">
404             <aside>
405                 [% INCLUDE 'tools-menu.inc' %]
406             </aside>
407         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
408      </div> <!-- /.row -->
409
410 [% MACRO jsinclude BLOCK %]
411     [% INCLUDE 'calendar.inc' %]
412     [% INCLUDE 'datatables.inc' %]
413     [% INCLUDE 'columns_settings.inc' %]
414     [% Asset.js("js/tools-menu.js") | $raw %]
415     <script>
416         var patron_attributes_lib = new Array();
417         var patron_attributes_values = new Array();
418         var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'batch_patron_modification', 'borrowerst', 'json' ) | $raw %];
419         [% FOREACH attrh IN attributes_header %]
420             table_settings.push({
421                 columname: "[% attrh.attribute | html %]",
422                 cannot_be_modified: 0,
423                 cannot_be_toggled: 0,
424                 is_hidden: 0
425             });
426         [% END %]
427         $(document).ready(function() {
428             [% IF borrowers %]
429                 let patron_table = KohaTable("borrowerst", {
430                     "order": [[ 1, "asc" ]],
431                     "autoWidth": false,
432                 }, table_settings);
433
434                 $("#selectallbutton").click(function() {
435                     $("#borrowerst").find("input:checkbox").each(function() {
436                         $(this).prop("checked", true);
437                     });
438                     return false;
439                 });
440                 $("#clearallbutton").click(function() {
441                     $("#borrowerst").find("input:checkbox").each(function() {
442                         $(this).prop("checked", false);
443                     });
444                     return false;
445                 });
446             [% END %]
447
448             var values = new Array();
449             var lib = new Array();
450             [% FOREACH pav IN patron_attributes_values %]
451                 values = new Array();
452                 lib = new Array();
453                 [% FOREACH option IN pav.options %]
454                     values.push("[% option.lib | html %]");
455                     lib.push("[% option.authorised_value | html %]");
456                 [% END %]
457                 patron_attributes_lib["[% pav.attribute_code | html %]"] = values;
458                 patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
459             [% END %]
460
461             $('select[name="patron_attributes"]').change(function() {
462                 updateAttrValues(this);
463             } );
464
465             $('select[name="patron_attributes"]').change();
466
467             $(".clear-date").on("click",function(e){
468                 e.preventDefault();
469                 var fieldID = this.id.replace("clear-date-","");
470                 $("#" + fieldID).val("");
471             });
472             $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
473                 e.preventDefault();
474                 add_attributes();
475             });
476             $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
477                 e.preventDefault();
478                 del_attributes(this);
479             });
480             $("#patron_batchmod_form").on("submit", function(){
481                 /* Reset form fields on inactive tabs */
482                 var tab = $(this).find('ul.nav-tabs li.active a').attr('href');
483                 if ( tab == '#usecardnumber' ) {
484                     $("#borrowernumberuploadfile, #patron_list_id, #borrowernumberlist").val("");
485                 } else if ( tab == '#useborrowernumber' ) {
486                     $("#cardnumberuploadfile, #cardnumberlist, #patron_list_id").val("");
487                 } else { // uselist
488                     $("#borrowernumberuploadfile, #cardnumberuploadfile, #borrowernumberlist, #cardnumberlist").val("");
489                 }
490             });
491
492             $('form[name="f"]').on("submit", function(){
493                 // Add the checkboxes to the DOM before we submit the form
494                 var form = this;
495                 var checkboxes = patron_table.$('input:checkbox:checked').serializeArray();
496                 $.each(checkboxes, function(){
497                     let borrowernumber = this.value;
498                     if(!$(form).find('input[name="borrowernumber"][value="'+borrowernumber+'"]').length){
499                         $(form).append(
500                             $('<input>')
501                                 .attr('type', 'hidden')
502                                 .attr('name', 'borrowernumber')
503                                 .val(borrowernumber)
504                         );
505                     }
506                 });
507             });
508         });
509
510         function updateAttrValues (select_attr) {
511             var attr_code = $(select_attr).val();
512             var selected_option = $(select_attr).find("option:selected");
513             var type = $(selected_option).attr('data-type');
514             var category = $(selected_option).attr('data-category');
515             var li_node = $(select_attr).parent().parent();
516             var span = $(li_node).find('span.patron_attributes_value');
517             var information_category_node = $(li_node).find('span.information_category');
518             information_category_node.html("");
519
520             if ( category && category.length > 0 ) {
521                 information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
522             }
523             var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
524             if ( type == 'select' ) {
525                 var options = '<option value = ""></option>';
526                 for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
527                     options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
528                 }
529                 span.html('<select name="patron_attributes_value">' + options + '</select>');
530                 $(disable_input_node).show();
531             } else if ( $(selected_option).val() != "" ) {
532                 span.html('<input type="text" name="patron_attributes_value"/>');
533                 $(disable_input_node).show();
534             } else {
535                 span.html('<input type="hidden" name="patron_attributes_value" />');
536                 $(disable_input_node).hide();
537             }
538         }
539
540         function add_attributes() {
541             var li_node = $("li.attributes:last");
542             var li_clone = $(li_node).clone();
543             if ( $(li_clone).find("a.del_attributes").length == 0 ) {
544                 $(li_clone).append('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash"></i> ' + _("Delete") + '</a>');
545             }
546             $(li_clone).find('select[name="patron_attributes"]').change(function() {
547                 updateAttrValues(this);
548             } );
549
550             $(li_clone).find('select[name="patron_attributes"]').change();
551
552             $("#fields_list>ol").append(li_clone);
553             update_attr_values();
554         }
555
556         function del_attributes(a_node) {
557             $(a_node).parent('li').remove();
558             update_attr_values();
559         }
560
561         function update_attr_values() {
562             $("li.attributes").each(function(i) {
563                 $(this).find("input:checkbox").val("attr"+i+"_value");
564             });
565         }
566         function clearDate(nodeid) {
567             $("#"+nodeid).val("");
568         }
569     </script>
570 [% END %]
571
572 [% INCLUDE 'intranet-bottom.inc' %]