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