7 [% USE TablesSettings %]
8 [% PROCESS 'i18n.inc' %]
10 [% INCLUDE 'doc-head-open.inc' %]
11 <title>[% FILTER collapse %]
12 [% IF ( op == 'show' or op == 'show_results' ) %]
13 [% IF ( op == 'show' ) %]
14 [% t("Modifications") | html %] ›
16 [% t("Results") | html %] ›
19 [% t("Batch patron modification") | html %] ›
20 [% t("Tools") | html %] ›
21 [% t("Koha") | html %]
23 [% INCLUDE 'doc-head-close.inc' %]
26 <body id="tools_modborrowers" class="tools">
27 [% WRAPPER 'header.inc' %]
28 [% INCLUDE 'cat-search.inc' %]
31 [% WRAPPER 'sub-header.inc' %]
32 [% WRAPPER breadcrumbs %]
33 [% WRAPPER breadcrumb_item %]
34 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
36 [% IF ( op == 'show' or op == 'show_results' ) %]
37 [% WRAPPER breadcrumb_item %]
38 <a href="/cgi-bin/koha/tools/modborrowers.pl">Batch patron modification</a>
40 [% IF ( op == 'show' ) %]
41 [% WRAPPER breadcrumb_item bc_active= 1 %]
42 [% t("Modifications") | html %]
45 [% WRAPPER breadcrumb_item bc_active= 1 %]
46 [% t("Results")| html %]
50 [% WRAPPER breadcrumb_item bc_active= 1 %]
51 <span>Batch patron modification</span>
54 [% END #/ WRAPPER breadcrumbs %]
55 [% END #/ WRAPPER sub-header.inc %]
57 <div class="main container-fluid">
59 <div class="col-sm-10 col-sm-push-2">
62 [% IF ( op == 'show_form' ) %]
63 <h1>Batch patron modification</h1>
64 <form id="patron_batchmod_form" method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
65 <input type="hidden" name="op" value="show" />
67 [% WRAPPER tabs id= "batch_patron_options" %]
68 [% WRAPPER tabs_nav %]
69 [% WRAPPER tab_item tabname= "usecardnumber" bt_active= 1 %] <span>By card number</span> [% END %]
70 [% WRAPPER tab_item tabname= "useborrowernumber" %] <span>By borrowernumber</span> [% END %]
72 [% WRAPPER tab_item tabname= "uselist" %] <span>By patron list</span> [% END %]
74 [% END # /WRAPPER tabs_nav %]
76 [% WRAPPER tab_panels %]
77 [% WRAPPER tab_panel tabname="usecardnumber" bt_active= 1 %]
78 <fieldset class="rows">
79 <legend>Use a file of card numbers</legend>
82 <label for="cardnumberuploadfile">File: </label> <input type="file"
83 id="cardnumberuploadfile" name="cardnumberuploadfile" />
84 <div class="hint">File must contain one card number per line.</div>
88 <fieldset class="rows">
89 <legend>Or list card numbers one by one</legend>
92 <label for="cardnumberlist">Card number list (one card number per line):
94 <textarea rows="10" cols="30" id="cardnumberlist"
95 name="cardnumberlist">[% cardnumberlist | html %]</textarea>
99 <fieldset class="action">
100 <input type="submit" class="btn btn-primary" value="Continue" />
101 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
103 [% END # /tab_panel# %]
105 [% WRAPPER tab_panel tabname="useborrowernumber" %]
106 <fieldset class="rows">
107 <legend>Use a file of borrowernumbers</legend>
110 <label for="borrowernumberuploadfile">File: </label> <input type="file"
111 id="borrowernumberuploadfile" name="borrowernumberuploadfile" />
112 <div class="hint">File must contain one borrowernumber per line.</div>
116 <fieldset class="rows">
117 <legend>List borrowernumbers one by one</legend>
120 <label for="borrowernumberlist">Borrowernumber list (one number per line):
122 <textarea rows="10" cols="30" id="borrowernumberlist"
123 name="borrowernumberlist">[% borrowernumberlist | html %]</textarea>
127 <fieldset class="action">
128 <input type="submit" class="btn btn-primary" value="Continue" />
129 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
131 [% END # /tab_panel# %]
133 [% IF patron_lists %]
134 [% WRAPPER tab_panel tabname="uselist" %]
135 <fieldset class="rows">
136 <legend>Use a patron list</legend>
139 <label for="patron_list_id">Patron list: </label>
140 <select id="patron_list_id" name="patron_list_id">
141 <option value=""> -- Choose a patron list -- </option>
142 [% FOREACH pl IN patron_lists %]
143 <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
149 <fieldset class="action">
150 <input type="submit" class="btn btn-primary" value="Continue" />
151 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
153 [% END # /tab_panel# %]
155 [% END # /WRAPPER tab_panels %]
156 [% END # /WRAPPER tabs %]
160 [% IF ( op == 'show') && (!borrowers) && (!notfoundcardnumbers) # Alert if no patrons given%]
161 [% op = 'noshow' # Change op to prevent display in code below %]
162 <h1>Batch patrons modification</h1>
163 <div class="dialog alert">
164 <p>No patron card numbers or borrowernumbers given.</p>
165 <form action="/cgi-bin/koha/tools/modborrowers.pl" method="get">
166 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
169 [% END #Alert if no patrons %]
171 [% IF ( op == 'show' or op == 'show_results' ) %]
172 <h1>Batch patron modification</h1>
173 [% UNLESS ( op == 'show' ) %]
176 [% IF ( notfoundcardnumbers ) %]
177 [% IF ( useborrowernumbers ) -%]
178 <div class="dialog alert"><p>Warning, the following borrowernumbers were not found:</p></div>
180 <div class="dialog alert"><p>Warning, the following card numbers were not found:</p></div>
183 <div class="page-section">
184 <table style="margin:auto;">
186 [% IF ( useborrowernumbers ) -%]
187 <tr><th>Borrowernumbers not found</th></tr>
189 <tr><th>Card numbers not found</th></tr>
193 [% FOREACH notfoundcardnumber IN notfoundcardnumbers %]
194 <tr><td>[% notfoundcardnumber.cardnumber | html %]</td></tr>
198 </div> <!-- /.page-section -->
201 [% IF ( op == 'show_results' ) %]
203 <div class="dialog alert">
204 <h4>Errors occurred:</h4>
205 <ul class="warnings">
206 [% FOREACH error IN errors %]
207 [% IF ( error.error == 'can_not_update' ) %]
208 <li>Can not update patron.
209 [% IF ( error.cardnumber ) %] Card number: [% error.cardnumber | html %] [% END %]
210 (Borrowernumber: [% error.borrowernumber | html %])
213 <li>[% error.error | html %]</li>
221 [% IF ( op == 'show' ) %]
222 <form name="f" action="modborrowers.pl" method="post">
223 <input type="hidden" name="op" value="do" />
224 [% IF ( borrowers ) %]
225 <div class="btn-toolbar selections-toolbar"><a id="selectallbutton" href="#"><i class="fa fa-check"></i> Select all</a> | <a id="clearallbutton" href="#"><i class="fa fa-times"></i> Clear all</a></div>
229 <div id="cataloguing_additem_itemlist" class="page-section">
230 <div style="overflow:auto">
231 <table id="borrowerst">
234 [% IF ( op == 'show' ) %]
235 <th class="NoSort"> </th>
237 <th class="NoVisible"> </th>
243 <th>Patron category</th>
244 <th>Street number</th>
249 <th>ZIP/Postal code</th>
251 <th>Primary email</th>
252 <th>Primary phone</th>
254 <th>Registration date</th>
256 [% IF CanUpdatePasswordExpiration %]
257 <th>Password expiration date</th>
259 <th>Circulation note</th>
261 <th>Restriction expiration</th>
262 <th>Restriction comment</th>
263 [% FOREACH attrh IN attributes_header %]
264 <th>[% attrh.attribute | html %]</th>
269 [% FOREACH borrower IN borrowers %]
271 [% IF ( op == 'show' ) %]
274 <td class="NoVisible">
276 <input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber | html %]" checked="checked" />
278 <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | uri %]">[% borrower.cardnumber | html %]</a></td>
279 <td>[% borrower.surname | html %]</td>
280 <td>[% borrower.firstname | html %]</td>
281 <td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
282 <td>[% Categories.GetName(borrower.categorycode) | html %]</td>
283 <td>[% borrower.streetnumber | html %]</td>
284 <td>[% borrower.address | html %]</td>
285 <td>[% borrower.address2 | html %]</td>
286 <td>[% borrower.city | html %]</td>
287 <td>[% borrower.state | html %]</td>
288 <td>[% borrower.zipcode | html %]</td>
289 <td>[% borrower.country | html %]</td>
290 <td>[% borrower.email | html %]</td>
291 <td>[% borrower.phone | html %]</td>
292 <td>[% borrower.mobile | html %]</td>
293 <td data-order="[% borrower.dateenrolled | html %]">[% borrower.dateenrolled | $KohaDates %]</td>
294 <td data-order="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</td>
295 [% IF CanUpdatePasswordExpiration %]
296 [% IF borrower.password_expiration_date %]
297 <td data-order="[% borrower.password_expiration_date | html %]">
298 [% borrower.password_expiration_date | $KohaDates %]
301 <td data-order="9999-99-99">Never</td>
304 <td>[% borrower.borrowernotes | $raw | html_line_break %]</td>
305 <td>[% borrower.opacnote | html %]</td>
306 <td data-order="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</td>
307 <td>[% borrower.debarredcomment | html %]</td>
308 [% FOREACH pa IN borrower.patron_attributes %]
310 [%# Replace pa.attribute with pa.description if we prefer to display the description %]
311 <td>[% pa.code | html %]=[% pa.attribute | html %]</td>
323 [% IF ( op == 'show' ) %]
324 <div id="cataloguing_additem_newitem">
325 <h2>Edit patrons</h2>
326 <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>
327 <fieldset class="rows" id="fields_list">
329 [% FOREACH field IN fields %]
331 [% IF ( field.mandatory ) %]
332 <label for="[% field.name | html %]" class="required">
334 <label for="[% field.name | html %]">
336 [% SWITCH ( field.name ) %]
337 [% CASE 'surname' %]<span>Surname:</span>
338 [% CASE 'firstname' %]<span>First name:</span>
339 [% CASE 'branchcode' %]<span>Library:</span>
340 [% CASE 'categorycode' %]<span>Patron category:</span>
341 [% CASE 'streetnumber' %]<span>Street number:</span>
342 [% CASE 'address' %]<span>Address:</span>
343 [% CASE 'address2' %]<span>Address 2:</span>
344 [% CASE 'city' %]<span>City:</span>
345 [% CASE 'state' %]<span>State:</span>
346 [% CASE 'zipcode' %]<span>ZIP/Postal code:</span>
347 [% CASE 'country' %]<span>Country:</span>
348 [% CASE 'email' %]<span>Primary email:</span>
349 [% CASE 'phone' %]<span>Primary phone:</span>
350 [% CASE 'mobile' %]<span>Other phone:</span>
351 [% CASE 'sort1' %]<span>Sort 1:</span>
352 [% CASE 'sort2' %]<span>Sort 2:</span>
353 [% CASE 'dateenrolled' %]<span>Registration date:</span>
354 [% CASE 'dateexpiry' %]<span>Expiry date:</span>
355 [% CASE 'borrowernotes' %]<span>Circulation note:</span>
356 [% CASE 'opacnote' %]<span>OPAC note:</span>
357 [% CASE 'debarred' %]<span>Restriction expiration:</span>
358 [% CASE 'debarredcomment' %]<span>Restriction comment:</span>
359 [% CASE 'password_expiration_date' %]<span>Password expiration date:</span>
362 [% IF ( field.type == 'text' ) %]
363 <input type="text" name="[% field.name | html %]" value="" />
365 [% IF ( field.type == 'select' ) %]
366 [% IF field.option.size %]
367 <select name="[% field.name | html %]" >
368 [% FOREACH opt IN field.option %]
369 <option value="[% opt.value | html %]">[% opt.lib | html %]</option>
373 There is no value defined for [% field.name | html %]
376 [% IF ( field.type == 'date' ) %]
377 <input type="text" name="[% field.name | html %]" id="[% field.name | html %]" value="" size="10" maxlength="10" class="flatpickr" />
378 <a href="#" class="clear-date" id="clear-date-[% field.name | html %]" ><i class="fa fa-fw fa-trash-can"></i> Clear</a>
380 [% IF field.mandatory %]
381 <input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name | html %]" disabled="disabled" readonly="readonly" />
382 <span class="required">Required fields cannot be cleared</span>
384 <input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name | html %]" />
388 [% IF ( patron_attributes_codes ) %]
389 <li class="attributes">
390 <label style="width:auto;">
391 <span>Patron attribute:</span>
393 <select name="patron_attributes">
394 <option value=""></option>
395 [% FOREACH pac IN patron_attributes_codes %]
396 <option value="[% pac.attribute_code | html %]" data-type="[% pac.type | html %]" data-category="[% pac.category_lib | html %]">[% pac.attribute_lib | html %]</option>
400 <input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
401 <span class="patron_attributes_value"><input type"hidden" name="patron_attributes_value" /></span>
402 <a href="#" class="add_attributes" title="Add an attribute"><i class="fa fa-fw fa-plus"></i> New</a>
403 <span class="information_category hint" style="width:25%;float:right;"></span>
405 <div class="hint">NOTE: Attributes set here will replace all attributes of the same type in the patron record.</div>
409 <fieldset class="action">
410 <input type="submit" name="mainformsubmit" class="btn btn-primary" value="Save" />
411 <a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
418 [% IF ( op == 'show_results' ) %]
420 <a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
425 </div> <!-- /.col-sm-10.col-sm-push-2 -->
427 <div class="col-sm-2 col-sm-pull-10">
429 [% INCLUDE 'tools-menu.inc' %]
431 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
432 </div> <!-- /.row -->
434 [% MACRO jsinclude BLOCK %]
435 [% INCLUDE 'calendar.inc' %]
436 [% INCLUDE 'datatables.inc' %]
437 [% INCLUDE 'columns_settings.inc' %]
438 [% Asset.js("js/tools-menu.js") | $raw %]
440 var patron_attributes_lib = new Array();
441 var patron_attributes_values = new Array();
442 var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'batch_patron_modification', 'borrowerst', 'json' ) | $raw %];
444 [% FOREACH attrh IN attributes_header %]
445 table_settings["columns"].push({
446 columname: "[% attrh.attribute | html %]",
447 cannot_be_modified: 0,
448 cannot_be_toggled: 0,
452 $(document).ready(function() {
454 let patron_table = KohaTable("borrowerst", {
455 "order": [[ 1, "asc" ]],
459 $("#selectallbutton").click(function() {
460 $("#borrowerst").find("input:checkbox").each(function() {
461 $(this).prop("checked", true);
465 $("#clearallbutton").click(function() {
466 $("#borrowerst").find("input:checkbox").each(function() {
467 $(this).prop("checked", false);
473 var values = new Array();
474 var lib = new Array();
475 [% FOREACH pav IN patron_attributes_values %]
476 values = new Array();
478 [% FOREACH option IN pav.options %]
479 values.push("[% option.lib | html %]");
480 lib.push("[% option.authorised_value | html %]");
482 patron_attributes_lib["[% pav.attribute_code | html %]"] = values;
483 patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
486 $('select[name="patron_attributes"]').change(function() {
487 updateAttrValues(this);
490 $('select[name="patron_attributes"]').change();
492 $(".clear-date").on("click",function(e){
494 var fieldID = this.id.replace("clear-date-","");
495 $("#" + fieldID).val("");
497 $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
501 $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
503 del_attributes(this);
505 $("#patron_batchmod_form").on("submit", function(){
506 /* Reset form fields on inactive tabs */
507 var tab = $(this).find('ul.nav-tabs li.active a').attr('href');
508 if ( tab == '#usecardnumber_panel' ) {
509 $("#borrowernumberuploadfile, #patron_list_id, #borrowernumberlist").val("");
510 } else if ( tab == '#useborrowernumber_panel' ) {
511 $("#cardnumberuploadfile, #cardnumberlist, #patron_list_id").val("");
512 } else { // uselist_panel
513 $("#borrowernumberuploadfile, #cardnumberuploadfile, #borrowernumberlist, #cardnumberlist").val("");
517 $('form[name="f"]').on("submit", function(){
518 // Add the checkboxes to the DOM before we submit the form
520 var checkboxes = patron_table.$('input:checkbox:checked').serializeArray();
521 $.each(checkboxes, function(){
522 let borrowernumber = this.value;
523 if(!$(form).find('input[name="borrowernumber"][value="'+borrowernumber+'"]').length){
526 .attr('type', 'hidden')
527 .attr('name', 'borrowernumber')
535 function updateAttrValues (select_attr) {
536 var attr_code = $(select_attr).val();
537 var selected_option = $(select_attr).find("option:selected");
538 var type = $(selected_option).attr('data-type');
539 var category = $(selected_option).attr('data-category');
540 var li_node = $(select_attr).parent();
541 var span = $(li_node).find('span.patron_attributes_value');
542 var information_category_node = $(li_node).find('span.information_category');
543 information_category_node.html("");
545 if ( category && category.length > 0 ) {
546 information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
548 var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
549 if ( type == 'select' ) {
550 var options = '<option value = ""></option>';
551 for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
552 options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
554 span.html('<select name="patron_attributes_value">' + options + '</select>');
555 $(disable_input_node).show();
556 } else if ( $(selected_option).val() != "" ) {
557 span.html('<input type="text" name="patron_attributes_value"/>');
558 $(disable_input_node).show();
560 span.html('<input type="hidden" name="patron_attributes_value" />');
561 $(disable_input_node).hide();
565 function add_attributes() {
566 var li_node = $("li.attributes:last");
567 var li_clone = $(li_node).clone();
568 if ( $(li_clone).find("a.del_attributes").length == 0 ) {
569 var add_attributes = $(li_clone).find("a.add_attributes")
570 $(add_attributes).after('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash-can"></i> ' + _("Delete") + '</a>');
572 $(li_clone).find('select[name="patron_attributes"]').change(function() {
573 updateAttrValues(this);
576 $(li_clone).find('select[name="patron_attributes"]').change();
578 $("#fields_list>ol").append(li_clone);
579 update_attr_values();
582 function del_attributes(a_node) {
583 $(a_node).parent('li').remove();
584 update_attr_values();
587 function update_attr_values() {
588 $("li.attributes").each(function(i) {
589 $(this).find("input:checkbox").val("attr"+i+"_value");
592 function clearDate(nodeid) {
593 $("#"+nodeid).val("");
598 [% INCLUDE 'intranet-bottom.inc' %]