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