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