Bug 27795: Misalignment of TOTAL value in lateorders page
[koha-ffzg.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 TablesSettings %]
6 [% USE Price %]
7 [% SET footerjs = 1 %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Koha &rsaquo; Acquisitions &rsaquo; Late orders</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 </head>
12
13 <body id="acq_lateorders" class="acq">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'acquisitions-search.inc' %]
16
17 <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>
18
19 <div class="main container-fluid">
20     <div class="row">
21         <div class="col-sm-10 col-sm-push-2">
22             <main>
23
24 <h1>[% IF bookseller_filter %][% bookseller_filter.name | html %] : [% END %]Late orders</h1>
25 <div id="acqui_lateorders">
26
27 [% IF error_claim %]
28     [% IF ( error_claim == "no_email" ) %]
29         <div class="dialog alert">This vendor has no email</div>
30     [% ELSIF ( error_claim == "no_order_selected" ) %]
31         <div class="dialog alert">No order selected</div>
32     [% ELSE %]
33         <div class="dialog alert">[% error_claim | html %]</div>
34     [% END %]
35 [% END %]
36 [% IF info_claim %]
37     <div class="dialog message">Email has been sent.</div>
38 [% END %]
39 [% IF lateorders.size %]
40 <form action="lateorders.pl" name="claim" method="post">
41   <input type="hidden" name="op" value="send_alert" />
42   <input type="hidden" name="delay" value="[% delay | html %]" />
43   <input type="hidden" name="booksellerid" value="[% bookseller_filter.id | html %]" />
44         [% IF ( letters ) %]
45         <p><label for="letter_code">Claim using notice: </label><select name="letter_code" id="letter_code">
46           [% FOREACH letter IN letters %]
47                 <option value="[% letter.code | html %]">[% letter.name | html %]</option>
48           [% END %]
49           </select>
50         </p>
51         [% END %]
52     [% SET total = 0 %]
53     [% SET total_quantity = 0 %]
54     [% IF bookseller_filter %]
55         <p><a id="CheckAll" href="#"><i class="fa fa-check"></i> Check all</a> <a id="CheckNone" href="#"><i class="fa fa-remove"></i> Uncheck all</a></p>
56     [% END %]
57     <table id="late_orders">
58       <thead>
59         <tr>
60             <th class="NoSort"></th>
61             <th>Order line</th>
62             <th class="title-string">Order date</th>
63             <th class="title-string">Estimated delivery date</th>
64             <th>Vendor</th>
65             <th class="anti-the">Information</th>
66             <th>Quantity</th>
67             <th>Total cost</th>
68             <th>Basket</th>
69             <th>Basket group</th>
70             <th>Library</th>
71             <th>Budget</th>
72             <th>Fund</th>
73             <th>Claims count</th>
74             <th class="title-string">Claimed date</th>
75             <th>Internal note</th>
76             <th>Vendor note</th>
77             <th>ISBN</th>
78         </tr>
79       </thead>
80       <tbody>
81       [% FOREACH lateorder IN lateorders %]
82         <tr>
83             <td>
84                 <input type="checkbox" value="[% lateorder.ordernumber | html %]" data-booksellerid="[% lateorder.basket.booksellerid | html %]" name="ordernumber">
85             </td>
86             <td>
87                 [% lateorder.ordernumber | $raw %]
88             </td>
89             <td>
90                 <span title="[% lateorder.basket.closedate | html %]">[% lateorder.basket.closedate | $KohaDates %] ([% lateorder.basket.late_since_days | html %] days)</span>
91             </td>
92             <td>
93                 [% SET estimated_delivery_date = lateorder.get_column('estimated_delivery_date') %]
94                 [% IF estimated_delivery_date %]
95                     <span title="[% estimated_delivery_date | html %]">[% estimated_delivery_date | $KohaDates  %]</span>
96                 [% END %]
97             </td>
98             <td>
99                 [% lateorder.basket.bookseller.name | html %]
100                 ([% lateorder.basket.bookseller.id | html %])
101             </td>
102             <td>
103                 <span class="title">[% INCLUDE 'biblio-title.inc' biblio=lateorder.biblio link=1 %]</span>
104                    [% IF ( lateorder.biblio.author ) %]<br/><em>Author:</em> [% lateorder.biblio.author | html %][% END %]
105                    [% IF ( lateorder.biblio.biblioitem.publishercode ) %]
106                         <br/><em>Published by:</em> [% lateorder.biblio.biblioitem.publishercode | html %]
107                         [% IF ( lateorder.biblio.biblioitem.publicationyear ) %]
108                             <em> in </em>[% lateorder.biblio.biblioitem.publicationyear | html %]
109                         [% END %]
110                    [% END %]
111             </td>
112             <td>
113                 [% lateorder.quantity | html %]
114                 [% SET total_quantity = total_quantity + lateorder.quantity %]
115             </td>
116             <td>
117                 [% SET subtotal = (lateorder.quantity - lateorder.quantityreceived) * lateorder.rrp %]
118                 [% SET total = total + subtotal %]
119                 [% lateorder.rrp | html %]x[% lateorder.quantity - lateorder.quantityreceived | html %] = [% subtotal | $Price %]
120             </td>
121             <td>
122                 [% IF ( CAN_user_acquisition_order_manage ) %]
123                     <a href="basket.pl?basketno=[% lateorder.basketno | uri %]" title="basket">[% lateorder.basket.basketname | html %] ([% lateorder.basketno | html %])</a>
124                 [% ELSE %]
125                     [% lateorder.basket.basketname | html %] ([% lateorder.basketno | html %])
126                 [% END %]
127             </td>
128             <td>
129                 [% IF ( lateorder.basket.basketgroupid ) %]
130                     [% IF ( CAN_user_acquisition_group_manage ) %]
131                         <a href="basketgroup.pl?op=add&booksellerid=[% lateorder.basket.booksellerid | uri %]&basketgroupid=[% lateorder.basket.basketgroupid | uri %]" title="basketgroup">[% lateorder.basket.basket_group.name | html %] ([% lateorder.basket.basketgroupid | html %])</a>
132                     [% ELSE %]
133                         [% lateorder.basket.basket_group.name | html %] ([% lateorder.basket.basketgroupid | html %])</a>
134                     [% END %]
135                 [% END %]
136             </td>
137             <td>[% Branches.GetName( lateorder.basket.authorizer.branchcode ) | html %]
138             </td>
139             <td>[% lateorder.fund.budget.budget_period_description | html %]</td>
140             <td>[% lateorder.fund.budget_name | html %]</td>
141             <td>[% lateorder.claims.count | html %]</td>
142             <td>
143                 [% FOR claim IN lateorder.claims %]
144                     <span title="[% lateorder.claims.last.claimed_on | html %]">[% claim.claimed_on | $KohaDates %]</span>
145                     [% UNLESS loop.last %]<br/>[% END %]
146                 [% END %]
147             </td>
148             <td>
149                 [% IF lateorder.order_internalnote %]
150                     <p class="ordernote">
151                         <span id="internal-note-[% lateorder.ordernumber | html %]">[% lateorder.order_internalnote | html %]</span>
152                         <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="internal" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=internal" title="Edit internal note">
153                             <i class="fa fa-pencil"></i> Edit internal note
154                         </a>
155                     </p>
156                 [% ELSE %]
157                     <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="internal" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=internal" title="Add internal note">
158                         <i class="fa fa-plus"></i> Add internal note
159                     </a>
160                 [% END %]
161             </td>
162             <td>
163                 [% IF lateorder.order_vendornote %]
164                     <p class="ordernote">
165                         <span id="vendor-note-[% lateorder.ordernumber | html %]">[% lateorder.order_vendornote | html %]</span>
166                         <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="vendor" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=vendor" title="Edit vendor note">
167                             <i class="fa fa-pencil"></i> Edit vendor note
168                         </a>
169                     </p>
170                 [% ELSE %]
171                     <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="vendor" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=vendor" title="Add vendor note">
172                         <i class="fa fa-plus"></i> Add vendor note
173                     </a>
174                 [% END %]
175             </td>
176             <td>[% lateorder.biblio.biblioitem.isbn | $raw %]</td>
177         </tr>
178       [% END %]
179       </tbody>
180       <tfoot>
181         <tr>
182             <th colspan="6">Total</th>
183             <th>[% total_quantity | html %]</th>
184             <th>[% total | $Price %]</th>
185             <th colspan="10">&nbsp;</th>
186         </tr>
187       </tfoot>
188     </table>
189
190     <fieldset class="action">
191         <div class="btn-group">
192           <a id="exportbutton" class="btn btn-default" href="/cgi-bin/koha/acqui/lateorders-export.pl"><i class="fa fa-download"></i> Export as CSV</a>
193           <a class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
194           <ul class="dropdown-menu" id="export-csv-menu">
195               <li><a href="#">Default</a></li>
196               [% IF csv_profiles %]
197                   [% FOR csv IN csv_profiles %]
198                     <li><a href="#" data-value="[% csv.export_format_id | html %]">[% csv.profile | html %]</a></li>
199                   [% END %]
200               [% END %]
201            </ul>
202         </div>
203
204         <input type="submit"  class="btn btn-default" value="Claim order" />
205     </fieldset>
206 </form>
207 [% ELSE %]<p>There are no late orders.</p>
208 [% END %]
209 </div> <!-- /#acqui_lateorders -->
210 </main>
211 </div> <!-- /.col-sm-10.col-sm-push-2 -->
212
213 <div class="col-sm-2 col-sm-pull-10">
214     <aside>
215 <form action="lateorders.pl" method="get">
216 <fieldset class="brief">
217 <h4>Filter results:</h4>
218 [% FOREACH ERROR_LOO IN ERROR_LOOP %]
219 [% 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 %]
220 [% END %]
221 <ol>
222     <li><label for="delay">Order date:</label><input size="3" maxlength="3" id="delay" type="text" name="delay" value="[% delay | html %]" /> days ago</li>
223     <li><label for="from">Estimated delivery date from: </label>
224         <input type="text" size="10" id="from" name="estimateddeliverydatefrom" value="[% estimateddeliverydatefrom | html %]" class="datepickerfrom" />
225         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
226     </li>
227     <li><label for="to">To: </label>
228         <input type="text" size="10" id="to" name="estimateddeliverydateto" value="[% estimateddeliverydateto | html %]" class="datepickerto" />
229         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
230     </li>
231
232     <li><label for="booksellerid">Vendor:</label>
233         <select id="booksellerid" tabindex="" name="booksellerid">
234             <option value=""></option>
235             [% FOREACH bookseller IN booksellers %]
236                 [% IF bookseller.id == bookseller_filter.id %]
237                     <option value="[% bookseller.id | html %]" selected="selected">[% bookseller.name | html %]</option>
238                 [% ELSE %]
239                     <option value="[% bookseller.id | html %]">[% bookseller.name | html %]</option>
240                 [% END %]
241             [% END %]
242         </select>
243 </ol>
244     <fieldset class="action"><input type="submit" value="Filter" /></fieldset>
245 </fieldset>
246     </form>
247 [% INCLUDE 'acquisitions-menu.inc' %]
248 </aside>
249 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
250 </div>
251
252 <!-- Modal for editing vendor and internal notes -->
253 <div class="modal" id="noteEditor" tabindex="-1" role="dialog" aria-labelledby="noteEditorLabel">
254     <div class="modal-dialog" role="document">
255         <form id="modify_order_notes" action="/cgi-bin/koha/acqui/modordernotes.pl" method="post">
256             <div class="modal-content">
257                 <div class="modal-header">
258                     <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
259                     <h4 class="modal-title" id="noteEditorLabel">Order note</h4>
260                 </div>
261                 <div class="modal-body">
262                 <textarea id="ordernotes" name="ordernotes" rows="3" cols="30" class="focus">[% ordernotes | html %]</textarea>
263                 <input type="hidden" id="ordernumber" name="ordernumber" value="" />
264                 <input type="hidden" name="op" value="save" />
265                 <input type="hidden" id="type" name="type" value="" />
266             </div>
267             <div class="modal-footer">
268                 <button type="submit" class="btn btn-default">Save</button>
269                 <button type="button" class="btn btn-link cancel" data-dismiss="modal">Cancel</button>
270             </div>
271             </div>
272         </form>
273     </div>
274 </div>
275
276 [% MACRO jsinclude BLOCK %]
277     [% Asset.js("js/acquisitions-menu.js") | $raw %]
278     [% INCLUDE 'datatables.inc' %]
279     [% INCLUDE 'columns_settings.inc' %]
280     [% INCLUDE 'calendar.inc' %]
281     <script>
282         var late_orderst;
283         function check_uncheck() {
284             var all_nodes = $(late_orderst.fnGetNodes());
285             if ( $(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
286                 var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
287                 $(all_nodes).find("input:checkbox[name=ordernumber][data-booksellerid!="+booksellerid+"]").prop('disabled', true);
288             } else {
289                 $("input:checkbox[name=ordernumber]").prop('disabled', false);
290             }
291         }
292
293         $(document).ready(function() {
294
295             var columns_settings = [% TablesSettings.GetColumns( 'acqui', 'lateorders', 'late_orders', 'json' ) | $raw %];
296             late_orderst = KohaTable("late_orders", {
297                 "sorting": [[ 1, "asc" ]],
298                 "sPaginationType": "full",
299                 "bAutoWidth": false,
300                 "fnDrawCallback": function() {
301                     if ( typeof late_orderst != 'undefined' ) {
302                         check_uncheck();
303                         $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
304                     };
305                 }
306             }, columns_settings );
307             $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
308             $('#CheckAll').click(function(e){
309                 e.preventDefault();
310                 $("#late_orders input:checkbox").prop("checked", true);
311             });
312             $('#CheckNone').click(function(e){
313                 e.preventDefault();
314                 $("#late_orders input:checkbox").prop("checked", false);
315             });
316
317             // Generates a dynamic link for exporting the selection's data as CSV
318             $("#exportbutton, #export-csv-menu a").click(function() {
319                 var all_nodes = $(late_orderst.fnGetNodes());
320                 var selected = $(all_nodes).find("input[name='ordernumber']:checked");
321
322                 if (selected.length == 0) {
323                     alert(_("Please select at least one item to export."));
324                     return false;
325                 }
326
327                 var url = $('#exportbutton').attr('href') + '?';
328                 // Building the url from currently checked boxes
329                 for (var i = 0; i < selected.length; i++) {
330                     url += '&amp;ordernumber=' + selected[i].value;
331                 }
332                 if($(this).attr("data-value")) {
333                     url += '&amp;csv_profile=' + $(this).attr("data-value");
334                 }
335                 // And redirecting to the CSV page
336                 location.href = url;
337                 return false;
338             });
339
340             $(".edit_note").on("click", function(e) {
341                 e.preventDefault();
342                 var ordernumber = $(this).data("ordernumber");
343                 var note_type = $(this).data("note_type");
344                 var modalTitle = $(this).attr("title") + " (order number " + ordernumber + ")";
345                 var note_text = $( "#" + note_type + "-note-" + ordernumber ).html();
346                 $("#noteEditor .modal-title").text(modalTitle);
347                 $("#ordernumber").val( ordernumber );
348                 $("#ordernotes").html( note_text );
349                 $("#type").val( note_type );
350                 $("#noteEditor").modal("show");
351                 $("#ordernotes").focus();
352             });
353
354              $("#noteEditor").on('hidden.bs.modal', function (e) {
355                 $("#noteEditorLabel").html("");
356                 $("#noteEditor .modal-title").text("");
357                 $("#ordernotes").html( "" );
358                 $("#ordernumber").val("");
359                 $("#type").val("");
360             });
361         });
362     </script>
363 [% END %]
364
365 [% INCLUDE 'intranet-bottom.inc' %]