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