Bug 34913: DataTables upgrade: Update CSS and option names
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / labels / label-edit-batch.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE ItemTypes %]
4 [% PROCESS 'i18n.inc' %]
5 [% SET footerjs = 1 %]
6     [% INCLUDE 'doc-head-open.inc' %]
7     <title>[% FILTER collapse %]
8         [% IF ( batch_id ) %]
9             [% tx("Edit label batch {batch_id}", { batch_id = batch_id }) | html %]
10         [% ELSE %]
11             [% t("New label batch") | html %]
12         [% END %] &rsaquo;
13             [% t("Batches") | html %] &rsaquo;
14         [% t("Label creator") | html %] &rsaquo;
15         [% t("Cataloging") | html %] &rsaquo;
16         [% t("Koha") | html %]
17     [% END %]</title>
18     [% INCLUDE 'doc-head-close.inc' %]
19 </head>
20
21 <body id="labels_label-edit-batch" class="tools labels" onload="dofocus();">
22     [% WRAPPER 'header.inc' %]
23     [% INCLUDE 'cat-search.inc' %]
24 [% END %]
25
26 [% WRAPPER 'sub-header.inc' %]
27     [% WRAPPER breadcrumbs %]
28         [% WRAPPER breadcrumb_item %]
29             <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
30         [% END %]
31         [% WRAPPER breadcrumb_item %]
32             <a href="/cgi-bin/koha/labels/label-home.pl">Label creator</a>
33         [% END %]
34         [% WRAPPER breadcrumb_item %]
35             <a href="/cgi-bin/koha/labels/label-manage.pl?label_element=batch">Batches</a>
36         [% END %]
37         [% WRAPPER breadcrumb_item bc_active= 1 %]
38             [% IF description %]
39                 <span>Edit [% description | html %]</span>
40             [% ELSIF batch_id %]
41                 <span>Edit label batch [% batch_id | html %]</span>
42             [% ELSE %]
43                 <span>New label batch</span>
44             [% END %]
45         [% END %]
46     [% END #/ WRAPPER breadcrumbs %]
47 [% END #/ WRAPPER sub-header.inc %]
48
49     <div class="main container-fluid">
50         <div class="row">
51             <div class="col-sm-10 col-sm-push-2">
52                 <main>
53
54                         [% INCLUDE 'labels-toolbar.inc' %]
55
56                         [% IF description %]
57                             <h1>Edit [% description | html %]</h1>
58                         [% ELSIF batch_id %]
59                             <h1>Edit label batch [% batch_id | html %]</h1>
60                         [% ELSE %]
61                             <h1>New label batch</h1>
62                         [% END %]
63
64                         [% IF ( err ) %]
65                             [% BLOCK xlate_errtype %]
66                             [%    SWITCH errtype %]
67                             [%       CASE 'ITEM_NOT_REMOVED' %]
68                             <span>Item(s) not removed from batch [% batch_id | html %].</span>
69                             [%       CASE 'BATCH_NOT_DELETED' %]
70                             <span>Batch [% batch_id | html %] was not deleted.</span>
71                             [%       CASE 'ITEM_NOT_ADDED' %]
72                             <span>Item(s) not added to batch [% batch_id | html %].</span>
73                             [%       CASE 'BRANCH_NOT_SET' %]
74                             <span>Library is not set, please set your library before adding items to a batch.</span>
75                             [%       CASE 'BATCH_NOT_DEDUP' %]
76                             <span>Batch [% batch_id | html %] not fully de-duplicated.</span>
77                             [%       CASE %]
78                             <span>Unknown error type [% errtype | html %].</span>
79                             [%    END %]
80                             [% END %]
81                             <div class="dialog alert">
82                                 <strong>WARNING:</strong> An error was encountered: [% PROCESS xlate_errtype %] Please have your system administrator check the error log for details.
83                             </div>
84                         [% ELSIF ( duplicate_message ) %]
85                             <div class="dialog message">
86                                 <strong>Duplicate item(s) removed from batch number [% batch_id | html %]: [% duplicate_count | html %]</strong>
87                             </div>
88                         [% END %]
89
90                         <div id="manage-label-batches">
91                             <form name="add_by_number" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post">
92                                 <div>
93                                     <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
94                                     <ol><li id="description">
95                                             <input type="hidden" name="op" value="add" />
96                                             <input type="hidden" name="batch_id" value="[% batch_id | html %]" />
97                                             <label for="description">Batch description: </label>
98                                             <input type="text" name="description" value="[% description | html %]"> <span id="change-status"></span>
99                                         </li>
100                                     <li>
101                                         <input type="radio" name="number_type" id="barcode_enter" value="barcode" checked />
102                                         <label for="barcode_enter">Enter by barcode:</label>
103                                     </li>
104                                     <li>
105                                         <input type="radio" name="number_type" id="itemnum_enter" value="itemnumber" />
106                                         <label for="itemnum_enter">Enter by itemnumber:</label>
107                                     </li>
108                                     <li>
109                                         <label for="number_list">
110                                             Add by barcode(s) or itemnumbers(s):
111                                         </label>
112                                         <textarea rows="5" id="number_list" name="number_list" tabindex="1" class="focus"></textarea>
113                                         <div class="hint">
114                                             One number per line.
115                                             <br /> Leave empty to add via item search (itemnumber)
116                                         </div>
117                                     </li></ol>
118                                     </fieldset>
119                                 </div>
120                             </form>
121                             <div id="batch-manage" class="btn-toolbar">
122                                 <a class="btn btn-default" id="additems" href="#"><i class="fa fa-plus"></i> Add item(s)</a>[% IF ( table_loop ) %]
123                                 <a class="btn btn-default" id="savedesc" href="#" data-batch_id="[% batch_id | html %]"><i class="fa fa-save"></i> Save description</a>
124                                 <a class="btn btn-default" id="removeitems" href="#"><i class="fa fa-trash-can"></i> Remove selected items</a>
125                                 <a class="btn btn-default" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
126                                 <a class="btn btn-default" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
127                                 <a class="btn btn-default" id="exportitems" href="#"><i class="fa-solid fa-share-from-square"></i> Export selected items</a>
128                                 <a class="btn btn-default" id="exportbatch" href="#"><i class="fa-solid fa-share-from-square"></i> Export full batch</a>[% END %]
129                             </div>
130                             [% IF ( table_loop ) %]
131                                 <form name="items">
132                                     <h2>Items in batch number [% batch_id | html %]</h2>
133
134                                     <div class="page-section">
135                                         <table id="batcht">
136                                             [% FOREACH table_loo IN table_loop %]
137                                                 [% IF ( table_loo.header_fields ) %]
138                                                     <thead>
139                                                         <tr>
140                                                             [% FOREACH header_field IN table_loo.header_fields %]
141                                                                 [% SWITCH header_field.field_label -%]
142                                                                     [% CASE "Label number" -%]
143                                                                         <th>Label number</th>
144                                                                     [% CASE "Summary" -%]
145                                                                         <th class="anti-the">Summary</th>
146                                                                     [% CASE "Item type" %]
147                                                                         <th>Item type</th>
148                                                                     [% CASE "Call number" %]
149                                                                         <th>Call number</th>
150                                                                     [% CASE "Barcode" %]
151                                                                         <th>Barcode</th>
152                                                                     [% CASE "Select" -%]
153                                                                         <th>Select</th>
154                                                                     [% CASE %]
155                                                                         <th>[% header_field.field_label | html %]</th>
156                                                                 [% END -%]
157                                                             [% END %]
158                                                         </tr>
159                                                     </thead>
160                                                     <tbody>
161                                                 [% ELSE %]
162                                                         <tr>
163                                                             [% FOREACH text_field IN table_loo.text_fields %]
164                                                                 [% IF ( text_field.select_field ) %]
165                                                                     <td>
166                                                                         <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&amp;batch_id=[% batch_id |url %]&amp;label_id=[% text_field.field_value |url %]"><i class="fa fa-trash-can"></i> Delete</a>
167                                                                         <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-solid fa-share-from-square"></i> Export</a>
168                                                                     </td>
169                                                                     <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]"></td>
170                                                                 [% ELSE %]
171                                                                     <td>
172                                                                         [% IF ( text_field.field_name == '_item_type_tbl' ) %]
173                                                                             [% ItemTypes.GetDescription( text_field.field_value ) | html %]
174                                                                         [% ELSE %]
175                                                                             [% text_field.field_value | $raw %]
176                                                                         [% END %]
177                                                                     </td>
178                                                                 [% END %]
179                                                             [% END %]
180                                                         </tr>
181                                                 [% END %]
182                                             [% END %]
183                                             </tbody>
184                                         </table>
185                                     </div> <!-- /.page-section -->
186                                 </form>
187                                 [% ELSE %]
188                                     <div class="dialog message">
189                                         <h4>There are no items in this batch yet</h4>
190                                         <p>Add items by using the text area above or leave empty to add via item search.</p>
191                                     </div>
192                                 [% END %]
193                             </div>
194             </main>
195         </div> <!-- /.col-sm-10.col-sm-push-2 -->
196
197         <div class="col-sm-2 col-sm-pull-10">
198             <aside>
199                 [% INCLUDE 'cat-menu.inc' %]
200             </aside>
201         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
202      </div> <!-- /.row -->
203
204 [% MACRO jsinclude BLOCK %]
205     [% INCLUDE 'greybox.inc' %]
206     [% INCLUDE 'datatables.inc' %]
207     <script>
208         function DeleteConfirm() {
209             var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id | html %]");
210             var answer = confirm(msg);
211             if (answer) {
212                 window.location = "/cgi-bin/koha/labels/label-manage.pl?op=delete&amp;label_element=batch&amp;element_id=[% batch_id | html %]";
213             }
214             else {
215                 return; // abort delete
216             }
217         }
218         function dofocus() {    // named function req'd for body onload event by some FF and IE7 security models
219             $(".focus:last").select();
220         }
221         function verifyBarcodes(barcodes) {
222             if (barcodes.value == '') {
223                 alert(_("Please add barcodes using either the direct entry text area or the item search."));
224                 return false;   // not ok
225             }
226             else {
227                 return true;    // ok
228             }
229         }
230         function Remove() {
231             items = new Array;
232             item_num = new Array;
233             if(document.items.action.length > 0) {
234                 for (var i=0; i < document.items.action.length; i++) {
235                     if (document.items.action[i].checked) {
236                         items.push("label_id=" +  document.items.action[i].value);
237                         item_num.push(i+1);
238                     }
239                 }
240                 getstr = items.join("&");
241                 item_msg = item_num.join(", ");
242                 var msg = _("Are you sure you want to remove label number(s): %s from this batch?").format(item_msg);
243             } else if (document.items.action.checked) {
244                 alert(_("Deletion of label from a batch with only one label will delete the batch.") + "\n\n" + _("If this is what you want, select the 'Delete batch' option from the toolbar"));
245                     return; // no deletion for single item batch
246             } else {
247                 alert(_("Please select at least one label to delete."));
248                 return;     // no item selected
249             }
250             var answer = confirm(msg);
251             if (answer) {
252                 window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&amp;batch_id=[% batch_id | html %]&amp;" + getstr;
253             } else {
254                 return; // abort delete
255             }
256         }
257         function Add() {
258             var number_list = document.getElementById("number_list");
259             if (number_list.value == '') {
260                 window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=[% batch_id | html %]&amp;type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
261             } else {
262                 document.forms["add_by_number"].submit();
263             }
264         }
265
266         function add_item(item_number) {
267             $("#itemnum_enter").prop("checked",true);
268             $("#number_list").val($("#number_list").val()+item_number+"\r\n");
269         }
270
271         function DeDuplicate() {
272             window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id | html %]";
273         }
274
275         function Xport(mode) {
276             if (mode == 'label') {
277                 labels= new Array;
278                 if(document.items.action.length > 0) {
279                     for (var i=0; i < document.items.action.length; i++) {
280                         if (document.items.action[i].checked) {
281                             labels.push("label_id=" +  document.items.action[i].value);
282                         }
283                     }
284                     if (labels.length < 1) {
285                         alert(_("Please select at least one label to export."));
286                         return;     // no batch selected
287                     }
288                     getstr = labels.join("&");
289                 }
290                 else if (document.items.action.checked) {
291                     getstr = document.items.action.value;
292                 } else {
293                     alert(_("Please select at least one label to export."));
294                     return;     // no batch selected
295                 }
296                 return GB_showCenter(_("Export labels"), "/cgi-bin/koha/labels/label-print.pl?batch_id=[% batch_id | html %]&" + getstr, 400, 800);
297             } else if (mode == 'batch') {
298                 return GB_showCenter(_("Export labels"), "/cgi-bin/koha/labels/label-print.pl?batch_id=[% batch_id | html %]", 400, 800);
299             } else {
300                 // some pass-thru error trapping just in case...
301             }
302         }
303
304         function selected_layout() {
305             if (document.items.action.length) {
306                 for (i=0;i<document.items.action.length;i++){
307                     if (document.items.action[i].checked==true){
308                         return(document.items.action[i].value);
309                     }
310                 }
311             } else {
312                 if (document.items.action.checked){
313                     return(document.items.action.value);
314                 }
315             }
316             alert(_("Please select at least one item."));
317             return (-1);
318         }
319
320         $(document).ready(function() {
321             $('#navmenulist a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current");
322             [% IF table_loop %]
323                 $("#description").show();
324             [% ELSE %]
325                 $("#description").hide();
326             [% END %]
327             $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
328                 "autoWidth": false,
329                 "columnDefs": [
330                     { "type": "anti-the", "targets":  [ "anti-the" ] },
331                     { "targets": [ -1, -2 ], "orderable": false, "searchable":  false },
332                 ],
333                 "order": [[ 0, "asc" ]],
334                 "pagingType": "full"
335             }));
336             $("#additems").click(function(){
337                 Add();
338                 return false;
339             });
340             $("#removeitems").click(function(){
341                 Remove();
342                 return false;
343             });
344             $("#deletebatch").click(function(){
345                 DeleteConfirm();
346                 return false;
347             });
348             $("#deduplicate").click(function(){
349                 DeDuplicate();
350                 return false;
351             });
352             $("#exportitems").click(function(){
353                 Xport('label');
354                 return false;
355             });
356             $("#exportbatch").click(function(){
357                 Xport('batch');
358                 return false;
359             });
360             $(".delete").on("click", function(){
361                 return confirmDelete( _("Are you sure you want to delete this?") );
362             });
363             $(".export").on("click", function(e){
364                 e.preventDefault();
365                 var label_id = $(this).data("label-id");
366                 var batch_id = $(this).data("batch-id");
367                 GB_showCenter(_("Export labels"),"/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id + "&label_id=" + label_id, 400, 800);
368             });
369             $("#savedesc").click(function(event){
370                 event.preventDefault(); // prevent form submission
371                 var newdescription = $('input[name="description"]').val();
372                 var batch_id = $(this).data('batch_id');
373                 var ajaxData = {
374                     'newdescription': newdescription,
375                     'batch_id': batch_id,
376                     'card_element': "batch",
377                     'creator': "label",
378                 };
379
380                 $.ajax({
381                     url: '/cgi-bin/koha/svc/creator_batches',
382                     type: 'POST',
383                     dataType: 'json',
384                     data: ajaxData,
385                 })
386
387                 .done(function(data){
388                     if (data.status == 'success') {
389                         $("input[name='description']").text(data.newdesc);
390                         $("#change-status").text(_("Saved"));
391                     } else {
392                         $("#change-status").text(_("Unable to save description"));
393                     }
394                 });
395             });
396          });
397     </script>
398 [% END %]
399
400 [% INCLUDE 'intranet-bottom.inc' %]