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