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