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