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