Bug 14667: UI/UX improvements for the Label creator
[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                 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=740,height=450,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 labels"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]&" + getstr, 700, 800);
92                 }
93                 else if (mode == 'batch') {
94                     return GB_showCenter(_("Export labels"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]", 700, 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": [ -1 ], "bSortable": false, "bSearchable": false }
121                 ],
122                 "aaSorting": [[ 1, "asc" ]],
123                 "sPaginationType": "four_button"
124             }));
125             $("#additems").click(function(){
126                 Add();
127                 return false;
128             });
129             $("#removeitems").click(function(){
130                 Remove();
131                 return false;
132             });
133             $("#deletebatch").click(function(){
134                 DeleteConfirm();
135                 return false;
136             });
137             $("#deduplicate").click(function(){
138                 DeDuplicate();
139                 return false;
140             });
141             $("#exportitems").click(function(){
142                 Xport('label');
143                 return false;
144             });
145             $("#exportbatch").click(function(){
146                 Xport('batch');
147                 return false;
148             });
149          });
150         //]]>
151     </script>
152 </head>
153 <body id="pcard_edit-batch" class="tools pcard">
154     [% INCLUDE 'header.inc' %]
155     [% INCLUDE 'cat-search.inc' %]
156     <div id="breadcrumbs">
157         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
158         <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
159         <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a> &rsaquo;
160         <a href="/cgi-bin/koha/patroncards/manage.pl?card_element=batch">Manage patron card batches</a> &rsaquo;
161         [% IF batch_id %]
162             Manage batch number [% batch_id %]
163         [% ELSE %]
164             Create new batch
165         [% END %]
166     </div>
167     <div id="doc3" class="yui-t2">
168         <div id="bd">
169             <div id="yui-main">
170                 <div class="yui-b">
171
172                 <div id="toolbar" class="btn-toolbar">
173                     <a class="btn btn-small" id="additems" href="#">Add item(s)</a>[% IF ( table_loop ) %]
174                     <a class="btn btn-small" id="removeitems" href="#">Remove item(s)</a>
175                     <a class="btn btn-small" id="deletebatch" href="#">Delete batch</a>
176                     <a class="btn btn-small" id="deduplicate" href="#">Remove duplicates</a>
177                     <a class="btn btn-small" id="exportitems" href="#">Export item(s)</a>
178                     <a class="btn btn-small" id="exportbatch" href="#">Export batch</a>[% END %]
179                 </div>
180
181                 [% IF ( duplicate_message ) %]
182                     <div class="dialog message">
183                         <strong>[% duplicate_count %] duplicate item(s) found</strong> and removed from batch [% batch_id %].
184                     </div>
185                 [% END %]
186
187                     [% INCLUDE 'patroncards-errors.inc' %]
188                     <div id="manage-patroncard-batches">
189                         <div class="hint">Current library: [% LoginBranchname %]</div>
190                             <form name="add_by_bor_num" action="/cgi-bin/koha/patroncards/edit-batch.pl" method="post">
191                                 <div>
192                                     <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
193                                     <ol><li>
194                                     <input type="hidden" name="op" value="add" />
195                                     <input type="hidden" name="batch_id" value="[% batch_id %]" />
196                                     <label for="bor_num_list">Add by borrowernumber(s):
197                                         <br /> <span class="hint">One borrowernumber per line.</span>
198                                     </label>
199                                     <textarea rows="5" id="bor_num_list" name="bor_num_list" tabindex="1" class="focus"></textarea>
200                                     </li></ol>
201                                     </fieldset>
202                                 </div>
203                             </form>
204                             [% IF ( table_loop ) %]
205                             <form name="items" class="checkboxed">
206                                 <h2>Items in batch number [% batch_id %]</h2>
207                                 <table id="batcht">
208                                     [% FOREACH table_loo IN table_loop %]
209                                         [% IF ( table_loo.header_fields ) %]
210                                             <thead>
211                                                 <tr>
212                                                     [% FOREACH header_field IN table_loo.header_fields %]
213                                                         [% SWITCH header_field.field_label -%]
214                                                             [% CASE "Card Number" -%]
215                                                                 <th>Card number</th>
216                                                             [% CASE "Summary" -%]
217                                                                 <th>Summary</th>
218                                                             [% CASE "Borrower Number" %]
219                                                                 <th>Borrower number</th>
220                                                             [% CASE "Select" -%]
221                                                                 <th>Select</th>
222                                                             [% CASE %]
223                                                                 <th>[% header_field.field_label %]</th>
224                                                         [% END -%]
225                                                     [% END %]
226                                                 </tr>
227                                             </thead>
228                                             <tbody>
229                                         [% ELSE %]
230                                             <tr>
231                                                 [% FOREACH text_field IN table_loo.text_fields %]
232                                                     [% IF ( text_field.select_field ) %]
233                                                         <td><input type="checkbox" name="action" value="[% text_field.field_value %]" /></td>
234                                                     [% ELSE %]
235                                                         <td>[% text_field.field_value %]</td>
236                                                     [% END %]
237                                                 [% END %]
238                                             </tr>
239                                         [% END %]
240                                     [% END %]
241                                     </tbody>
242                                 </table>
243                             </form>
244                             [% ELSE %]
245                                 <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
246                                 <ol><li>
247                                     <div class="dialog message">
248                                         <h4>There are no items in this batch yet</h4>
249                                         <p>Add items by borrowernumber using the text area above or leave empty to add via patron search.</p>
250                                     </div>
251                                 </li></ol>
252                                 </fieldset>
253                             [% END %]
254                         </div>
255                     </div>
256                 </div>
257                 <div class="yui-b">
258                     [% INCLUDE 'patroncards-menu.inc' %]
259                 </div>
260             </div>
261     [% INCLUDE 'intranet-bottom.inc' %]