Bug 7720: add options for controlling display of an item's home and/or holdings location
[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="[% themelang %]/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                         "aoColumns": [
18                             null,null,null,null,null,{ "sType": "title-string" },{ "sType": "title-string" }[% FOREACH attrh IN attributes_header %],null[% END %]
19                         ],
20                     [% ELSE %]
21                         "aoColumnDefs": [
22                             { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
23                         ],
24                         "aoColumns": [
25                             null,null,null,null,null,null,{ "sType": "title-string" },{ "sType": "title-string" }[% FOREACH attrh IN attributes_header %],null[% END %]
26                         ],
27                     [% END %]
28                     "bPaginate": false
29                 }));
30                 $("#selectallbutton").click(function() {
31                     $("#borrowerst").find("input:checkbox").each(function() {
32                         $(this).attr("checked", true);
33                     });
34                     return false;
35                 });
36                 $("#clearallbutton").click(function() {
37                     $("#borrowerst").find("input:checkbox").each(function() {
38                         $(this).attr("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         } );
64
65         function updateAttrValues (select_attr) {
66             var attr_code = $(select_attr).val();
67             var type = $(select_attr).find("option:selected").attr('data-type');
68             var category = $(select_attr).find("option:selected").attr('data-category');
69             var span = $(select_attr).parent().parent().find('span.patron_attributes_value');
70             var information_category_node = $(select_attr).parent().parent().find('span.information_category');
71             information_category_node.html("");
72             if ( category.length > 0 ) {
73                 information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
74             }
75             if ( type == 'select' ) {
76                 var options = '<option value = ""></option>';
77                 for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
78                     options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
79                 }
80                 span.html('<select name="patron_attributes_value">' + options + '</select>');
81             } else {
82                 span.html('<input type="text" name="patron_attributes_value"/>')
83             }
84         }
85
86         function add_attributes() {
87             var li_node = $("li.attributes:last");
88             var li_clone = $(li_node).clone();
89             if ( $(li_clone).find("a.delete").length == 0 ) {
90                 $(li_clone).append('<a href="#" title="Delete" class="delete clear-field" onclick="del_attributes(this);return false;">Delete</a>');
91             }
92             $(li_clone).find('select[name="patron_attributes"]').change(function() {
93                 updateAttrValues(this);
94             } );
95
96             $(li_clone).find('select[name="patron_attributes"]').change();
97
98             $("#fields_list>ol").append(li_clone);
99             update_attr_values();
100         }
101
102         function del_attributes(a_node) {
103             $(a_node).parent('li').remove();
104             update_attr_values();
105         }
106
107         function update_attr_values() {
108             $("li.attributes").each(function(i) {
109                 $(this).find("input:checkbox").val("attr"+i+"_value");
110             });
111         }
112         function clearDate(nodeid) {
113             $("#"+nodeid).val("");
114         }
115
116 //]]>
117 </script>
118 </head>
119 <body>
120 [% INCLUDE 'header.inc' %]
121 [% INCLUDE 'cat-search.inc' %]
122
123 <div id="breadcrumbs">
124     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
125     <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
126     <a href="/cgi-bin/koha/tools/modborrowers.pl">Batch patron modification</a>
127 </div>
128
129 <div id="doc3" class="yui-t2">
130     <div id="bd">
131         <div id="yui-main">
132             <div class="yui-b">
133                 [% IF ( op == 'show_form' ) %]
134                 <h1>Batch patron modification</h1>
135                 <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
136                     <fieldset class="rows">
137                         <legend>Use a file</legend>
138                         <ol>
139                             <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
140                         </ol>
141                     </fieldset>
142
143                     [% IF patron_lists %]
144                     <fieldset class="rows">
145                         <legend>Or use a patron list</legend>
146                         <ol>
147                             <li>
148                                 <label for="patron_list_id">Patron list: </label>
149                                 <select id="patron_list_id" name="patron_list_id">
150                                     <option value=""></option>
151                                     [% FOREACH pl IN patron_lists %]
152                                         <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
153                                     [% END %]
154                                 </select>
155                             </li>
156                         </ol>
157                     </fieldset>
158                     [% END %]
159
160                     <fieldset class="rows">
161                         <legend>Or list cardnumbers one by one</legend>
162                         <ol>
163                             <li>
164                               <label for="cardnumberlist">Card number list (one cardnumber per line): </label>
165                               <textarea rows="10" cols="30" id="cardnumberlist" name="cardnumberlist">[% cardnumberlist %]</textarea>
166                             </li>
167                         </ol>
168                     </fieldset>
169                     <input type="hidden" name="op" value="show" />
170                     <fieldset class="action">
171                         <input type="submit" value="Continue" class="button" />
172                         <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
173                     </fieldset>
174                 </form>
175                 [% END %]
176
177                 [% IF ( op == 'show' or op == 'show_results' ) %]
178                     [% IF ( op == 'show' ) %]
179                         <h1>Batch patrons modification</h1>
180                     [% ELSE %]
181                         <h1>Batch patrons results</h1>
182                     [% END %]
183                     [% IF ( notfoundcardnumbers ) %]
184                         <div class="dialog alert"><p>Warning, the following cardnumbers were not found:</p></div>
185                         <table style="margin:auto;">
186                             <thead>
187                                 <tr><th>Cardnumbers not found</th></tr>
188                             </thead>
189                             <tbody>
190                                 [% FOREACH notfoundcardnumber IN notfoundcardnumbers %]
191                                     <tr><td>[% notfoundcardnumber.cardnumber %]</td></tr>
192                                 [% END %]
193                             </tbody>
194                         </table>
195                     [% END %]
196
197                     [% IF ( op == 'show_results' ) %]
198                         [% IF ( errors ) %]
199                             <div class="dialog alert">
200                             <h4>Errors occurred:</h4>
201                             <ul class="warnings">
202                             [% FOREACH error IN errors %]
203                                 [% IF ( error.error == 'can_not_update' ) %]
204                                     <li>Can not update patron with borrowernumber [% error.borrowernumber %]</li>
205                                 [% ELSE %]
206                                     <li>[% error.error %]</li>
207                                 [% END %]
208                             [% END %]
209                             </ul>
210                             </div>
211                         [% END %]
212                     [% END %]
213
214                     [% IF ( op == 'show' ) %]
215                     <form name="f" action="modborrowers.pl" method="post">
216                         <input type="hidden" name="op" value="do" />
217                         [% IF ( borrowers ) %]
218                             <div id="toolbar"><a id="selectallbutton" href="#">Select all</a> | <a id="clearallbutton" href="#">Clear all</a></div>
219                         [% END %]
220                     [% END %]
221                         [% IF borrowers %]
222                             <div id="cataloguing_additem_itemlist">
223                                 <div style="overflow:auto">
224                                     <table id="borrowerst">
225                                         <thead>
226                                             <tr>
227                                                 [% IF ( op == 'show' ) %]
228                                                     <th>&nbsp;</th>
229                                                 [% END %]
230                                                 <th>Card number</th>
231                                                 <th>Surname</th>
232                                                 <th>First name</th>
233                                                 <th>Library</th>
234                                                 <th>Category</th>
235                                                 <th>Registration date</th>
236                                                 <th>Expiry date</th>
237                                                 [% FOREACH attrh IN attributes_header %]
238                                                     <th>[% attrh.attribute %]</th>
239                                                 [% END %]
240                                             </tr>
241                                         </thead>
242                                         <tbody>
243                                             [% FOREACH borrower IN borrowers %]
244                                                 <tr>
245                                                     [% IF ( op == 'show' ) %]
246                                                         <td><input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber %]" checked="checked" /></td>
247                                                     [% END %]
248                                                     <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber %]">[% borrower.cardnumber %]</a></td>
249                                                     <td>[% borrower.surname %]</td>
250                                                     <td>[% borrower.firstname %]</td>
251                                                     <td>[% borrower.branchname %]</td>
252                                                     <td>[% borrower.categorycode %]</td>
253                                                     <td><span title="[% borrower.dateenrolled %]">[% borrower.dateenrolled | $KohaDates %]</span></td>
254                                                     <td><span title="[% borrower.dateexpiry %]">[% borrower.dateexpiry | $KohaDates %]</span></td>
255                                                     [% FOREACH pa IN borrower.patron_attributes %]
256                                                         [% IF ( pa.code ) %]
257                                                             <td>[% pa.code %]=[% pa.value %]</td>
258                                                         [% ELSE %]
259                                                             <td></td>
260                                                         [% END %]
261                                                     [% END %]
262                                                 </tr>
263                                             [% END %]
264                                         </tbody>
265                                     </table>
266                                 </div>
267                             </div>
268
269                             [% IF ( op == 'show' ) %]
270                             <div id="cataloguing_additem_newitem">
271                                 <h2>Edit patrons</h2>
272                                 <div class="hint">Checking the box right next the label will disable the entry and delete the values of that field on all selected patrons</div>
273                                 <fieldset class="rows" id="fields_list">
274                                     <ol>
275                                         [% FOREACH field IN fields %]
276                                         <li>
277                                             [% IF ( field.mandatory ) %]
278                                             <label for="[% field.name %]" class="required">
279                                             [% ELSE %]
280                                             <label for="[% field.name %]">
281                                             [% END %]
282                                             [% SWITCH ( field.name ) %]
283                                                 [% CASE 'surname' %]
284                                                 Surname:
285                                                 [% CASE 'firstname' %]
286                                                 First name:
287                                                 [% CASE 'branchcode' %]
288                                                 Library:
289                                                 [% CASE 'categorycode' %]
290                                                 Category
291                                                 [% CASE 'sort1' %]
292                                                 Sort 1:
293                                                 [% CASE 'sort2' %]
294                                                 Sort 2:
295                                                 [% CASE 'dateenrolled' %]
296                                                 Registration date:
297                                                 [% CASE 'dateexpiry' %]
298                                                 Expiry date:
299                                                 [% CASE 'borrowernotes' %]
300                                                 Circulation note:
301                                             [% END %]
302                                             </label>
303                                             [% IF field.mandatory %]
304                                                 <input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name %]" readonly="readonly" onclick="return false;" />
305                                             [% ELSE %]
306                                                 <input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name %]" />
307                                             [% END %]
308                                             [% IF ( field.type == 'text' ) %]
309                                                 <input type="text" name="[% field.name %]" value="" />
310                                             [% END %]
311                                             [% IF ( field.type == 'select' ) %]
312                                                 [% IF field.option.size %]
313                                                     <select name="[% field.name %]" >
314                                                         [% FOREACH opt IN field.option %]
315                                                             <option value="[% opt.value %]">[% opt.lib %]</option>
316                                                         [% END %]
317                                                     </select>
318                                                 [% ELSE %]
319                                                     There is no value defined for [% field.name %]
320                                                 [% END %]
321                                             [% END %]
322                                             [% IF ( field.type == 'date' ) %]
323                                                 <input type="text" name="[% field.name %]" id="[% field.name %]" value="" size="10" maxlength="10" readonly="readonly" class="datepicker" />
324                                                 <a href="#" class="clear-field" onclick="clearDate('[% field.name %]');return false;">Clear</a>
325                                                 [% END %]
326                                         </li>
327                                         [% END %]
328                                         [% IF ( patron_attributes_codes ) %]
329                                             <li class="attributes">
330                                                 <label style="width:auto;">Attribute:
331                                                     <select name="patron_attributes">
332                                                         [% FOREACH pac IN patron_attributes_codes %]
333                                                             <option value="[% pac.attribute_code %]" data-type="[% pac.type %]" data-category="[% pac.category_lib %]">[% pac.attribute_lib %]</option>
334                                                         [% END %]
335                                                     </select>
336                                                 </label>
337                                                 <input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
338                                                 <span class="patron_attributes_value"></span>
339                                                 <a href="#" class="clone-field" title="Add an attribute" onclick="add_attributes(); return false;">New</a>
340                                                 <span class="information_category hint" style="width:25%;float:right;"></span>
341                                             </li>
342                                         [% END %]
343                                     </ol>
344                                 </fieldset>
345                                 <fieldset class="action">
346                                     <input type="submit" name="mainformsubmit" value="Save" />
347                                     <a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
348                                 </fieldset>
349                             </div>
350                         </form>
351                         [% END %]
352                     [% END %]
353                 [% END %]
354                 [% IF ( op == 'show_results' ) %]
355                 <p>
356                     <a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
357                 </p>
358                 [% END %]
359             </div>
360             </div>
361             <div class="yui-b">
362                 [% INCLUDE 'tools-menu.inc' %]
363             </div>
364         </div>
365     </div>
366 </div>
367 </body>
368 </html>