Bug 10855: Search subscriptions by additional fields on the claim page
[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
50             function Add() {
51                 window.open("/cgi-bin/koha/patroncards/add_user_search.pl",
52                    'PatronPopup',
53                    'width=740,height=450,location=yes,toolbar=no,'
54                    + 'scrollbars=yes,resize=yes'
55                );
56             }
57
58             function add_user(borrowernumber) {
59                 var myurl = "edit-batch.pl?op=add&batch_id=[% batch_id %]&borrower_number="+borrowernumber;
60                 window.location.href = myurl;
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 labels"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]&" + getstr, 700, 800);
89                 }
90                 else if (mode == 'batch') {
91                     return GB_showCenter(_("Export labels"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]", 700, 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": [ -1 ], "bSortable": false, "bSearchable": false }
118                 ],
119                 "aaSorting": [[ 1, "asc" ]],
120                 "sPaginationType": "four_button"
121             }));
122             $("#additems").click(function(){
123                 Add();
124                 return false;
125             });
126             $("#removeitems").click(function(){
127                 Remove();
128                 return false;
129             });
130             $("#deletebatch").click(function(){
131                 DeleteConfirm();
132                 return false;
133             });
134             $("#deduplicate").click(function(){
135                 DeDuplicate();
136                 return false;
137             });
138             $("#exportitems").click(function(){
139                 Xport('label');
140                 return false;
141             });
142             $("#exportbatch").click(function(){
143                 Xport('batch');
144                 return false;
145             });
146          });
147         //]]>
148     </script>
149 </head>
150 <body id="pcard_edit-batch" class="tools pcard">
151     [% INCLUDE 'header.inc' %]
152     [% INCLUDE 'cat-search.inc' %]
153     <div id="breadcrumbs">
154         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
155         <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
156         <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a> &rsaquo;
157         <a href="/cgi-bin/koha/patroncards/manage.pl?card_element=batch">Manage patron card batches</a> &rsaquo;
158         Manage batch number [% batch_id %]
159     </div>
160     <div id="doc3" class="yui-t2">
161         <div id="bd">
162             <div id="yui-main">
163                 <div class="yui-b">
164
165                 <div id="toolbar" class="btn-toolbar">
166                     <a class="btn btn-small" id="additems" href="#">Add item(s)</a>[% IF ( table_loop ) %]
167                     <a class="btn btn-small" id="removeitems" href="#">Remove item(s)</a>
168                     <a class="btn btn-small" id="deletebatch" href="#">Delete batch</a>
169                     <a class="btn btn-small" id="deduplicate" href="#">Remove duplicates</a>
170                     <a class="btn btn-small" id="exportitems" href="#">Export item(s)</a>
171                     <a class="btn btn-small" id="exportbatch" href="#">Export batch</a>[% END %]
172                 </div>
173
174                 [% IF ( duplicate_message ) %]
175                     <div class="dialog message">
176                         <strong>[% duplicate_count %] duplicate item(s) found</strong> and removed from batch [% batch_id %].
177                     </div>
178                 [% END %]
179
180                     [% INCLUDE 'patroncards-errors.inc' %]
181                     <div id="manage-patroncard-batches">
182                         <div class="hint">Current library: [% LoginBranchname %]</div>
183                             [% IF ( table_loop ) %]
184                             <form name="items" class="checkboxed">
185                                 <h2>Items in batch number [% batch_id %]</h2>
186                                 <table id="batcht">
187                                     [% FOREACH table_loo IN table_loop %]
188                                         [% IF ( table_loo.header_fields ) %]
189                                             <thead>
190                                                 <tr>
191                                                     [% FOREACH header_field IN table_loo.header_fields %]
192                                                         [% SWITCH header_field.field_label -%]
193                                                             [% CASE "Card Number" -%]
194                                                                 <th>Card number</th>
195                                                             [% CASE "Summary" -%]
196                                                                 <th>Summary</th>
197                                                             [% CASE "Borrower Number" %]
198                                                                 <th>Borrower number</th>
199                                                             [% CASE "Select" -%]
200                                                                 <th>Select</th>
201                                                             [% CASE %]
202                                                                 <th>[% header_field.field_label %]</th>
203                                                         [% END -%]
204                                                     [% END %]
205                                                 </tr>
206                                             </thead>
207                                             <tbody>
208                                         [% ELSE %]
209                                             <tr>
210                                                 [% FOREACH text_field IN table_loo.text_fields %]
211                                                     [% IF ( text_field.select_field ) %]
212                                                         <td><input type="checkbox" name="action" value="[% text_field.field_value %]" /></td>
213                                                     [% ELSE %]
214                                                         <td>[% text_field.field_value %]</td>
215                                                     [% END %]
216                                                 [% END %]
217                                             </tr>
218                                         [% END %]
219                                     [% END %]
220                                     </tbody>
221                                 </table>
222                             </form>
223                             [% ELSE %]
224                                 <div class="dialog message">
225                                 <h4>There are no items in batch [% batch_id %] yet</h4>
226                                 <p>Use the toolbar above to add items.</p></div>
227                             [% END %]
228                         </div>
229                     </div>
230                 </div>
231                 <div class="yui-b">
232                     [% INCLUDE 'patroncards-menu.inc' %]
233                 </div>
234             </div>
235     [% INCLUDE 'intranet-bottom.inc' %]