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