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 <a href="/cgi-bin/koha/patroncards/edit-batch.pl?op=edit&element_id=[% batch_id | html %]">[% description | html %]</a>
21 Edit <a href="/cgi-bin/koha/patroncards/edit-batch.pl?op=edit&element_id=[% batch_id | html %]">([% batch_id | html %])</a>
26 <div id="doc3" class="yui-t2">
31 [% INCLUDE 'patroncards-toolbar.inc' %]
32 <div class="yui-u first">
37 [% IF ( duplicate_message ) %]
38 <div class="dialog message">
39 <strong>Duplicate patrons removed from batch number [% batch_id | html %]: [% duplicate_count | html %]</strong>
43 [% INCLUDE 'patroncards-errors.inc' %]
44 <div id="manage-patroncard-batches">
45 <div class="hint">Current library: [% LoginBranchname | html %]</div>
46 <form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
48 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
49 <ol><li id="description">
50 <input type="hidden" name="op" value="add" />
51 <input type="hidden" name="batch_id" value="[% batch_id | html %]" />
52 <label for="description">Batch description: </label>
53 <input type="text" name="description" value="[% description | html %]"> <span id="change-status"></span>
55 <label for="bor_num_list">Add by borrowernumber(s):
56 <br /> <span class="hint">One borrowernumber per line.</span>
58 <textarea rows="5" id="bor_num_list" name="bor_num_list" tabindex="1" class="focus"></textarea>
63 <div id="batch-manage" class="action">
64 <a class="btn btn-default btn-sm" id="additems" href="#"><i class="fa fa-plus"></i> Add patron(s)</a>[% IF ( table_loop ) %]
65 <a class="btn btn-default btn-sm" id="savedesc" href="#" data-batch_id="[% batch_id | html %]"><i class="fa fa-save"></i> Save description</a>
66 <a class="btn btn-default btn-sm" id="removeitems" href="#"><i class="fa fa-trash"></i> Remove selected patrons</a>
67 <a class="btn btn-default btn-sm" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
68 <a class="btn btn-default btn-sm" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
69 <a class="btn btn-default btn-sm" id="exportitems" href="#"><i class="fa fa-share-square-o"></i> Export selected card(s)</a>
70 <a class="btn btn-default btn-sm" id="exportbatch" href="#"><i class="fa fa-share-square-o"></i> Export card batch</a>[% END %]
72 [% IF ( table_loop ) %]
73 <form name="items" class="checkboxed">
74 <h2>Patrons in batch number [% batch_id | html %]</h2>
76 [% FOREACH table_loo IN table_loop %]
77 [% IF ( table_loo.header_fields ) %]
80 [% FOREACH header_field IN table_loo.header_fields %]
81 [% SWITCH header_field.field_label -%]
83 <th>Borrower name</th>
84 [% CASE "Borrower Number" %]
85 <th>Borrower number</th>
91 <th>[% header_field.field_label | html %]</th>
99 [% FOREACH text_field IN table_loo.text_fields %]
100 [% IF ( text_field.select_field ) %]
102 <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>
103 <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>
105 <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>
107 <td>[% text_field.field_value | html %]</td>
117 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
119 <div class="dialog message">
120 <h4>There are no patrons in this batch yet</h4>
121 <p>Add patrons by borrowernumber using the text area above or leave empty to add via patron search.</p>
130 [% INCLUDE 'tools-menu.inc' %]
134 [% MACRO jsinclude BLOCK %]
135 [% INCLUDE 'greybox.inc' %]
136 [% INCLUDE 'datatables.inc' %]
138 function DeleteConfirm() {
139 var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id | html %]");
140 var answer = confirm(msg);
142 window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=batch&element_id=[% batch_id | html %]";
144 return; // abort delete
150 if(document.items.action.length > 0) {
151 for (var i=0; i < document.items.action.length; i++) {
152 if (document.items.action[i].checked) {
153 items.push("label_id=" + document.items.action[i].value);
156 getstr = items.join("&");
157 var msg = _("Are you sure you want to remove the selected patron(s) from this batch?");
158 } else if (document.items.action.checked) {
159 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"));
160 return; // no deletion for single item batch
162 alert(_("Please select at least one patron to delete."));
163 return; // no item selected
165 var answer = confirm(msg);
167 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&batch_id=[% batch_id | html %]&" + getstr;
169 return; // abort delete
173 var bor_nums = document.getElementById("bor_num_list");
174 if (bor_nums.value == '') {
175 window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
177 'width=840,height=500,location=yes,toolbar=no,'
178 + 'scrollbars=yes,resize=yes');
180 document.forms["add_by_bor_num"].submit();
184 function add_user(borrowernumber) {
185 $("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n");
188 function DeDuplicate() {
189 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&batch_id=[% batch_id | html %]";
191 function Xport(mode) {
192 if (mode == 'label') {
193 patroncards= new Array;
194 if(document.items.action.length > 0) {
195 for (var i=0; i < document.items.action.length; i++) {
196 if (document.items.action[i].checked) {
197 patroncards.push("label_id=" + document.items.action[i].value);
200 if (patroncards.length < 1) {
201 alert(_("Please select at least one card to export."));
202 return; // no batch selected
204 getstr = patroncards.join("&");
205 } else if (document.items.action.checked) {
206 getstr = document.items.action.value;
208 alert(_("Please select at least one card to export."));
209 return; // no batch selected
211 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]&" + getstr, 400, 800);
212 } else if (mode == 'batch') {
213 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]", 400, 800);
215 // some pass-thru error trapping just in case...
218 function selected_layout() {
219 if (document.items.action.length) {
220 for (i=0;i<document.items.action.length;i++){
221 if (document.items.action[i].checked==true){
222 return(document.items.action[i].value);
226 if (document.items.action.checked){
227 return(document.items.action.value);
230 alert(_("Please select at least one item."));
234 $(document).ready(function() {
236 $("#description").show();
238 $("#description").hide();
240 $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
242 { "aTargets": [ -2, -1 ], "bSortable": false, "bSearchable": false }
244 "aaSorting": [[ 0, "asc" ]],
245 "sPaginationType": "four_button",
248 $("#additems").click(function(){
252 $("#removeitems").click(function(){
256 $("#deletebatch").click(function(){
260 $("#deduplicate").click(function(){
264 $("#exportitems").click(function(){
268 $("#exportbatch").click(function(){
272 $(".delete").on("click", function(){
273 return confirmDelete( _("Are you sure you want to delete this patron from the card batch?") );
275 $(".export").on("click", function(e){
277 var label_id = $(this).data("label-id");
278 var batch_id = $(this).data("batch-id");
279 GB_showCenter( _("Export single card"),'/cgi-bin/koha/patroncards/print.pl?batch_id=' + batch_id + '&label_id=' + label_id, 400, 800);
281 $("#savedesc").click(function(event){
282 var newdescription = $(this).siblings('input[name="description"]').val();
283 var batch_id = $(this).data('batch_id');
285 'newdescription': newdescription,
286 'batch_id': batch_id,
287 'card_element': "batch",
288 'creator': "patroncard",
292 url: '/cgi-bin/koha/svc/creator_batches',
298 .done(function(data){
299 if (data.status == 'success') {
300 $("input[name='description']").text(data.newdesc);
301 $("#change-status").text(_("Saved"));
303 $("#change-status").text(_("Unable to save description"));
307 $("#savedesc").click(function(event){
308 var newdescription = $('input[name="description"]').val();
309 var batch_id = $(this).data('batch_id');
311 'newdescription': newdescription,
312 'batch_id': batch_id,
313 'card_element': "batch",
314 'creator': "patroncard",
318 url: '/cgi-bin/koha/svc/creator_batches',
324 .done(function(data){
325 if (data.status == 'success') {
326 $("input[name='description']").text(data.newdesc);
327 $("#change-status").text(_("Saved"));
329 $("#change-status").text(_("Unable to save description"));
337 [% INCLUDE 'intranet-bottom.inc' %]