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 [% WRAPPER 'header.inc' %]
11 [% INCLUDE 'cat-search.inc' %]
14 [% WRAPPER 'sub-header.inc' %]
15 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
18 <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
21 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
24 <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a>
27 <a href="/cgi-bin/koha/patroncards/manage.pl?card_element=batch">Batches</a>
30 <a href="#" aria-current="page">
32 <span>Edit [% description | html %]</span>
34 <span>Edit ([% batch_id | html %])</span>
44 <div class="main container-fluid">
46 <div class="col-sm-10 col-sm-push-2">
49 [% INCLUDE 'patroncards-toolbar.inc' %]
51 <h1>[% IF description %]<span>Edit</span> [% description | html %]
52 [% ELSIF batch_id %]<span>Edit patron card batch</span> [% batch_id | html %]
53 [% ELSE %]<span>New patron card batch</span>[% END %]
56 [% IF ( duplicate_message ) %]
57 <div class="dialog message">
58 <strong>Duplicate patrons removed from batch number [% batch_id | html %]: [% duplicate_count | html %]</strong>
62 [% INCLUDE 'patroncards-errors.inc' %]
63 <div id="manage-patroncard-batches">
64 <form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
66 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
67 <ol><li id="description">
68 <input type="hidden" name="op" value="add" />
69 <input type="hidden" name="batch_id" value="[% batch_id | html %]" />
70 <label for="description">Batch description: </label>
71 <input type="text" name="description" value="[% description | html %]"> <span id="change-status"></span>
73 <label for="bor_num_list">Add by borrowernumber(s):
74 <br /> <span class="hint">One borrowernumber per line.</span>
76 <textarea rows="5" id="bor_num_list" name="bor_num_list" tabindex="1" class="focus"></textarea>
81 <div id="batch-manage" class="action">
82 <a class="btn btn-default" id="additems" href="#"><i class="fa fa-plus"></i> Add patron(s)</a>[% IF ( table_loop ) %]
83 <a class="btn btn-default" id="savedesc" href="#" data-batch_id="[% batch_id | html %]"><i class="fa fa-save"></i> Save description</a>
84 <a class="btn btn-default" id="removeitems" href="#"><i class="fa fa-trash"></i> Remove selected patrons</a>
85 <a class="btn btn-default" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
86 <a class="btn btn-default" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
87 <a class="btn btn-default" id="exportitems" href="#"><i class="fa fa-share-square-o"></i> Export selected card(s)</a>
88 <a class="btn btn-default" id="exportbatch" href="#"><i class="fa fa-share-square-o"></i> Export card batch</a>[% END %]
90 [% IF ( table_loop ) %]
92 <h2>Patrons in batch number [% batch_id | html %]</h2>
94 [% FOREACH table_loo IN table_loop %]
95 [% IF ( table_loo.header_fields ) %]
98 [% FOREACH header_field IN table_loo.header_fields %]
99 [% SWITCH header_field.field_label -%]
100 [% CASE "Summary" -%]
102 [% CASE "Borrower Number" %]
103 <th>Borrower number</th>
104 [% CASE "Actions " %]
105 <th class="noExport">Actions</th>
109 <th>[% header_field.field_label | html %]</th>
117 [% FOREACH text_field IN table_loo.text_fields %]
118 [% IF ( text_field.select_field ) %]
120 <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>
121 <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>
123 <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>
125 <td>[% text_field.field_value | html %]</td>
135 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
137 <div class="dialog message">
138 <h4>There are no patrons in this batch yet</h4>
139 <p>Add patrons by borrowernumber using the text area above or leave empty to add via patron search.</p>
147 </div> <!-- /.col-sm-10.col-sm-push-2 -->
149 <div class="col-sm-2 col-sm-pull-10">
151 [% INCLUDE 'tools-menu.inc' %]
153 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
154 </div> <!-- /.row -->
155 [% MACRO jsinclude BLOCK %]
156 [% INCLUDE 'greybox.inc' %]
157 [% INCLUDE 'datatables.inc' %]
159 function DeleteConfirm() {
160 var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id | html %]");
161 var answer = confirm(msg);
163 window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=batch&element_id=[% batch_id | html %]";
165 return; // abort delete
171 if(document.items.action.length > 0) {
172 for (var i=0; i < document.items.action.length; i++) {
173 if (document.items.action[i].checked) {
174 items.push("label_id=" + document.items.action[i].value);
177 getstr = items.join("&");
178 var msg = _("Are you sure you want to remove the selected patron(s) from this batch?");
179 } else if (document.items.action.checked) {
180 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"));
181 return; // no deletion for single item batch
183 alert(_("Please select at least one patron to delete."));
184 return; // no item selected
186 var answer = confirm(msg);
188 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&batch_id=[% batch_id | html %]&" + getstr;
190 return; // abort delete
194 var bor_nums = document.getElementById("bor_num_list");
195 if (bor_nums.value == '') {
196 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add",
198 'width=1024,height=768,location=yes,toolbar=no,'
199 + 'scrollbars=yes,resize=yes');
201 document.forms["add_by_bor_num"].submit();
205 function add_user(borrowernumber) {
206 $("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n");
209 function DeDuplicate() {
210 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&batch_id=[% batch_id | html %]";
212 function Xport(mode) {
213 if (mode == 'label') {
214 patroncards= new Array;
215 if(document.items.action.length > 0) {
216 for (var i=0; i < document.items.action.length; i++) {
217 if (document.items.action[i].checked) {
218 patroncards.push("label_id=" + document.items.action[i].value);
221 if (patroncards.length < 1) {
222 alert(_("Please select at least one card to export."));
223 return; // no batch selected
225 getstr = patroncards.join("&");
226 } else if (document.items.action.checked) {
227 getstr = document.items.action.value;
229 alert(_("Please select at least one card to export."));
230 return; // no batch selected
232 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]&" + getstr, 400, 800);
233 } else if (mode == 'batch') {
234 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]", 400, 800);
236 // some pass-thru error trapping just in case...
239 function selected_layout() {
240 if (document.items.action.length) {
241 for (i=0;i<document.items.action.length;i++){
242 if (document.items.action[i].checked==true){
243 return(document.items.action[i].value);
247 if (document.items.action.checked){
248 return(document.items.action.value);
251 alert(_("Please select at least one item."));
255 $(document).ready(function() {
256 // Prepare DataTables settings
257 var aLengthMenu = [10, 20, 50, 100, -1];
258 var aLengthMenuLabel = [10, 20, 50, 100, _("All")];
259 var patronsPerPage = [% Koha.Preference('PatronsPerPage') | html %];
260 for ( var i = 0; i < aLengthMenu.length; i++ ) {
261 if ( aLengthMenu[i] == patronsPerPage ) {
264 if ( aLengthMenu[i] > patronsPerPage || aLengthMenu[i] == -1 ) {
265 aLengthMenu.splice(i, 0, patronsPerPage);
266 aLengthMenuLabel.splice(i, 0, patronsPerPage);
272 $("#description").show();
274 $("#description").hide();
276 $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
278 { "aTargets": [ -2, -1 ], "bSortable": false, "bSearchable": false }
280 "aaSorting": [[ 0, "asc" ]],
281 "sPaginationType": "full",
282 "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
283 "pageLength": patronsPerPage,
286 $("#additems").click(function(){
290 $("#removeitems").click(function(){
294 $("#deletebatch").click(function(){
298 $("#deduplicate").click(function(){
302 $("#exportitems").click(function(){
306 $("#exportbatch").click(function(){
310 $(".delete").on("click", function(){
311 return confirmDelete( _("Are you sure you want to delete this patron from the card batch?") );
313 $(".export").on("click", function(e){
315 var label_id = $(this).data("label-id");
316 var batch_id = $(this).data("batch-id");
317 GB_showCenter( _("Export single card"),'/cgi-bin/koha/patroncards/print.pl?batch_id=' + batch_id + '&label_id=' + label_id, 400, 800);
319 $("#savedesc").click(function(event){
320 var newdescription = $(this).siblings('input[name="description"]').val();
321 var batch_id = $(this).data('batch_id');
323 'newdescription': newdescription,
324 'batch_id': batch_id,
325 'card_element': "batch",
326 'creator': "patroncard",
330 url: '/cgi-bin/koha/svc/creator_batches',
336 .done(function(data){
337 if (data.status == 'success') {
338 $("input[name='description']").text(data.newdesc);
339 $("#change-status").text(_("Saved"));
341 $("#change-status").text(_("Unable to save description"));
345 $("#savedesc").click(function(event){
346 var newdescription = $('input[name="description"]').val();
347 var batch_id = $(this).data('batch_id');
349 'newdescription': newdescription,
350 'batch_id': batch_id,
351 'card_element': "batch",
352 'creator': "patroncard",
356 url: '/cgi-bin/koha/svc/creator_batches',
362 .done(function(data){
363 if (data.status == 'success') {
364 $("input[name='description']").text(data.newdesc);
365 $("#change-status").text(_("Saved"));
367 $("#change-status").text(_("Unable to save description"));
375 [% INCLUDE 'intranet-bottom.inc' %]