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