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