Bug 24161: Display claimed dates vertically
[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 ColumnsSettings %]
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 ( Supplier ) %][% Supplier | 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.count %]
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="[% booksellerid | 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     <table id="late_orders">
54       <thead>
55         <tr>
56             [% IF Supplier %]
57                 <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
58             [% ELSE %]
59                 <th></th>
60             [% END %]
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>Total cost</th>
67             <th>Basket</th>
68             <th>Basket group</th>
69             <th>Library</th>
70             <th>Fund</th>
71             <th>Claims count</th>
72             <th class="title-string">Claimed date</th>
73             <th>Internal note</th>
74             <th>Vendor note</th>
75             <th>ISBN</th>
76         </tr>
77       </thead>
78       <tbody>
79       [% FOREACH lateorder IN lateorders %]
80         <tr>
81             <td>
82                 <input type="checkbox" value="[% lateorder.ordernumber | html %]" data-booksellerid="[% lateorder.basket.booksellerid | html %]" name="ordernumber">
83             </td>
84             <td>
85                 [% lateorder.ordernumber | $raw %]
86             </td>
87             <td>
88                 <span title="[% lateorder.basket.closedate | html %]">[% lateorder.basket.closedate | $KohaDates %] ([% lateorder.basket.late_since_days | html %] days)</span>
89             </td>
90             <td>
91                 [% SET estimated_delivery_date = lateorder.get_column('estimated_delivery_date') %]
92                 [% IF estimated_delivery_date %]
93                     <span title="[% estimated_delivery_date | html %]">[% estimated_delivery_date | $KohaDates  %]</span>
94                 [% END %]
95             </td>
96             <td>
97                 [% lateorder.basket.bookseller.name | html %]
98                 ([% lateorder.basket.bookseller.id | html %])
99             </td>
100             <td>
101                 <b>[% lateorder.biblio.title | html %]</b>
102                    [% IF ( lateorder.biblio.author ) %]<br/><i>Author:</i> [% lateorder.biblio.author | html %][% END %]
103                    [% IF ( lateorder.biblio.biblioitem.publishercode ) %]
104                         <br/><i>Published by:</i> [% lateorder.biblio.biblioitem.publishercode | html %]
105                         [% IF ( lateorder.biblio.biblioitem.publicationyear ) %]
106                             <i> in </i>[% lateorder.biblio.biblioitem.publicationyear | html %]
107                         [% END %]
108                    [% END %]
109             </td>
110             <td>
111                 [% SET subtotal = (lateorder.quantity - lateorder.quantityreceived) * lateorder.rrp %]
112                 [% SET total = total + subtotal %]
113                 [% lateorder.rrp | html %]x[% lateorder.quantity - lateorder.quantityreceived | html %] = [% subtotal | $Price %]
114             </td>
115             <td>
116                 [% IF ( CAN_user_acquisition_order_manage ) %]
117                     <a href="basket.pl?basketno=[% lateorder.basketno | uri %]" title="basket">[% lateorder.basket.basketname | html %] ([% lateorder.basketno | html %])</a>
118                 [% ELSE %]
119                     [% lateorder.basket.basketname | html %] ([% lateorder.basketno | html %])
120                 [% END %]
121             </td>
122             <td>
123                 [% IF ( lateorder.basket.basketgroupid ) %]
124                     [% IF ( CAN_user_acquisition_group_manage ) %]
125                         <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>
126                     [% ELSE %]
127                         [% lateorder.basket.basket_group.name | html %] ([% lateorder.basket.basketgroupid | html %])</a>
128                     [% END %]
129                 [% END %]
130             </td>
131             <td>[% Branches.GetName( lateorder.basket.authorizer.branchcode ) | html %]
132             </td>
133             <td>[% lateorder.fund.budget_name | html %]
134             </td>
135             <td>[% lateorder.claims.count | html %]</td>
136             <td>
137                 [% FOR claim IN lateorder.claims %]
138                     <span title="[% lateorder.claims.last.claimed_on | html %]">[% claim.claimed_on | $KohaDates %]</span>
139                     [% UNLESS loop.last %]<br/>[% END %]
140                 [% END %]
141             </td>
142             <td>
143                 [% IF lateorder.order_internalnote %]
144                     <p class="ordernote">
145                         <span id="internal-note-[% lateorder.ordernumber | html %]">[% lateorder.order_internalnote | html %]</span>
146                         <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">
147                             <i class="fa fa-pencil"></i> Edit internal note
148                         </a>
149                     </p>
150                 [% ELSE %]
151                     <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">
152                         <i class="fa fa-plus"></i> Add internal note
153                     </a>
154                 [% END %]
155             </td>
156             <td>
157                 [% IF lateorder.order_vendornote %]
158                     <p class="ordernote">
159                         <span id="vendor-note-[% lateorder.ordernumber | html %]">[% lateorder.order_vendornote | html %]</span>
160                         <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">
161                             <i class="fa fa-pencil"></i> Edit vendor note
162                         </a>
163                     </p>
164                 [% ELSE %]
165                     <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">
166                         <i class="fa fa-plus"></i> Add vendor note
167                     </a>
168                 [% END %]
169             </td>
170             <td>[% lateorder.biblio.biblioitem.isbn | $raw %]</td>
171         </tr>
172       [% END %]
173       </tbody>
174       <tfoot>
175         <tr>
176             <th colspan="6">Total</th>
177             <th>[% total | $Price %]</th>
178             <th colspan="9">&nbsp;</th>
179         </tr>
180       </tfoot>
181     </table>
182     <div class="spacer"></div>
183
184     <p style="display:block;">
185         <input type="button" value="Export as CSV" id="ExportSelected" />
186         <input type="submit"  value="Claim order" />
187     </p>
188 </form>
189 [% ELSE %]<p>There are no late orders.</p>
190 [% END %]
191 </div> <!-- /#acqui_lateorders -->
192 </main>
193 </div> <!-- /.col-sm-10.col-sm-push-2 -->
194
195 <div class="col-sm-2 col-sm-pull-10">
196     <aside>
197 <form action="lateorders.pl" method="get">
198 <fieldset class="brief">
199 <h4>Filter results:</h4>
200 [% FOREACH ERROR_LOO IN ERROR_LOOP %]
201 [% 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 %]
202 [% END %]
203 <ol>
204     <li><label for="delay">Order date:</label><input size="3" maxlength="3" id="delay" type="text" name="delay" value="[% delay | html %]" /> days ago</li>
205     <li><label for="from">Estimated delivery date from: </label>
206         <input type="text" size="10" id="from" name="estimateddeliverydatefrom" value="[% estimateddeliverydatefrom | html %]" class="datepickerfrom" />
207         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
208     </li>
209     <li><label for="to">To: </label>
210         <input type="text" size="10" id="to" name="estimateddeliverydateto" value="[% estimateddeliverydateto | html %]" class="datepickerto" />
211         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
212     </li>
213
214         <li><label for="booksellerid">Vendor:</label>
215                 <select id="booksellerid" size="1" tabindex="" name="booksellerid">
216             <option value=""></option>
217                         [% FOREACH SUPPLIER_LOO IN SUPPLIER_LOOP %]
218                 [% IF ( SUPPLIER_LOO.selected ) %]<option value="[% SUPPLIER_LOO.id | html %]" selected="selected">[% SUPPLIER_LOO.name | html %]</option>
219                 [% ELSE %]<option value="[% SUPPLIER_LOO.id | html %]">[% SUPPLIER_LOO.name | html %]</option>[% END %]
220                 [% END %]
221                 </select>
222 </ol>
223     <fieldset class="action"><input type="submit" value="Filter" /></fieldset>
224 </fieldset>
225     </form>
226 [% INCLUDE 'acquisitions-menu.inc' %]
227 </aside>
228 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
229 </div>
230
231 <!-- Modal for editing vendor and internal notes -->
232 <div class="modal" id="noteEditor" tabindex="-1" role="dialog" aria-labelledby="noteEditorLabel">
233     <div class="modal-dialog" role="document">
234         <form id="modify_order_notes" action="/cgi-bin/koha/acqui/modordernotes.pl" method="post">
235             <div class="modal-content">
236                 <div class="modal-header">
237                     <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
238                     <h4 class="modal-title" id="noteEditorLabel">Order note</h4>
239                 </div>
240                 <div class="modal-body">
241                 <textarea id="ordernotes" name="ordernotes" rows="3" cols="30" class="focus">[% ordernotes | html %]</textarea>
242                 <input type="hidden" id="ordernumber" name="ordernumber" value="" />
243                 <input type="hidden" name="op" value="save" />
244                 <input type="hidden" id="type" name="type" value="" />
245             </div>
246             <div class="modal-footer">
247                 <button type="submit" class="btn btn-default">Save</button>
248                 <button type="button" class="btn btn-link cancel" data-dismiss="modal">Cancel</button>
249             </div>
250             </div>
251         </form>
252     </div>
253 </div>
254
255 [% MACRO jsinclude BLOCK %]
256     [% Asset.js("js/acquisitions-menu.js") | $raw %]
257     [% INCLUDE 'datatables.inc' %]
258     [% INCLUDE 'columns_settings.inc' %]
259     [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
260     [% INCLUDE 'calendar.inc' %]
261     <script>
262         var late_orderst;
263         function check_uncheck() {
264             var all_nodes = $(late_orderst.fnGetNodes());
265             if ( $(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
266                 var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
267                 $(all_nodes).find("input:checkbox[name=ordernumber][data-booksellerid!="+booksellerid+"]").prop('disabled', true);
268             } else {
269                 $("input:checkbox[name=ordernumber]").prop('disabled', false);
270             }
271         }
272
273         $(document).ready(function() {
274
275             var columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'lateorders', 'late_orders', 'json' ) | $raw %];
276             late_orderst = KohaTable("late_orders", {
277                 "aoColumnDefs": [
278                     { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
279                     { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
280                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
281                 ],
282                 "sPaginationType": "full",
283                 "bAutoWidth": false,
284                 "fnDrawCallback": function() {
285                     if ( typeof late_orderst != 'undefined' ) {
286                         check_uncheck();
287                         $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
288                     };
289                 }
290             }, columns_settings );
291             $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
292             $('#CheckAll').click(function(){ $(late_orderst.fnGetNodes()).find("td").checkCheckboxes();});
293             $('#CheckNone').click(function(){ $(late_orderst.fnGetNodes()).find("td").unCheckCheckboxes();});
294
295             // Generates a dynamic link for exporting the selection's data as CSV
296             $("#ExportSelected").click(function() {
297                 var all_nodes = $(late_orderst.fnGetNodes());
298                 var selected = $(all_nodes).find("input[name='ordernumber']:checked");
299
300                 if (selected.length == 0) {
301                     alert(_("Please select at least one item to export."));
302                     return false;
303                 }
304
305                 // Building the url from currently checked boxes
306                 var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
307                 for (var i = 0; i < selected.length; i++) {
308                     url += '&amp;ordernumber=' + selected[i].value;
309                 }
310                 // And redirecting to the CSV page
311                 location.href = url;
312                 return false;
313             });
314
315             $(".edit_note").on("click", function(e) {
316                 e.preventDefault();
317                 var ordernumber = $(this).data("ordernumber");
318                 var note_type = $(this).data("note_type");
319                 var modalTitle = $(this).attr("title") + " (order number " + ordernumber + ")";
320                 var note_text = $( "#" + note_type + "-note-" + ordernumber ).html();
321                 $("#noteEditor .modal-title").text(modalTitle);
322                 $("#ordernumber").val( ordernumber );
323                 $("#ordernotes").html( note_text );
324                 $("#type").val( note_type );
325                 $("#noteEditor").modal("show");
326                 $("#ordernotes").focus();
327             });
328
329              $("#noteEditor").on('hidden.bs.modal', function (e) {
330                 $("#noteEditorLabel").html("");
331                 $("#noteEditor .modal-title").text("");
332                 $("#ordernotes").html( "" );
333                 $("#ordernumber").val("");
334                 $("#type").val("");
335             });
336         });
337     </script>
338 [% END %]
339
340 [% INCLUDE 'intranet-bottom.inc' %]