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 [% WRAPPER breadcrumbs %]
16 [% WRAPPER breadcrumb_item %]
17 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
19 [% WRAPPER breadcrumb_item %]
20 <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a>
22 [% WRAPPER breadcrumb_item %]
23 <a href="/cgi-bin/koha/patroncards/manage.pl?card_element=batch">Batches</a>
25 [% WRAPPER breadcrumb_item bc_active= 1 %]
27 <span>Edit [% description | html %]</span>
29 <span>Edit ([% batch_id | html %])</span>
34 [% END #/ WRAPPER breadcrumbs %]
35 [% END #/ WRAPPER sub-header.inc %]
37 <div class="main container-fluid">
39 <div class="col-sm-10 col-sm-push-2">
42 [% INCLUDE 'patroncards-toolbar.inc' %]
44 <h1>[% IF description %]<span>Edit</span> [% description | html %]
45 [% ELSIF batch_id %]<span>Edit patron card batch</span> [% batch_id | html %]
46 [% ELSE %]<span>New patron card batch</span>[% END %]
49 [% IF ( duplicate_message ) %]
50 <div class="dialog message">
51 <strong>Duplicate patrons removed from batch number [% batch_id | html %]: [% duplicate_count | html %]</strong>
55 [% INCLUDE 'patroncards-errors.inc' %]
56 <div id="manage-patroncard-batches">
57 <form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
59 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
60 <ol><li id="description">
61 <input type="hidden" name="op" value="add" />
62 <input type="hidden" name="batch_id" value="[% batch_id | html %]" />
63 <label for="description">Batch description: </label>
64 <input type="text" name="description" value="[% description | html %]"> <span id="change-status"></span>
66 <label for="bor_num_list">Add by borrowernumber(s):
67 <br /> <span class="hint">One borrowernumber per line.</span>
69 <textarea rows="5" id="bor_num_list" name="bor_num_list" tabindex="1" class="focus"></textarea>
74 <div id="batch-manage" class="action">
75 <a class="btn btn-default" id="additems" href="#"><i class="fa fa-plus"></i> Add patron(s)</a>[% IF ( table_loop ) %]
76 <a class="btn btn-default" id="savedesc" href="#" data-batch_id="[% batch_id | html %]"><i class="fa fa-save"></i> Save description</a>
77 <a class="btn btn-default" id="removeitems" href="#"><i class="fa fa-trash"></i> Remove selected patrons</a>
78 <a class="btn btn-default" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
79 <a class="btn btn-default" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
80 <a class="btn btn-default" id="exportitems" href="#"><i class="fa fa-share-square-o"></i> Export selected card(s)</a>
81 <a class="btn btn-default" id="exportbatch" href="#"><i class="fa fa-share-square-o"></i> Export card batch</a>[% END %]
83 [% IF ( table_loop ) %]
85 <h2>Patrons in batch number [% batch_id | html %]</h2>
86 <div class="page-section">
88 [% FOREACH table_loo IN table_loop %]
89 [% IF ( table_loo.header_fields ) %]
92 [% FOREACH header_field IN table_loo.header_fields %]
93 [% SWITCH header_field.field_label -%]
96 [% CASE "Borrower Number" %]
97 <th>Borrower number</th>
99 <th class="noExport">Actions</th>
103 <th>[% header_field.field_label | html %]</th>
111 [% FOREACH text_field IN table_loo.text_fields %]
112 [% IF ( text_field.select_field ) %]
114 <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>
115 <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>
117 <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>
119 <td>[% text_field.field_value | html %]</td>
130 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
132 <div class="dialog message">
133 <h4>There are no patrons in this batch yet</h4>
134 <p>Add patrons by borrowernumber using the text area above or leave empty to add via patron search.</p>
142 </div> <!-- /.col-sm-10.col-sm-push-2 -->
144 <div class="col-sm-2 col-sm-pull-10">
146 [% INCLUDE 'tools-menu.inc' %]
148 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
149 </div> <!-- /.row -->
150 [% MACRO jsinclude BLOCK %]
151 [% INCLUDE 'greybox.inc' %]
152 [% INCLUDE 'datatables.inc' %]
154 function DeleteConfirm() {
155 var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id | html %]");
156 var answer = confirm(msg);
158 window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=batch&element_id=[% batch_id | html %]";
160 return; // abort delete
166 if(document.items.action.length > 0) {
167 for (var i=0; i < document.items.action.length; i++) {
168 if (document.items.action[i].checked) {
169 items.push("label_id=" + document.items.action[i].value);
172 getstr = items.join("&");
173 var msg = _("Are you sure you want to remove the selected patron(s) from this batch?");
174 } else if (document.items.action.checked) {
175 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"));
176 return; // no deletion for single item batch
178 alert(_("Please select at least one patron to delete."));
179 return; // no item selected
181 var answer = confirm(msg);
183 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&batch_id=[% batch_id | html %]&" + getstr;
185 return; // abort delete
189 var bor_nums = document.getElementById("bor_num_list");
190 if (bor_nums.value == '') {
191 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add",
193 'width=1024,height=768,location=yes,toolbar=no,'
194 + 'scrollbars=yes,resize=yes');
196 document.forms["add_by_bor_num"].submit();
200 function add_user(borrowernumber) {
201 $("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n");
204 function DeDuplicate() {
205 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&batch_id=[% batch_id | html %]";
207 function Xport(mode) {
208 if (mode == 'label') {
209 patroncards= new Array;
210 if(document.items.action.length > 0) {
211 for (var i=0; i < document.items.action.length; i++) {
212 if (document.items.action[i].checked) {
213 patroncards.push("label_id=" + document.items.action[i].value);
216 if (patroncards.length < 1) {
217 alert(_("Please select at least one card to export."));
218 return; // no batch selected
220 getstr = patroncards.join("&");
221 } else if (document.items.action.checked) {
222 getstr = document.items.action.value;
224 alert(_("Please select at least one card to export."));
225 return; // no batch selected
227 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]&" + getstr, 400, 800);
228 } else if (mode == 'batch') {
229 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]", 400, 800);
231 // some pass-thru error trapping just in case...
234 function selected_layout() {
235 if (document.items.action.length) {
236 for (i=0;i<document.items.action.length;i++){
237 if (document.items.action[i].checked==true){
238 return(document.items.action[i].value);
242 if (document.items.action.checked){
243 return(document.items.action.value);
246 alert(_("Please select at least one item."));
250 $(document).ready(function() {
251 // Prepare DataTables settings
252 var aLengthMenu = [10, 20, 50, 100, -1];
253 var aLengthMenuLabel = [10, 20, 50, 100, _("All")];
254 var patronsPerPage = [% Koha.Preference('PatronsPerPage') | html %];
255 for ( var i = 0; i < aLengthMenu.length; i++ ) {
256 if ( aLengthMenu[i] == patronsPerPage ) {
259 if ( aLengthMenu[i] > patronsPerPage || aLengthMenu[i] == -1 ) {
260 aLengthMenu.splice(i, 0, patronsPerPage);
261 aLengthMenuLabel.splice(i, 0, patronsPerPage);
267 $("#description").show();
269 $("#description").hide();
271 $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
273 { "aTargets": [ -2, -1 ], "bSortable": false, "bSearchable": false }
275 "aaSorting": [[ 0, "asc" ]],
276 "sPaginationType": "full",
277 "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
278 "pageLength": patronsPerPage,
281 $("#additems").click(function(){
285 $("#removeitems").click(function(){
289 $("#deletebatch").click(function(){
293 $("#deduplicate").click(function(){
297 $("#exportitems").click(function(){
301 $("#exportbatch").click(function(){
305 $(".delete").on("click", function(){
306 return confirmDelete( _("Are you sure you want to delete this patron from the card batch?") );
308 $(".export").on("click", function(e){
310 var label_id = $(this).data("label-id");
311 var batch_id = $(this).data("batch-id");
312 GB_showCenter( _("Export single card"),'/cgi-bin/koha/patroncards/print.pl?batch_id=' + batch_id + '&label_id=' + label_id, 400, 800);
314 $("#savedesc").click(function(event){
315 var newdescription = $(this).siblings('input[name="description"]').val();
316 var batch_id = $(this).data('batch_id');
318 'newdescription': newdescription,
319 'batch_id': batch_id,
320 'card_element': "batch",
321 'creator': "patroncard",
325 url: '/cgi-bin/koha/svc/creator_batches',
331 .done(function(data){
332 if (data.status == 'success') {
333 $("input[name='description']").text(data.newdesc);
334 $("#change-status").text(_("Saved"));
336 $("#change-status").text(_("Unable to save description"));
340 $("#savedesc").click(function(event){
341 var newdescription = $('input[name="description"]').val();
342 var batch_id = $(this).data('batch_id');
344 'newdescription': newdescription,
345 'batch_id': batch_id,
346 'card_element': "batch",
347 'creator': "patroncard",
351 url: '/cgi-bin/koha/svc/creator_batches',
357 .done(function(data){
358 if (data.status == 'success') {
359 $("input[name='description']").text(data.newdesc);
360 $("#change-status").text(_("Saved"));
362 $("#change-status").text(_("Unable to save description"));
370 [% INCLUDE 'intranet-bottom.inc' %]