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