Bug 31417: Update and reference cat-menu.inc
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / labels / label-manage.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% PROCESS 'i18n.inc' %]
4 [% SET footerjs = 1 %]
5 [% BLOCK translate_label_element %]
6 [%-  SWITCH element -%]
7 [%-  CASE 'layout'    -%][% t('layout') | html %]
8 [%-  CASE 'Layouts'   -%][% t('Layouts') | html %]
9 [%-  CASE 'template'  -%][% t('template') | html %]
10 [%-  CASE 'Templates' -%][% t('Templates') | html %]
11 [%-  CASE 'profile'   -%][% t('profile') | html %]
12 [%-  CASE 'Profiles'  -%][% t('Profiles') | html %]
13 [%-  CASE 'batch'     -%][% t('batch') | html %]
14 [%-  CASE 'Batches'   -%][% t('Batches') | html %]
15 [%-  END -%]
16 [% END %]
17     [% INCLUDE 'doc-head-open.inc' %]
18     <title>[% PROCESS translate_label_element element=label_element_title %] &rsaquo; Label creator &rsaquo; Tools &rsaquo; Koha</title>
19     [% INCLUDE 'doc-head-close.inc' %]
20 </head>
21
22 <body id="labels_label-manage" class="tools labels">
23     [% WRAPPER 'header.inc' %]
24     [% INCLUDE 'cat-search.inc' %]
25 [% END %]
26
27     [% WRAPPER 'sub-header.inc' %]
28     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
29         <ol>
30             <li>
31                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
32             </li>
33             <li>
34                 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
35             </li>
36             <li>
37                 <a href="/cgi-bin/koha/labels/label-home.pl">Label creator</a>
38             </li>
39             <li>
40                 <a href="#" aria-current="page">
41                     [% PROCESS translate_label_element element=label_element_title %]
42                 </a>
43             </li>
44         </ol>
45     </nav>
46     [% END %]
47
48     <div class="main container-fluid">
49         <div class="row">
50             <div class="col-sm-10 col-sm-push-2">
51                 <main>
52
53                     [% INCLUDE 'labels-toolbar.inc' %]
54                     <h1>Manage labels</h1>
55
56                         [% IF ( error ) %]
57                             <div class="dialog alert">
58                                 <strong>WARNING:</strong> An error was encountered and the [% op | html %] operation for [% label_element | html %] [% element_id | html %] was not completed. Please have your system administrator check the error log for details.
59                             </div>
60                         [% END %]
61
62                         <div id="manage-label-layouts">
63                             [% IF ( table_loop ) %]
64                             <form name="layouts" action="/cgi-bin/koha/label-manage.pl?label_element=[% label_element | html %]">
65                             [% IF    ( label_element == 'layout' ) %]
66                             <h2>Currently available layouts</h2>
67                             [% ELSIF ( label_element == 'template' ) %]
68                             <h2>Currently available templates</h2>
69                             [% ELSIF ( label_element == 'profile' ) %]
70                             <h2>Currently available profiles</h2>
71                             [% ELSIF ( label_element == 'batch' ) %]
72                             <h2>Currently available batches</h2>
73                             [% END %]
74                             <table id="labels-table">
75                                 [% FOREACH table_loo IN table_loop %]
76                                     [% IF ( table_loo.header_fields ) %]
77                                         <thead>
78                                         <tr>
79                                             [% FOREACH header_field IN table_loo.header_fields %]
80                                                 [% SWITCH header_field.field_label %]
81                                                     [% CASE 'Layout ID'       %]<th>Layout ID</th>
82                                                     [% CASE 'Layout'          %]<th>Layout</th>
83                                                     [% CASE 'Barcode Type'    %]<th>Barcode type</th>
84                                                     [% CASE 'Print Type'      %]<th>Print type</th>
85                                                     [% CASE 'Template ID'     %]<th>Template ID</th>
86                                                     [% CASE 'Template Name'   %]<th>Template name</th>
87                                                     [% CASE 'Description'     %]<th>Description</th>
88                                                     [% CASE 'Actions'         %]<th class="noExport">Actions</th>
89                                                     [% CASE 'Profile ID'      %]<th>Profile ID</th>
90                                                     [% CASE 'Printer Name'    %]<th>Printer name</th>
91                                                     [% CASE 'Paper Bin'       %]<th>Paper bin</th>
92                                                     [% CASE 'Batch ID'        %]<th>Batch ID</th>
93                                                     [% CASE 'Item Count'      %]<th>Item count</th>
94                                                     [% CASE 'Fields to Print' %]<th>Fields to print</th>
95                                                     [% CASE                   %]<th>[% header_field.field_label | html %]</th>
96                                                 [% END %]
97                                             [% END %]
98                                         </tr>
99                                         </thead>
100                                     [% ELSE %]
101                                         <tr>
102                                         [% FOREACH text_field IN table_loo.text_fields %]
103                                             [% IF ( text_field.select_field ) %]
104                                                 <td class="actions">
105                                                     <a class="btn btn-default btn-xs" href="/cgi-bin/koha/labels/label-edit-[% label_element |url %].pl?op=edit&amp;element_id=[% text_field.field_value |url %]"><i class="fa fa-edit"></i> Edit</a>
106                                                     <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/labels/label-manage.pl?op=delete&amp;label_element=[% label_element | html %]&amp;element_id=[% text_field.field_value |url %]"><i class="fa fa-trash"></i> Delete</a>
107                                                 </td>
108                                                 [% IF label_element == 'batch' %] <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>[% END %]
109                                             [% ELSIF ( text_field.field_value ) %]
110                                                 <td>[% text_field.field_value | html %]</td>
111                                             [% ELSE %]
112                                                 <td>&nbsp;</td>
113                                             [% END %]
114                                         [% END %]
115                                         </tr>
116                                     [% END %]
117                                 [% END %]
118                             </table>
119                             [% IF ( print ) %]<button type="button" class="btn btn-default" id="print">Export selected</button>[% END %]
120                             </fieldset>
121                             </form>
122                             [% ELSE %]
123                                                         <div class="dialog message">
124                             <h4>There are no
125                             [% PROCESS translate_label_element element=label_element_title %]
126                             currently available.</h4>
127                             <p>Use the toolbar above to create a new
128                             [% PROCESS translate_label_element element=label_element %].</p></div>
129                             [% END %]
130                         </div>
131             </main>
132         </div> <!-- /.col-sm-10.col-sm-push-2 -->
133
134         <div class="col-sm-2 col-sm-pull-10">
135             <aside>
136                 [% INCLUDE 'cat-menu.inc' %]
137             </aside>
138         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
139      </div> <!-- /.row -->
140
141 [% MACRO jsinclude BLOCK %]
142     [% INCLUDE 'greybox.inc' %]
143     [% INCLUDE 'datatables.inc' %]
144     <script>
145         function Xport() {
146             batches= new Array;
147             if(document.layouts.action.length > 0) {
148                 for (var i=0; i < document.layouts.action.length; i++) {
149                     if (document.layouts.action[i].checked) {
150                         batches.push("batch_id=" +  document.layouts.action[i].value);
151                     }
152                 }
153                 if (batches.length < 1) {
154                     alert(_("Please select at least one batch to export."));
155                     return;     // no batch selected
156                 }
157                 getstr = batches.join("&");
158             }
159             else if (document.layouts.action.checked) {
160                 getstr = "batch_id="+document.layouts.action.value;
161             }
162             else {
163                 alert(_("Please select at least one batch to export."));
164                 return;     // no batch selected
165             }
166             return GB_showCenter(_("Export labels"), "/cgi-bin/koha/labels/label-print.pl?" + getstr, 400, 800);
167         }
168         function selected_layout(op) {
169             var selected = new Array;
170             if (document.layouts.action.length) {
171                 for (i=0;i<document.layouts.action.length;i++){
172                     if (document.layouts.action[i].checked){
173                         selected.push(i);
174                     }
175                 };
176                 if (selected.length == 1) {
177                     return(document.layouts.action[selected[0]].value);
178                 }
179                 else {
180                     alert(_("Please select only one %s to %s.").format("[% label_element | html %]", op));
181                     return (-1);
182                 }
183             }
184             else {
185                 if (document.layouts.action.checked){
186                     return(document.layouts.action.value);
187                 }
188             };
189             alert(_("Please select a %s.").format("[% label_element | html %]"));
190             return (-1);
191         }
192         $(document).ready(function(){
193             $('#navmenulist a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current");
194             $("#print").click(function(e){
195                 e.preventDefault();
196                 Xport();
197             });
198             $(".delete").on("click", function(){
199                 return confirmDelete( _("Are you sure you want to delete this?") );
200             });
201             $("#labels-table").dataTable($.extend(true, {}, dataTablesDefaults, {
202                 "sPaginationType": "full",
203                 "aaSorting": [[ 1, "asc" ]],
204                 "aoColumnDefs": [
205                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
206                 ]
207             }));
208         });
209     </script>
210 [% END %]
211
212 [% INCLUDE 'intranet-bottom.inc' %]