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