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