8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Koha › Tools › Batch patron modification</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 [% Asset.css("css/datatables.css") | $raw %]
14 <body id="tools_modborrowers" class="tools">
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'cat-search.inc' %]
18 <div id="breadcrumbs">
19 <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
20 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> ›
21 <a href="/cgi-bin/koha/tools/modborrowers.pl">Batch patron modification</a>
24 <div class="main container-fluid">
26 <div class="col-sm-10 col-sm-push-2">
29 [% IF ( op == 'show_form' ) %]
30 <h1>Batch patron modification</h1>
31 <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/modborrowers.pl">
32 <fieldset class="rows">
33 <legend>Use a file</legend>
35 <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
40 <fieldset class="rows">
41 <legend>Or use a patron list</legend>
44 <label for="patron_list_id">Patron list: </label>
45 <select id="patron_list_id" name="patron_list_id">
46 <option value=""></option>
47 [% FOREACH pl IN patron_lists %]
48 <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
56 <fieldset class="rows">
57 <legend>Or list cardnumbers one by one</legend>
60 <label for="cardnumberlist">Card number list (one cardnumber per line): </label>
61 <textarea rows="10" cols="30" id="cardnumberlist" name="cardnumberlist">[% cardnumberlist | html %]</textarea>
65 <input type="hidden" name="op" value="show" />
66 <fieldset class="action">
67 <input type="submit" value="Continue" class="button" />
68 <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
73 [% IF ( op == 'show') && (!borrowers) && (!notfoundcardnumbers) # Alert if no patrons given%]
74 [% op = 'noshow' # Change op to prevent display in code below %]
75 <h1>Batch patrons modification</h1>
76 <div class="dialog alert">
77 <p>No patron card numbers given.</p>
78 <form action="/cgi-bin/koha/tools/modborrowers.pl" method="get">
79 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
82 [% END #Alert if no patrons %]
84 [% IF ( op == 'show' or op == 'show_results' ) %]
85 [% IF ( op == 'show' ) %]
86 <h1>Batch patrons modification</h1>
88 <h1>Batch patrons results</h1>
90 [% IF ( notfoundcardnumbers ) %]
91 <div class="dialog alert"><p>Warning, the following cardnumbers were not found:</p></div>
92 <table style="margin:auto;">
94 <tr><th>Cardnumbers not found</th></tr>
97 [% FOREACH notfoundcardnumber IN notfoundcardnumbers %]
98 <tr><td>[% notfoundcardnumber.cardnumber | html %]</td></tr>
104 [% IF ( op == 'show_results' ) %]
106 <div class="dialog alert">
107 <h4>Errors occurred:</h4>
108 <ul class="warnings">
109 [% FOREACH error IN errors %]
110 [% IF ( error.error == 'can_not_update' ) %]
111 <li>Can not update patron.
112 [% IF ( error.cardnumber ) %] Cardnumber: [% error.cardnumber | html %] [% END %]
113 (Borrowernumber: [% error.borrowernumber | html %])
116 <li>[% error.error | html %]</li>
124 [% IF ( op == 'show' ) %]
125 <form name="f" action="modborrowers.pl" method="post">
126 <input type="hidden" name="op" value="do" />
127 [% IF ( borrowers ) %]
128 <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>
132 <div id="cataloguing_additem_itemlist">
133 <div style="overflow:auto">
134 <table id="borrowerst">
137 [% IF ( op == 'show' ) %]
147 <th>ZIP/Postal code</th>
149 <th class="title-string">Registration date</th>
150 <th class="title-string">Expiry date</th>
151 <th>Circulation note</th>
153 [% FOREACH attrh IN attributes_header %]
154 <th>[% attrh.attribute | html %]</th>
159 [% FOREACH borrower IN borrowers %]
161 [% IF ( op == 'show' ) %]
162 <td><input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber | html %]" checked="checked" /></td>
164 <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | uri %]">[% borrower.cardnumber | html %]</a></td>
165 <td>[% borrower.surname | html %]</td>
166 <td>[% borrower.firstname | html %]</td>
167 <td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
168 <td>[% Categories.GetName(borrower.categorycode) | html %]</td>
169 <td>[% borrower.city | html %]</td>
170 <td>[% borrower.state | html %]</td>
171 <td>[% borrower.zipcode | html %]</td>
172 <td>[% borrower.country | html %]</td>
173 <td><span title="[% borrower.dateenrolled | html %]">[% borrower.dateenrolled | $KohaDates %]</span></td>
174 <td><span title="[% borrower.dateexpiry | html %]">[% borrower.dateexpiry | $KohaDates %]</span></td>
175 <td>[% borrower.borrowernotes | html %]</td>
176 <td>[% borrower.opacnote | html %]</td>
177 [% FOREACH pa IN borrower.patron_attributes %]
179 <td>[% pa.code | html %]=[% pa.value | html %]</td>
191 [% IF ( op == 'show' ) %]
192 <div id="cataloguing_additem_newitem">
193 <h2>Edit patrons</h2>
194 <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>
195 <fieldset class="rows" id="fields_list">
197 [% FOREACH field IN fields %]
199 [% IF ( field.mandatory ) %]
200 <label for="[% field.name | html %]" class="required">
202 <label for="[% field.name | html %]">
204 [% SWITCH ( field.name ) %]
207 [% CASE 'firstname' %]
209 [% CASE 'branchcode' %]
211 [% CASE 'categorycode' %]
225 [% CASE 'dateenrolled' %]
227 [% CASE 'dateexpiry' %]
229 [% CASE 'borrowernotes' %]
231 [% CASE 'opacnote' %]
235 [% IF ( field.type == 'text' ) %]
236 <input type="text" name="[% field.name | html %]" value="" />
238 [% IF ( field.type == 'select' ) %]
239 [% IF field.option.size %]
240 <select name="[% field.name | html %]" >
241 [% FOREACH opt IN field.option %]
242 <option value="[% opt.value | html %]">[% opt.lib | html %]</option>
246 There is no value defined for [% field.name | html %]
249 [% IF ( field.type == 'date' ) %]
250 <input type="text" name="[% field.name | html %]" id="[% field.name | html %]" value="" size="10" maxlength="10" class="datepicker" />
251 <a href="#" class="clear-date" id="clear-date-[% field.name | html %]" ><i class="fa fa-fw fa-trash"></i> Clear</a>
253 [% IF field.mandatory %]
254 <input type="checkbox" title="This field is mandatory" name="disable_input" value="[% field.name | html %]" disabled="disabled" readonly="readonly" />
255 <span class="required">Required fields cannot be cleared</span>
257 <input type="checkbox" title="Check to delete this field" name="disable_input" value="[% field.name | html %]" />
261 [% IF ( patron_attributes_codes ) %]
262 <li class="attributes">
263 <label style="width:auto;">Attribute:
264 <select name="patron_attributes">
265 <option value=""></option>
266 [% FOREACH pac IN patron_attributes_codes %]
267 <option value="[% pac.attribute_code | html %]" data-type="[% pac.type | html %]" data-category="[% pac.category_lib | html %]">[% pac.attribute_lib | html %]</option>
271 <input type="checkbox" title="check to delete this field" name="disable_input" value="attr0_value" />
272 <span class="patron_attributes_value"></span>
273 <a href="#" class="add_attributes" title="Add an attribute"><i class="fa fa-fw fa-plus"></i> New</a>
274 <span class="information_category hint" style="width:25%;float:right;"></span>
279 <fieldset class="action">
280 <input type="submit" name="mainformsubmit" value="Save" />
281 <a href="/cgi-bin/koha/tools/modborrowers.pl" class="cancel">Cancel</a>
288 [% IF ( op == 'show_results' ) %]
290 <a href="/cgi-bin/koha/tools/modborrowers.pl" title="New batch patrons modification">New batch patron modification</a>
295 </div> <!-- /.col-sm-10.col-sm-push-2 -->
297 <div class="col-sm-2 col-sm-pull-10">
299 [% INCLUDE 'tools-menu.inc' %]
301 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
302 </div> <!-- /.row -->
304 [% MACRO jsinclude BLOCK %]
305 [% INCLUDE 'calendar.inc' %]
306 [% INCLUDE 'datatables.inc' %]
307 [% Asset.js("js/tools-menu.js") | $raw %]
309 var patron_attributes_lib = new Array();
310 var patron_attributes_values = new Array();
311 $(document).ready(function() {
313 $("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, {
315 [% IF ( op == 'show_results' ) %]
317 { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
321 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
322 { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
327 $("#selectallbutton").click(function() {
328 $("#borrowerst").find("input:checkbox").each(function() {
329 $(this).prop("checked", true);
333 $("#clearallbutton").click(function() {
334 $("#borrowerst").find("input:checkbox").each(function() {
335 $(this).prop("checked", false);
341 var values = new Array();
342 var lib = new Array();
343 [% FOREACH pav IN patron_attributes_values %]
344 values = new Array();
346 [% FOREACH option IN pav.options %]
347 values.push("[% option.lib | html %]");
348 lib.push("[% option.authorised_value | html %]");
350 patron_attributes_lib["[% pav.attribute_code | html %]"] = values;
351 patron_attributes_values["[% pav.attribute_code | html %]"] = lib;
354 $('select[name="patron_attributes"]').change(function() {
355 updateAttrValues(this);
358 $('select[name="patron_attributes"]').change();
360 $(".clear-date").on("click",function(e){
362 var fieldID = this.id.replace("clear-date-","");
363 $("#" + fieldID).val("");
365 $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){
369 $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){
371 del_attributes(this);
375 function updateAttrValues (select_attr) {
376 var attr_code = $(select_attr).val();
377 var selected_option = $(select_attr).find("option:selected");
378 var type = $(selected_option).attr('data-type');
379 var category = $(selected_option).attr('data-category');
380 var li_node = $(select_attr).parent().parent();
381 var span = $(li_node).find('span.patron_attributes_value');
382 var information_category_node = $(li_node).find('span.information_category');
383 information_category_node.html("");
385 if ( category && category.length > 0 ) {
386 information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category));
388 var disable_input_node = $(li_node).find("input:checkbox[name='disable_input']");
389 if ( type == 'select' ) {
390 var options = '<option value = ""></option>';
391 for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) {
392 options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>';
394 span.html('<select name="patron_attributes_value">' + options + '</select>');
395 $(disable_input_node).show();
396 } else if ( $(selected_option).val() != "" ) {
397 span.html('<input type="text" name="patron_attributes_value"/>');
398 $(disable_input_node).show();
401 $(disable_input_node).hide();
405 function add_attributes() {
406 var li_node = $("li.attributes:last");
407 var li_clone = $(li_node).clone();
408 if ( $(li_clone).find("a.del_attributes").length == 0 ) {
409 $(li_clone).append('<a href="#" title="' + _("Delete") + '" class="del_attributes"><i class="fa fa-fw fa-trash"></i> ' + _("Delete") + '</a>');
411 $(li_clone).find('select[name="patron_attributes"]').change(function() {
412 updateAttrValues(this);
415 $(li_clone).find('select[name="patron_attributes"]').change();
417 $("#fields_list>ol").append(li_clone);
418 update_attr_values();
421 function del_attributes(a_node) {
422 $(a_node).parent('li').remove();
423 update_attr_values();
426 function update_attr_values() {
427 $("li.attributes").each(function(i) {
428 $(this).find("input:checkbox").val("attr"+i+"_value");
431 function clearDate(nodeid) {
432 $("#"+nodeid).val("");
437 [% INCLUDE 'intranet-bottom.inc' %]