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