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