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