4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha › Tools › Patron card creator › Batches › [% IF batch_id %]Edit ([% batch_id | html %])[% ELSE %]New[% END %]</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% Asset.css("css/datatables.css") | $raw %]
10 <body id="pcard_edit-batch" class="tools pcard">
11 [% INCLUDE 'header.inc' %]
12 [% INCLUDE 'cat-search.inc' %]
13 <div id="breadcrumbs">
14 <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
15 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> ›
16 <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a> ›
17 <a href="/cgi-bin/koha/patroncards/manage.pl?card_element=batch">Batches</a> ›
19 Edit ([% batch_id | html %])
24 <div id="doc3" class="yui-t2">
29 [% INCLUDE 'patroncards-toolbar.inc' %]
30 <div class="yui-u first">
35 [% IF ( duplicate_message ) %]
36 <div class="dialog message">
37 <strong>Duplicate patrons removed from batch number [% batch_id | html %]: [% duplicate_count | html %]</strong>
41 [% INCLUDE 'patroncards-errors.inc' %]
42 <div id="manage-patroncard-batches">
43 <div class="hint">Current library: [% LoginBranchname | html %]</div>
44 <form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
46 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
47 <ol><li id="description">
48 <input type="hidden" name="op" value="add" />
49 <input type="hidden" name="batch_id" value="[% batch_id | html %]" />
50 <label for="description">Batch description: </label>
51 <input type="text" name="description" value="[% description | html %]">
52 <a href="#" id="savedesc" data-batch_id="[% batch_id | html %]" class="btn btn-default btn-xs">Save description</a> <span id="change-status"></span>
54 <label for="bor_num_list">Add by borrowernumber(s):
55 <br /> <span class="hint">One borrowernumber per line.</span>
57 <textarea rows="5" id="bor_num_list" name="bor_num_list" tabindex="1" class="focus"></textarea>
62 <div id="batch-manage" class="action">
63 <a class="btn btn-default btn-sm" id="additems" href="#"><i class="fa fa-plus"></i> Add patron(s)</a>[% IF ( table_loop ) %]
64 <a class="btn btn-default btn-sm" id="removeitems" href="#"><i class="fa fa-trash"></i> Remove selected patrons</a>
65 <a class="btn btn-default btn-sm" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
66 <a class="btn btn-default btn-sm" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
67 <a class="btn btn-default btn-sm" id="exportitems" href="#"><i class="fa fa-share-square-o"></i> Export selected card(s)</a>
68 <a class="btn btn-default btn-sm" id="exportbatch" href="#"><i class="fa fa-share-square-o"></i> Export card batch</a>[% END %]
70 [% IF ( table_loop ) %]
71 <form name="items" class="checkboxed">
72 <h2>Patrons in batch number [% batch_id | html %]</h2>
74 [% FOREACH table_loo IN table_loop %]
75 [% IF ( table_loo.header_fields ) %]
78 [% FOREACH header_field IN table_loo.header_fields %]
79 [% SWITCH header_field.field_label -%]
81 <th>Borrower name</th>
82 [% CASE "Borrower Number" %]
83 <th>Borrower number</th>
89 <th>[% header_field.field_label | html %]</th>
97 [% FOREACH text_field IN table_loo.text_fields %]
98 [% IF ( text_field.select_field ) %]
100 <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&batch_id=[% batch_id | html %]&label_id=[% text_field.field_value | html %]"><i class="fa fa-trash"></i> Delete</a>
101 <a class="btn btn-default btn-xs export" href="#" data-batch-id="[% batch_id | html %]" data-label-id="[% text_field.field_value | html %]"><i class="fa fa-share-square-o"></i> Export</a>
103 <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>
105 <td>[% text_field.field_value | html %]</td>
115 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
117 <div class="dialog message">
118 <h4>There are no patrons in this batch yet</h4>
119 <p>Add patrons by borrowernumber using the text area above or leave empty to add via patron search.</p>
128 [% INCLUDE 'tools-menu.inc' %]
132 [% MACRO jsinclude BLOCK %]
133 [% INCLUDE 'greybox.inc' %]
134 [% INCLUDE 'datatables.inc' %]
136 function DeleteConfirm() {
137 var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id | html %]");
138 var answer = confirm(msg);
140 window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=batch&element_id=[% batch_id | html %]";
142 return; // abort delete
148 if(document.items.action.length > 0) {
149 for (var i=0; i < document.items.action.length; i++) {
150 if (document.items.action[i].checked) {
151 items.push("label_id=" + document.items.action[i].value);
154 getstr = items.join("&");
155 var msg = _("Are you sure you want to remove the selected patron(s) from this batch?");
156 } else if (document.items.action.checked) {
157 alert(_("Deletion of patron from a batch with only one patron will delete the batch.") + "\n\n" + _("If this is what you want, select the 'Delete batch' option from the toolbar"));
158 return; // no deletion for single item batch
160 alert(_("Please select at least one patron to delete."));
161 return; // no item selected
163 var answer = confirm(msg);
165 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&batch_id=[% batch_id | html %]&" + getstr;
167 return; // abort delete
171 var bor_nums = document.getElementById("bor_num_list");
172 if (bor_nums.value == '') {
173 window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
175 'width=840,height=500,location=yes,toolbar=no,'
176 + 'scrollbars=yes,resize=yes');
178 document.forms["add_by_bor_num"].submit();
182 function add_user(borrowernumber) {
183 $("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n");
186 function DeDuplicate() {
187 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&batch_id=[% batch_id | html %]";
189 function Xport(mode) {
190 if (mode == 'label') {
191 patroncards= new Array;
192 if(document.items.action.length > 0) {
193 for (var i=0; i < document.items.action.length; i++) {
194 if (document.items.action[i].checked) {
195 patroncards.push("label_id=" + document.items.action[i].value);
198 if (patroncards.length < 1) {
199 alert(_("Please select at least one card to export."));
200 return; // no batch selected
202 getstr = patroncards.join("&");
203 } else if (document.items.action.checked) {
204 getstr = document.items.action.value;
206 alert(_("Please select at least one card to export."));
207 return; // no batch selected
209 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]&" + getstr, 400, 800);
210 } else if (mode == 'batch') {
211 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]", 400, 800);
213 // some pass-thru error trapping just in case...
216 function selected_layout() {
217 if (document.items.action.length) {
218 for (i=0;i<document.items.action.length;i++){
219 if (document.items.action[i].checked==true){
220 return(document.items.action[i].value);
224 if (document.items.action.checked){
225 return(document.items.action.value);
228 alert(_("Please select at least one item."));
232 $(document).ready(function() {
234 $("#description").show();
236 $("#description").hide();
238 $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
240 { "aTargets": [ -2, -1 ], "bSortable": false, "bSearchable": false }
242 "aaSorting": [[ 0, "asc" ]],
243 "sPaginationType": "four_button",
246 $("#additems").click(function(){
250 $("#removeitems").click(function(){
254 $("#deletebatch").click(function(){
258 $("#deduplicate").click(function(){
262 $("#exportitems").click(function(){
266 $("#exportbatch").click(function(){
270 $(".delete").on("click", function(){
271 return confirmDelete( _("Are you sure you want to delete this patron from the card batch?") );
273 $(".export").on("click", function(e){
275 var label_id = $(this).data("label-id");
276 var batch_id = $(this).data("batch-id");
277 GB_showCenter( _("Export single card"),'/cgi-bin/koha/patroncards/print.pl?batch_id=' + batch_id + '&label_id=' + label_id, 400, 800);
279 $("#savedesc").click(function(event){
280 var newdescription = $(this).siblings('input[name="description"]').val();
281 var batch_id = $(this).data('batch_id');
283 'newdescription': newdescription,
284 'batch_id': batch_id,
285 'card_element': "batch",
286 'creator': "patroncard",
290 url: '/cgi-bin/koha/svc/creator_batches',
296 .done(function(data){
297 if (data.status == 'success') {
298 $("input[name='description']").text(data.newdesc);
299 $("#change-status").text(_("Saved"));
301 $("#change-status").text(_("Unable to save description"));
309 [% INCLUDE 'intranet-bottom.inc' %]