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