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