Bug 7298: add option to export late orders as CSV
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / lateorders.tt
1 [% USE KohaDates %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Acquisitions &rsaquo; Late orders</title>
4 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
5 [% INCLUDE 'doc-head-close.inc' %]
6 [% INCLUDE 'datatables.inc' %]
7 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
8 [% INCLUDE 'calendar.inc' %]
9 <script type="text/javascript">
10 //<![CDATA[
11 [% IF (dateformat == 'metric') %]
12     dt_add_type_uk_date();
13 [% END %]
14
15 var late_orderst;
16 function check_uncheck() {
17     var all_nodes = $(late_orderst.fnGetNodes());
18     if ( $(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
19         var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
20         $(all_nodes).find("input:checkbox[name=ordernumber][data-booksellerid!="+booksellerid+"]").attr('disabled', 'disabled');
21     } else {
22         $("input:checkbox[name=ordernumber]").removeAttr('disabled');
23     }
24 }
25
26 $(document).ready(function() {
27
28     late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
29         "aoColumnDefs": [
30             { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
31         ],
32         "sPaginationType": "four_button",
33         "bAutoWidth": false,
34         "fnDrawCallback": function() {
35             if ( typeof late_orderst != 'undefined' ) {
36                 check_uncheck();
37                 $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
38             };
39         }
40     } ) );
41     $('#CheckAll').click(function(){ $(late_orderst.fnGetNodes()).find("td").checkCheckboxes();});
42     $('#CheckNone').click(function(){ $(late_orderst.fnGetNodes()).find("td").unCheckCheckboxes();});
43
44     // Generates a dynamic link for exporting the selection's data as CSV
45     $("#ExportSelected").click(function() {
46         var all_nodes = $(late_orderst.fnGetNodes());
47         var selected = $(all_nodes).find("input[name='ordernumber']:checked");
48
49         if (selected.length == 0) {
50             alert(_("Please select at least one item to export."));
51             return false;
52         }
53
54         // Building the url from currently checked boxes
55         var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
56         for (var i = 0; i < selected.length; i++) {
57             url += '&amp;ordernumber=' + selected[i].value;
58         }
59         // And redirecting to the CSV page
60         location.href = url;
61         return false;
62     });
63 });
64 //]]>
65 </script>
66 </head>
67 <body id="acq_lateorders" class="acq">
68 [% INCLUDE 'header.inc' %]
69 [% INCLUDE 'acquisitions-search.inc' %]
70
71 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="lateorders.pl">Late orders</a></div>
72
73 <div id="doc3" class="yui-t2">
74    
75    <div id="bd">
76         <div id="yui-main">
77         <div class="yui-b">
78         
79 <h1>[% IF ( Supplier ) %][% Supplier %] : [% END %]Late orders</h1>
80 <div id="acqui_lateorders">
81
82 [% IF error_claim %]
83     [% IF ( error_claim == "no_email" ) %]
84         <div class="error">This vendor has no email</div>
85     [% ELSE %]
86         <div class="error">[% error_claim %]</div>
87     [% END %]
88 [% END %]
89 [% IF info_claim %]
90     <div class="dialog message">Email has been sent.</div>
91 [% END %]
92 [% IF ( lateorders ) %]
93 <form action="lateorders.pl" name="claim" method="post">
94   <input type="hidden" name="op" value="send_alert" />
95   <input type="hidden" name="delay" value="[% delay %]" />
96   <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
97         [% IF ( letters ) %]
98         <p><label for="letter_code">Claim using notice: </label><select name="letter_code" id="letter_code">
99           [% FOREACH letter IN letters %]
100                 <option value="[% letter.code %]">[% letter.name %]</option>
101           [% END %]
102           </select>
103         </p>
104         [% END %]
105     <table id="late_orders">
106       <thead>
107         <tr>
108             [% IF Supplier %]
109                 <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
110             [% ELSE %]
111                 <th></th>
112             [% END %]
113             <th>Order date</th>
114             <th>Estimated delivery date</th>
115             <th>Vendor</th>
116             <th>Information</th>
117             <th>Total cost</th>
118             <th>Basket</th>
119             <th>Claims count</th>
120             <th>Claimed date</th>
121         </tr>
122       </thead>
123       <tbody>
124       [% FOREACH lateorder IN lateorders %]
125         [% UNLESS ( loop.odd ) %]<tr class="highlight">
126         [% ELSE %]<tr>[% END %]
127             <td>
128                 <input type="checkbox" value="[% lateorder.ordernumber %]" data-booksellerid="[% lateorder.supplierid %]" name="ordernumber">
129             </td>
130             <td>
131                 ([% lateorder.supplierid %])
132                 [% lateorder.orderdate %]
133                 ([% lateorder.latesince %] days)
134             </td>
135             <td>
136                 [% IF ( lateorder.estimateddeliverydate ) %]
137                     [% lateorder.estimateddeliverydate | $KohaDates  %]
138                 [% END %]
139             </td>
140             <td>
141                 [% lateorder.supplier %]
142             </td>
143             <td>
144                 <b>[% lateorder.title |html %]</b>
145                    [% IF ( lateorder.author ) %]<br/><i>Author:</i> [% lateorder.author %][% END %]
146                    [% IF ( lateorder.publisher ) %]
147                         <br/><i>Published by:</i> [% lateorder.publisher %]
148                         [% IF ( lateorder.publicationyear ) %]
149                             <i> in </i>[% lateorder.publicationyear %]
150                         [% END %]
151                    [% END %]
152             </td>
153             <td>
154                    [% lateorder.unitpricesupplier %]x[% lateorder.quantity %] = 
155                    [% lateorder.subtotal %]
156                     <p title="budget">[% lateorder.budget %]</p>
157             </td>
158             <td>
159                  <p><a href="basket.pl?basketno=[% lateorder.basketno %]" title="basket">
160                         [% lateorder.basketno %]
161                         </a>
162                  </p>
163                  <p title="branch">[% lateorder.branch %]</p>
164             </td>
165             <td>[% lateorder.claims_count %]</td>
166             <td>[% lateorder.claimed_date %]</td>
167         </tr>
168       [% END %]
169       </tbody>
170       <tfoot>
171         <tr>
172             <th colspan="5">Total</th>
173             <th>[% total %]</th>
174             <th colspan="3">&nbsp;</th>
175         </tr>
176       </tfoot>
177     </table>
178     <div class="spacer"></div>
179
180     <p style="display:block;">
181         <input type="button" value="Export as CSV" id="ExportSelected" />
182         [% UNLESS lateorder.budget_lock %]
183             <input type="submit"  value="Claim Order" />
184         [% END %]
185     </p>
186 </form>
187 [% ELSE %]<p>There are no late orders.</p>
188 [% END %]
189 </div>
190 </div>
191 </div>
192 <div class="yui-b">
193 <form action="lateorders.pl" method="get">
194 <fieldset class="brief">
195 <h4>Filter Results:</h4>
196 [% FOREACH ERROR_LOO IN ERROR_LOOP %]
197 [% IF ( ERROR_LOO.delay_digits ) %]<p class="error">The number of days ([% ERROR_LOO.bad_delay %]) must be a number between 0 and 999.</p>[% END %]
198 [% END %]
199 <ol>
200     <li><label for="delay">Order date:</label><input size="3" maxlength="3" id="delay" type="text" name="delay" value="[% delay %]" /> days ago</li>
201     <li><label for="from">Estimated delivery date from: </label>
202         <input type="text" size="10" id="from" name="estimateddeliverydatefrom" value="[% estimateddeliverydatefrom %]" class="datepickerfrom" />
203         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
204     </li>
205     <li><label for="to">To: </label>
206         <input type="text" size="10" id="to" name="estimateddeliverydateto" value="[% estimateddeliverydateto %]" class="datepickerto" />
207         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
208     </li>
209
210         <li><label for="booksellerid">Vendor:</label>
211                 <select id="booksellerid" size="1" tabindex="" name="booksellerid">
212                         <option value=""/>
213                         [% FOREACH SUPPLIER_LOO IN SUPPLIER_LOOP %]
214                 [% IF ( SUPPLIER_LOO.selected ) %]<option value="[% SUPPLIER_LOO.id %]" selected="selected">[% SUPPLIER_LOO.name %]</option>
215                 [% ELSE %]<option value="[% SUPPLIER_LOO.id %]">[% SUPPLIER_LOO.name %]</option>[% END %]
216                 [% END %]
217                 </select>
218 </ol>
219         <fieldset class="action"><input type="submit" value="filter" /></fieldset>
220 </fieldset>
221     </form>
222 [% INCLUDE 'acquisitions-menu.inc' %]
223 </div>
224 </div>
225 [% INCLUDE 'intranet-bottom.inc' %]