Lines 1-134
Link Here
|
1 |
[% USE Koha %] |
1 |
[% USE Koha %] |
2 |
[% USE KohaDates %] |
2 |
[% USE KohaDates %] |
3 |
[% USE Branches %] |
3 |
[% USE Branches %] |
4 |
[% INCLUDE 'doc-head-open.inc'%] |
4 |
[% SET footerjs = 1 %] |
|
|
5 |
[% INCLUDE 'doc-head-open.inc' %] |
5 |
<title>Koha › Tools › Batch patron modification</title> |
6 |
<title>Koha › Tools › Batch patron modification</title> |
6 |
[% INCLUDE 'doc-head-close.inc' %] |
7 |
[% INCLUDE 'doc-head-close.inc' %] |
7 |
[% INCLUDE 'calendar.inc' %] |
|
|
8 |
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> |
8 |
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> |
9 |
[% INCLUDE 'datatables.inc' %] |
|
|
10 |
<script type="text/javascript"> |
11 |
//<![CDATA[ |
12 |
var patron_attributes_lib = new Array(); |
13 |
var patron_attributes_values = new Array(); |
14 |
$(document).ready(function() { |
15 |
[% IF borrowers %] |
16 |
$("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, { |
17 |
"sDom": 't', |
18 |
[% IF ( op == 'show_results' ) %] |
19 |
"aoColumnDefs": [ |
20 |
{ 'sType': "title-string", 'aTargets' : [ 'title-string'] } |
21 |
], |
22 |
[% ELSE %] |
23 |
"aoColumnDefs": [ |
24 |
{ "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }, |
25 |
{ 'sType': "title-string", 'aTargets' : [ 'title-string'] } |
26 |
], |
27 |
[% END %] |
28 |
"bPaginate": false |
29 |
})); |
30 |
$("#selectallbutton").click(function() { |
31 |
$("#borrowerst").find("input:checkbox").each(function() { |
32 |
$(this).prop("checked", true); |
33 |
}); |
34 |
return false; |
35 |
}); |
36 |
$("#clearallbutton").click(function() { |
37 |
$("#borrowerst").find("input:checkbox").each(function() { |
38 |
$(this).prop("checked", false); |
39 |
}); |
40 |
return false; |
41 |
}); |
42 |
[% END %] |
43 |
|
44 |
var values = new Array(); |
45 |
var lib = new Array(); |
46 |
[% FOREACH pav IN patron_attributes_values %] |
47 |
values = new Array(); |
48 |
lib = new Array(); |
49 |
[% FOREACH option IN pav.options %] |
50 |
values.push("[% option.lib %]"); |
51 |
lib.push("[% option.authorised_value %]"); |
52 |
[% END %] |
53 |
patron_attributes_lib["[% pav.attribute_code %]"] = values; |
54 |
patron_attributes_values["[% pav.attribute_code %]"] = lib; |
55 |
[% END %] |
56 |
|
57 |
$('select[name="patron_attributes"]').change(function() { |
58 |
updateAttrValues(this); |
59 |
} ); |
60 |
|
61 |
$('select[name="patron_attributes"]').change(); |
62 |
|
63 |
$(".clear-date").on("click",function(e){ |
64 |
e.preventDefault(); |
65 |
var fieldID = this.id.replace("clear-date-",""); |
66 |
$("#" + fieldID).val(""); |
67 |
}); |
68 |
$("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){ |
69 |
e.preventDefault(); |
70 |
add_attributes(); |
71 |
}); |
72 |
$("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){ |
73 |
e.preventDefault(); |
74 |
del_attributes(this); |
75 |
}); |
76 |
}); |
77 |
|
78 |
function updateAttrValues (select_attr) { |
79 |
var attr_code = $(select_attr).val(); |
80 |
var type = $(select_attr).find("option:selected").attr('data-type'); |
81 |
var category = $(select_attr).find("option:selected").attr('data-category'); |
82 |
var span = $(select_attr).parent().parent().find('span.patron_attributes_value'); |
83 |
var information_category_node = $(select_attr).parent().parent().find('span.information_category'); |
84 |
information_category_node.html(""); |
85 |
if ( category.length > 0 ) { |
86 |
information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category)); |
87 |
} |
88 |
if ( type == 'select' ) { |
89 |
var options = '<option value = ""></option>'; |
90 |
for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) { |
91 |
options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>'; |
92 |
} |
93 |
span.html('<select name="patron_attributes_value">' + options + '</select>'); |
94 |
} else { |
95 |
span.html('<input type="text" name="patron_attributes_value"/>') |
96 |
} |
97 |
} |
98 |
|
99 |
function add_attributes() { |
100 |
var li_node = $("li.attributes:last"); |
101 |
var li_clone = $(li_node).clone(); |
102 |
if ( $(li_clone).find("a.del_attributes").length == 0 ) { |
103 |
$(li_clone).append('<a href="#" title="Delete" class="del_attributes"><i class="fa fa-fw fa-trash"></i> Delete</a>'); |
104 |
} |
105 |
$(li_clone).find('select[name="patron_attributes"]').change(function() { |
106 |
updateAttrValues(this); |
107 |
} ); |
108 |
|
109 |
$(li_clone).find('select[name="patron_attributes"]').change(); |
110 |
|
111 |
$("#fields_list>ol").append(li_clone); |
112 |
update_attr_values(); |
113 |
} |
114 |
|
115 |
function del_attributes(a_node) { |
116 |
$(a_node).parent('li').remove(); |
117 |
update_attr_values(); |
118 |
} |
119 |
|
120 |
function update_attr_values() { |
121 |
$("li.attributes").each(function(i) { |
122 |
$(this).find("input:checkbox").val("attr"+i+"_value"); |
123 |
}); |
124 |
} |
125 |
function clearDate(nodeid) { |
126 |
$("#"+nodeid).val(""); |
127 |
} |
128 |
|
129 |
//]]> |
130 |
</script> |
131 |
</head> |
9 |
</head> |
|
|
10 |
|
132 |
<body id="tools_modborrowers" class="tools"> |
11 |
<body id="tools_modborrowers" class="tools"> |
133 |
[% INCLUDE 'header.inc' %] |
12 |
[% INCLUDE 'header.inc' %] |
134 |
[% INCLUDE 'cat-search.inc' %] |
13 |
[% INCLUDE 'cat-search.inc' %] |
Lines 412-415
Link Here
|
412 |
[% INCLUDE 'tools-menu.inc' %] |
291 |
[% INCLUDE 'tools-menu.inc' %] |
413 |
</div> |
292 |
</div> |
414 |
</div> |
293 |
</div> |
|
|
294 |
|
295 |
[% MACRO jsinclude BLOCK %] |
296 |
[% INCLUDE 'calendar.inc' %] |
297 |
[% INCLUDE 'datatables.inc' %] |
298 |
<script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script> |
299 |
<script type="text/javascript"> |
300 |
var patron_attributes_lib = new Array(); |
301 |
var patron_attributes_values = new Array(); |
302 |
$(document).ready(function() { |
303 |
[% IF borrowers %] |
304 |
$("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, { |
305 |
"sDom": 't', |
306 |
[% IF ( op == 'show_results' ) %] |
307 |
"aoColumnDefs": [ |
308 |
{ 'sType': "title-string", 'aTargets' : [ 'title-string'] } |
309 |
], |
310 |
[% ELSE %] |
311 |
"aoColumnDefs": [ |
312 |
{ "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }, |
313 |
{ 'sType': "title-string", 'aTargets' : [ 'title-string'] } |
314 |
], |
315 |
[% END %] |
316 |
"bPaginate": false |
317 |
})); |
318 |
$("#selectallbutton").click(function() { |
319 |
$("#borrowerst").find("input:checkbox").each(function() { |
320 |
$(this).prop("checked", true); |
321 |
}); |
322 |
return false; |
323 |
}); |
324 |
$("#clearallbutton").click(function() { |
325 |
$("#borrowerst").find("input:checkbox").each(function() { |
326 |
$(this).prop("checked", false); |
327 |
}); |
328 |
return false; |
329 |
}); |
330 |
[% END %] |
331 |
|
332 |
var values = new Array(); |
333 |
var lib = new Array(); |
334 |
[% FOREACH pav IN patron_attributes_values %] |
335 |
values = new Array(); |
336 |
lib = new Array(); |
337 |
[% FOREACH option IN pav.options %] |
338 |
values.push("[% option.lib %]"); |
339 |
lib.push("[% option.authorised_value %]"); |
340 |
[% END %] |
341 |
patron_attributes_lib["[% pav.attribute_code %]"] = values; |
342 |
patron_attributes_values["[% pav.attribute_code %]"] = lib; |
343 |
[% END %] |
344 |
|
345 |
$('select[name="patron_attributes"]').change(function() { |
346 |
updateAttrValues(this); |
347 |
} ); |
348 |
|
349 |
$('select[name="patron_attributes"]').change(); |
350 |
|
351 |
$(".clear-date").on("click",function(e){ |
352 |
e.preventDefault(); |
353 |
var fieldID = this.id.replace("clear-date-",""); |
354 |
$("#" + fieldID).val(""); |
355 |
}); |
356 |
$("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){ |
357 |
e.preventDefault(); |
358 |
add_attributes(); |
359 |
}); |
360 |
$("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){ |
361 |
e.preventDefault(); |
362 |
del_attributes(this); |
363 |
}); |
364 |
}); |
365 |
|
366 |
function updateAttrValues (select_attr) { |
367 |
var attr_code = $(select_attr).val(); |
368 |
var type = $(select_attr).find("option:selected").attr('data-type'); |
369 |
var category = $(select_attr).find("option:selected").attr('data-category'); |
370 |
var span = $(select_attr).parent().parent().find('span.patron_attributes_value'); |
371 |
var information_category_node = $(select_attr).parent().parent().find('span.information_category'); |
372 |
information_category_node.html(""); |
373 |
if ( category.length > 0 ) { |
374 |
information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category)); |
375 |
} |
376 |
if ( type == 'select' ) { |
377 |
var options = '<option value = ""></option>'; |
378 |
for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) { |
379 |
options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>'; |
380 |
} |
381 |
span.html('<select name="patron_attributes_value">' + options + '</select>'); |
382 |
} else { |
383 |
span.html('<input type="text" name="patron_attributes_value"/>') |
384 |
} |
385 |
} |
386 |
|
387 |
function add_attributes() { |
388 |
var li_node = $("li.attributes:last"); |
389 |
var li_clone = $(li_node).clone(); |
390 |
if ( $(li_clone).find("a.del_attributes").length == 0 ) { |
391 |
$(li_clone).append('<a href="#" title="Delete" class="del_attributes"><i class="fa fa-fw fa-trash"></i> Delete</a>'); |
392 |
} |
393 |
$(li_clone).find('select[name="patron_attributes"]').change(function() { |
394 |
updateAttrValues(this); |
395 |
} ); |
396 |
|
397 |
$(li_clone).find('select[name="patron_attributes"]').change(); |
398 |
|
399 |
$("#fields_list>ol").append(li_clone); |
400 |
update_attr_values(); |
401 |
} |
402 |
|
403 |
function del_attributes(a_node) { |
404 |
$(a_node).parent('li').remove(); |
405 |
update_attr_values(); |
406 |
} |
407 |
|
408 |
function update_attr_values() { |
409 |
$("li.attributes").each(function(i) { |
410 |
$(this).find("input:checkbox").val("attr"+i+"_value"); |
411 |
}); |
412 |
} |
413 |
function clearDate(nodeid) { |
414 |
$("#"+nodeid).val(""); |
415 |
} |
416 |
</script> |
417 |
[% END %] |
418 |
|
415 |
[% INCLUDE 'intranet-bottom.inc' %] |
419 |
[% INCLUDE 'intranet-bottom.inc' %] |