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