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