Bug 15758: Koha::Libraries - Remove GetBranchName
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / modborrowers.tt
1 [% USE Koha %]
2 [% USE KohaDates %]
3 [% USE Branches %]
4 [% INCLUDE 'doc-head-open.inc'%]
5 <title>Koha &rsaquo; Tools &rsaquo; Batch patron modification</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% INCLUDE 'calendar.inc' %]
8 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
9 [% INCLUDE 'datatables.inc' %]
10 <script type="text/javascript">
11 //<![CDATA[
12         var patron_attributes_lib = new Array();
13         var patron_attributes_values = new Array();
14         $(document).ready(function() {
15             [% IF borrowers %]
16                 $("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, {
17                     "sDom": 't',
18                     [% IF ( op == 'show_results' ) %]
19                         "aoColumnDefs": [
20                             { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
21                         ],
22                     [% ELSE %]
23                         "aoColumnDefs": [
24                             { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
25                             { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
26                         ],
27                     [% END %]
28                     "bPaginate": false
29                 }));
30                 $("#selectallbutton").click(function() {
31                     $("#borrowerst").find("input:checkbox").each(function() {
32                         $(this).prop("checked", true);
33                     });
34                     return false;
35                 });
36                 $("#clearallbutton").click(function() {
37                     $("#borrowerst").find("input:checkbox").each(function() {
38                         $(this).prop("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" onclick="del_attributes(this);return false;"><i class="fa fa-fw fa-trash"></i> 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 id="tools_modborrowers" class="tools">
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') && (!borrowers) && (!notfoundcardnumbers) # Alert if no patrons given%]
178                     [% op = 'noshow' # Change op to prevent display in code below %]
179                     <h1>Batch patrons modification</h1>
180                     <div class="dialog alert">
181                         <p>No patron card numbers given.</p>
182                         <form action="/cgi-bin/koha/tools/modborrowers.pl" method="get">
183                          <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
184                         </form>
185                     </div>
186                 [% END #Alert if no patrons %]
187
188                 [% IF ( op == 'show' or op == 'show_results' ) %]
189                     [% IF ( op == 'show' ) %]
190                         <h1>Batch patrons modification</h1>
191                     [% ELSE %]
192                         <h1>Batch patrons results</h1>
193                     [% END %]
194                     [% IF ( notfoundcardnumbers ) %]
195                         <div class="dialog alert"><p>Warning, the following cardnumbers were not found:</p></div>
196                         <table style="margin:auto;">
197                             <thead>
198                                 <tr><th>Cardnumbers not found</th></tr>
199                             </thead>
200                             <tbody>
201                                 [% FOREACH notfoundcardnumber IN notfoundcardnumbers %]
202                                     <tr><td>[% notfoundcardnumber.cardnumber %]</td></tr>
203                                 [% END %]
204                             </tbody>
205                         </table>
206                     [% END %]
207
208                     [% IF ( op == 'show_results' ) %]
209                         [% IF ( errors ) %]
210                             <div class="dialog alert">
211                             <h4>Errors occurred:</h4>
212                             <ul class="warnings">
213                             [% FOREACH error IN errors %]
214                                 [% IF ( error.error == 'can_not_update' ) %]
215                                     <li>Can not update patron.
216                                     [% IF ( error.cardnumber ) %] Cardnumber:  [% error.cardnumber %] [% END %]
217                                     (Borrowernumber: [% error.borrowernumber %])
218                                     </li>
219                                 [% ELSE %]
220                                     <li>[% error.error %]</li>
221                                 [% END %]
222                             [% END %]
223                             </ul>
224                             </div>
225                         [% END %]
226                     [% END %]
227
228                     [% IF ( op == 'show' ) %]
229                     <form name="f" action="modborrowers.pl" method="post">
230                         <input type="hidden" name="op" value="do" />
231                         [% IF ( borrowers ) %]
232                             <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>
233                         [% END %]
234                     [% END %]
235                         [% IF borrowers %]
236                             <div id="cataloguing_additem_itemlist">
237                                 <div style="overflow:auto">
238                                     <table id="borrowerst">
239                                         <thead>
240                                             <tr>
241                                                 [% IF ( op == 'show' ) %]
242                                                     <th>&nbsp;</th>
243                                                 [% END %]
244                                                 <th>Card number</th>
245                                                 <th>Surname</th>
246                                                 <th>First name</th>
247                                                 <th>Library</th>
248                                                 <th>Category</th>
249                                                 <th>City</th>
250                                                 <th>State</th>
251                                                 <th>ZIP/Postal code</th>
252                                                 <th>Country</th>
253                                                 <th class="title-string">Registration date</th>
254                                                 <th class="title-string">Expiry date</th>
255                                                 <th>Circulation note</th>
256                                                 <th>Opac Note</th>
257                                                 [% FOREACH attrh IN attributes_header %]
258                                                     <th>[% attrh.attribute %]</th>
259                                                 [% END %]
260                                             </tr>
261                                         </thead>
262                                         <tbody>
263                                             [% FOREACH borrower IN borrowers %]
264                                                 <tr>
265                                                     [% IF ( op == 'show' ) %]
266                                                         <td><input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber %]" checked="checked" /></td>
267                                                     [% END %]
268                                                     <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber %]">[% borrower.cardnumber %]</a></td>
269                                                     <td>[% borrower.surname %]</td>
270                                                     <td>[% borrower.firstname %]</td>
271                                                     <td>[% Branches.GetName( borrower.branchcode ) %]</td>
272                                                     <td>[% borrower.categorycode %]</td>
273                                                     <td>[% borrower.city %]</td>
274                                                     <td>[% borrower.state %]</td>
275                                                     <td>[% borrower.zipcode %]</td>
276                                                     <td>[% borrower.country %]</td>
277                                                     <td><span title="[% borrower.dateenrolled %]">[% borrower.dateenrolled | $KohaDates %]</span></td>
278                                                     <td><span title="[% borrower.dateexpiry %]">[% borrower.dateexpiry | $KohaDates %]</span></td>
279                                                     <td>[% borrower.borrowernotes %]</td>
280                                                     <td>[% borrower.opacnote %]</td>
281                                                     [% FOREACH pa IN borrower.patron_attributes %]
282                                                         [% IF ( pa.code ) %]
283                                                             <td>[% pa.code %]=[% pa.value %]</td>
284                                                         [% ELSE %]
285                                                             <td></td>
286                                                         [% END %]
287                                                     [% END %]
288                                                 </tr>
289                                             [% END %]
290                                         </tbody>
291                                     </table>
292                                 </div>
293                             </div>
294
295                             [% IF ( op == 'show' ) %]
296                             <div id="cataloguing_additem_newitem">
297                                 <h2>Edit patrons</h2>
298                                 <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>
299                                 <fieldset class="rows" id="fields_list">
300                                     <ol>
301                                         [% FOREACH field IN fields %]
302                                         <li>
303                                             [% IF ( field.mandatory ) %]
304                                             <label for="[% field.name %]" class="required">
305                                             [% ELSE %]
306                                             <label for="[% field.name %]">
307                                             [% END %]
308                                             [% SWITCH ( field.name ) %]
309                                                 [% CASE 'surname' %]
310                                                 Surname:
311                                                 [% CASE 'firstname' %]
312                                                 First name:
313                                                 [% CASE 'branchcode' %]
314                                                 Library:
315                                                 [% CASE 'categorycode' %]
316                                                 Category
317                                                 [% CASE 'city' %]
318                                                 City
319                                                 [% CASE 'state' %]
320                                                 State
321                                                 [% CASE 'zipcode' %]
322                                                 ZIP/Postal code
323                                                 [% CASE 'country' %]
324                                                 Country
325                                                 [% CASE 'sort1' %]
326                                                 Sort 1:
327                                                 [% CASE 'sort2' %]
328                                                 Sort 2:
329                                                 [% CASE 'dateenrolled' %]
330                                                 Registration date:
331                                                 [% CASE 'dateexpiry' %]
332                                                 Expiry date:
333                                                 [% CASE 'borrowernotes' %]
334                                                 Circulation note:
335                                                 [% CASE 'opacnote' %]
336                                                 OPAC note:
337                                             [% END %]
338                                             </label>
339                                             [% IF field.mandatory %]
340                                                 <input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name %]" onclick="return false;" />
341                                             [% ELSE %]
342                                                 <input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name %]" />
343                                             [% END %]
344                                             [% IF ( field.type == 'text' ) %]
345                                                 <input type="text" name="[% field.name %]" value="" />
346                                             [% END %]
347                                             [% IF ( field.type == 'select' ) %]
348                                                 [% IF field.option.size %]
349                                                     <select name="[% field.name %]" >
350                                                         [% FOREACH opt IN field.option %]
351                                                             <option value="[% opt.value %]">[% opt.lib %]</option>
352                                                         [% END %]
353                                                     </select>
354                                                 [% ELSE %]
355                                                     There is no value defined for [% field.name %]
356                                                 [% END %]
357                                             [% END %]
358                                             [% IF ( field.type == 'date' ) %]
359                                                 <input type="text" name="[% field.name %]" id="[% field.name %]" value="" size="10" maxlength="10" class="datepicker" />
360                                                 <a href="#" onclick="clearDate('[% field.name %]');return false;"><i class="fa fa-fw fa-trash"></i> Clear</a>
361                                             [% END %]
362                                             [% IF field.mandatory %]
363                                                 <span class="required">Required fields cannot be cleared</span>
364                                             [% END %]
365                                         </li>
366                                         [% END %]
367                                         [% IF ( patron_attributes_codes ) %]
368                                             <li class="attributes">
369                                                 <label style="width:auto;">Attribute:
370                                                     <select name="patron_attributes">
371                                                         [% FOREACH pac IN patron_attributes_codes %]
372                                                             <option value="[% pac.attribute_code %]" data-type="[% pac.type %]" data-category="[% pac.category_lib %]">[% pac.attribute_lib %]</option>
373                                                         [% END %]
374                                                     </select>
375                                                 </label>
376                                                 <input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
377                                                 <span class="patron_attributes_value"></span>
378                                                 <a href="#" title="Add an attribute" onclick="add_attributes(); return false;"><i class="fa fa-fw fa-plus"></i> New</a>
379                                                 <span class="information_category hint" style="width:25%;float:right;"></span>
380                                             </li>
381                                         [% END %]
382                                     </ol>
383                                 </fieldset>
384                                 <fieldset class="action">
385                                     <input type="submit" name="mainformsubmit" value="Save" />
386                                     <a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
387                                 </fieldset>
388                             </div>
389                         </form>
390                         [% END %]
391                     [% END %]
392                 [% END %]
393                 [% IF ( op == 'show_results' ) %]
394                 <p>
395                     <a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
396                 </p>
397                 [% END %]
398             </div>
399             </div>
400             <div class="yui-b">
401                 [% INCLUDE 'tools-menu.inc' %]
402             </div>
403         </div>
404 [% INCLUDE 'intranet-bottom.inc' %]