8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Koha › Tools › Batch patron modification</title>
10 [% INCLUDE 'doc-head-close.inc' %]
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 class="main container-fluid">
25 <div class="col-sm-10 col-sm-push-2">
28 [% IF ( op == 'show_form' ) %]
29 <h1>Batch patron modification</h1>
30 <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
31 <fieldset class="rows">
32 <legend>Use a file</legend>
34 <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
39 <fieldset class="rows">
40 <legend>Or use a patron list</legend>
43 <label for="patron_list_id">Patron list: </label>
44 <select id="patron_list_id" name="patron_list_id">
45 <option value=""></option>
46 [% FOREACH pl IN patron_lists %]
47 <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
55 <fieldset class="rows">
56 <legend>Or list cardnumbers one by one</legend>
59 <label for="cardnumberlist">Card number list (one cardnumber per line): </label>
60 <textarea rows="10" cols="30" id="cardnumberlist" name="cardnumberlist">[% cardnumberlist | html %]</textarea>
64 <input type="hidden" name="op" value="show" />
65 <fieldset class="action">
66 <input type="submit" value="Continue" class="button" />
67 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
72 [% IF ( op == 'show') && (!borrowers) && (!notfoundcardnumbers) # Alert if no patrons given%]
73 [% op = 'noshow' # Change op to prevent display in code below %]
74 <h1>Batch patrons modification</h1>
75 <div class="dialog alert">
76 <p>No patron card numbers given.</p>
77 <form action="/cgi-bin/koha/tools/modborrowers.pl" method="get">
78 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
81 [% END #Alert if no patrons %]
83 [% IF ( op == 'show' or op == 'show_results' ) %]
84 [% IF ( op == 'show' ) %]
85 <h1>Batch patrons modification</h1>
87 <h1>Batch patrons results</h1>
89 [% IF ( notfoundcardnumbers ) %]
90 <div class="dialog alert"><p>Warning, the following cardnumbers were not found:</p></div>
91 <table style="margin:auto;">
93 <tr><th>Cardnumbers not found</th></tr>
96 [% FOREACH notfoundcardnumber IN notfoundcardnumbers %]
97 <tr><td>[% notfoundcardnumber.cardnumber | html %]</td></tr>
103 [% IF ( op == 'show_results' ) %]
105 <div class="dialog alert">
106 <h4>Errors occurred:</h4>
107 <ul class="warnings">
108 [% FOREACH error IN errors %]
109 [% IF ( error.error == 'can_not_update' ) %]
110 <li>Can not update patron.
111 [% IF ( error.cardnumber ) %] Cardnumber: [% error.cardnumber | html %] [% END %]
112 (Borrowernumber: [% error.borrowernumber | html %])
115 <li>[% error.error | html %]</li>
123 [% IF ( op == 'show' ) %]
124 <form name="f" action="modborrowers.pl" method="post">
125 <input type="hidden" name="op" value="do" />
126 [% IF ( borrowers ) %]
127 <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>
131 <div id="cataloguing_additem_itemlist">
132 <div style="overflow:auto">
133 <table id="borrowerst">
136 [% IF ( op == 'show' ) %]
143 <th>Patron category</th>
144 <th>Street number</th>
149 <th>ZIP/Postal code</th>
151 <th>Primary email</th>
154 <th class="title-string">Registration date</th>
155 <th class="title-string">Expiry date</th>
156 <th>Circulation note</th>
158 <th>Restriction expiration</th>
159 <th>Restriction comment</th>
160 [% FOREACH attrh IN attributes_header %]
161 <th>[% attrh.attribute | html %]</th>
166 [% FOREACH borrower IN borrowers %]
168 [% IF ( op == 'show' ) %]
169 <td><input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber | html %]" checked="checked" /></td>
171 <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | uri %]">[% borrower.cardnumber | html %]</a></td>
172 <td>[% borrower.surname | html %]</td>
173 <td>[% borrower.firstname | html %]</td>
174 <td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
175 <td>[% Categories.GetName(borrower.categorycode) | html %]</td>
176 <td>[% borrower.streetnumber | html %]</td>
177 <td>[% borrower.address | html %]</td>
178 <td>[% borrower.address2 | html %]</td>
179 <td>[% borrower.city | html %]</td>
180 <td>[% borrower.state | html %]</td>
181 <td>[% borrower.zipcode | html %]</td>
182 <td>[% borrower.country | html %]</td>
183 <td>[% borrower.email | html %]</td>
184 <td>[% borrower.phone | html %]</td>
185 <td>[% borrower.mobile | html %]</td>
186 <td><span title="[% borrower.dateenrolled | html %]">[% borrower.dateenrolled | $KohaDates %]</span></td>
187 <td><span title="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</span></td>
188 <td>[% borrower.borrowernotes | html %]</td>
189 <td>[% borrower.opacnote | html %]</td>
190 <td><span title="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</span></td>
191 <td>[% borrower.debarredcomment | html %]</td>
192 [% FOREACH pa IN borrower.patron_attributes %]
194 [%# Replace pa.attribute with pa.description if we prefer to display the description %]
195 <td>[% pa.code | html %]=[% pa.attribute | html %]</td>
207 [% IF ( op == 'show' ) %]
208 <div id="cataloguing_additem_newitem">
209 <h2>Edit patrons</h2>
210 <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>
211 <fieldset class="rows" id="fields_list">
213 [% FOREACH field IN fields %]
215 [% IF ( field.mandatory ) %]
216 <label for="[% field.name | html %]" class="required">
218 <label for="[% field.name | html %]">
220 [% SWITCH ( field.name ) %]
223 [% CASE 'firstname' %]
225 [% CASE 'branchcode' %]
227 [% CASE 'categorycode' %]
229 [% CASE 'streetnumber' %]
233 [% CASE 'address2' %]
253 [% CASE 'dateenrolled' %]
255 [% CASE 'dateexpiry' %]
257 [% CASE 'borrowernotes' %]
259 [% CASE 'opacnote' %]
261 [% CASE 'debarred' %]
262 Restriction expiration:
263 [% CASE 'debarredcomment' %]
267 [% IF ( field.type == 'text' ) %]
268 <input type="text" name="[% field.name | html %]" value="" />
270 [% IF ( field.type == 'select' ) %]
271 [% IF field.option.size %]
272 <select name="[% field.name | html %]" >
273 [% FOREACH opt IN field.option %]
274 <option value="[% opt.value | html %]">[% opt.lib | html %]</option>
278 There is no value defined for [% field.name | html %]
281 [% IF ( field.type == 'date' ) %]
282 <input type="text" name="[% field.name | html %]" id="[% field.name | html %]" value="" size="10" maxlength="10" class="datepicker" />
283 <a href="#" class="clear-date" id="clear-date-[% field.name | html %]" ><i class="fa fa-fw fa-trash"></i> Clear</a>
285 [% IF field.mandatory %]
286 <input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name | html %]" disabled="disabled" readonly="readonly" />
287 <span class="required">Required fields cannot be cleared</span>
289 <input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name | html %]" />
293 [% IF ( patron_attributes_codes ) %]
294 <li class="attributes">
295 <label style="width:auto;">Patron attribute:
296 <select name="patron_attributes">
297 <option value=""></option>
298 [% FOREACH pac IN patron_attributes_codes %]
299 <option value="[% pac.attribute_code | html %]" data-type="[% pac.type | html %]" data-category="[% pac.category_lib | html %]">[% pac.attribute_lib | html %]</option>
303 <input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
304 <span class="patron_attributes_value"><input type"hidden" name="patron_attributes_value" /></span>
305 <a href="#" class="add_attributes" title="Add an attribute"><i class="fa fa-fw fa-plus"></i> New</a>
306 <span class="information_category hint" style="width:25%;float:right;"></span>
311 <fieldset class="action">
312 <input type="submit" name="mainformsubmit" value="Save" />
313 <a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
320 [% IF ( op == 'show_results' ) %]
322 <a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
327 </div> <!-- /.col-sm-10.col-sm-push-2 -->
329 <div class="col-sm-2 col-sm-pull-10">
331 [% INCLUDE 'tools-menu.inc' %]
333 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
334 </div> <!-- /.row -->
336 [% MACRO jsinclude BLOCK %]
337 [% INCLUDE 'calendar.inc' %]
338 [% INCLUDE 'datatables.inc' %]
339 [% Asset.js("js/tools-menu.js") | $raw %]
341 var patron_attributes_lib = new Array();
342 var patron_attributes_values = new Array();
343 $(document).ready(function() {
345 $("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, {
347 [% IF ( op == 'show_results' ) %]
349 { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
353 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
354 { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
359 $("#selectallbutton").click(function() {
360 $("#borrowerst").find("input:checkbox").each(function() {
361 $(this).prop("checked", true);
365 $("#clearallbutton").click(function() {
366 $("#borrowerst").find("input:checkbox").each(function() {
367 $(this).prop("checked", false);
373 var values = new Array();
374 var lib = new Array();
375 [% FOREACH pav IN patron_attributes_values %]
376 values = new Array();
378 [% FOREACH option IN pav.options %]
379 values.push("[% option.lib | html %]");
380 lib.push("[% option.authorised_value | html %]");
382 patron_attributes_lib["[% pav.attribute_code | html %]"] = values;
383 patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
386 $('select[name="patron_attributes"]').change(function() {
387 updateAttrValues(this);
390 $('select[name="patron_attributes"]').change();
392 $(".clear-date").on("click",function(e){
394 var fieldID = this.id.replace("clear-date-","");
395 $("#" + fieldID).val("");
397 $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
401 $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
403 del_attributes(this);
407 function updateAttrValues (select_attr) {
408 var attr_code = $(select_attr).val();
409 var selected_option = $(select_attr).find("option:selected");
410 var type = $(selected_option).attr('data-type');
411 var category = $(selected_option).attr('data-category');
412 var li_node = $(select_attr).parent().parent();
413 var span = $(li_node).find('span.patron_attributes_value');
414 var information_category_node = $(li_node).find('span.information_category');
415 information_category_node.html("");
417 if ( category && category.length > 0 ) {
418 information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
420 var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
421 if ( type == 'select' ) {
422 var options = '<option value = ""></option>';
423 for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
424 options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
426 span.html('<select name="patron_attributes_value">' + options + '</select>');
427 $(disable_input_node).show();
428 } else if ( $(selected_option).val() != "" ) {
429 span.html('<input type="text" name="patron_attributes_value"/>');
430 $(disable_input_node).show();
432 span.html('<input type="hidden" name="patron_attributes_value" />');
433 $(disable_input_node).hide();
437 function add_attributes() {
438 var li_node = $("li.attributes:last");
439 var li_clone = $(li_node).clone();
440 if ( $(li_clone).find("a.del_attributes").length == 0 ) {
441 $(li_clone).append('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash"></i> ' + _("Delete") + '</a>');
443 $(li_clone).find('select[name="patron_attributes"]').change(function() {
444 updateAttrValues(this);
447 $(li_clone).find('select[name="patron_attributes"]').change();
449 $("#fields_list>ol").append(li_clone);
450 update_attr_values();
453 function del_attributes(a_node) {
454 $(a_node).parent('li').remove();
455 update_attr_values();
458 function update_attr_values() {
459 $("li.attributes").each(function(i) {
460 $(this).find("input:checkbox").val("attr"+i+"_value");
463 function clearDate(nodeid) {
464 $("#"+nodeid).val("");
469 [% INCLUDE 'intranet-bottom.inc' %]