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' ) %]
146 <th>ZIP/Postal code</th>
148 <th class="title-string">Registration date</th>
149 <th class="title-string">Expiry date</th>
150 <th>Circulation note</th>
152 <th>Restriction expiration</th>
153 <th>Restriction comment</th>
154 [% FOREACH attrh IN attributes_header %]
155 <th>[% attrh.attribute | html %]</th>
160 [% FOREACH borrower IN borrowers %]
162 [% IF ( op == 'show' ) %]
163 <td><input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber | html %]" checked="checked" /></td>
165 <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | uri %]">[% borrower.cardnumber | html %]</a></td>
166 <td>[% borrower.surname | html %]</td>
167 <td>[% borrower.firstname | html %]</td>
168 <td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
169 <td>[% Categories.GetName(borrower.categorycode) | html %]</td>
170 <td>[% borrower.city | html %]</td>
171 <td>[% borrower.state | html %]</td>
172 <td>[% borrower.zipcode | html %]</td>
173 <td>[% borrower.country | html %]</td>
174 <td><span title="[% borrower.dateenrolled | html %]">[% borrower.dateenrolled | $KohaDates %]</span></td>
175 <td><span title="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</span></td>
176 <td>[% borrower.borrowernotes | html %]</td>
177 <td>[% borrower.opacnote | html %]</td>
178 <td><span title="[% borrower.debarred | html %]">[% borrower.debarred | $KohaDates %]</span></td>
179 <td>[% borrower.debarredcomment | html %]</td>
180 [% FOREACH pa IN borrower.patron_attributes %]
182 <td>[% pa.code | html %]=[% pa.value | html %]</td>
194 [% IF ( op == 'show' ) %]
195 <div id="cataloguing_additem_newitem">
196 <h2>Edit patrons</h2>
197 <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>
198 <fieldset class="rows" id="fields_list">
200 [% FOREACH field IN fields %]
202 [% IF ( field.mandatory ) %]
203 <label for="[% field.name | html %]" class="required">
205 <label for="[% field.name | html %]">
207 [% SWITCH ( field.name ) %]
210 [% CASE 'firstname' %]
212 [% CASE 'branchcode' %]
214 [% CASE 'categorycode' %]
228 [% CASE 'dateenrolled' %]
230 [% CASE 'dateexpiry' %]
232 [% CASE 'borrowernotes' %]
234 [% CASE 'opacnote' %]
236 [% CASE 'debarred' %]
237 Restriction expiration:
238 [% CASE 'debarredcomment' %]
242 [% IF ( field.type == 'text' ) %]
243 <input type="text" name="[% field.name | html %]" value="" />
245 [% IF ( field.type == 'select' ) %]
246 [% IF field.option.size %]
247 <select name="[% field.name | html %]" >
248 [% FOREACH opt IN field.option %]
249 <option value="[% opt.value | html %]">[% opt.lib | html %]</option>
253 There is no value defined for [% field.name | html %]
256 [% IF ( field.type == 'date' ) %]
257 <input type="text" name="[% field.name | html %]" id="[% field.name | html %]" value="" size="10" maxlength="10" class="datepicker" />
258 <a href="#" class="clear-date" id="clear-date-[% field.name | html %]" ><i class="fa fa-fw fa-trash"></i> Clear</a>
260 [% IF field.mandatory %]
261 <input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name | html %]" disabled="disabled" readonly="readonly" />
262 <span class="required">Required fields cannot be cleared</span>
264 <input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name | html %]" />
268 [% IF ( patron_attributes_codes ) %]
269 <li class="attributes">
270 <label style="width:auto;">Attribute:
271 <select name="patron_attributes">
272 <option value=""></option>
273 [% FOREACH pac IN patron_attributes_codes %]
274 <option value="[% pac.attribute_code | html %]" data-type="[% pac.type | html %]" data-category="[% pac.category_lib | html %]">[% pac.attribute_lib | html %]</option>
278 <input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
279 <span class="patron_attributes_value"><input type"hidden" name="patron_attributes_value" /></span>
280 <a href="#" class="add_attributes" title="Add an attribute"><i class="fa fa-fw fa-plus"></i> New</a>
281 <span class="information_category hint" style="width:25%;float:right;"></span>
286 <fieldset class="action">
287 <input type="submit" name="mainformsubmit" value="Save" />
288 <a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
295 [% IF ( op == 'show_results' ) %]
297 <a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
302 </div> <!-- /.col-sm-10.col-sm-push-2 -->
304 <div class="col-sm-2 col-sm-pull-10">
306 [% INCLUDE 'tools-menu.inc' %]
308 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
309 </div> <!-- /.row -->
311 [% MACRO jsinclude BLOCK %]
312 [% INCLUDE 'calendar.inc' %]
313 [% INCLUDE 'datatables.inc' %]
314 [% Asset.js("js/tools-menu.js") | $raw %]
316 var patron_attributes_lib = new Array();
317 var patron_attributes_values = new Array();
318 $(document).ready(function() {
320 $("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, {
322 [% IF ( op == 'show_results' ) %]
324 { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
328 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
329 { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
334 $("#selectallbutton").click(function() {
335 $("#borrowerst").find("input:checkbox").each(function() {
336 $(this).prop("checked", true);
340 $("#clearallbutton").click(function() {
341 $("#borrowerst").find("input:checkbox").each(function() {
342 $(this).prop("checked", false);
348 var values = new Array();
349 var lib = new Array();
350 [% FOREACH pav IN patron_attributes_values %]
351 values = new Array();
353 [% FOREACH option IN pav.options %]
354 values.push("[% option.lib | html %]");
355 lib.push("[% option.authorised_value | html %]");
357 patron_attributes_lib["[% pav.attribute_code | html %]"] = values;
358 patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
361 $('select[name="patron_attributes"]').change(function() {
362 updateAttrValues(this);
365 $('select[name="patron_attributes"]').change();
367 $(".clear-date").on("click",function(e){
369 var fieldID = this.id.replace("clear-date-","");
370 $("#" + fieldID).val("");
372 $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
376 $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
378 del_attributes(this);
382 function updateAttrValues (select_attr) {
383 var attr_code = $(select_attr).val();
384 var selected_option = $(select_attr).find("option:selected");
385 var type = $(selected_option).attr('data-type');
386 var category = $(selected_option).attr('data-category');
387 var li_node = $(select_attr).parent().parent();
388 var span = $(li_node).find('span.patron_attributes_value');
389 var information_category_node = $(li_node).find('span.information_category');
390 information_category_node.html("");
392 if ( category && category.length > 0 ) {
393 information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
395 var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
396 if ( type == 'select' ) {
397 var options = '<option value = ""></option>';
398 for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
399 options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
401 span.html('<select name="patron_attributes_value">' + options + '</select>');
402 $(disable_input_node).show();
403 } else if ( $(selected_option).val() != "" ) {
404 span.html('<input type="text" name="patron_attributes_value"/>');
405 $(disable_input_node).show();
407 span.html('<input type="hidden" name="patron_attributes_value" />');
408 $(disable_input_node).hide();
412 function add_attributes() {
413 var li_node = $("li.attributes:last");
414 var li_clone = $(li_node).clone();
415 if ( $(li_clone).find("a.del_attributes").length == 0 ) {
416 $(li_clone).append('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash"></i> ' + _("Delete") + '</a>');
418 $(li_clone).find('select[name="patron_attributes"]').change(function() {
419 updateAttrValues(this);
422 $(li_clone).find('select[name="patron_attributes"]').change();
424 $("#fields_list>ol").append(li_clone);
425 update_attr_values();
428 function del_attributes(a_node) {
429 $(a_node).parent('li').remove();
430 update_attr_values();
433 function update_attr_values() {
434 $("li.attributes").each(function(i) {
435 $(this).find("input:checkbox").val("attr"+i+"_value");
438 function clearDate(nodeid) {
439 $("#"+nodeid).val("");
444 [% INCLUDE 'intranet-bottom.inc' %]