Bug 24163: Allow to define CSV profile for late orders export
[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         <div class="btn-group">
186           <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>
187           <a class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
188           <ul class="dropdown-menu" id="export-csv-menu">
189               <li><a href="#">Default</a></li>
190               [% IF csv_profiles %]
191                   [% FOR csv IN csv_profiles %]
192                     <li><a href="#" data-value="[% csv.export_format_id | html %]">[% csv.profile | html %]</a></li>
193                   [% END %]
194               [% END %]
195            </ul>
196         </div>
197
198         <input type="submit"  class="btn btn-default" value="Claim order" />
199     </p>
200 </form>
201 [% ELSE %]<p>There are no late orders.</p>
202 [% END %]
203 </div> <!-- /#acqui_lateorders -->
204 </main>
205 </div> <!-- /.col-sm-10.col-sm-push-2 -->
206
207 <div class="col-sm-2 col-sm-pull-10">
208     <aside>
209 <form action="lateorders.pl" method="get">
210 <fieldset class="brief">
211 <h4>Filter results:</h4>
212 [% FOREACH ERROR_LOO IN ERROR_LOOP %]
213 [% 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 %]
214 [% END %]
215 <ol>
216     <li><label for="delay">Order date:</label><input size="3" maxlength="3" id="delay" type="text" name="delay" value="[% delay | html %]" /> days ago</li>
217     <li><label for="from">Estimated delivery date from: </label>
218         <input type="text" size="10" id="from" name="estimateddeliverydatefrom" value="[% estimateddeliverydatefrom | html %]" class="datepickerfrom" />
219         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
220     </li>
221     <li><label for="to">To: </label>
222         <input type="text" size="10" id="to" name="estimateddeliverydateto" value="[% estimateddeliverydateto | html %]" class="datepickerto" />
223         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
224     </li>
225
226         <li><label for="booksellerid">Vendor:</label>
227                 <select id="booksellerid" size="1" tabindex="" name="booksellerid">
228             <option value=""></option>
229                         [% FOREACH SUPPLIER_LOO IN SUPPLIER_LOOP %]
230                 [% IF ( SUPPLIER_LOO.selected ) %]<option value="[% SUPPLIER_LOO.id | html %]" selected="selected">[% SUPPLIER_LOO.name | html %]</option>
231                 [% ELSE %]<option value="[% SUPPLIER_LOO.id | html %]">[% SUPPLIER_LOO.name | html %]</option>[% END %]
232                 [% END %]
233                 </select>
234 </ol>
235     <fieldset class="action"><input type="submit" value="Filter" /></fieldset>
236 </fieldset>
237     </form>
238 [% INCLUDE 'acquisitions-menu.inc' %]
239 </aside>
240 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
241 </div>
242
243 <!-- Modal for editing vendor and internal notes -->
244 <div class="modal" id="noteEditor" tabindex="-1" role="dialog" aria-labelledby="noteEditorLabel">
245     <div class="modal-dialog" role="document">
246         <form id="modify_order_notes" action="/cgi-bin/koha/acqui/modordernotes.pl" method="post">
247             <div class="modal-content">
248                 <div class="modal-header">
249                     <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
250                     <h4 class="modal-title" id="noteEditorLabel">Order note</h4>
251                 </div>
252                 <div class="modal-body">
253                 <textarea id="ordernotes" name="ordernotes" rows="3" cols="30" class="focus">[% ordernotes | html %]</textarea>
254                 <input type="hidden" id="ordernumber" name="ordernumber" value="" />
255                 <input type="hidden" name="op" value="save" />
256                 <input type="hidden" id="type" name="type" value="" />
257             </div>
258             <div class="modal-footer">
259                 <button type="submit" class="btn btn-default">Save</button>
260                 <button type="button" class="btn btn-link cancel" data-dismiss="modal">Cancel</button>
261             </div>
262             </div>
263         </form>
264     </div>
265 </div>
266
267 [% MACRO jsinclude BLOCK %]
268     [% Asset.js("js/acquisitions-menu.js") | $raw %]
269     [% INCLUDE 'datatables.inc' %]
270     [% INCLUDE 'columns_settings.inc' %]
271     [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
272     [% INCLUDE 'calendar.inc' %]
273     <script>
274         var late_orderst;
275         function check_uncheck() {
276             var all_nodes = $(late_orderst.fnGetNodes());
277             if ( $(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
278                 var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
279                 $(all_nodes).find("input:checkbox[name=ordernumber][data-booksellerid!="+booksellerid+"]").prop('disabled', true);
280             } else {
281                 $("input:checkbox[name=ordernumber]").prop('disabled', false);
282             }
283         }
284
285         $(document).ready(function() {
286
287             var columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'lateorders', 'late_orders', 'json' ) | $raw %];
288             late_orderst = KohaTable("late_orders", {
289                 "aoColumnDefs": [
290                     { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
291                     { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
292                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
293                 ],
294                 "sPaginationType": "full",
295                 "bAutoWidth": false,
296                 "fnDrawCallback": function() {
297                     if ( typeof late_orderst != 'undefined' ) {
298                         check_uncheck();
299                         $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
300                     };
301                 }
302             }, columns_settings );
303             $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
304             $('#CheckAll').click(function(){ $(late_orderst.fnGetNodes()).find("td").checkCheckboxes();});
305             $('#CheckNone').click(function(){ $(late_orderst.fnGetNodes()).find("td").unCheckCheckboxes();});
306
307             // Generates a dynamic link for exporting the selection's data as CSV
308             $("#exportbutton, #export-csv-menu a").click(function() {
309                 var all_nodes = $(late_orderst.fnGetNodes());
310                 var selected = $(all_nodes).find("input[name='ordernumber']:checked");
311
312                 if (selected.length == 0) {
313                     alert(_("Please select at least one item to export."));
314                     return false;
315                 }
316
317                 var url = $('#exportbutton').attr('href') + '?';
318                 // Building the url from currently checked boxes
319                 for (var i = 0; i < selected.length; i++) {
320                     url += '&amp;ordernumber=' + selected[i].value;
321                 }
322                 if($(this).attr("data-value")) {
323                     url += '&amp;csv_profile=' + $(this).attr("data-value");
324                 }
325                 // And redirecting to the CSV page
326                 location.href = url;
327                 return false;
328             });
329
330             $(".edit_note").on("click", function(e) {
331                 e.preventDefault();
332                 var ordernumber = $(this).data("ordernumber");
333                 var note_type = $(this).data("note_type");
334                 var modalTitle = $(this).attr("title") + " (order number " + ordernumber + ")";
335                 var note_text = $( "#" + note_type + "-note-" + ordernumber ).html();
336                 $("#noteEditor .modal-title").text(modalTitle);
337                 $("#ordernumber").val( ordernumber );
338                 $("#ordernotes").html( note_text );
339                 $("#type").val( note_type );
340                 $("#noteEditor").modal("show");
341                 $("#ordernotes").focus();
342             });
343
344              $("#noteEditor").on('hidden.bs.modal', function (e) {
345                 $("#noteEditorLabel").html("");
346                 $("#noteEditor .modal-title").text("");
347                 $("#ordernotes").html( "" );
348                 $("#ordernumber").val("");
349                 $("#type").val("");
350             });
351         });
352     </script>
353 [% END %]
354
355 [% INCLUDE 'intranet-bottom.inc' %]