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 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
20 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
23 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
26 <a href="#" aria-current="page">Batch patron modification</a>
31 <div class="main container-fluid">
33 <div class="col-sm-10 col-sm-push-2">
36 [% IF ( op == 'show_form' ) %]
37 <h1>Batch patron modification</h1>
38 <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
39 <fieldset class="rows">
40 <legend>Use a file</legend>
42 <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
47 <fieldset class="rows">
48 <legend>Or use a patron list</legend>
51 <label for="patron_list_id">Patron list: </label>
52 <select id="patron_list_id" name="patron_list_id">
53 <option value=""></option>
54 [% FOREACH pl IN patron_lists %]
55 <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
63 <fieldset class="rows">
64 <legend>Or list cardnumbers one by one</legend>
67 <label for="cardnumberlist">Card number list (one cardnumber per line): </label>
68 <textarea rows="10" cols="30" id="cardnumberlist" name="cardnumberlist">[% cardnumberlist | html %]</textarea>
72 <input type="hidden" name="op" value="show" />
73 <fieldset class="action">
74 <input type="submit" value="Continue" class="button" />
75 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
80 [% IF ( op == 'show') && (!borrowers) && (!notfoundcardnumbers) # Alert if no patrons given%]
81 [% op = 'noshow' # Change op to prevent display in code below %]
82 <h1>Batch patrons modification</h1>
83 <div class="dialog alert">
84 <p>No patron card numbers given.</p>
85 <form action="/cgi-bin/koha/tools/modborrowers.pl" method="get">
86 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
89 [% END #Alert if no patrons %]
91 [% IF ( op == 'show' or op == 'show_results' ) %]
92 [% IF ( op == 'show' ) %]
93 <h1>Batch patrons modification</h1>
95 <h1>Batch patrons results</h1>
97 [% IF ( notfoundcardnumbers ) %]
98 <div class="dialog alert"><p>Warning, the following cardnumbers were not found:</p></div>
99 <table style="margin:auto;">
101 <tr><th>Cardnumbers not found</th></tr>
104 [% FOREACH notfoundcardnumber IN notfoundcardnumbers %]
105 <tr><td>[% notfoundcardnumber.cardnumber | html %]</td></tr>
111 [% IF ( op == 'show_results' ) %]
113 <div class="dialog alert">
114 <h4>Errors occurred:</h4>
115 <ul class="warnings">
116 [% FOREACH error IN errors %]
117 [% IF ( error.error == 'can_not_update' ) %]
118 <li>Can not update patron.
119 [% IF ( error.cardnumber ) %] Cardnumber: [% error.cardnumber | html %] [% END %]
120 (Borrowernumber: [% error.borrowernumber | html %])
123 <li>[% error.error | html %]</li>
131 [% IF ( op == 'show' ) %]
132 <form name="f" action="modborrowers.pl" method="post">
133 <input type="hidden" name="op" value="do" />
134 [% IF ( borrowers ) %]
135 <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>
139 <div id="cataloguing_additem_itemlist">
140 <div style="overflow:auto">
141 <table id="borrowerst">
144 [% IF ( op == 'show' ) %]
151 <th>Patron category</th>
152 <th>Street number</th>
157 <th>ZIP/Postal code</th>
159 <th>Primary email</th>
162 <th class="title-string">Registration date</th>
163 <th class="title-string">Expiry date</th>
164 <th>Circulation note</th>
166 <th>Restriction expiration</th>
167 <th>Restriction comment</th>
168 [% FOREACH attrh IN attributes_header %]
169 <th>[% attrh.attribute | html %]</th>
174 [% FOREACH borrower IN borrowers %]
176 [% IF ( op == 'show' ) %]
177 <td><input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber | html %]" checked="checked" /></td>
179 <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | uri %]">[% borrower.cardnumber | html %]</a></td>
180 <td>[% borrower.surname | html %]</td>
181 <td>[% borrower.firstname | html %]</td>
182 <td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
183 <td>[% Categories.GetName(borrower.categorycode) | html %]</td>
184 <td>[% borrower.streetnumber | html %]</td>
185 <td>[% borrower.address | html %]</td>
186 <td>[% borrower.address2 | html %]</td>
187 <td>[% borrower.city | html %]</td>
188 <td>[% borrower.state | html %]</td>
189 <td>[% borrower.zipcode | html %]</td>
190 <td>[% borrower.country | html %]</td>
191 <td>[% borrower.email | html %]</td>
192 <td>[% borrower.phone | html %]</td>
193 <td>[% borrower.mobile | html %]</td>
194 <td><span title="[% borrower.dateenrolled | html %]">[% borrower.dateenrolled | $KohaDates %]</span></td>
195 <td><span title="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</span></td>
196 <td>[% borrower.borrowernotes | html %]</td>
197 <td>[% borrower.opacnote | html %]</td>
198 <td><span title="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</span></td>
199 <td>[% borrower.debarredcomment | html %]</td>
200 [% FOREACH pa IN borrower.patron_attributes %]
202 [%# Replace pa.attribute with pa.description if we prefer to display the description %]
203 <td>[% pa.code | html %]=[% pa.attribute | html %]</td>
215 [% IF ( op == 'show' ) %]
216 <div id="cataloguing_additem_newitem">
217 <h2>Edit patrons</h2>
218 <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>
219 <fieldset class="rows" id="fields_list">
221 [% FOREACH field IN fields %]
223 [% IF ( field.mandatory ) %]
224 <label for="[% field.name | html %]" class="required">
226 <label for="[% field.name | html %]">
228 [% SWITCH ( field.name ) %]
231 [% CASE 'firstname' %]
233 [% CASE 'branchcode' %]
235 [% CASE 'categorycode' %]
237 [% CASE 'streetnumber' %]
241 [% CASE 'address2' %]
261 [% CASE 'dateenrolled' %]
263 [% CASE 'dateexpiry' %]
265 [% CASE 'borrowernotes' %]
267 [% CASE 'opacnote' %]
269 [% CASE 'debarred' %]
270 Restriction expiration:
271 [% CASE 'debarredcomment' %]
275 [% IF ( field.type == 'text' ) %]
276 <input type="text" name="[% field.name | html %]" value="" />
278 [% IF ( field.type == 'select' ) %]
279 [% IF field.option.size %]
280 <select name="[% field.name | html %]" >
281 [% FOREACH opt IN field.option %]
282 <option value="[% opt.value | html %]">[% opt.lib | html %]</option>
286 There is no value defined for [% field.name | html %]
289 [% IF ( field.type == 'date' ) %]
290 <input type="text" name="[% field.name | html %]" id="[% field.name | html %]" value="" size="10" maxlength="10" class="datepicker" />
291 <a href="#" class="clear-date" id="clear-date-[% field.name | html %]" ><i class="fa fa-fw fa-trash"></i> Clear</a>
293 [% IF field.mandatory %]
294 <input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name | html %]" disabled="disabled" readonly="readonly" />
295 <span class="required">Required fields cannot be cleared</span>
297 <input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name | html %]" />
301 [% IF ( patron_attributes_codes ) %]
302 <li class="attributes">
303 <label style="width:auto;">Patron attribute:
304 <select name="patron_attributes">
305 <option value=""></option>
306 [% FOREACH pac IN patron_attributes_codes %]
307 <option value="[% pac.attribute_code | html %]" data-type="[% pac.type | html %]" data-category="[% pac.category_lib | html %]">[% pac.attribute_lib | html %]</option>
311 <input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
312 <span class="patron_attributes_value"><input type"hidden" name="patron_attributes_value" /></span>
313 <a href="#" class="add_attributes" title="Add an attribute"><i class="fa fa-fw fa-plus"></i> New</a>
314 <span class="information_category hint" style="width:25%;float:right;"></span>
319 <fieldset class="action">
320 <input type="submit" name="mainformsubmit" value="Save" />
321 <a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
328 [% IF ( op == 'show_results' ) %]
330 <a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
335 </div> <!-- /.col-sm-10.col-sm-push-2 -->
337 <div class="col-sm-2 col-sm-pull-10">
339 [% INCLUDE 'tools-menu.inc' %]
341 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
342 </div> <!-- /.row -->
344 [% MACRO jsinclude BLOCK %]
345 [% INCLUDE 'calendar.inc' %]
346 [% INCLUDE 'datatables.inc' %]
347 [% Asset.js("js/tools-menu.js") | $raw %]
349 var patron_attributes_lib = new Array();
350 var patron_attributes_values = new Array();
351 $(document).ready(function() {
353 $("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, {
355 [% IF ( op == 'show_results' ) %]
357 { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
361 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
362 { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
367 $("#selectallbutton").click(function() {
368 $("#borrowerst").find("input:checkbox").each(function() {
369 $(this).prop("checked", true);
373 $("#clearallbutton").click(function() {
374 $("#borrowerst").find("input:checkbox").each(function() {
375 $(this).prop("checked", false);
381 var values = new Array();
382 var lib = new Array();
383 [% FOREACH pav IN patron_attributes_values %]
384 values = new Array();
386 [% FOREACH option IN pav.options %]
387 values.push("[% option.lib | html %]");
388 lib.push("[% option.authorised_value | html %]");
390 patron_attributes_lib["[% pav.attribute_code | html %]"] = values;
391 patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
394 $('select[name="patron_attributes"]').change(function() {
395 updateAttrValues(this);
398 $('select[name="patron_attributes"]').change();
400 $(".clear-date").on("click",function(e){
402 var fieldID = this.id.replace("clear-date-","");
403 $("#" + fieldID).val("");
405 $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
409 $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
411 del_attributes(this);
415 function updateAttrValues (select_attr) {
416 var attr_code = $(select_attr).val();
417 var selected_option = $(select_attr).find("option:selected");
418 var type = $(selected_option).attr('data-type');
419 var category = $(selected_option).attr('data-category');
420 var li_node = $(select_attr).parent().parent();
421 var span = $(li_node).find('span.patron_attributes_value');
422 var information_category_node = $(li_node).find('span.information_category');
423 information_category_node.html("");
425 if ( category && category.length > 0 ) {
426 information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
428 var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
429 if ( type == 'select' ) {
430 var options = '<option value = ""></option>';
431 for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
432 options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
434 span.html('<select name="patron_attributes_value">' + options + '</select>');
435 $(disable_input_node).show();
436 } else if ( $(selected_option).val() != "" ) {
437 span.html('<input type="text" name="patron_attributes_value"/>');
438 $(disable_input_node).show();
440 span.html('<input type="hidden" name="patron_attributes_value" />');
441 $(disable_input_node).hide();
445 function add_attributes() {
446 var li_node = $("li.attributes:last");
447 var li_clone = $(li_node).clone();
448 if ( $(li_clone).find("a.del_attributes").length == 0 ) {
449 $(li_clone).append('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash"></i> ' + _("Delete") + '</a>');
451 $(li_clone).find('select[name="patron_attributes"]').change(function() {
452 updateAttrValues(this);
455 $(li_clone).find('select[name="patron_attributes"]').change();
457 $("#fields_list>ol").append(li_clone);
458 update_attr_values();
461 function del_attributes(a_node) {
462 $(a_node).parent('li').remove();
463 update_attr_values();
466 function update_attr_values() {
467 $("li.attributes").each(function(i) {
468 $(this).find("input:checkbox").val("attr"+i+"_value");
471 function clearDate(nodeid) {
472 $("#"+nodeid).val("");
477 [% INCLUDE 'intranet-bottom.inc' %]