Bug 30952: Staff interface redesign (header)
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / parcel.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Price %]
6 [% PROCESS 'i18n.inc' %]
7 [% SET footerjs = 1 %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>
10     [% IF ( invoiceclosedate ) %]
11         Receipt summary for [% name | html %] [% IF ( invoice ) %]invoice [
12         % invoice | html %][% END %]
13     [% ELSE %]
14         Receive orders from [% name | html %]
15     [% END %] &rsaquo; Acquisitions &rsaquo; Koha
16 </title>
17 [% INCLUDE 'doc-head-close.inc' %]
18 </head>
19
20 <body id="acq_parcel" class="acq">
21 [% WRAPPER 'header.inc' %]
22     [% INCLUDE 'acquisitions-search.inc' %]
23 [% END %]
24
25 [% WRAPPER 'sub-header.inc' %]
26 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
27     <ol>
28         <li>
29             <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
30         </li>
31         <li>
32             <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
33         </li>
34         [% IF invoiceclosedate %]
35             <li>
36                 Receipt summary for <em>[% name | html %]</em>
37                 [% IF ( invoice ) %]
38                     <em>[ [% invoice | html %] ]</em>
39                 [% END %]
40             </li>
41         [% ELSE %]
42             <li>
43                 <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% name | html %]</a>
44             </li>
45             <li>
46                 Receive orders from [% name | html %]
47             </li>
48         [% END %]
49     </ol>
50 </nav>
51 [% END %]
52
53
54 <div class="main container-fluid">
55     <div class="row">
56         <div class="col-sm-10 col-sm-push-2">
57             <main>
58
59     [% IF ( receive_error ) %]
60     <div class="dialog alert">
61     <h3>Error adding items:</h3>
62     <ul>
63     [% FOREACH error_loo IN error_loop %]
64         <li>[% error_loo.error_param | html %][% IF ( error_loo.error_duplicate_barcode ) %]Duplicate barcode[% END %] <!-- todo: other error conditions come here. --></li>
65     [% END %]
66     </ul>
67     </div>
68     [% END %]
69     <h1>
70         [% IF ( invoiceclosedate ) %]
71             <span>Receipt summary for <em>[% name | html %]</em></span> [% IF ( invoice ) %] <em> [ [% invoice | html %] ] </em>[% END %]
72         [% ELSE %]
73             <span>Receive orders from [% name | html %]</span>
74         [% END %]
75     </h1>
76
77     [% IF ( success_delorder ) %]
78     <div class="dialog message">The order has been successfully canceled.</div>
79     [% ELSE %]
80     [% IF ( error_delitem ) %]
81         <div class="dialog alert">The order has been canceled, although one or more items could not have been deleted.</div>
82     [% END %]
83     [% IF ( error_delbiblio ) %]
84         <div class="dialog alert">The order has been canceled, although the record has not been deleted.</div>
85     [% END %]
86     [% END %]
87
88     [% IF (error_cancelling_receipt) %]
89       <div class="dialog alert">
90       <span>Cannot cancel receipt. Possible reasons:</span>
91       <ul>
92         <li>
93           The order line you are trying to cancel was created from a partial receipt
94           of another order line which is already received. Try to cancel this
95           one first and retry.
96         </li>
97         <li>
98           The order line you are trying to cancel was created from a partial receipt
99           of another order line which has been deleted. Cancellation is not
100           possible.
101         </li>
102       </ul>
103       </div>
104     [% END %]
105
106     [% IF error_invoice_not_known %]
107         <div class="dialog alert">
108             The invoice referenced by this invoiceid does not exist.
109         </div>
110     [% END %]
111
112 [% UNLESS no_orders_to_display %]
113 <div id="acqui_receive_summary">
114 <p><strong>Invoice number:</strong> [% invoice | html %] <strong>Shipment date:</strong> [% shipmentdate | $KohaDates %]</p>
115 </div>
116 [% UNLESS (invoiceclosedate) %]
117     <div id="acqui_receive_search">
118         <h3>Pending orders</h3>
119         <table id="pending_orders" class="table table-bordered table-striped">
120             <thead>
121                 <tr>
122                     <th>Basket</th>
123                     <th>Basket group</th>
124                     <th>Order line</th>
125                     <th>Summary</th>
126                     <th>View</th>
127                     <th>Replacement price</th>
128                     <th>Quantity</th>
129                     <th>Unit cost</th>
130                     <th>Order cost</th>
131                     <th>Fund</th>
132                     <th>&nbsp;</th>
133                     <th>&nbsp;</th>
134                 </tr>
135             </thead>
136         </table>
137     </div>
138 [% ELSE %]
139     <p>
140         <span>Invoice is closed, so you can't receive orders anymore.</span>
141         [% IF CAN_user_acquisition_reopen_closed_invoices %]
142             <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid | uri %]&referer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]">Reopen it</a>.
143         [% END %]
144     </p>
145 [% END %]
146
147 <div id="acqui_receive_receivelist">
148     <h3>Already received</h3>
149
150    [% IF ( loop_received ) %]
151    <form action="/cgi-bin/koha/acqui/parcel.pl" method="get" name="orderform">
152     <table id="receivedt">
153       <thead>
154         <tr>
155           <th>Basket</th>
156           <th>Basket group</th>
157           <th>Order line</th>
158           <th title="Item holds / Total holds">Holds</th>
159           <th>Summary</th>
160           <th>More</th>
161           <th>Replacement price</th>
162           <th>Quantity</th>
163           <th>Fund</th>
164           <th>Est cost</th>
165           <th>Actual cost</th>
166           <th>TOTAL</th>
167           <th></th>
168         </tr>
169       </thead>
170     <tfoot>
171         [% FOREACH key IN subtotal_for_funds.keys.sort %]
172             <tr>
173                 [% IF invoiceincgst %]
174                     <td colspan="6" class="total">(Tax inc.)</td>
175                 [% ELSE %]
176                     <td colspan="6" class="total">(Tax exc.)</td>
177                 [% END %]
178                 <td colspan="3"><em>Subtotal for</em> [% key | html %]</td>
179                 <td>[% subtotal_for_funds.$key.ecost | $Price %]</td>
180                 <td>[% subtotal_for_funds.$key.unitprice | $Price %]</td>
181                 <td>&nbsp;</td>
182                 <td>&nbsp;</td>
183             </tr>
184         [% END %]
185         <tr>
186             <th colspan="11" class="total">Total tax exc.</th>
187             <th>[% total_tax_excluded | $Price %]</th>
188             <th></th>
189         </tr>
190         [% FOREACH book_foot IN book_foot_loop %]
191             <tr>
192                 <th colspan="11">Total (GST [% book_foot.tax_rate * 100 | html %]%)</th>
193                 <th>[% book_foot.tax_value | $Price %]</th>
194                 <th></th>
195             </tr>
196         [% END %]
197         <tr>
198             <th colspan="11" class="total">Total tax inc.</th>
199             <th>[% total_tax_included | $Price %]</th>
200             <th></th>
201         </tr>
202     </tfoot>
203     <tbody class="filterclass">
204         [% FOREACH order IN loop_received %]
205             <tr>
206                 <td><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% order.basketno | uri %]"> [% order.basketname | html %] ([% order.basketno | html %])</a></td>
207                 <td>
208                   [% IF order.basketgroupid %]
209                   <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid=[% booksellerid | uri %]">[% order.basketgroupname | html %] ([% order.basketgroupid | html %])</a>
210                   [% ELSE %]
211                     No basket group
212                   [% END %]
213                 </td>
214                 <td>
215                   <a href="neworderempty.pl?ordernumber=[% order.ordernumber | uri %]&amp;booksellerid=[% booksellerid | uri %]">[% order.ordernumber | html %]</a>
216                   [% IF (order.parent_ordernumber && (order.parent_ordernumber != order.ordernumber)) %]
217                     (<a href="neworderempty.pl?ordernumber=[% order.parent_ordernumber | uri %]&amp;booksellerid=[% booksellerid | uri %]" title="Original order line">[% order.parent_ordernumber | html %]</a>)
218                   [% END %]
219                 </td>
220                 <td>
221                   [% IF order.total_holds > 0 %]
222                     [% IF order.item_holds > 0 %]
223                       <span class="error"><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% order.biblionumber | uri %]">[% order.item_holds | html %]</a></span>
224                     [% ELSE %]
225                       0
226                     [% END %]
227                     /
228                     <span class="error"><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% order.biblionumber | uri %]">[% order.total_holds | html %]</a></span>
229                   [% ELSE %]
230                     0
231                   [% END %]
232                 </td>
233                 <td>
234                     [% INCLUDE 'biblio-title.inc' biblio=order link = 1 %]
235                 [% IF ( order.author ) %] / [% order.author | html %][% END %]
236                 [% IF ( order.isbn ) %] - [% order.isbn | html %][% END %]
237                 [% IF ( order.publishercode ) %]
238                     <br />Publisher: [% order.publishercode | html %]
239                     [%- IF    ( order.publicationyear > 0) -%], [% order.publicationyear | html %]
240                     [%- ELSIF ( order.copyrightdate   > 0) -%] [% order.copyrightdate | html %]
241                     [% END %]
242                 [% END %]
243                 [% IF ( order.suggestionid ) %]
244                     <br/>
245                     Suggested by: [% order.surnamesuggestedby | html %][% IF ( order.firstnamesuggestedby ) %], [% order.firstnamesuggestedby | html %] [% END %]
246                     (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% order.suggestionid | uri %]&amp;op=show">suggestion #[% order.suggestionid | html %]</a>)
247                 [% END %]
248                 <br />
249                 [% IF ( order.order_internalnote ) %]
250                     <p class="ordernote"><strong>Internal note: </strong>[% order.order_internalnote | html %] [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% order.ordernumber | uri %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]&type=internal">Change internal note</a>]</p>
251                 [% ELSE %]
252                     [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% order.ordernumber | uri %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]&type=internal">Add internal note</a>]
253                 [% END %]
254                 [% IF ( order.order_vendornote ) %]
255                     <p class="ordernote"><strong>Vendor note: </strong>[% order.order_vendornote | html %]</p>
256                 [% ELSE %]
257                     [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% order.ordernumber | uri %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]&type=vendor">Add vendor note</a>]
258                 [% END %]
259                 </td>
260                 <td>
261                   <a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=[% order.ordernumber | uri %]" class="previewData">[% tp('noun', 'Order') | html %]</a><br>
262                   <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% order.biblionumber | uri %]" class="previewData">MARC</a><br>
263                   <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% order.biblionumber | uri %]" class="previewData">Card</a>
264                 </td>
265                 <td>[% order.replacementprice | $Price %]</td>
266                 <td>[% order.quantityreceived | html %]</td>
267                 <td>[% order.budget.budget_name | html %]</td>
268                 <td>[% order.ecost | $Price %]</td>
269                 <td>[% order.unitprice | $Price %]</td>
270                 <td>[% order.total | $Price %]</td>
271                 <td>
272                     [% IF loop_receive.cannot_cancel or ( order.basket.effective_create_items == "receiving" and loop_receive.holds > 0 ) %]
273                       [% IF loop_receive.cannot_cancel %]
274                         [% span_title = BLOCK %]
275                             <span>Cannot cancel receipt of this order line because it
276                             was created from a partial receipt of order line no.
277                             [% order.parent_ordernumber | html %], which is
278                             already received. Try cancelling this one first and
279                             retry.</span>
280                         [% END %]
281                       [% ELSE %]
282                         [%# FIXME Here we block the cancellation if holds exist. Actually it could be possible if items will be exist after the deletion %]
283                         [%# Some additional checks should be added in the pl file %]
284                         [% span_title = BLOCK %]
285                           <span>Cannot cancel receipt of this order line because at least one hold exists on the records.</span>
286                         [% END %]
287                       [% END %]
288                       <span title="[% span_title | collapse | html %]">
289                           Can't cancel receipt
290                       </span>
291                     [% ELSE %]
292                         <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]&op=cancelreceipt&ordernumber=[% order.ordernumber | uri %]">Cancel receipt</a>
293                     [% END %]
294                 </td>
295             </tr>
296         [% END %]
297     </tbody>
298     </table>
299     </form>
300
301     [% ELSE %]There are no received orders.[% END %]
302 </div>
303
304 <div class="modal" id="dataPreview" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel">
305     <div class="modal-dialog modal-wide" role="document">
306         <div class="modal-content">
307             <div class="modal-header">
308                 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
309                 <h3 id="dataPreviewLabel">MARC previews</h3>
310             </div>
311             <div class="modal-body">
312                 <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
313             </div>
314             <div class="modal-footer">
315                 <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
316             </div>
317         </div> <!-- /.modal-content -->
318     </div> <!-- /.modal-dialog -->
319 </div> <!-- /.modal -->
320
321 [% IF (invoiceclosedate) %]
322     <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid | uri %]">View invoice</a>
323 [% ELSE %]
324     <form action="/cgi-bin/koha/acqui/invoice.pl" method="get">
325         <input type="hidden" name="invoiceid" value="[% invoiceid | html %]" />
326         <fieldset class="action">
327             <input type="submit" value="Finish receiving" />
328         </fieldset>
329     </form>
330 [% END %]
331
332 [% END %]
333
334 </main>
335 </div> <!-- /.col-sm-10.col-sm-push-2 -->
336
337 <div class="col-sm-2 col-sm-pull-10">
338 <aside>
339
340 [% INCLUDE 'acquisitions-menu.inc' %]
341     </aside>
342 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
343 </div> <!-- /.row -->
344
345 [% MACRO jsinclude BLOCK %]
346     [% Asset.js("js/acquisitions-menu.js") | $raw %]
347     [% INCLUDE 'datatables.inc' %]
348     [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
349     <script>
350         dt_overwrite_html_sorting_localeCompare();
351         var columns_filter = {};
352
353         $(document).ready(function(){
354
355             if ( $("#receivedt").length ) {
356                 var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
357                     "bStateSave": true,
358                     "iDisplayLength": 10,
359                     "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
360                     "aoColumnDefs": [
361                         { "aTargets": [ 5, -1 ], "bSortable": false, "bSearchable": false },
362                     ],
363                     "aoColumns": [
364                         { "sType": "html" },
365                         { "sType": "html" },
366                         { "sType": "html" },
367                         { "sType": "num-html" },
368                         { "sType": "anti-the" },
369                         null,
370                         null,
371                         null,
372                         null,
373                         null,
374                         null,
375                         null,
376                         null
377                     ],
378                     "sPaginationType": "full"
379                 }));
380             }
381
382             var pending_orders_table = $("#pending_orders").kohaTable({
383                 "ajax": {
384                     "url": '/api/v1/acquisitions/orders?only_active=1'
385                 },
386                 "header_filter": true,
387                 "embed": [
388                     "basket.basket_group",
389                     "biblio.active_orders+count",
390                     "biblio.holds+count",
391                     "biblio.items+count",
392                     "biblio.suggestions.suggester",
393                     "fund",
394                     "current_item_level_holds+count",
395                     "items"
396                 ],
397                 "stateSave": true, // remember state on page reload
398                 "drawCallback": function (settings) {
399                     $(".previewData").on("click", function(e){
400                         e.preventDefault();
401                         var ltitle = $(this).text();
402                         var page = $(this).attr("href");
403                         $("#dataPreviewLabel").text(ltitle);
404                         $("#dataPreview .modal-body").load(page + " div");
405                         $('#dataPreview').modal({show:true});
406                     });
407                 },
408                 "columns": [
409                     { "data": "basket.name",
410                     "searchable": true,
411                       "orderable": true,
412                       "render": function(data, type, row, meta) {
413                         if (type != 'display') return escape_str(data);
414                         return "<a href=\"/cgi-bin/koha/acqui/basket.pl?basketno=" + encodeURIComponent(row.basket.basket_id) + "\">" + escape_str(data) + " (" + escape_str(row.basket.basket_id) + ")</a>";
415                       }
416                     },
417                     { "data": "basket.basket_group.name",
418                       "orderable": true,
419                       "render": function(data, type, row, meta) {
420                         if ( type != 'display' ) {
421                             return escape_str(data);
422                         }
423                         if ( row.basket.basket_group_id == null ) {
424                             return _("No basket group");
425                         }
426                         else {
427                             return "<a href=\"/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid="
428                                     + encodeURIComponent(row.basket.vendor_id) + "&amp;basketgroupid="
429                                     + encodeURIComponent(row.basket.basket_group_id) + "\">"
430                                     + escape_str(row.basket.basket_group.name) + " (" + escape_str(row.basket.basket_group_id) + ")</a>";
431                         }
432                       }
433                     },
434                     {
435                         "data": "order_id",
436                         "render": function(data, type, row, meta) {
437                             if (type != 'display') return escape_str(data);
438                             return "<a href=\"neworderempty.pl?ordernumber="+encodeURIComponent(data)+"&amp;booksellerid="+encodeURIComponent(row.basket.vendor_id)+"\">"+escape_str(data)+"</a>";
439                         }
440                     },
441                     {
442                         [% SET summary_fields = "biblio.title:biblio.author:biblio.isbn:biblio.publisher:me.internal_note:me.vendor_note" %]
443                         [% IF Koha.Preference('marcflavour')=='UNIMARC' %][% SET summary_fields = summary_fields _ ":biblio.ean" %][% END %]
444                         "data": "[% summary_fields | html %]",
445                         "render": function(data, type, row, meta) {
446                             var result = '';
447                             if ( row && row.biblio_id != null ) {
448                                 result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+escape_str(row.biblio.title)+"</a>";
449                                 if ( row.biblio.author != null )
450                                     result += _(" by ") + escape_str(row.biblio.author);
451                                 if ( row.biblio.isbn != null )
452                                     result += " &ndash; " + escape_str(row.biblio.isbn);
453                                 [% IF Koha.Preference('marcflavour')=='UNIMARC' %]
454                                     if ( row.biblio.ean != null )
455                                         result += " &ndash; EAN:" + escape_str(row.biblio.ean);
456                                 [% END %]
457                                 if ( row.biblio.publisher != null ) {
458                                     result += "<br/>" + _("Publisher: ") + escape_str(row.biblio.publisher);
459                                     if ( row.biblio.publication_year != null ) {
460                                         result += ", " + escape_str(row.biblio.publication_year);
461                                     }
462                                     else if ( row.biblio.copyright_date != null ) {
463                                         result += escape_str(row.biblio.copyright_date);
464                                     }
465                                 }
466                                 var suggestions = row.biblio.suggestions;
467                                 if ( suggestions != null && suggestions.length > 0 ) {
468                                     var suggestion = suggestions[0];
469                                     if ( suggestion.suggester != null ) {
470                                         var suggester = suggestion.suggester;
471                                         var suggested_by = [];
472                                         if ( suggester.surname != null ) {
473                                             suggested_by.push(escape_str(suggester.surname));
474                                         }
475                                         if ( suggester.firstname != null ) {
476                                             suggested_by.push(escape_str(suggester.firstname));
477                                         }
478
479                                             result += "<br/>" + _("Suggested by: ") +
480                                                         '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
481                                                             + encodeURIComponent(suggestion.suggestionid)
482                                                             + '&amp;op=show">'
483                                                             + suggested_by.join(", ")
484                                                             + " (#" + escape_str(suggestions[0].suggestionid) + ")</a>"; // FIXME: could be changed if we allow matching multiple suggestions
485                                     }
486                                 }
487                                 result += '</p>';
488                             }
489
490                             var internal_note = row.internal_note;
491                             if ( internal_note != null && internal_note != '' ) {
492                                 result += '<p class="ordernote"><strong>'
493                                             + _("Internal note: ")
494                                             + '</strong>' + escape_str(internal_note)
495                                             + ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
496                                             + encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
497                                             + '&type=internal">' + _("Change internal note") + '</a>]</p>';
498                             }
499                             else {
500                                 result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
501                                             + encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
502                                             + '&type=internal">' + _("Add internal note") + '</a>]';
503                             }
504
505                             var vendor_note = row.vendor_note;
506                             if ( vendor_note != null && vendor_note != '' ) {
507                                 result += '<p class="ordernote"><strong>'
508                                             + _("Vendor note: ")
509                                             + '</strong>' + escape_str(vendor_note) + '</p>';
510                             }
511                             else {
512                                 result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
513                                             + encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
514                                             + '&type=vendor">' + _("Add vendor note") + '</a>]';
515                             }
516
517                             return result;
518                         },
519                         "orderable": true,
520                     },
521                     {
522                         "data": "",
523                         "render": function(data, type, row, meta) {
524                             var result = '<div class="btn-group dropup">';
525                             result += '<button id="view' + row.order_id + '" type="button" class="btn btn-default btn-xs" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">';
526                                 result += ' <i class="fa fa-eye" aria-hidden="true"></i> ' + _("View");
527                                 result += ' <span class="caret"></span> ';
528                             result += '</button>';
529                             result += '<ul class="dropdown-menu" aria-labelledby="view' + row.order_id + '">';
530                                 result += '<li><a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '" class="previewData">' + _("Order") + '</a></li>';
531                                 result += '<li><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("MARC") + '</a></li>';
532                                 result += '<li><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("Card") + '</a></li>';
533                             result += '</ul>';
534                             result += '</div>';
535                             return result;
536                         },
537                         "orderable": false,
538                         "searchable": false
539                     },
540                     {
541                         "data": "replacement_price",
542                         "render": function(data, type, row, meta) {
543                             return escape_price(row.replacement_price);
544                         },
545                     },
546                     {
547                         "data": "quantity",
548                         "orderable": true
549                     },
550                     {
551                         "data": "ecost",
552                         "render": function(data, type, row, meta) {
553                             return escape_price(row.ecost);
554                         },
555                     },
556                     {
557                         "data": "",
558                         "render": function(data, type, row, meta) {
559                             return escape_price(row.quantity * row.ecost);
560                         },
561                         "orderable": false, // FIXME: How can we do it in DBIC?
562                         "searchable": false
563                     },
564                     {
565                         "data": "fund.name",
566                         "render": function(data, type, row, meta) {
567                             if (type != 'display') return escape_str(data);
568                             return escape_str(row.fund.name);
569                         }
570                     },
571                     {
572                         "data": "",
573                         "render": function(data, type, row, meta) {
574                             return '<a href="orderreceive.pl?ordernumber='
575                                     + encodeURIComponent(row.order_id) + '&amp;invoiceid=[% invoiceid | uri %]' + '">'
576                                     + _("Receive") + '</a><br/>'
577                                     + '<a href="#" onclick="transfer_order_popup(' + escape_str(row.order_id) + '); return false;">'
578                                     + _("Transfer") + '</a>';
579                         },
580                         "orderable": false,
581                         "searchable": false
582                     },
583                     {
584                         "data": "",
585                         "render": function(data, type, row, meta) {
586                             var result = "";
587
588                             if ( row.current_holds_count > 0 ) {
589                                 result += '<span class="button" title="'
590                                         + _("Can't cancel order, (%s) holds are linked with this order. Cancel holds first").format( escape_str(row.holds_count) ) + '">'
591                                         + _("Can't cancel order") + '</span><br/>';
592                             }
593                             else {
594                                 result += '<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber='
595                                             + encodeURIComponent(row.order_id)
596                                             + '&biblionumber=' + encodeURIComponent(row.biblio_id)
597                                             + '&referrer=/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">'
598                                             + _("Cancel order") + '</a><br/>';
599                             }
600
601                             if ( row.biblio != null ) {
602                                 if ( row.biblio.items_count - row.items.length > 0 ||
603                                     row.biblio.active_orders_count > 1 ||
604                                     row.biblio.subscriptions_count > 0 ||
605                                     row.biblio.holds_count > 0 ) { // biblio can be deleted
606                                     result += '<span class="button" title="'
607                                             + _("Can't delete catalog record, see constraints below") + '">'
608                                             + _("Can't cancel order and delete catalog record") + '</span><br>';
609                                 }
610                                 else {
611                                     result += '<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber='
612                                             + encodeURIComponent(row.order_id) + '&biblionumber=' + encodeURIComponent(row.biblio_id)
613                                             + '&del_biblio=1&referrer="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[$ invoiceid | uri ]">'
614                                             + _("Cancel order and catalog record") + '</a><br/>';
615                                 }
616
617                                 if ( row.biblio.items_count - row.items.length > 0 ) {
618                                     result += '<strong title="'
619                                             + _("Can't delete catalog record, because of %s existing item(s)").format(row.items.length)
620                                             +'">' + (row.biblio.items_count - row.items.length) + _(" item(s) left") + '</strong><br/>';
621                                 }
622
623                                 if ( row.biblio.active_orders_count > 1 ) {
624                                     result += '<strong title="'
625                                             + _("Can't delete catalog record, delete other orders linked to it first") + '">'
626                                             + (row.biblio.active_orders_count - 1) + _(" order(s) left") + '</strong><br/>';
627                                 }
628
629                                 if ( row.biblio.subscriptions_count > 0 ) {
630                                     result += '<strong title="' + _("Can't delete catalog record, delete subscriptions first") + '">'
631                                             + _("%s subscription(s) left").format(row.biblio.subscriptions_count)
632                                             + '</strong><br>';
633                                 }
634
635                                 if ( row.biblio.holds_count > 0 ) {
636                                     result += '<strong title="' + _("Can't delete catalog record or order, cancel holds first") + '">'
637                                             + _("%s hold(s) left").format(row.biblio.holds_count) + '</strong>';
638                                 }
639                             }
640
641                             return result;
642                         },
643                         "orderable": false,
644                         "searchable": false
645                     }
646                 ]
647             }, null, 1, {"basket.vendor_id": [% booksellerid | html %]});
648
649             $(".previewData").on("click", function(e){
650                 e.preventDefault();
651                 var ltitle = $(this).text();
652                 var page = $(this).attr("href");
653                 $("#dataPreviewLabel").text(ltitle);
654                 $("#dataPreview .modal-body").load(page + " div");
655                 $('#dataPreview').modal("show");
656             });
657
658             $("#dataPreview").on("hidden.bs.modal", function(){
659                 $("#dataPreviewLabel").html("");
660                 $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
661             });
662         });
663
664         // Case-insensitive version of jquery's contains function
665         jQuery.extend(jQuery.expr[':'], {
666             icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
667         });
668
669         // Contains exactly function
670         jQuery.extend(jQuery.expr[':'], {
671             containsExactly: "$(a).text() == m[3]"
672         });
673
674         function transfer_order_popup(ordernumber) {
675         var url = "/cgi-bin/koha/acqui/transferorder.pl?"
676             + "ordernumber=" + ordernumber
677             window.open(url, 'TransferOrder');
678         }
679     </script>
680 [% END %]
681
682 [% INCLUDE 'intranet-bottom.inc' %]