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