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