Bug 19754: Move template JavaScript to the footer: Acquisitions, part 2
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / lateorders.tt
1 [% USE KohaDates %]
2 [% USE Branches %]
3 [% USE ColumnsSettings %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Acquisitions &rsaquo; Late orders</title>
7 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
8 [% INCLUDE 'doc-head-close.inc' %]
9 </head>
10
11 <body id="acq_lateorders" class="acq">
12 [% INCLUDE 'header.inc' %]
13 [% INCLUDE 'acquisitions-search.inc' %]
14
15 <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>
16
17 <div id="doc3" class="yui-t2">
18    
19    <div id="bd">
20         <div id="yui-main">
21         <div class="yui-b">
22         
23 <h1>[% IF ( Supplier ) %][% Supplier %] : [% END %]Late orders</h1>
24 <div id="acqui_lateorders">
25
26 [% IF error_claim %]
27     [% IF ( error_claim == "no_email" ) %]
28         <div class="error">This vendor has no email</div>
29     [% ELSIF ( error_claim == "no_order_selected" ) %]
30         <div class="error">No order selected</div>
31     [% ELSE %]
32         <div class="error">[% error_claim %]</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 %]" />
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 %]">[% letter.name %]</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 %]" data-booksellerid="[% lateorder.supplierid %]" name="ordernumber">
77             </td>
78             <td>
79                 <span title="[% lateorder.orderdate %]">[% lateorder.orderdate | $KohaDates %] ([% lateorder.latesince %] days)</span>
80             </td>
81             <td>
82                 [% IF ( lateorder.estimateddeliverydate ) %]
83                     <span title="[% lateorder.estimateddeliverydate %]">[% lateorder.estimateddeliverydate | $KohaDates  %]</span>
84                 [% ELSE %]
85                     <span title="0000-00-00"></span>
86                 [% END %]
87             </td>
88             <td>
89                 [% lateorder.supplier %]
90                 ([% lateorder.supplierid %])
91             </td>
92             <td>
93                 <b>[% lateorder.title |html %]</b>
94                    [% IF ( lateorder.author ) %]<br/><i>Author:</i> [% lateorder.author %][% END %]
95                    [% IF ( lateorder.publisher ) %]
96                         <br/><i>Published by:</i> [% lateorder.publisher %]
97                         [% IF ( lateorder.publicationyear ) %]
98                             <i> in </i>[% lateorder.publicationyear %]
99                         [% END %]
100                    [% END %]
101             </td>
102             <td>
103                    [% lateorder.unitpricesupplier %]x[% lateorder.quantity %] = 
104                    [% lateorder.subtotal %]
105             </td>
106             <td>
107                 [% IF ( CAN_user_acquisition_order_manage ) %]
108                     <a href="basket.pl?basketno=[% lateorder.basketno %]" title="basket">[% lateorder.basketname %] ([% lateorder.basketno %])</a>
109                 [% ELSE %]
110                     [% lateorder.basketname %] ([% lateorder.basketno %])
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 %]&basketgroupid=[% lateorder.basketgroupid %]" title="basketgroup">[% lateorder.basketgroupname %] ([% lateorder.basketgroupid %])</a>
117                     [% ELSE %]
118                         [% lateorder.basketgroupname %] ([% lateorder.basketgroupid %])</a>
119                     [% END %]
120                 [% END %]
121             </td>
122             <td>[% Branches.GetName( lateorder.branch ) %]
123             </td>
124             <td>[% lateorder.budget %]
125             </td>
126             <td>[% lateorder.claims_count %]</td>
127             <td>
128                 [% IF ( lateorder.claimed_date ) %]
129                     <span title="[% lateorder.claimed_date %]">[% 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 %]</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>
157 </div>
158 </div>
159 <div class="yui-b">
160 <form action="lateorders.pl" method="get">
161 <fieldset class="brief">
162 <h4>Filter results:</h4>
163 [% FOREACH ERROR_LOO IN ERROR_LOOP %]
164 [% 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 %]
165 [% END %]
166 <ol>
167     <li><label for="delay">Order date:</label><input size="3" maxlength="3" id="delay" type="text" name="delay" value="[% delay | html%]" /> days ago</li>
168     <li><label for="from">Estimated delivery date from: </label>
169         <input type="text" size="10" id="from" name="estimateddeliverydatefrom" value="[% estimateddeliverydatefrom %]" class="datepickerfrom" />
170         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
171     </li>
172     <li><label for="to">To: </label>
173         <input type="text" size="10" id="to" name="estimateddeliverydateto" value="[% estimateddeliverydateto %]" class="datepickerto" />
174         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
175     </li>
176
177         <li><label for="booksellerid">Vendor:</label>
178                 <select id="booksellerid" size="1" tabindex="" name="booksellerid">
179             <option value=""></option>
180                         [% FOREACH SUPPLIER_LOO IN SUPPLIER_LOOP %]
181                 [% IF ( SUPPLIER_LOO.selected ) %]<option value="[% SUPPLIER_LOO.id %]" selected="selected">[% SUPPLIER_LOO.name %]</option>
182                 [% ELSE %]<option value="[% SUPPLIER_LOO.id %]">[% SUPPLIER_LOO.name %]</option>[% END %]
183                 [% END %]
184                 </select>
185 </ol>
186     <fieldset class="action"><input type="submit" value="Filter" /></fieldset>
187 </fieldset>
188     </form>
189 [% INCLUDE 'acquisitions-menu.inc' %]
190 </div>
191 </div>
192
193 [% MACRO jsinclude BLOCK %]
194     <script type="text/javascript" src="[% interface %]/[% theme %]/js/acquisitions-menu_[% KOHA_VERSION %].js"></script>
195     [% INCLUDE 'datatables.inc' %]
196     [% INCLUDE 'columns_settings.inc' %]
197     <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min_[% KOHA_VERSION %].js"></script>
198     [% INCLUDE 'calendar.inc' %]
199     <script type="text/javascript">
200         var late_orderst;
201         function check_uncheck() {
202             var all_nodes = $(late_orderst.fnGetNodes());
203             if ( $(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
204                 var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
205                 $(all_nodes).find("input:checkbox[name=ordernumber][data-booksellerid!="+booksellerid+"]").prop('disabled', true);
206             } else {
207                 $("input:checkbox[name=ordernumber]").prop('disabled', false);
208             }
209         }
210
211         $(document).ready(function() {
212
213             var columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'lateorders', 'late_orders', 'json' ) %];
214             late_orderst = KohaTable("late_orders", {
215                 "aoColumnDefs": [
216                     { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
217                     { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
218                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
219                 ],
220                 "sPaginationType": "four_button",
221                 "bAutoWidth": false,
222                 "fnDrawCallback": function() {
223                     if ( typeof late_orderst != 'undefined' ) {
224                         check_uncheck();
225                         $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
226                     };
227                 }
228             }, columns_settings );
229             $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
230             $('#CheckAll').click(function(){ $(late_orderst.fnGetNodes()).find("td").checkCheckboxes();});
231             $('#CheckNone').click(function(){ $(late_orderst.fnGetNodes()).find("td").unCheckCheckboxes();});
232
233             // Generates a dynamic link for exporting the selection's data as CSV
234             $("#ExportSelected").click(function() {
235                 var all_nodes = $(late_orderst.fnGetNodes());
236                 var selected = $(all_nodes).find("input[name='ordernumber']:checked");
237
238                 if (selected.length == 0) {
239                     alert(_("Please select at least one item to export."));
240                     return false;
241                 }
242
243                 // Building the url from currently checked boxes
244                 var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
245                 for (var i = 0; i < selected.length; i++) {
246                     url += '&amp;ordernumber=' + selected[i].value;
247                 }
248                 // And redirecting to the CSV page
249                 location.href = url;
250                 return false;
251             });
252         });
253     </script>
254 [% END %]
255
256 [% INCLUDE 'intranet-bottom.inc' %]