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