7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha › Tools › Batch patron modification</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% Asset.css("css/datatables.css") | $raw %]
13 <body id="tools_modborrowers" class="tools">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'cat-search.inc' %]
17 <div id="breadcrumbs">
18 <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
19 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> ›
20 <a href="/cgi-bin/koha/tools/modborrowers.pl">Batch patron modification</a>
23 <div id="doc3" class="yui-t2">
27 [% IF ( op == 'show_form' ) %]
28 <h1>Batch patron modification</h1>
29 <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
30 <fieldset class="rows">
31 <legend>Use a file</legend>
33 <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
38 <fieldset class="rows">
39 <legend>Or use a patron list</legend>
42 <label for="patron_list_id">Patron list: </label>
43 <select id="patron_list_id" name="patron_list_id">
44 <option value=""></option>
45 [% FOREACH pl IN patron_lists %]
46 <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
54 <fieldset class="rows">
55 <legend>Or list cardnumbers one by one</legend>
58 <label for="cardnumberlist">Card number list (one cardnumber per line): </label>
59 <textarea rows="10" cols="30" id="cardnumberlist" name="cardnumberlist">[% cardnumberlist | html %]</textarea>
63 <input type="hidden" name="op" value="show" />
64 <fieldset class="action">
65 <input type="submit" value="Continue" class="button" />
66 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
71 [% IF ( op == 'show') && (!borrowers) && (!notfoundcardnumbers) # Alert if no patrons given%]
72 [% op = 'noshow' # Change op to prevent display in code below | html %]
73 <h1>Batch patrons modification</h1>
74 <div class="dialog alert">
75 <p>No patron card numbers given.</p>
76 <form action="/cgi-bin/koha/tools/modborrowers.pl" method="get">
77 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
80 [% END #Alert if no patrons %]
82 [% IF ( op == 'show' or op == 'show_results' ) %]
83 [% IF ( op == 'show' ) %]
84 <h1>Batch patrons modification</h1>
86 <h1>Batch patrons results</h1>
88 [% IF ( notfoundcardnumbers ) %]
89 <div class="dialog alert"><p>Warning, the following cardnumbers were not found:</p></div>
90 <table style="margin:auto;">
92 <tr><th>Cardnumbers not found</th></tr>
95 [% FOREACH notfoundcardnumber IN notfoundcardnumbers %]
96 <tr><td>[% notfoundcardnumber.cardnumber | html %]</td></tr>
102 [% IF ( op == 'show_results' ) %]
104 <div class="dialog alert">
105 <h4>Errors occurred:</h4>
106 <ul class="warnings">
107 [% FOREACH error IN errors %]
108 [% IF ( error.error == 'can_not_update' ) %]
109 <li>Can not update patron.
110 [% IF ( error.cardnumber ) %] Cardnumber: [% error.cardnumber | html %] [% END %]
111 (Borrowernumber: [% error.borrowernumber | html %])
114 <li>[% error.error | html %]</li>
122 [% IF ( op == 'show' ) %]
123 <form name="f" action="modborrowers.pl" method="post">
124 <input type="hidden" name="op" value="do" />
125 [% IF ( borrowers ) %]
126 <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>
130 <div id="cataloguing_additem_itemlist">
131 <div style="overflow:auto">
132 <table id="borrowerst">
135 [% IF ( op == 'show' ) %]
145 <th>ZIP/Postal code</th>
147 <th class="title-string">Registration date</th>
148 <th class="title-string">Expiry date</th>
149 <th>Circulation note</th>
151 [% FOREACH attrh IN attributes_header %]
152 <th>[% attrh.attribute | html %]</th>
157 [% FOREACH borrower IN borrowers %]
159 [% IF ( op == 'show' ) %]
160 <td><input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber | html %]" checked="checked" /></td>
162 <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | html %]">[% borrower.cardnumber | html %]</a></td>
163 <td>[% borrower.surname | html %]</td>
164 <td>[% borrower.firstname | html %]</td>
165 <td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
166 <td>[% borrower.category_description | html %]</td>
167 <td>[% borrower.city | html %]</td>
168 <td>[% borrower.state | html %]</td>
169 <td>[% borrower.zipcode | html %]</td>
170 <td>[% borrower.country | html %]</td>
171 <td><span title="[% borrower.dateenrolled | html %]">[% borrower.dateenrolled | $KohaDates %]</span></td>
172 <td><span title="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</span></td>
173 <td>[% borrower.borrowernotes | html %]</td>
174 <td>[% borrower.opacnote | html %]</td>
175 [% FOREACH pa IN borrower.patron_attributes %]
177 <td>[% pa.code | html %]=[% pa.value | html %]</td>
189 [% IF ( op == 'show' ) %]
190 <div id="cataloguing_additem_newitem">
191 <h2>Edit patrons</h2>
192 <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>
193 <fieldset class="rows" id="fields_list">
195 [% FOREACH field IN fields %]
197 [% IF ( field.mandatory ) %]
198 <label for="[% field.name | html %]" class="required">
200 <label for="[% field.name | html %]">
202 [% SWITCH ( field.name ) %]
205 [% CASE 'firstname' %]
207 [% CASE 'branchcode' %]
209 [% CASE 'categorycode' %]
223 [% CASE 'dateenrolled' %]
225 [% CASE 'dateexpiry' %]
227 [% CASE 'borrowernotes' %]
229 [% CASE 'opacnote' %]
233 [% IF ( field.type == 'text' ) %]
234 <input type="text" name="[% field.name | html %]" value="" />
236 [% IF ( field.type == 'select' ) %]
237 [% IF field.option.size %]
238 <select name="[% field.name | html %]" >
239 [% FOREACH opt IN field.option %]
240 <option value="[% opt.value | html %]">[% opt.lib | html %]</option>
244 There is no value defined for [% field.name | html %]
247 [% IF ( field.type == 'date' ) %]
248 <input type="text" name="[% field.name | html %]" id="[% field.name | html %]" value="" size="10" maxlength="10" class="datepicker" />
249 <a href="#" class="clear-date" id="clear-date-[% field.name | html %]" ><i class="fa fa-fw fa-trash"></i> Clear</a>
251 [% IF field.mandatory %]
252 <input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name | html %]" disabled="disabled" readonly="readonly" />
253 <span class="required">Required fields cannot be cleared</span>
255 <input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name | html %]" />
259 [% IF ( patron_attributes_codes ) %]
260 <li class="attributes">
261 <label style="width:auto;">Attribute:
262 <select name="patron_attributes">
263 <option value=""></option>
264 [% FOREACH pac IN patron_attributes_codes %]
265 <option value="[% pac.attribute_code | html %]" data-type="[% pac.type | html %]" data-category="[% pac.category_lib | html %]">[% pac.attribute_lib | html %]</option>
269 <input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
270 <span class="patron_attributes_value"></span>
271 <a href="#" class="add_attributes" title="Add an attribute"><i class="fa fa-fw fa-plus"></i> New</a>
272 <span class="information_category hint" style="width:25%;float:right;"></span>
277 <fieldset class="action">
278 <input type="submit" name="mainformsubmit" value="Save" />
279 <a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
286 [% IF ( op == 'show_results' ) %]
288 <a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
294 [% INCLUDE 'tools-menu.inc' %]
298 [% MACRO jsinclude BLOCK %]
299 [% INCLUDE 'calendar.inc' %]
300 [% INCLUDE 'datatables.inc' %]
301 [% Asset.js("js/tools-menu.js") | $raw %]
302 <script type="text/javascript">
303 var patron_attributes_lib = new Array();
304 var patron_attributes_values = new Array();
305 $(document).ready(function() {
307 $("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, {
309 [% IF ( op == 'show_results' ) %]
311 { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
315 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
316 { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
321 $("#selectallbutton").click(function() {
322 $("#borrowerst").find("input:checkbox").each(function() {
323 $(this).prop("checked", true);
327 $("#clearallbutton").click(function() {
328 $("#borrowerst").find("input:checkbox").each(function() {
329 $(this).prop("checked", false);
335 var values = new Array();
336 var lib = new Array();
337 [% FOREACH pav IN patron_attributes_values %]
338 values = new Array();
340 [% FOREACH option IN pav.options %]
341 values.push("[% option.lib | html %]");
342 lib.push("[% option.authorised_value | html %]");
344 patron_attributes_lib["[% pav.attribute_code | html %]"] = values;
345 patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
348 $('select[name="patron_attributes"]').change(function() {
349 updateAttrValues(this);
352 $('select[name="patron_attributes"]').change();
354 $(".clear-date").on("click",function(e){
356 var fieldID = this.id.replace("clear-date-","");
357 $("#" + fieldID).val("");
359 $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
363 $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
365 del_attributes(this);
369 function updateAttrValues (select_attr) {
370 var attr_code = $(select_attr).val();
371 var selected_option = $(select_attr).find("option:selected");
372 var type = $(selected_option).attr('data-type');
373 var category = $(selected_option).attr('data-category');
374 var li_node = $(select_attr).parent().parent();
375 var span = $(li_node).find('span.patron_attributes_value');
376 var information_category_node = $(li_node).find('span.information_category');
377 information_category_node.html("");
379 if ( category && category.length > 0 ) {
380 information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
382 var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
383 if ( type == 'select' ) {
384 var options = '<option value = ""></option>';
385 for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
386 options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
388 span.html('<select name="patron_attributes_value">' + options + '</select>');
389 $(disable_input_node).show();
390 } else if ( $(selected_option).val() != "" ) {
391 span.html('<input type="text" name="patron_attributes_value"/>');
392 $(disable_input_node).show();
395 $(disable_input_node).hide();
399 function add_attributes() {
400 var li_node = $("li.attributes:last");
401 var li_clone = $(li_node).clone();
402 if ( $(li_clone).find("a.del_attributes").length == 0 ) {
403 $(li_clone).append('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash"></i> ' + _("Delete") + '</a>');
405 $(li_clone).find('select[name="patron_attributes"]').change(function() {
406 updateAttrValues(this);
409 $(li_clone).find('select[name="patron_attributes"]').change();
411 $("#fields_list>ol").append(li_clone);
412 update_attr_values();
415 function del_attributes(a_node) {
416 $(a_node).parent('li').remove();
417 update_attr_values();
420 function update_attr_values() {
421 $("li.attributes").each(function(i) {
422 $(this).find("input:checkbox").val("attr"+i+"_value");
425 function clearDate(nodeid) {
426 $("#"+nodeid).val("");
431 [% INCLUDE 'intranet-bottom.inc' %]