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