Bug 32955: Standardize structure around action fieldsets in various templates
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / patroncards / manage.tt
1 [% USE CGI %]
2 [% PROCESS 'i18n.inc' %]
3 [% SET footerjs = 1 %]
4 [% BLOCK translate_card_element %]
5 [%-  SWITCH element -%]
6 [%-  CASE 'layout'    -%][% t('layout') | html %]
7 [%-  CASE 'Layouts'   -%][% t('Layouts') | html %]
8 [%-  CASE 'template'  -%][% t('template') | html %]
9 [%-  CASE 'Templates' -%][% t('Templates') | html %]
10 [%-  CASE 'profile'   -%][% t('profile') | html %]
11 [%-  CASE 'Profiles'  -%][% t('Profiles') | html %]
12 [%-  CASE 'batch'     -%][% t('batch') | html %]
13 [%-  CASE 'Batches'   -%][% t('Batches') | html %]
14 [%-  CASE 'Actions'   -%][% t('Actions') | html %]
15 [%-  END -%]
16 [% END %]
17 [% BLOCK translate_card_elements %]
18 [%-  SWITCH element -%]
19 [%-  CASE 'layout'    -%]<span>layouts</span>
20 [%-  CASE 'template'  -%]<span>templates</span>
21 [%-  CASE 'profile'   -%]<span>profiles</span>
22 [%-  CASE 'batch'     -%]<span>batches</span>
23 [%-  END -%]
24 [% END %]
25
26     [% INCLUDE 'doc-head-open.inc' %]
27     <title>[% PROCESS translate_card_element element=card_element_title %] &rsaquo; Patron card creator &rsaquo; Tools &rsaquo; Koha</title>
28     [% INCLUDE 'doc-head-close.inc' %]
29 </head>
30
31 <body id="pcard_manage" class="tools pcard">
32     [% WRAPPER 'header.inc' %]
33     [% INCLUDE 'cat-search.inc' %]
34 [% END %]
35
36     [% WRAPPER 'sub-header.inc' %]
37         [% WRAPPER breadcrumbs %]
38             [% WRAPPER breadcrumb_item %]
39                 <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
40             [% END %]
41             [% WRAPPER breadcrumb_item %]
42                 <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a>
43             [% END %]
44             [% WRAPPER breadcrumb_item bc_active= 1 %]
45                 [% PROCESS translate_card_element element=card_element_title %]
46             [% END %]
47         [% END #/ WRAPPER breadcrumbs %]
48     [% END #/ WRAPPER sub-header.inc %]
49
50     <div class="main container-fluid">
51         <div class="row">
52             <div class="col-sm-10 col-sm-push-2">
53                 <main>
54
55                     [% INCLUDE 'patroncards-toolbar.inc' %]
56
57                     <h1>Patron card templates</h1>
58
59                     [% INCLUDE 'patroncards-errors.inc' %]
60                         <div id="manage-patroncards-layouts">
61                             [% IF ( table_loop ) %]
62                             <form name="layouts" action="/cgi-bin/koha/manage.pl?card_element=[% card_element | html %]">
63                             <div class="page-section">
64                                 <h2>Currently available [% PROCESS translate_card_element element=card_element_title FILTER lower %]</h2>
65                                 <table>
66                                     [% FOREACH table_loo IN table_loop %]
67                                         [% IF ( table_loo.header_fields ) %]
68                                             <tr>
69                                                 [% FOREACH header_field IN table_loo.header_fields %]
70                                                     [% SWITCH header_field.field_label -%]
71                                                         [%-  CASE 'Layout ID'     -%]<th>Layout ID</th>
72                                                         [%-  CASE 'Layout'        -%]<th>Layout</th>
73                                                         [%-  CASE 'Action'        -%]<th>Action</th>
74                                                         [%-  CASE 'Actions'       -%]<th class="noExport">Actions</th>
75                                                         [%-  CASE 'Select'        -%][% IF ( print ) %]<th>Select</th>[% END %]
76                                                         [%-  CASE 'Template ID'   -%]<th>Template ID</th>
77                                                         [%-  CASE 'Template Name' -%]<th>Template name</th>
78                                                         [%-  CASE 'Description'   -%]<th>Description</th>
79                                                         [%-  CASE 'Profile ID'    -%]<th>Profile ID</th>
80                                                         [%-  CASE 'Printer Name'  -%]<th>Printer name</th>
81                                                         [%-  CASE 'Paper Bin'     -%]<th>Paper bin</th>
82                                                         [%-  CASE 'Batch ID'      -%]<th>Batch ID</th>
83                                                         [%-  CASE 'Patron Count'  -%]<th>Patron count</th>
84                                                         [%-  CASE                 -%]<th>[% header_field.field_label | html %]</th>
85                                                     [% END -%]
86                                                 [% END %]
87                                             </tr>
88                                         [% ELSE %]
89                                             <tr>
90                                                 [% FOREACH text_field IN table_loo.text_fields %]
91                                                     [% IF ( text_field.select_field ) %]
92                                                         <td>
93                                                         <a class="btn btn-default btn-xs" href="/cgi-bin/koha/patroncards/edit-[% card_element | html %].pl?op=edit&element_id=[% text_field.field_value | html %]"><i class="fa fa-edit"></i> Edit</a>
94                                                         [% IF ( print ) %]<a class="btn btn-default btn-xs export" data-batch-id="[% text_field.field_value |url %]" href="/cgi-bin/koha/patroncards/print.pl?batch_id=[% text_field.field_value |url %]"><i class="fa fa-share-square-o"></i> Export</a>[% END %]
95                                                         <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element | html %]&element_id=[% text_field.field_value | html %]"><i class="fa fa-trash"></i> Delete</a>
96                                                         </td>
97                                                         [% IF ( print ) %]<td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>[% END %]
98                                                     [% ELSIF ( text_field.field_value ) %]
99                                                         <td>[% text_field.field_value | html %]</td>
100                                                     [% ELSE %]
101                                                         <td>&nbsp;</td>
102                                                     [% END %]
103                                                 [% END %]
104                                             </tr>
105                                         [% END %]
106                                     [% END %]
107                                 </table>
108                                 <fieldset class="action">
109                                     [% IF ( print ) %]<input type="button" id="print" value="Export selected batches" />[% END %]
110                                 </fieldset>
111                             </div> <!-- /.page-section -->
112                             [% IF patron_lists %]
113                             <fieldset class="rows">
114                                 <legend>Or use a patron list</legend>
115                                 <ol>
116                                     <li>
117                                         <label for="patron_list_id">Patron list: </label>
118                                         <select id="patron_list_id" name="patron_list_id">
119                                             <option value=""></option>
120                                             [% FOREACH pl IN patron_lists %]
121                                                 <option value="[% pl.patron_list_id | html %]">[% pl.name | html %]</option>
122                                             [% END %]
123                                         </select>
124                                     </li>
125                                 </ol>
126                             </fieldset>
127                             <fieldset class="action">
128                                 <input type="button" id="printlist" value="Export from patron list" />
129                             </fieldset>
130                             [% END %]
131                             </form>
132
133                             [% ELSE %]
134                         <div class="dialog message">
135                             <h4>There are no [% PROCESS translate_card_element element=card_element_title %] currently available.</h4>
136                             <p>Use the toolbar above to create a new [% PROCESS translate_card_element element=card_element %].</p></div>
137                             [% END %]
138                         </div>
139
140             </main>
141         </div> <!-- /.col-sm-10.col-sm-push-2 -->
142
143         <div class="col-sm-2 col-sm-pull-10">
144             <aside>
145                 [% INCLUDE 'tools-menu.inc' %]
146             </aside>
147         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
148      </div> <!-- /.row -->
149
150 [% MACRO jsinclude BLOCK %]
151     [% INCLUDE 'greybox.inc' %]
152     <script>
153         function DeleteConfirm() {
154             var element_ids = selected_layouts("delete");
155
156             var msg;
157             if (element_ids.length > 1) {
158                 msg = _("Are you sure you want to delete %s %s?").format(element_ids.length, "[% PROCESS translate_card_elements element=card_element %]");
159             } else if (element_ids.length == 1) {
160                 msg = _("Are you sure you want to delete %s %s?").format("[% PROCESS translate_card_element element=card_element %]", element_ids[0]);
161             }
162
163             if (msg && confirm(msg)) {
164                 var elements = "";
165                 for (var i = 0; i < element_ids.length; i++) {
166                     if (element_ids[i] > -1) {
167                         elements += element_ids[i] + ","
168                     }
169                     else {
170                         return;     // no layout selected
171                     }
172                 }
173
174                 window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=[% card_element | html %]&element_id=" + elements;
175             }
176             else {
177                 return; // abort delete
178             }
179
180         };
181
182         function Edit() {
183             var element_id = selected_layouts("edit");
184             if (element_id>-1) {
185                 window.location = "/cgi-bin/koha/patroncards/edit-[% card_element | html %].pl?op=edit&element_id=" + element_id;
186             }
187             else {
188                 return;     // no layout selected
189             };
190         };
191         function Xport() {
192             batches= new Array;
193             if(document.layouts.action.length > 0) {
194                 for (var i=0; i < document.layouts.action.length; i++) {
195                     if (document.layouts.action[i].checked) {
196                         batches.push("batch_id=" +  document.layouts.action[i].value);
197                     }
198                 }
199                 if (batches.length < 1) {
200                     alert(_("Please select at least one batch to export."));
201                     return;     // no batch selected
202                 }
203                 getstr = batches.join("&");
204             }
205             else if (document.layouts.action.checked) {
206                 getstr = "batch_id="+document.layouts.action.value;
207             }
208             else {
209                 alert(_("Please select at least one batch to export."));
210                 return;     // no batch selected
211             }
212             return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?" + getstr, 400, 800);
213         };
214
215         function XportPatronlist() {
216             if ( patron_list_id.value.length < 1 ) {
217                 alert(_("Please select a patron list."));
218                 return;     // no patron list selected
219             }
220             getstr = 'patronlist_id='+patron_list_id.value;
221             return GB_showCenter(_("Export patron cards from list"), "/cgi-bin/koha/patroncards/print.pl?" + getstr, 700, 800);
222         };
223
224         function selected_layout(op) {
225             if (document.layouts.action.length) {
226                 var selected = new Array();
227                 for (i=0;i<document.layouts.action.length;i++){
228                     if (document.layouts.action[i].checked){
229                         selected.push(i);
230                     }
231                 };
232                 if (selected.length == 1 || (op == "delete" && selected.length >= 1)) {
233                     if (op == "delete") {
234                         var selectedDelete = new Array;
235                         for (i = 0; i < selected.length; i++) {
236                             selectedDelete.push(document.layouts.action[selected[i]].value);
237                         }
238                         return(selectedDelete);
239                     } else {
240                         // op == 'edit' returns only the object and not list
241                         return(document.layouts.action[selected[0]].value);
242                     }
243                 }
244                 else if (selected.length < 1) {
245                     if (op == "edit") {
246                         alert(_("Please select one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op));
247                     } else {
248                         alert(_("Please select at least one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op));
249                     }
250                     return (-1);
251                 }
252                 else {
253                     alert(_("Please select only one %s to %s.").format("[% PROCESS translate_card_element element=card_element %]", op));
254                     return (-1);
255                 }
256             }
257             else {
258                 if (document.layouts.action.checked){
259                     return([document.layouts.action.value]);
260                 }
261             };
262             alert(_("Please select a %s.").format("[% PROCESS translate_card_element element=card_element %]"));
263             return (-1);
264         };
265
266         $(document).ready(function() {
267             $("#edit").click(function(){
268                 Edit();
269                 return false;
270             });
271             $("#delete").click(function(){
272                 DeleteConfirm();
273                 return false;
274             });
275             $("#print").click(function(){
276                 Xport();
277                 return false;
278             });
279             $("#printlist").click(function(){
280                 XportPatronlist();
281                 return false;
282             });
283             $(".delete").on("click", function(){
284                 return confirmDelete( _("Are you sure you want to delete this?") );
285             });
286             $(".export").on("click", function(e){
287                 e.preventDefault();
288                 var batch_id = $(this).data("batch-id");
289                 GB_showCenter( _("Export single batch"),'/cgi-bin/koha/patroncards/print.pl?batch_id='+batch_id, 400, 800);
290             });
291         });
292     </script>
293 [% END %]
294
295 [% INCLUDE 'intranet-bottom.inc' %]