4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>[% IF batch_id %]Edit ([% batch_id | html %])[% ELSE %]New[% END %] › Batches › Patron card creator › Tools › Koha</title>
6 [% INCLUDE 'doc-head-close.inc' %]
9 <body id="pcard_edit-batch" class="tools pcard">
10 [% INCLUDE 'header.inc' %]
11 [% INCLUDE 'cat-search.inc' %]
13 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
16 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
19 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
22 <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a>
25 <a href="/cgi-bin/koha/patroncards/manage.pl?card_element=batch">Batches</a>
28 <a href="#" aria-current="page">
30 <span>Edit [% description | html %]</span>
32 <span>Edit ([% batch_id | html %])</span>
41 <div class="main container-fluid">
43 <div class="col-sm-10 col-sm-push-2">
46 [% INCLUDE 'patroncards-toolbar.inc' %]
48 <h1>[% IF description %]<span>Edit</span> [% description | html %]
49 [% ELSIF batch_id %]<span>Edit patron card batch</span> [% batch_id | html %]
50 [% ELSE %]<span>New patron card batch</span>[% END %]
53 [% IF ( duplicate_message ) %]
54 <div class="dialog message">
55 <strong>Duplicate patrons removed from batch number [% batch_id | html %]: [% duplicate_count | html %]</strong>
59 [% INCLUDE 'patroncards-errors.inc' %]
60 <div id="manage-patroncard-batches">
61 <form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
63 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
64 <ol><li id="description">
65 <input type="hidden" name="op" value="add" />
66 <input type="hidden" name="batch_id" value="[% batch_id | html %]" />
67 <label for="description">Batch description: </label>
68 <input type="text" name="description" value="[% description | html %]"> <span id="change-status"></span>
70 <label for="bor_num_list">Add by borrowernumber(s):
71 <br /> <span class="hint">One borrowernumber per line.</span>
73 <textarea rows="5" id="bor_num_list" name="bor_num_list" tabindex="1" class="focus"></textarea>
78 <div id="batch-manage" class="action">
79 <a class="btn btn-default" id="additems" href="#"><i class="fa fa-plus"></i> Add patron(s)</a>[% IF ( table_loop ) %]
80 <a class="btn btn-default" id="savedesc" href="#" data-batch_id="[% batch_id | html %]"><i class="fa fa-save"></i> Save description</a>
81 <a class="btn btn-default" id="removeitems" href="#"><i class="fa fa-trash"></i> Remove selected patrons</a>
82 <a class="btn btn-default" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
83 <a class="btn btn-default" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
84 <a class="btn btn-default" id="exportitems" href="#"><i class="fa fa-share-square-o"></i> Export selected card(s)</a>
85 <a class="btn btn-default" id="exportbatch" href="#"><i class="fa fa-share-square-o"></i> Export card batch</a>[% END %]
87 [% IF ( table_loop ) %]
89 <h2>Patrons in batch number [% batch_id | html %]</h2>
91 [% FOREACH table_loo IN table_loop %]
92 [% IF ( table_loo.header_fields ) %]
95 [% FOREACH header_field IN table_loo.header_fields %]
96 [% SWITCH header_field.field_label -%]
99 [% CASE "Borrower Number" %]
100 <th>Borrower number</th>
101 [% CASE "Actions " %]
102 <th class="noExport">Actions</th>
106 <th>[% header_field.field_label | html %]</th>
114 [% FOREACH text_field IN table_loo.text_fields %]
115 [% IF ( text_field.select_field ) %]
117 <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>
118 <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>
120 <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>
122 <td>[% text_field.field_value | html %]</td>
132 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
134 <div class="dialog message">
135 <h4>There are no patrons in this batch yet</h4>
136 <p>Add patrons by borrowernumber using the text area above or leave empty to add via patron search.</p>
144 </div> <!-- /.col-sm-10.col-sm-push-2 -->
146 <div class="col-sm-2 col-sm-pull-10">
148 [% INCLUDE 'tools-menu.inc' %]
150 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
151 </div> <!-- /.row -->
152 [% MACRO jsinclude BLOCK %]
153 [% INCLUDE 'greybox.inc' %]
154 [% INCLUDE 'datatables.inc' %]
156 function DeleteConfirm() {
157 var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id | html %]");
158 var answer = confirm(msg);
160 window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=batch&element_id=[% batch_id | html %]";
162 return; // abort delete
168 if(document.items.action.length > 0) {
169 for (var i=0; i < document.items.action.length; i++) {
170 if (document.items.action[i].checked) {
171 items.push("label_id=" + document.items.action[i].value);
174 getstr = items.join("&");
175 var msg = _("Are you sure you want to remove the selected patron(s) from this batch?");
176 } else if (document.items.action.checked) {
177 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"));
178 return; // no deletion for single item batch
180 alert(_("Please select at least one patron to delete."));
181 return; // no item selected
183 var answer = confirm(msg);
185 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&batch_id=[% batch_id | html %]&" + getstr;
187 return; // abort delete
191 var bor_nums = document.getElementById("bor_num_list");
192 if (bor_nums.value == '') {
193 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add",
195 'width=1024,height=768,location=yes,toolbar=no,'
196 + 'scrollbars=yes,resize=yes');
198 document.forms["add_by_bor_num"].submit();
202 function add_user(borrowernumber) {
203 $("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n");
206 function DeDuplicate() {
207 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&batch_id=[% batch_id | html %]";
209 function Xport(mode) {
210 if (mode == 'label') {
211 patroncards= new Array;
212 if(document.items.action.length > 0) {
213 for (var i=0; i < document.items.action.length; i++) {
214 if (document.items.action[i].checked) {
215 patroncards.push("label_id=" + document.items.action[i].value);
218 if (patroncards.length < 1) {
219 alert(_("Please select at least one card to export."));
220 return; // no batch selected
222 getstr = patroncards.join("&");
223 } else if (document.items.action.checked) {
224 getstr = document.items.action.value;
226 alert(_("Please select at least one card to export."));
227 return; // no batch selected
229 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]&" + getstr, 400, 800);
230 } else if (mode == 'batch') {
231 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]", 400, 800);
233 // some pass-thru error trapping just in case...
236 function selected_layout() {
237 if (document.items.action.length) {
238 for (i=0;i<document.items.action.length;i++){
239 if (document.items.action[i].checked==true){
240 return(document.items.action[i].value);
244 if (document.items.action.checked){
245 return(document.items.action.value);
248 alert(_("Please select at least one item."));
252 $(document).ready(function() {
253 // Prepare DataTables settings
254 var aLengthMenu = [10, 20, 50, 100, -1];
255 var aLengthMenuLabel = [10, 20, 50, 100, _("All")];
256 var patronsPerPage = [% Koha.Preference('PatronsPerPage') | html %];
257 for ( var i = 0; i < aLengthMenu.length; i++ ) {
258 if ( aLengthMenu[i] == patronsPerPage ) {
261 if ( aLengthMenu[i] > patronsPerPage || aLengthMenu[i] == -1 ) {
262 aLengthMenu.splice(i, 0, patronsPerPage);
263 aLengthMenuLabel.splice(i, 0, patronsPerPage);
269 $("#description").show();
271 $("#description").hide();
273 $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
275 { "aTargets": [ -2, -1 ], "bSortable": false, "bSearchable": false }
277 "aaSorting": [[ 0, "asc" ]],
278 "sPaginationType": "full",
279 "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
280 "pageLength": patronsPerPage,
283 $("#additems").click(function(){
287 $("#removeitems").click(function(){
291 $("#deletebatch").click(function(){
295 $("#deduplicate").click(function(){
299 $("#exportitems").click(function(){
303 $("#exportbatch").click(function(){
307 $(".delete").on("click", function(){
308 return confirmDelete( _("Are you sure you want to delete this patron from the card batch?") );
310 $(".export").on("click", function(e){
312 var label_id = $(this).data("label-id");
313 var batch_id = $(this).data("batch-id");
314 GB_showCenter( _("Export single card"),'/cgi-bin/koha/patroncards/print.pl?batch_id=' + batch_id + '&label_id=' + label_id, 400, 800);
316 $("#savedesc").click(function(event){
317 var newdescription = $(this).siblings('input[name="description"]').val();
318 var batch_id = $(this).data('batch_id');
320 'newdescription': newdescription,
321 'batch_id': batch_id,
322 'card_element': "batch",
323 'creator': "patroncard",
327 url: '/cgi-bin/koha/svc/creator_batches',
333 .done(function(data){
334 if (data.status == 'success') {
335 $("input[name='description']").text(data.newdesc);
336 $("#change-status").text(_("Saved"));
338 $("#change-status").text(_("Unable to save description"));
342 $("#savedesc").click(function(event){
343 var newdescription = $('input[name="description"]').val();
344 var batch_id = $(this).data('batch_id');
346 'newdescription': newdescription,
347 'batch_id': batch_id,
348 'card_element': "batch",
349 'creator': "patroncard",
353 url: '/cgi-bin/koha/svc/creator_batches',
359 .done(function(data){
360 if (data.status == 'success') {
361 $("input[name='description']").text(data.newdesc);
362 $("#change-status").text(_("Saved"));
364 $("#change-status").text(_("Unable to save description"));
372 [% INCLUDE 'intranet-bottom.inc' %]