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