Merge branch 'bug_7368' into 3.14-master
[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     <script type="text/javascript">
6         //<![CDATA[
7            function DeleteConfirm() {
8                 var msg = _("Are you sure you want to delete batch") + " [% batch_id %]?";
9                 var answer = confirm(msg);
10                 if (answer) {
11                     window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&amp;card_element=batch&amp;element_id=[% batch_id %]";
12                 }
13                 else {
14                     return; // abort delete
15                 }
16             };
17             function Remove() {
18                 items = new Array;
19                 item_num = new Array;
20                 if(document.items.action.length > 0) {
21                     for (var i=0; i < document.items.action.length; i++) {
22                         if (document.items.action[i].checked) {
23                             items.push("label_id=" +  document.items.action[i].value);
24                             item_num.push(i+1);
25                         }
26                     }
27                     if (items.length < 1) {
28                         alert(_("Please select at least one item to delete."));
29                         return;     // no item selected
30                     }
31                     getstr = items.join("&");
32                     item_msg = item_num.join(", ");
33                     var msg = "Are you sure you want to remove card number(s): " + item_msg + " from this batch?"
34                 }
35                 else {
36                     alert(_("Please select at least label to delete."));
37                     return;     // no item selected
38                 }
39                 var answer = confirm(msg);
40                 if (answer) {
41                     window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=remove&amp;batch_id=[% batch_id %]&amp;" + getstr;
42                 }
43                 else {
44                     return; // abort delete
45                 }
46             };
47             function Add() {
48                 window.open("/cgi-bin/koha/patroncards/members-search.pl?batch_id=[% batch_id %]",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
49             };
50             function DeDuplicate() {
51                 window.location = "/cgi-bin/koha/patroncards/edit-batch.pl?op=de_duplicate&amp;batch_id=[% batch_id %]";
52             };
53             function Xport(mode) {
54                 if (mode == 'label') {
55                     patroncards= new Array;
56                     if(document.items.action.length > 0) {
57                         for (var i=0; i < document.items.action.length; i++) {
58                             if (document.items.action[i].checked) {
59                                 patroncards.push("label_id=" +  document.items.action[i].value);
60                             }
61                         }
62                         if (patroncards.length < 1) {
63                             alert(_("Please select at least one card to export."));
64                             return;     // no batch selected
65                         }
66                         getstr = patroncards.join("&");
67                     }
68                     else if (document.items.action.checked) {
69                         getstr = document.items.action.value;
70                     }
71                     else {
72                         alert(_("Please select at least one card to export."));
73                         return;     // no batch selected
74                     }
75                     return GB_showCenter(_("Export labels"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]&" + getstr, 700, 800);
76                 }
77                 else if (mode == 'batch') {
78                     return GB_showCenter(_("Export labels"), "/cgi-bin/koha/patroncards/print.pl?batch_id=[% batch_id %]", 700, 800);
79                 }
80                 else {
81                     // some pass-thru error trapping just in case...
82                 }
83             };
84            function selected_layout() {
85                 if (document.items.action.length) {
86                 for (i=0;i<document.items.action.length;i++){
87                     if (document.items.action[i].checked==true){
88                         return(document.items.action[i].value);
89                     }
90                 };
91                 }
92                 else {
93                     if (document.items.action.checked){
94                         return(document.items.action.value);
95                     }
96                 };
97                 alert(_("Please select at least one item."));
98                 return (-1);
99             };
100
101          $(document).ready(function() {
102             $("#additems").click(function(){
103                 Add();
104                 return false;
105             });
106             $("#removeitems").click(function(){
107                 Remove();
108                 return false;
109             });
110             $("#deletebatch").click(function(){
111                 DeleteConfirm();
112                 return false;
113             });
114             $("#deduplicate").click(function(){
115                 DeDuplicate();
116                 return false;
117             });
118             $("#exportitems").click(function(){
119                 Xport('label');
120                 return false;
121             });
122             $("#exportbatch").click(function(){
123                 Xport('batch');
124                 return false;
125             });
126          });
127         //]]>
128     </script>
129 </head>
130 <body id="pcard_edit-batch" class="tools pcard">
131     [% INCLUDE 'header.inc' %]
132     [% INCLUDE 'cat-search.inc' %]
133     <div id="breadcrumbs">
134         <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
135         <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
136         <a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a> &rsaquo;
137         <a href="/cgi-bin/koha/patroncards/manage.pl?card_element=batch">Manage patron card batches</a> &rsaquo;
138         Manage batch number [% batch_id %]
139     </div>
140     <div id="doc3" class="yui-t2">
141         <div id="bd">
142             <div id="yui-main">
143                 <div class="yui-b">
144
145                 <div id="toolbar" class="btn-toolbar">
146                     <a class="btn btn-small" id="additems" href="#">Add item(s)</a>[% IF ( table_loop ) %]
147                     <a class="btn btn-small" id="removeitems" href="#">Remove item(s)</a>
148                     <a class="btn btn-small" id="deletebatch" href="#">Delete batch</a>
149                     <a class="btn btn-small" id="deduplicate" href="#">Remove duplicates</a>
150                     <a class="btn btn-small" id="exportitems" href="#">Export item(s)</a>
151                     <a class="btn btn-small" id="exportbatch" href="#">Export batch</a>[% END %]
152                 </div>
153
154
155                     [% INCLUDE 'error-messages.inc' %]
156                     <div class="yui-g">
157                         <div class="yui-u first" id="manage-patroncard-batches">
158                             <div class="hint">Current library: [% LoginBranchname %]</div>
159                                 [% IF ( table_loop ) %]
160                                 <form name="items" class="checkboxed">
161                                     <h2>Items in batch number [% batch_id %]</h2>
162                                     <table>
163                                         [% FOREACH table_loo IN table_loop %]
164                                         [% IF ( table_loo.header_fields ) %]
165                                         <tr>
166                                         [% FOREACH header_field IN table_loo.header_fields %]
167                                             <th>[% header_field.field_label %]</th>
168                                         [% END %]
169                                         </tr>
170                                         [% ELSE %]
171                                         <tr>
172                                         [% FOREACH text_field IN table_loo.text_fields %]
173                                         [% IF ( text_field.select_field ) %]
174                                             <td align="center"><input type="checkbox" name="action" value="[% text_field.field_value %]"></td>
175                                         [% ELSE %]
176                                             <td>[% text_field.field_value %]</td>
177                                         [% END %]
178                                         [% END %]
179                                         </tr>
180                                         [% END %]
181                                         [% END %]
182                                     </table>
183                                 </form>
184                                 [% ELSE %]
185                                     <div class="dialog message"><h4>There are no items in batch [% batch_id %] yet</h4>
186                                     <p>Use the toolbar above to add items.</p></div>
187                                 [% END %]
188                             </div>
189                             [% IF ( duplicate_message ) %]
190                             <div class="yui-u">
191                                 <div class="dialog message">
192                                     <strong>[% duplicate_count %] duplicate item(s) found</strong> and removed from batch [% batch_id %].
193                                 </div>
194                             </div>
195                             [% END %]
196                         </div>
197                     </div>
198                 </div>
199                 <div class="yui-b">
200                     [% INCLUDE 'patroncards-menu.inc' %]
201                 </div>
202             </div>
203         </div>
204     [% INCLUDE 'intranet-bottom.inc' %]