Bug 12138 - Use placeholders in translatable Javascript strings
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / patroncards / edit-batch.tt
1     [% INCLUDE 'doc-head-open.inc' %]
2     <title>Koha &rsaquo; Tools &rsaquo; Patron card creator &rsaquo; Manage patron card batches</title>
3     [% INCLUDE 'doc-head-close.inc' %]
4     [% INCLUDE 'greybox.inc' %]
5     <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
6     [% INCLUDE 'datatables.inc' %]
7     <script type="text/javascript">
8         //<![CDATA[
9            function DeleteConfirm() {
10                 var msg = _("Are you sure you want to delete batch %s?").format("[% batch_id %]");
11                 var answer = confirm(msg);
12                 if (answer) {
13                     window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&amp;card_element=batch&amp;element_id=[% batch_id %]";
14                 }
15                 else {
16                     return; // abort delete
17                 }
18             };
19             function Remove() {
20                 items = new Array;
21                 item_num = new Array;
22                 if(document.items.action.length > 0) {
23                     for (var i=0; i < document.items.action.length; i++) {
24                         if (document.items.action[i].checked) {
25                             items.push("label_id=" +  document.items.action[i].value);
26                             item_num.push(i+1);
27                         }
28                     }
29                     if (items.length < 1) {
30                         alert(_("Please select at least one item to delete."));
31                         return;     // no item selected
32                     }
33                     getstr = items.join("&");
34                     item_msg = item_num.join(", ");
35                     var msg = _("Are you sure you want to remove card number(s): %s from this batch?").format(item_msg);
36                 }
37                 else {
38                     alert(_("Please select at least label to delete."));
39                     return;     // no item selected
40                 }
41                 var answer = confirm(msg);
42                 if (answer) {
43                     window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&amp;batch_id=[% batch_id %]&amp;" + getstr;
44                 }
45                 else {
46                     return; // abort delete
47                 }
48             };
49             function Add() {
50                 window.open("/cgi-bin/koha/patroncards/members-search.pl?batch_id=[% batch_id %]",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
51             };
52             function DeDuplicate() {
53                 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id %]";
54             };
55             function Xport(mode) {
56                 if (mode == 'label') {
57                     patroncards= new Array;
58                     if(document.items.action.length > 0) {
59                         for (var i=0; i < document.items.action.length; i++) {
60                             if (document.items.action[i].checked) {
61                                 patroncards.push("label_id=" +  document.items.action[i].value);
62                             }
63                         }
64                         if (patroncards.length < 1) {
65                             alert(_("Please select at least one card to export."));
66                             return;     // no batch selected
67                         }
68                         getstr = patroncards.join("&");
69                     }
70                     else if (document.items.action.checked) {
71                         getstr = document.items.action.value;
72                     }
73                     else {
74                         alert(_("Please select at least one card to export."));
75                         return;     // no batch selected
76                     }
77                     return GB_showCenter(_("Export labels"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]&" + getstr, 700, 800);
78                 }
79                 else if (mode == 'batch') {
80                     return GB_showCenter(_("Export labels"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]", 700, 800);
81                 }
82                 else {
83                     // some pass-thru error trapping just in case...
84                 }
85             };
86            function selected_layout() {
87                 if (document.items.action.length) {
88                 for (i=0;i<document.items.action.length;i++){
89                     if (document.items.action[i].checked==true){
90                         return(document.items.action[i].value);
91                     }
92                 };
93                 }
94                 else {
95                     if (document.items.action.checked){
96                         return(document.items.action.value);
97                     }
98                 };
99                 alert(_("Please select at least one item."));
100                 return (-1);
101             };
102
103          $(document).ready(function() {
104             $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
105                 "aoColumnDefs": [
106                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }
107                 ],
108                 "aaSorting": [[ 1, "asc" ]],
109                 "sPaginationType": "four_button"
110             }));
111             $("#additems").click(function(){
112                 Add();
113                 return false;
114             });
115             $("#removeitems").click(function(){
116                 Remove();
117                 return false;
118             });
119             $("#deletebatch").click(function(){
120                 DeleteConfirm();
121                 return false;
122             });
123             $("#deduplicate").click(function(){
124                 DeDuplicate();
125                 return false;
126             });
127             $("#exportitems").click(function(){
128                 Xport('label');
129                 return false;
130             });
131             $("#exportbatch").click(function(){
132                 Xport('batch');
133                 return false;
134             });
135          });
136         //]]>
137     </script>
138 </head>
139 <body id="pcard_edit-batch" class="tools pcard">
140     [% INCLUDE 'header.inc' %]
141     [% INCLUDE 'cat-search.inc' %]
142     <div id="breadcrumbs">
143         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
144         <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
145         <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a> &rsaquo;
146         <a href="/cgi-bin/koha/patroncards/manage.pl?card_element=batch">Manage patron card batches</a> &rsaquo;
147         Manage batch number [% batch_id %]
148     </div>
149     <div id="doc3" class="yui-t2">
150         <div id="bd">
151             <div id="yui-main">
152                 <div class="yui-b">
153
154                 <div id="toolbar" class="btn-toolbar">
155                     <a class="btn btn-small" id="additems" href="#">Add item(s)</a>[% IF ( table_loop ) %]
156                     <a class="btn btn-small" id="removeitems" href="#">Remove item(s)</a>
157                     <a class="btn btn-small" id="deletebatch" href="#">Delete batch</a>
158                     <a class="btn btn-small" id="deduplicate" href="#">Remove duplicates</a>
159                     <a class="btn btn-small" id="exportitems" href="#">Export item(s)</a>
160                     <a class="btn btn-small" id="exportbatch" href="#">Export batch</a>[% END %]
161                 </div>
162
163                 [% IF ( duplicate_message ) %]
164                     <div class="dialog message">
165                         <strong>[% duplicate_count %] duplicate item(s) found</strong> and removed from batch [% batch_id %].
166                     </div>
167                 [% END %]
168
169                     [% INCLUDE 'patroncards-errors.inc' %]
170                     <div id="manage-patroncard-batches">
171                         <div class="hint">Current library: [% LoginBranchname %]</div>
172                             [% IF ( table_loop ) %]
173                             <form name="items" class="checkboxed">
174                                 <h2>Items in batch number [% batch_id %]</h2>
175                                 <table id="batcht">
176                                     [% FOREACH table_loo IN table_loop %]
177                                         [% IF ( table_loo.header_fields ) %]
178                                             <thead>
179                                                 <tr>
180                                                     [% FOREACH header_field IN table_loo.header_fields %]
181                                                         [% SWITCH header_field.field_label -%]
182                                                             [% CASE "Card Number" -%]
183                                                                 <th>Card number</th>
184                                                             [% CASE "Summary" -%]
185                                                                 <th>Summary</th>
186                                                             [% CASE "Borrower Number" %]
187                                                                 <th>Borrower number</th>
188                                                             [% CASE "Select" -%]
189                                                                 <th>Select</th>
190                                                             [% CASE %]
191                                                                 <th>[% header_field.field_label %]</th>
192                                                         [% END -%]
193                                                     [% END %]
194                                                 </tr>
195                                             </thead>
196                                             <tbody>
197                                         [% ELSE %]
198                                             <tr>
199                                                 [% FOREACH text_field IN table_loo.text_fields %]
200                                                     [% IF ( text_field.select_field ) %]
201                                                         <td><input type="checkbox" name="action" value="[% text_field.field_value %]" /></td>
202                                                     [% ELSE %]
203                                                         <td>[% text_field.field_value %]</td>
204                                                     [% END %]
205                                                 [% END %]
206                                             </tr>
207                                         [% END %]
208                                     [% END %]
209                                     </tbody>
210                                 </table>
211                             </form>
212                             [% ELSE %]
213                                 <div class="dialog message">
214                                 <h4>There are no items in batch [% batch_id %] yet</h4>
215                                 <p>Use the toolbar above to add items.</p></div>
216                             [% END %]
217                         </div>
218                     </div>
219                 </div>
220                 <div class="yui-b">
221                     [% INCLUDE 'patroncards-menu.inc' %]
222                 </div>
223             </div>
224     [% INCLUDE 'intranet-bottom.inc' %]