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