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