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