Bug 20073: Move Elasticsearch configs to yaml files and improve the default settings.
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / patroncards / edit-batch.tt
1 [% USE Asset %]
2 [% SET footerjs = 1 %]
3     [% INCLUDE 'doc-head-open.inc' %]
4     <title>Koha &rsaquo; Tools &rsaquo; Patron card creator &rsaquo; Batches &rsaquo; [% IF batch_id %]Edit ([% batch_id %])[% ELSE %]New[% END %]</title>
5     [% INCLUDE 'doc-head-close.inc' %]
6     [% Asset.css("css/datatables.css") %]
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 batch_id %]
18             Edit ([% batch_id %])
19         [% ELSE %]
20             New
21         [% END %]
22     </div>
23     <div id="doc3" class="yui-t2">
24         <div id="bd">
25             <div id="yui-main">
26                 <div class="yui-b">
27                     <div class="yui-g">
28                     [% INCLUDE 'patroncards-toolbar.inc' %]
29                         <div class="yui-u first">
30
31                         </div>
32                     </div>
33
34                 [% IF ( duplicate_message ) %]
35                     <div class="dialog message">
36                         <strong>Duplicate patrons removed from batch number [% batch_id %]: [% duplicate_count %]</strong>
37                     </div>
38                 [% END %]
39
40                     [% INCLUDE 'patroncards-errors.inc' %]
41                     <div id="manage-patroncard-batches">
42                         <div class="hint">Current library: [% LoginBranchname %]</div>
43                             <form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
44                                 <div>
45                                     <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
46                                     <ol><li>
47                                     <input type="hidden" name="op" value="add" />
48                                     <input type="hidden" name="batch_id" value="[% batch_id %]" />
49                                     <label for="bor_num_list">Add by borrowernumber(s):
50                                         <br /> <span class="hint">One borrowernumber per line.</span>
51                                     </label>
52                                     <textarea rows="5" id="bor_num_list" name="bor_num_list" tabindex="1" class="focus"></textarea>
53                                     </li></ol>
54                                     </fieldset>
55                                 </div>
56                             </form>
57                             <div id="batch-manage" class="action">
58                                 <a class="btn btn-default btn-sm" id="additems" href="#"><i class="fa fa-plus"></i> Add patron(s)</a>[% IF ( table_loop ) %]
59                                 <a class="btn btn-default btn-sm" id="removeitems" href="#"><i class="fa fa-trash"></i> Remove selected patrons</a>
60                                 <a class="btn btn-default btn-sm" id="deletebatch" href="#"><i class="fa fa-minus-square"></i> Delete batch</a>
61                                 <a class="btn btn-default btn-sm" id="deduplicate" href="#"><i class="fa fa-minus"></i> Remove duplicates</a>
62                                 <a class="btn btn-default btn-sm" id="exportitems" href="#"><i class="fa fa-share-square-o"></i> Export selected card(s)</a>
63                                 <a class="btn btn-default btn-sm" id="exportbatch" href="#"><i class="fa fa-share-square-o"></i> Export card batch</a>[% END %]
64                             </div>
65                             [% IF ( table_loop ) %]
66                             <form name="items" class="checkboxed">
67                                 <h2>Patrons in batch number [% batch_id %]</h2>
68                                 <table id="batcht">
69                                     [% FOREACH table_loo IN table_loop %]
70                                         [% IF ( table_loo.header_fields ) %]
71                                             <thead>
72                                                 <tr>
73                                                     [% FOREACH header_field IN table_loo.header_fields %]
74                                                         [% SWITCH header_field.field_label -%]
75                                                             [% CASE "Summary" -%]
76                                                                 <th>Borrower name</th>
77                                                             [% CASE "Borrower Number" %]
78                                                                 <th>Borrower number</th>
79                                                             [% CASE "Actions " %]
80                                                                 <th>Actions</th>
81                                                             [% CASE "Select" -%]
82                                                                 <th>Select</th>
83                                                             [% CASE %]
84                                                                 <th>[% header_field.field_label %]</th>
85                                                         [% END -%]
86                                                     [% END %]
87                                                 </tr>
88                                             </thead>
89                                             <tbody>
90                                         [% ELSE %]
91                                             <tr>
92                                                 [% FOREACH text_field IN table_loo.text_fields %]
93                                                     [% IF ( text_field.select_field ) %]
94                                                         <td>
95                                                             <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&amp;batch_id=[% batch_id %]&amp;label_id=[% text_field.field_value %]"><i class="fa fa-trash"></i> Delete</a>
96                                                             <a class="btn btn-default btn-xs export" href="#" data-batch-id="[% batch_id %]" data-label-id="[% text_field.field_value %]"><i class="fa fa-share-square-o"></i> Export</a>
97                                                         </td>
98                                                         <td><input type="checkbox" name="action" value="[% text_field.field_value %]" /></td>
99                                                     [% ELSE %]
100                                                         <td>[% text_field.field_value %]</td>
101                                                     [% END %]
102                                                 [% END %]
103                                             </tr>
104                                         [% END %]
105                                     [% END %]
106                                     </tbody>
107                                 </table>
108                             </form>
109                             [% ELSE %]
110                                 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
111                                 <ol><li>
112                                     <div class="dialog message">
113                                         <h4>There are no patrons in this batch yet</h4>
114                                         <p>Add patrons by borrowernumber using the text area above or leave empty to add via patron search.</p>
115                                     </div>
116                                 </li></ol>
117                                 </fieldset>
118                             [% END %]
119                         </div>
120                     </div>
121                 </div>
122                 <div class="yui-b">
123                   [% INCLUDE 'tools-menu.inc' %]
124                 </div>
125             </div>
126
127 [% MACRO jsinclude BLOCK %]
128     [% INCLUDE 'greybox.inc' %]
129     [% INCLUDE 'datatables.inc' %]
130     <script>
131         function DeleteConfirm() {
132             var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id %]");
133             var answer = confirm(msg);
134             if (answer) {
135                 window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&amp;card_element=batch&amp;element_id=[% batch_id %]";
136             } else {
137                 return; // abort delete
138             }
139         };
140         function Remove() {
141             items = new Array;
142
143             if(document.items.action.length > 0) {
144                 for (var i=0; i < document.items.action.length; i++) {
145                     if (document.items.action[i].checked) {
146                         items.push("label_id=" +  document.items.action[i].value);
147                     }
148                 }
149                 getstr = items.join("&");
150                 var msg = _("Are you sure you want to remove the selected patron(s) from this batch?");
151             } else if (document.items.action.checked) {
152                 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"));
153                 return; // no deletion for single item batch
154             } else {
155                 alert(_("Please select at least one patron to delete."));
156                 return;     // no item selected
157             }
158             var answer = confirm(msg);
159             if (answer) {
160                 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&amp;batch_id=[% batch_id %]&amp;" + getstr;
161             } else {
162                 return; // abort delete
163             }
164         };
165         function Add() {
166             var bor_nums = document.getElementById("bor_num_list");
167             if (bor_nums.value == '') {
168                 window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
169                'PatronPopup',
170                'width=840,height=500,location=yes,toolbar=no,'
171                + 'scrollbars=yes,resize=yes');
172             } else {
173                 document.forms["add_by_bor_num"].submit();
174             }
175         };
176
177         function add_user(borrowernumber) {
178             $("#bor_num_list").val($("#bor_num_list").val()+borrowernumber+"\r\n");
179         }
180
181         function DeDuplicate() {
182             window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id %]";
183         };
184         function Xport(mode) {
185             if (mode == 'label') {
186                 patroncards= new Array;
187                 if(document.items.action.length > 0) {
188                     for (var i=0; i < document.items.action.length; i++) {
189                         if (document.items.action[i].checked) {
190                             patroncards.push("label_id=" +  document.items.action[i].value);
191                         }
192                     }
193                     if (patroncards.length < 1) {
194                         alert(_("Please select at least one card to export."));
195                         return;     // no batch selected
196                     }
197                     getstr = patroncards.join("&");
198                 } else if (document.items.action.checked) {
199                     getstr = document.items.action.value;
200                 } else {
201                     alert(_("Please select at least one card to export."));
202                     return;     // no batch selected
203                 }
204                 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]&" + getstr, 400, 800);
205             } else if (mode == 'batch') {
206                 return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]", 400, 800);
207             } else {
208                 // some pass-thru error trapping just in case...
209             }
210         };
211         function selected_layout() {
212             if (document.items.action.length) {
213             for (i=0;i<document.items.action.length;i++){
214                 if (document.items.action[i].checked==true){
215                     return(document.items.action[i].value);
216                 }
217             };
218             } else {
219                 if (document.items.action.checked){
220                     return(document.items.action.value);
221                 }
222             };
223             alert(_("Please select at least one item."));
224             return (-1);
225         };
226
227         $(document).ready(function() {
228             $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
229                 "aoColumnDefs": [
230                     { "aTargets": [ -2, -1 ], "bSortable": false, "bSearchable": false }
231                 ],
232                 "aaSorting": [[ 0, "asc" ]],
233                 "sPaginationType": "four_button",
234                 "autoWidth": false
235             }));
236             $("#additems").click(function(){
237                 Add();
238                 return false;
239             });
240             $("#removeitems").click(function(){
241                 Remove();
242                 return false;
243             });
244             $("#deletebatch").click(function(){
245                 DeleteConfirm();
246                 return false;
247             });
248             $("#deduplicate").click(function(){
249                 DeDuplicate();
250                 return false;
251             });
252             $("#exportitems").click(function(){
253                 Xport('label');
254                 return false;
255             });
256             $("#exportbatch").click(function(){
257                 Xport('batch');
258                 return false;
259             });
260             $(".delete").on("click", function(){
261                 return confirmDelete( _("Are you sure you want to delete this patron from the card batch?") );
262             });
263             $(".export").on("click", function(e){
264                 e.preventDefault();
265                 var label_id = $(this).data("label-id");
266                 var batch_id = $(this).data("batch-id");
267                 GB_showCenter( _("Export single card"),'/cgi-bin/koha/patroncards/print.pl?batch_id='+batch_id+'&label_id='+label_id, 400, 800);
268             });
269         });
270     </script>
271 [% END %]
272
273 [% INCLUDE 'intranet-bottom.inc' %]