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