7 [% USE TablesSettings %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Batch patron modification › Tools › Koha</title>
11 [% INCLUDE 'doc-head-close.inc' %]
14 <body id="tools_modborrowers" class="tools">
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'cat-search.inc' %]
18 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
21 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
24 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
27 <a href="#" aria-current="page">Batch patron modification</a>
32 <div class="main container-fluid">
34 <div class="col-sm-10 col-sm-push-2">
37 [% IF ( op == 'show_form' ) %]
38 <h1>Batch patron modification</h1>
39 <form id="patron_batchmod_form" method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
40 <input type="hidden" name="op" value="show" />
41 <div id="batch_patron_options" class="toptabs">
44 <a href="#usecardnumber">By card number</a>
47 <a href="#useborrowernumber">By borrowernumber</a>
51 <a href="#uselist">By patron list</a>
55 <div id="usecardnumber">
56 <fieldset class="rows">
57 <legend>Use a file of card numbers</legend>
60 <label for="cardnumberuploadfile">File: </label> <input type="file" id="cardnumberuploadfile" name="cardnumberuploadfile" />
61 <div class="hint">File must contain one card number per line.</div>
65 <fieldset class="rows">
66 <legend>Or list card numbers one by one</legend>
69 <label for="cardnumberlist">Card number list (one card number per line): </label>
70 <textarea rows="10" cols="30" id="cardnumberlist" name="cardnumberlist">[% cardnumberlist | html %]</textarea>
74 <fieldset class="action">
75 <input type="submit" value="Continue" class="button" />
76 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
79 <div id="useborrowernumber">
80 <fieldset class="rows">
81 <legend>Use a file of borrowernumbers</legend>
84 <label for="borrowernumberuploadfile">File: </label> <input type="file" id="borrowernumberuploadfile" name="borrowernumberuploadfile" />
85 <div class="hint">File must contain one borrowernumber per line.</div>
89 <fieldset class="rows">
90 <legend>List borrowernumbers one by one</legend>
93 <label for="borrowernumberlist">Borrowernumber list (one number per line): </label>
94 <textarea rows="10" cols="30" id="borrowernumberlist" name="borrowernumberlist">[% borrowernumberlist | html %]</textarea>
98 <fieldset class="action">
99 <input type="submit" value="Continue" class="button" />
100 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
103 [% IF patron_lists %]
105 <fieldset class="rows">
106 <legend>Use a patron list</legend>
109 <label for="patron_list_id">Patron list: </label>
110 <select id="patron_list_id" name="patron_list_id">
111 <option value=""> -- Choose a patron list -- </option>
112 [% FOREACH pl IN patron_lists %]
113 <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
119 <fieldset class="action">
120 <input type="submit" value="Continue" class="button" />
121 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
125 </div><!-- /#batch_patron_options -->
129 [% IF ( op == 'show') && (!borrowers) && (!notfoundcardnumbers) # Alert if no patrons given%]
130 [% op = 'noshow' # Change op to prevent display in code below %]
131 <h1>Batch patrons modification</h1>
132 <div class="dialog alert">
133 <p>No patron card numbers or borrowernumbers given.</p>
134 <form action="/cgi-bin/koha/tools/modborrowers.pl" method="get">
135 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
138 [% END #Alert if no patrons %]
140 [% IF ( op == 'show' or op == 'show_results' ) %]
141 [% IF ( op == 'show' ) %]
142 <h1>Batch patrons modification</h1>
144 <h1>Batch patrons results</h1>
146 [% IF ( notfoundcardnumbers ) %]
147 [% IF ( useborrowernumbers ) -%]
148 <div class="dialog alert"><p>Warning, the following borrowernumbers were not found:</p></div>
150 <div class="dialog alert"><p>Warning, the following card numbers were not found:</p></div>
153 <table style="margin:auto;">
155 [% IF ( useborrowernumbers ) -%]
156 <tr><th>Borrowernumbers not found</th></tr>
158 <tr><th>Card numbers not found</th></tr>
162 [% FOREACH notfoundcardnumber IN notfoundcardnumbers %]
163 <tr><td>[% notfoundcardnumber.cardnumber | html %]</td></tr>
169 [% IF ( op == 'show_results' ) %]
171 <div class="dialog alert">
172 <h4>Errors occurred:</h4>
173 <ul class="warnings">
174 [% FOREACH error IN errors %]
175 [% IF ( error.error == 'can_not_update' ) %]
176 <li>Can not update patron.
177 [% IF ( error.cardnumber ) %] Card number: [% error.cardnumber | html %] [% END %]
178 (Borrowernumber: [% error.borrowernumber | html %])
181 <li>[% error.error | html %]</li>
189 [% IF ( op == 'show' ) %]
190 <form name="f" action="modborrowers.pl" method="post">
191 <input type="hidden" name="op" value="do" />
192 [% IF ( borrowers ) %]
193 <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>
197 <div id="cataloguing_additem_itemlist">
198 <div style="overflow:auto">
199 <table id="borrowerst">
202 [% IF ( op == 'show' ) %]
203 <th class="NoSort"> </th>
205 <th class="hidden"> </th>
211 <th>Patron category</th>
212 <th>Street number</th>
217 <th>ZIP/Postal code</th>
219 <th>Primary email</th>
222 <th>Registration date</th>
224 <th>Circulation note</th>
226 <th>Restriction expiration</th>
227 <th>Restriction comment</th>
228 [% FOREACH attrh IN attributes_header %]
229 <th>[% attrh.attribute | html %]</th>
234 [% FOREACH borrower IN borrowers %]
236 [% IF ( op == 'show' ) %]
241 <input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber | html %]" checked="checked" />
243 <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | uri %]">[% borrower.cardnumber | html %]</a></td>
244 <td>[% borrower.surname | html %]</td>
245 <td>[% borrower.firstname | html %]</td>
246 <td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
247 <td>[% Categories.GetName(borrower.categorycode) | html %]</td>
248 <td>[% borrower.streetnumber | html %]</td>
249 <td>[% borrower.address | html %]</td>
250 <td>[% borrower.address2 | html %]</td>
251 <td>[% borrower.city | html %]</td>
252 <td>[% borrower.state | html %]</td>
253 <td>[% borrower.zipcode | html %]</td>
254 <td>[% borrower.country | html %]</td>
255 <td>[% borrower.email | html %]</td>
256 <td>[% borrower.phone | html %]</td>
257 <td>[% borrower.mobile | html %]</td>
258 <td data-order="[% borrower.dateenrolled | html %]">[% borrower.dateenrolled | $KohaDates %]</td>
259 <td data-order="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</td>
260 <td>[% borrower.borrowernotes | html %]</td>
261 <td>[% borrower.opacnote | html %]</td>
262 <td data-order="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</td>
263 <td>[% borrower.debarredcomment | html %]</td>
264 [% FOREACH pa IN borrower.patron_attributes %]
266 [%# Replace pa.attribute with pa.description if we prefer to display the description %]
267 <td>[% pa.code | html %]=[% pa.attribute | html %]</td>
279 [% IF ( op == 'show' ) %]
280 <div id="cataloguing_additem_newitem">
281 <h2>Edit patrons</h2>
282 <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>
283 <fieldset class="rows" id="fields_list">
285 [% FOREACH field IN fields %]
287 [% IF ( field.mandatory ) %]
288 <label for="[% field.name | html %]" class="required">
290 <label for="[% field.name | html %]">
292 [% SWITCH ( field.name ) %]
295 [% CASE 'firstname' %]
297 [% CASE 'branchcode' %]
299 [% CASE 'categorycode' %]
301 [% CASE 'streetnumber' %]
305 [% CASE 'address2' %]
325 [% CASE 'dateenrolled' %]
327 [% CASE 'dateexpiry' %]
329 [% CASE 'borrowernotes' %]
331 [% CASE 'opacnote' %]
333 [% CASE 'debarred' %]
334 Restriction expiration:
335 [% CASE 'debarredcomment' %]
339 [% IF ( field.type == 'text' ) %]
340 <input type="text" name="[% field.name | html %]" value="" />
342 [% IF ( field.type == 'select' ) %]
343 [% IF field.option.size %]
344 <select name="[% field.name | html %]" >
345 [% FOREACH opt IN field.option %]
346 <option value="[% opt.value | html %]">[% opt.lib | html %]</option>
350 There is no value defined for [% field.name | html %]
353 [% IF ( field.type == 'date' ) %]
354 <input type="text" name="[% field.name | html %]" id="[% field.name | html %]" value="" size="10" maxlength="10" class="flatpickr" />
355 <a href="#" class="clear-date" id="clear-date-[% field.name | html %]" ><i class="fa fa-fw fa-trash"></i> Clear</a>
357 [% IF field.mandatory %]
358 <input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name | html %]" disabled="disabled" readonly="readonly" />
359 <span class="required">Required fields cannot be cleared</span>
361 <input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name | html %]" />
365 [% IF ( patron_attributes_codes ) %]
366 <li class="attributes">
367 <label style="width:auto;">Patron attribute:
368 <select name="patron_attributes">
369 <option value=""></option>
370 [% FOREACH pac IN patron_attributes_codes %]
371 <option value="[% pac.attribute_code | html %]" data-type="[% pac.type | html %]" data-category="[% pac.category_lib | html %]">[% pac.attribute_lib | html %]</option>
375 <input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
376 <span class="patron_attributes_value"><input type"hidden" name="patron_attributes_value" /></span>
377 <a href="#" class="add_attributes" title="Add an attribute"><i class="fa fa-fw fa-plus"></i> New</a>
378 <span class="information_category hint" style="width:25%;float:right;"></span>
383 <fieldset class="action">
384 <input type="submit" name="mainformsubmit" value="Save" />
385 <a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
392 [% IF ( op == 'show_results' ) %]
394 <a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
399 </div> <!-- /.col-sm-10.col-sm-push-2 -->
401 <div class="col-sm-2 col-sm-pull-10">
403 [% INCLUDE 'tools-menu.inc' %]
405 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
406 </div> <!-- /.row -->
408 [% MACRO jsinclude BLOCK %]
409 [% INCLUDE 'calendar.inc' %]
410 [% INCLUDE 'datatables.inc' %]
411 [% INCLUDE 'columns_settings.inc' %]
412 [% Asset.js("js/tools-menu.js") | $raw %]
414 var patron_attributes_lib = new Array();
415 var patron_attributes_values = new Array();
416 var table_settings = [% TablesSettings.GetColumns( 'tools', 'batch_patron_modification', 'borrowerst', 'json' ) | $raw %];
417 [% FOREACH attrh IN attributes_header %]
418 table_settings.push({
419 columname: "[% attrh.attribute | html %]",
420 cannot_be_modified: 0,
421 cannot_be_toggled: 0,
425 $(document).ready(function() {
427 KohaTable("borrowerst", {
428 "order": [[ 1, "asc" ]],
431 { "visible": false, "targets" : [ "hidden" ] }
435 $("#selectallbutton").click(function() {
436 $("#borrowerst").find("input:checkbox").each(function() {
437 $(this).prop("checked", true);
441 $("#clearallbutton").click(function() {
442 $("#borrowerst").find("input:checkbox").each(function() {
443 $(this).prop("checked", false);
448 $("#batch_patron_options").tabs();
451 var values = new Array();
452 var lib = new Array();
453 [% FOREACH pav IN patron_attributes_values %]
454 values = new Array();
456 [% FOREACH option IN pav.options %]
457 values.push("[% option.lib | html %]");
458 lib.push("[% option.authorised_value | html %]");
460 patron_attributes_lib["[% pav.attribute_code | html %]"] = values;
461 patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
464 $('select[name="patron_attributes"]').change(function() {
465 updateAttrValues(this);
468 $('select[name="patron_attributes"]').change();
470 $(".clear-date").on("click",function(e){
472 var fieldID = this.id.replace("clear-date-","");
473 $("#" + fieldID).val("");
475 $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
479 $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
481 del_attributes(this);
483 $("#patron_batchmod_form").on("submit", function(){
484 /* Reset form fields on inactive tabs */
485 var tab = $(this).find('.ui-tabs-active:first a').attr('href');
486 if ( tab == '#usecardnumber' ) {
487 $("#borrowernumberuploadfile, #patron_list_id, #borrowernumberlist").val("");
488 } else if ( tab == '#useborrowernumber' ) {
489 $("#cardnumberuploadfile, #cardnumberlist, #patron_list_id").val("");
491 $("#borrowernumberuploadfile, #cardnumberuploadfile, #borrowernumberlist, #cardnumberlist").val("");
496 function updateAttrValues (select_attr) {
497 var attr_code = $(select_attr).val();
498 var selected_option = $(select_attr).find("option:selected");
499 var type = $(selected_option).attr('data-type');
500 var category = $(selected_option).attr('data-category');
501 var li_node = $(select_attr).parent().parent();
502 var span = $(li_node).find('span.patron_attributes_value');
503 var information_category_node = $(li_node).find('span.information_category');
504 information_category_node.html("");
506 if ( category && category.length > 0 ) {
507 information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
509 var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
510 if ( type == 'select' ) {
511 var options = '<option value = ""></option>';
512 for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
513 options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
515 span.html('<select name="patron_attributes_value">' + options + '</select>');
516 $(disable_input_node).show();
517 } else if ( $(selected_option).val() != "" ) {
518 span.html('<input type="text" name="patron_attributes_value"/>');
519 $(disable_input_node).show();
521 span.html('<input type="hidden" name="patron_attributes_value" />');
522 $(disable_input_node).hide();
526 function add_attributes() {
527 var li_node = $("li.attributes:last");
528 var li_clone = $(li_node).clone();
529 if ( $(li_clone).find("a.del_attributes").length == 0 ) {
530 $(li_clone).append('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash"></i> ' + _("Delete") + '</a>');
532 $(li_clone).find('select[name="patron_attributes"]').change(function() {
533 updateAttrValues(this);
536 $(li_clone).find('select[name="patron_attributes"]').change();
538 $("#fields_list>ol").append(li_clone);
539 update_attr_values();
542 function del_attributes(a_node) {
543 $(a_node).parent('li').remove();
544 update_attr_values();
547 function update_attr_values() {
548 $("li.attributes").each(function(i) {
549 $(this).find("input:checkbox").val("attr"+i+"_value");
552 function clearDate(nodeid) {
553 $("#"+nodeid).val("");
558 [% INCLUDE 'intranet-bottom.inc' %]