Bug 26602: Don't export "actions" column
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / patroncards / edit-batch.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4     [% INCLUDE 'doc-head-open.inc' %]
5     <title>Koha &rsaquo; Tools &rsaquo; Patron card creator &rsaquo; Batches &rsaquo; [% IF batch_id %]Edit ([% batch_id | html %])[% ELSE %]New[% END %]</title>
6     [% INCLUDE 'doc-head-close.inc' %]
7 </head>
8
9 <body id="pcard_edit-batch" class="tools pcard">
10     [% INCLUDE 'header.inc' %]
11     [% INCLUDE 'cat-search.inc' %]
12     <div id="breadcrumbs">
13         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
14         <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
15         <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a> &rsaquo;
16         <a href="/cgi-bin/koha/patroncards/manage.pl?card_element=batch">Batches</a> &rsaquo;
17         [% IF description %]
18             Edit <a href="/cgi-bin/koha/patroncards/edit-batch.pl?op=edit&element_id=[% batch_id | uri %]">[% description | html %]</a>
19         [% ELSIF batch_id %]
20             Edit <a href="/cgi-bin/koha/patroncards/edit-batch.pl?op=edit&element_id=[% batch_id | uri %]">([% batch_id | html %])</a>
21         [% ELSE %]
22             New
23         [% END %]
24     </div>
25
26     <div class="main container-fluid">
27         <div class="row">
28             <div class="col-sm-10 col-sm-push-2">
29                 <main>
30
31                     [% INCLUDE 'patroncards-toolbar.inc' %]
32
33                 [% IF ( duplicate_message ) %]
34                     <div class="dialog message">
35                         <strong>Duplicate patrons removed from batch number [% batch_id | html %]: [% duplicate_count | html %]</strong>
36                     </div>
37                 [% END %]
38
39                     [% INCLUDE 'patroncards-errors.inc' %]
40                     <div id="manage-patroncard-batches">
41                             <form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
42                                 <div>
43                                     <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
44                                     <ol><li id="description">
45                                         <input type="hidden" name="op" value="add" />
46                                         <input type="hidden" name="batch_id" value="[% batch_id | html %]" />
47                                         <label for="description">Batch description: </label>
48                                         <input type="text" name="description" value="[% description | html %]"> <span id="change-status"></span>
49                                     </li><li>
50                                         <label for="bor_num_list">Add by borrowernumber(s):
51                                             <br /> <span class="hint">One borrowernumber per line.</span>
52                                         </label>
53                                         <textarea rows="5" id="bor_num_list" name="bor_num_list" tabindex="1" class="focus"></textarea>
54                                     </li></ol>
55                                     </fieldset>
56                                 </div>
57                             </form>
58                             <div id="batch-manage" class="action">
59                                 <a class="btn btn-default" id="additems" href="#"><i class="fa fa-plus"></i> Add patron(s)</a>[% IF ( table_loop ) %]
60                                 <a class="btn btn-default" id="savedesc" href="#" data-batch_id="[% batch_id | html %]"><i class="fa fa-save"></i> Save description</a>
61                                 <a class="btn btn-default" id="removeitems" href="#"><i class="fa fa-trash"></i> Remove selected patrons</a>
62                                 <a class="btn btn-default" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
63                                 <a class="btn btn-default" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
64                                 <a class="btn btn-default" id="exportitems" href="#"><i class="fa fa-share-square-o"></i> Export selected card(s)</a>
65                                 <a class="btn btn-default" id="exportbatch" href="#"><i class="fa fa-share-square-o"></i> Export card batch</a>[% END %]
66                             </div>
67                             [% IF ( table_loop ) %]
68                             <form name="items">
69                                 <h2>Patrons in batch number [% batch_id | html %]</h2>
70                                 <table id="batcht">
71                                     [% FOREACH table_loo IN table_loop %]
72                                         [% IF ( table_loo.header_fields ) %]
73                                             <thead>
74                                                 <tr>
75                                                     [% FOREACH header_field IN table_loo.header_fields %]
76                                                         [% SWITCH header_field.field_label -%]
77                                                             [% CASE "Summary" -%]
78                                                                 <th>Borrower name</th>
79                                                             [% CASE "Borrower Number" %]
80                                                                 <th>Borrower number</th>
81                                                             [% CASE "Actions " %]
82                                                                 <th class="noExport">Actions</th>
83                                                             [% CASE "Select" -%]
84                                                                 <th>Select</th>
85                                                             [% CASE %]
86                                                                 <th>[% header_field.field_label | html %]</th>
87                                                         [% END -%]
88                                                     [% END %]
89                                                 </tr>
90                                             </thead>
91                                             <tbody>
92                                         [% ELSE %]
93                                             <tr>
94                                                 [% FOREACH text_field IN table_loo.text_fields %]
95                                                     [% IF ( text_field.select_field ) %]
96                                                         <td>
97                                                             <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&amp;batch_id=[% batch_id | html %]&amp;label_id=[% text_field.field_value | html %]"><i class="fa fa-trash"></i> Delete</a>
98                                                             <a class="btn btn-default btn-xs export" href="#" data-batch-id="[% batch_id | html %]" data-label-id="[% text_field.field_value | html %]"><i class="fa fa-share-square-o"></i> Export</a>
99                                                         </td>
100                                                         <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>
101                                                     [% ELSE %]
102                                                         <td>[% text_field.field_value | html %]</td>
103                                                     [% END %]
104                                                 [% END %]
105                                             </tr>
106                                         [% END %]
107                                     [% END %]
108                                     </tbody>
109                                 </table>
110                             </form>
111                             [% ELSE %]
112                                 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
113                                 <ol><li>
114                                     <div class="dialog message">
115                                         <h4>There are no patrons in this batch yet</h4>
116                                         <p>Add patrons by borrowernumber using the text area above or leave empty to add via patron search.</p>
117                                     </div>
118                                 </li></ol>
119                                 </fieldset>
120                             [% END %]
121                         </div>
122
123             </main>
124         </div> <!-- /.col-sm-10.col-sm-push-2 -->
125
126         <div class="col-sm-2 col-sm-pull-10">
127             <aside>
128                 [% INCLUDE 'tools-menu.inc' %]
129             </aside>
130         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
131      </div> <!-- /.row -->
132 [% MACRO jsinclude BLOCK %]
133     [% INCLUDE 'greybox.inc' %]
134     [% INCLUDE 'datatables.inc' %]
135     <script>
136         function DeleteConfirm() {
137             var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id | html %]");
138             var answer = confirm(msg);
139             if (answer) {
140                 window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&amp;card_element=batch&amp;element_id=[% batch_id | html %]";
141             } else {
142                 return; // abort delete
143             }
144         };
145         function Remove() {
146             items = new Array;
147
148             if(document.items.action.length > 0) {
149                 for (var i=0; i < document.items.action.length; i++) {
150                     if (document.items.action[i].checked) {
151                         items.push("label_id=" +  document.items.action[i].value);
152                     }
153                 }
154                 getstr = items.join("&");
155                 var msg = _("Are you sure you want to remove the selected patron(s) from this batch?");
156             } else if (document.items.action.checked) {
157                 alert(_("Deletion of patron from a batch with only one patron will delete the batch.") + "\n\n" + _("If this is what you want, select the 'Delete batch' option from the toolbar"));
158                 return; // no deletion for single item batch
159             } else {
160                 alert(_("Please select at least one patron to delete."));
161                 return;     // no item selected
162             }
163             var answer = confirm(msg);
164             if (answer) {
165                 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&amp;batch_id=[% batch_id | html %]&amp;" + getstr;
166             } else {
167                 return; // abort delete
168             }
169         };
170         function Add() {
171             var bor_nums = document.getElementById("bor_num_list");
172             if (bor_nums.value == '') {
173                 window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
174                'PatronPopup',
175                'width=840,height=500,location=yes,toolbar=no,'
176                + 'scrollbars=yes,resize=yes');
177             } else {
178                 document.forms["add_by_bor_num"].submit();
179             }
180         };
181
182         function add_user(borrowernumber) {
183             $("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n");
184         }
185
186         function DeDuplicate() {
187             window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id | html %]";
188         };
189         function Xport(mode) {
190             if (mode == 'label') {
191                 patroncards= new Array;
192                 if(document.items.action.length > 0) {
193                     for (var i=0; i < document.items.action.length; i++) {
194                         if (document.items.action[i].checked) {
195                             patroncards.push("label_id=" +  document.items.action[i].value);
196                         }
197                     }
198                     if (patroncards.length < 1) {
199                         alert(_("Please select at least one card to export."));
200                         return;     // no batch selected
201                     }
202                     getstr = patroncards.join("&");
203                 } else if (document.items.action.checked) {
204                     getstr = document.items.action.value;
205                 } else {
206                     alert(_("Please select at least one card to export."));
207                     return;     // no batch selected
208                 }
209                 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]&" + getstr, 400, 800);
210             } else if (mode == 'batch') {
211                 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id | html %]", 400, 800);
212             } else {
213                 // some pass-thru error trapping just in case...
214             }
215         };
216         function selected_layout() {
217             if (document.items.action.length) {
218             for (i=0;i<document.items.action.length;i++){
219                 if (document.items.action[i].checked==true){
220                     return(document.items.action[i].value);
221                 }
222             };
223             } else {
224                 if (document.items.action.checked){
225                     return(document.items.action.value);
226                 }
227             };
228             alert(_("Please select at least one item."));
229             return (-1);
230         };
231
232         $(document).ready(function() {
233             [% IF table_loop %]
234                 $("#description").show();
235             [% ELSE %]
236                 $("#description").hide();
237             [% END %]
238             $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
239                 "aoColumnDefs": [
240                     { "aTargets": [ -2, -1 ], "bSortable": false, "bSearchable": false }
241                 ],
242                 "aaSorting": [[ 0, "asc" ]],
243                 "sPaginationType": "full",
244                 "autoWidth": false
245             }));
246             $("#additems").click(function(){
247                 Add();
248                 return false;
249             });
250             $("#removeitems").click(function(){
251                 Remove();
252                 return false;
253             });
254             $("#deletebatch").click(function(){
255                 DeleteConfirm();
256                 return false;
257             });
258             $("#deduplicate").click(function(){
259                 DeDuplicate();
260                 return false;
261             });
262             $("#exportitems").click(function(){
263                 Xport('label');
264                 return false;
265             });
266             $("#exportbatch").click(function(){
267                 Xport('batch');
268                 return false;
269             });
270             $(".delete").on("click", function(){
271                 return confirmDelete( _("Are you sure you want to delete this patron from the card batch?") );
272             });
273             $(".export").on("click", function(e){
274                 e.preventDefault();
275                 var label_id = $(this).data("label-id");
276                 var batch_id = $(this).data("batch-id");
277                 GB_showCenter( _("Export single card"),'/cgi-bin/koha/patroncards/print.pl?batch_id=' + batch_id + '&label_id=' + label_id, 400, 800);
278             });
279             $("#savedesc").click(function(event){
280                 var newdescription = $(this).siblings('input[name="description"]').val();
281                 var batch_id = $(this).data('batch_id');
282                 var ajaxData = {
283                     'newdescription': newdescription,
284                     'batch_id': batch_id,
285                     'card_element': "batch",
286                     'creator': "patroncard",
287                 };
288
289                 $.ajax({
290                     url: '/cgi-bin/koha/svc/creator_batches',
291                     type: 'POST',
292                     dataType: 'json',
293                     data: ajaxData,
294                 })
295
296                 .done(function(data){
297                     if (data.status == 'success') {
298                         $("input[name='description']").text(data.newdesc);
299                         $("#change-status").text(_("Saved"));
300                     } else {
301                         $("#change-status").text(_("Unable to save description"));
302                     }
303                 });
304             });
305             $("#savedesc").click(function(event){
306                 var newdescription = $('input[name="description"]').val();
307                 var batch_id = $(this).data('batch_id');
308                 var ajaxData = {
309                     'newdescription': newdescription,
310                     'batch_id': batch_id,
311                     'card_element': "batch",
312                     'creator': "patroncard",
313                 };
314
315                 $.ajax({
316                     url: '/cgi-bin/koha/svc/creator_batches',
317                     type: 'POST',
318                     dataType: 'json',
319                     data: ajaxData,
320                 })
321
322                 .done(function(data){
323                     if (data.status == 'success') {
324                         $("input[name='description']").text(data.newdesc);
325                         $("#change-status").text(_("Saved"));
326                     } else {
327                         $("#change-status").text(_("Unable to save description"));
328                     }
329                 });
330             });
331         });
332     </script>
333 [% END %]
334
335 [% INCLUDE 'intranet-bottom.inc' %]