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