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