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