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