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