Bug 16239: Update templates
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / labels / label-edit-batch.tt
1 [% USE ItemTypes %]
2     [% INCLUDE 'doc-head-open.inc' %]
3     <title>Koha &rsaquo; Tools &rsaquo; Label creator &rsaquo; Batches &rsaquo; [% IF batch_id %]Edit ([% batch_id %])[% ELSE %]New[% END %]</title>
4     [% INCLUDE 'doc-head-close.inc' %]
5     [% INCLUDE 'greybox.inc' %]
6     <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
7     [% INCLUDE 'datatables.inc' %]
8     <script type="text/javascript">
9     //<![CDATA[
10         function DeleteConfirm() {
11             var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id %]");
12             var answer = confirm(msg);
13             if (answer) {
14                 window.location = "/cgi-bin/koha/labels/label-manage.pl?op=delete&amp;label_element=batch&amp;element_id=[% batch_id %]";
15             }
16             else {
17                 return; // abort delete
18             }
19         };
20         function dofocus() {    // named function req'd for body onload event by some FF and IE7 security models
21             $(".focus:last").select();
22         }
23         function verifyBarcodes(barcodes) {
24             if (barcodes.value == '') {
25                 alert(_("Please add barcodes using either the direct entry text area or the item search."));
26                 return false;   // not ok
27             }
28             else {
29                 return true;    // ok
30             };
31         }
32             function Remove() {
33                 items = new Array;
34                 item_num = new Array;
35                 if(document.items.action.length > 0) {
36                     for (var i=0; i < document.items.action.length; i++) {
37                         if (document.items.action[i].checked) {
38                             items.push("label_id=" +  document.items.action[i].value);
39                             item_num.push(i+1);
40                         }
41                     }
42                     getstr = items.join("&");
43                     item_msg = item_num.join(", ");
44                     var msg = "Are you sure you want to remove label number(s): " + item_msg + " from this batch?"
45                 } else if (document.items.action.checked) {
46                     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"));
47                     return; // no deletion for single item batch
48                 }
49                 else {
50                     alert(_("Please select at least one label to delete."));
51                     return;     // no item selected
52                 }
53                 var answer = confirm(msg);
54                 if (answer) {
55                     window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&amp;batch_id=[% batch_id %]&amp;" + getstr;
56                 }
57                 else {
58                     return; // abort delete
59                 }
60             };
61             function Add() {
62                 var number_list = document.getElementById("number_list");
63                 if (number_list.value == '') {
64                     window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=[% batch_id %]&amp;type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
65                 }
66                 else {
67                     document.forms["add_by_number"].submit();
68                 }
69             };
70
71             function add_item(item_number) {
72                 $("#itemnum_enter").prop("checked",true);
73                 $("#number_list").val($("#number_list").val()+item_number+"\r\n");
74             };
75
76             function DeDuplicate() {
77                 window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id %]";
78             };
79             function Xport(mode) {
80                 if (mode == 'label') {
81                     labels= new Array;
82                     if(document.items.action.length > 0) {
83                         for (var i=0; i < document.items.action.length; i++) {
84                             if (document.items.action[i].checked) {
85                                 labels.push("label_id=" +  document.items.action[i].value);
86                             }
87                         }
88                         if (labels.length < 1) {
89                             alert(_("Please select at least one label to export."));
90                             return;     // no batch selected
91                         }
92                         getstr = labels.join("&");
93                     }
94                     else if (document.items.action.checked) {
95                         getstr = document.items.action.value;
96                     }
97                     else {
98                         alert(_("Please select at least one label to export."));
99                         return;     // no batch selected
100                     }
101                     return GB_showCenter('Export labels', "/cgi-bin/koha/labels/label-print.pl?batch_id=[% batch_id %]&" + getstr, 400, 800);
102                 }
103                 else if (mode == 'batch') {
104                     return GB_showCenter('Export labels', "/cgi-bin/koha/labels/label-print.pl?batch_id=[% batch_id %]", 400, 800);
105                 }
106                 else {
107                     // some pass-thru error trapping just in case...
108                 }
109             };
110            function selected_layout() {
111                 if (document.items.action.length) {
112                 for (i=0;i<document.items.action.length;i++){
113                     if (document.items.action[i].checked==true){
114                         return(document.items.action[i].value);
115                     }
116                 };
117                 }
118                 else {
119                     if (document.items.action.checked){
120                         return(document.items.action.value);
121                     }
122                 };
123                 alert(_("Please select at least one item."));
124                 return (-1);
125             };
126
127          $(document).ready(function() {
128             $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
129                 "autoWidth": false,
130                 "aoColumnDefs": [
131                     { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
132                     { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
133                 ],
134                 "aaSorting": [[ 0, "asc" ]],
135                 "sPaginationType": "four_button"
136             }));
137             $("#additems").click(function(){
138                 Add();
139                 return false;
140             });
141             $("#removeitems").click(function(){
142                 Remove();
143                 return false;
144             });
145             $("#deletebatch").click(function(){
146                 DeleteConfirm();
147                 return false;
148             });
149             $("#deduplicate").click(function(){
150                 DeDuplicate();
151                 return false;
152             });
153             $("#exportitems").click(function(){
154                 Xport('label');
155                 return false;
156             });
157             $("#exportbatch").click(function(){
158                 Xport('batch');
159                 return false;
160             });
161             $(".delete").on("click", function(){
162                 return confirmDelete( _("Are you sure you want to delete this?") );
163             });
164             $(".export").on("click", function(e){
165                 e.preventDefault();
166                 var label_id = $(this).data("label-id");
167                 var batch_id = $(this).data("batch-id");
168                 GB_showCenter(_("Export labels"),"/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id + "&label_id=" + label_id, 400, 800);
169             });
170          });
171     //]]>
172     </script>
173 </head>
174 <body id="labels_label-edit-batch" class="tools labels" onload="dofocus();">
175     [% INCLUDE 'header.inc' %]
176     [% INCLUDE 'cat-search.inc' %]
177     <div id="breadcrumbs">
178         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
179         <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
180         <a href="/cgi-bin/koha/labels/label-home.pl">Label creator</a> &rsaquo;
181         <a href="/cgi-bin/koha/labels/label-manage.pl?label_element=batch">Batches</a> &rsaquo;
182         [% IF batch_id %]
183             Edit ([% batch_id %])
184         [% ELSE %]
185             New
186         [% END %]
187     </div>
188     <div id="doc3" class="yui-t2">
189         <div id="bd">
190             <div id="yui-main">
191                 <div class="yui-b">
192                         [% INCLUDE 'labels-toolbar.inc' %]
193                         [% IF ( err ) %]
194                             <div class="dialog alert">
195                                 <strong>WARNING:</strong> An error was encountered and [% errstr %] Please have your system administrator check the error log for details.
196                             </div>
197                         [% ELSIF ( duplicate_message ) %]
198                             <div class="dialog message">
199                                 <strong>Duplicate item(s) removed from batch number [% batch_id %]: [% duplicate_count %]</strong>
200                             </div>
201                         [% END %]
202
203                         <div id="manage-label-batches">
204                             <div class="hint">Current library: [% LoginBranchname %]</div>
205                             <form name="add_by_number" action="/cgi-bin/koha/labels/label-edit-batch.pl" method="post">
206                                 <div>
207                                     <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
208                                     <ol><li>
209                                         <input type="hidden" name="op" value="add" />
210                                         <input type="hidden" name="batch_id" value="[% batch_id %]" />
211                                     </li>
212                                     <li>
213                                         <input type="radio" name="number_type" id="barcode_enter" value="barcode" checked />
214                                         <label for="barcode_enter">Enter by barcode:</label><br/>
215                                         <input type="radio" name="number_type" id="itemnum_enter" value="itemnumber" />
216                                         <label for="itemnum_enter">Enter by itemnumber:</label>
217                                     </li>
218                                     <li>
219                                         <label for="number_list">Add by barcode(s) or itemnumbers(s):
220                                             <br /> <span class="hint">One number per line.</span>
221                                             <br /> <span class="hint">Leave empty to add via item search (itemnumber).</span>
222                                         </label>
223                                         <textarea rows="5" id="number_list" name="number_list" tabindex="1" class="focus"></textarea>
224                                     </li></ol>
225                                     </fieldset>
226                                 </div>
227                             </form>
228                             <div id="batch-manage" class="btn-toolbar">
229                                 <a class="btn btn-default btn-sm" id="additems" href="#"><i class="fa fa-plus"></i> Add item(s)</a>[% IF ( table_loop ) %]
230                                 <a class="btn btn-default btn-sm" id="removeitems" href="#"><i class="fa fa-trash"></i> Remove selected items</a>
231                                 <a class="btn btn-default btn-sm" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
232                                 <a class="btn btn-default btn-sm" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
233                                 <a class="btn btn-default btn-sm" id="exportitems" href="#"><i class="fa fa-share-square-o"></i> Export selected items</a>
234                                 <a class="btn btn-default btn-sm" id="exportbatch" href="#"><i class="fa fa-share-square-o"></i> Export full batch</a>[% END %]
235                             </div>
236                             [% IF ( table_loop ) %]
237                                 <form name="items" class="checkboxed">
238                                     <h2>Items in batch number [% batch_id %]</h2>
239                                     <table id="batcht">
240                                         [% FOREACH table_loo IN table_loop %]
241                                             [% IF ( table_loo.header_fields ) %]
242                                                 <thead>
243                                                     <tr>
244                                                         [% FOREACH header_field IN table_loo.header_fields %]
245                                                             [% SWITCH header_field.field_label -%]
246                                                                 [% CASE "Label number" -%]
247                                                                     <th>Label number</th>
248                                                                 [% CASE "Summary" -%]
249                                                                     <th class="anti-the">Summary</th>
250                                                                 [% CASE "Item type" %]
251                                                                     <th>Item type</th>
252                                                                 [% CASE "Barcode" %]
253                                                                     <th>Barcode</th>
254                                                                 [% CASE "Select" -%]
255                                                                     <th>Select</th>
256                                                                 [% CASE %]
257                                                                     <th>[% header_field.field_label %]</th>
258                                                             [% END -%]
259                                                         [% END %]
260                                                     </tr>
261                                                 </thead>
262                                                 <tbody>
263                                             [% ELSE %]
264                                                     <tr>
265                                                         [% FOREACH text_field IN table_loo.text_fields %]
266                                                             [% IF ( text_field.select_field ) %]
267                                                                 <td>
268                                                                     <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"></i> Delete</a>
269                                                                     <a class="btn btn-default btn-xs export" href="#" data-batch-id="[% batch_id %]" data-label-id="[% text_field.field_value |html %]"><i class="fa fa-share-square-o"></i> Export</a>
270                                                                 </td>
271                                                                 <td><input type="checkbox" name="action" value="[% text_field.field_value %]"></td>
272                                                             [% ELSE %]
273                                                                 <td>
274                                                                     [% IF ( text_field.field_name == '_item_type_tbl' ) %]
275                                                                         [% ItemTypes.GetDescription( text_field.field_value ) %]
276                                                                     [% ELSE %]
277                                                                         [% text_field.field_value %]
278                                                                     [% END %]
279                                                                 </td>
280                                                             [% END %]
281                                                         [% END %]
282                                                     </tr>
283                                             [% END %]
284                                         [% END %]
285                                         </tbody>
286                                     </table>
287                                 </form>
288                                 [% ELSE %]
289                                     <div class="dialog message">
290                                         <h4>There are no items in this batch yet</h4>
291                                         <p>Add items by using the text area above or leave empty to add via item search.</p>
292                                     </div>
293                                 [% END %]
294                             </div>
295                         </div>
296                 </div>
297             <div class="yui-b">
298               [% INCLUDE 'tools-menu.inc' %]
299             </div>
300             </div>
301     [% INCLUDE 'intranet-bottom.inc' %]