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