Bug 27930: Move _escape_* from acqui/parcel.tt to js/staff-global.js
[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     <style>#dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }</style>
332     <script>
333         dt_overwrite_html_sorting_localeCompare();
334         var columns_filter = {};
335
336         $(document).ready(function(){
337
338             if ( $("#receivedt").length ) {
339                 var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
340                     "bStateSave": true,
341                     "iDisplayLength": 10,
342                     "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
343                     "aoColumnDefs": [
344                         { "aTargets": [ 5, -1 ], "bSortable": false, "bSearchable": false },
345                     ],
346                     "aoColumns": [
347                         { "sType": "html" },
348                         { "sType": "html" },
349                         { "sType": "html" },
350                         { "sType": "num-html" },
351                         { "sType": "anti-the" },
352                         null,
353                         null,
354                         null,
355                         null,
356                         null,
357                         null,
358                         null,
359                         null
360                     ],
361                     "sPaginationType": "full"
362                 }));
363             }
364
365             var pending_orders_table = $("#pending_orders").api({
366                 "ajax": {
367                     "url": '/api/v1/acquisitions/orders?only_active=1'
368                 },
369                 "header_filter": true,
370                 "embed": [
371                     "basket.basket_group",
372                     "biblio.active_orders+count",
373                     "biblio.holds+count",
374                     "biblio.items+count",
375                     "biblio.suggestions.suggester",
376                     "fund",
377                     "current_item_level_holds+count",
378                     "items"
379                 ],
380                 "stateSave": true, // remember state on page reload
381                 "drawCallback": function (settings) {
382                     $(".previewData").on("click", function(e){
383                         e.preventDefault();
384                         var ltitle = $(this).text();
385                         var page = $(this).attr("href");
386                         $("#dataPreviewLabel").text(ltitle);
387                         $("#dataPreview .modal-body").load(page + " div");
388                         $('#dataPreview').modal({show:true});
389                     });
390                 },
391                 "columns": [
392                     { "data": "basket.name",
393                     "searchable": true,
394                       "orderable": true,
395                       "render": function(data, type, row, meta) {
396                         if (type != 'display') return escape_str(data);
397                         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>";
398                       }
399                     },
400                     { "data": "basket.basket_group.name",
401                       "orderable": true,
402                       "render": function(data, type, row, meta) {
403                         if ( type != 'display' ) {
404                             return escape_str(data);
405                         }
406                         if ( row.basket.basket_group_id == null ) {
407                             return _("No basket group");
408                         }
409                         else {
410                             return "<a href=\"/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid="
411                                     + encodeURIComponent(row.basket.vendor_id) + "&amp;basketgroupid="
412                                     + encodeURIComponent(row.basket.basket_group_id) + "\">"
413                                     + escape_str(row.basket.basket_group.name) + " (" + escape_str(row.basket.basket_group_id) + ")</a>";
414                         }
415                       }
416                     },
417                     {
418                         "data": "order_id",
419                         "render": function(data, type, row, meta) {
420                             if (type != 'display') return escape_str(data);
421                             return "<a href=\"neworderempty.pl?ordernumber="+encodeURIComponent(data)+"&amp;booksellerid="+encodeURIComponent(row.basket.vendor_id)+"\">"+escape_str(data)+"</a>";
422                         }
423                     },
424                     {
425                         [% SET summary_fields = "biblio.author:biblio.title:biblio.isbn:biblio.publisher:me.internal_note:me.vendor_note" %]
426                         [% IF Koha.Preference('marcflavour')=='UNIMARC' %][% SET summary_fields = summary_fields _ ":biblio.ean" %][% END %]
427                         "data": "[% summary_fields | html %]",
428                         "render": function(data, type, row, meta) {
429                             var result = '';
430                             if ( row && row.biblio_id != null ) {
431                                 result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+escape_str(row.biblio.title)+"</a>";
432                                 if ( row.biblio.author != null )
433                                     result += _(" by ") + escape_str(row.biblio.author);
434                                 if ( row.biblio.isbn != null )
435                                     result += " &ndash; " + escape_str(row.biblio.isbn);
436                                 [% IF Koha.Preference('marcflavour')=='UNIMARC' %]
437                                     if ( row.biblio.ean != null )
438                                         result += " &ndash; EAN:" + escape_str(row.biblio.ean);
439                                 [% END %]
440                                 if ( row.biblio.publisher != null ) {
441                                     result += "<br/>" + _("Publisher: ") + escape_str(row.biblio.publisher);
442                                     if ( row.biblio.publication_year != null ) {
443                                         result += ", " + escape_str(row.biblio.publication_year);
444                                     }
445                                     else if ( row.biblio.copyright_date != null ) {
446                                         result += escape_str(row.biblio.copyright_date);
447                                     }
448                                 }
449                                 var suggestions = row.biblio.suggestions;
450                                 if ( suggestions != null && suggestions.length > 0 ) {
451                                     var suggestion = suggestions[0];
452                                     if ( suggestion.suggester != null ) {
453                                         var suggester = suggestion.suggester;
454                                         var suggested_by = [];
455                                         if ( suggester.surname != null ) {
456                                             suggested_by.push(escape_str(suggester.surname));
457                                         }
458                                         if ( suggester.firstname != null ) {
459                                             suggested_by.push(escape_str(suggester.firstname));
460                                         }
461
462                                             result += "<br/>" + _("Suggested by: ") +
463                                                         '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
464                                                             + encodeURIComponent(suggestion.suggestionid)
465                                                             + '&amp;op=show">'
466                                                             + suggested_by.join(", ")
467                                                             + " (#" + escape_str(suggestions[0].suggestionid) + ")</a>"; // FIXME: could be changed if we allow matching multiple suggestions
468                                     }
469                                 }
470                                 result += '</p>';
471                             }
472
473                             var internal_note = row.internal_note;
474                             if ( internal_note != null && internal_note != '' ) {
475                                 result += '<p class="ordernote"><strong>'
476                                             + _("Internal note: ")
477                                             + '</strong>' + escape_str(internal_note)
478                                             + ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
479                                             + encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
480                                             + '&type=internal">' + _("Change internal note") + '</a>]</p>';
481                             }
482                             else {
483                                 result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
484                                             + encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
485                                             + '&type=internal">' + _("Add internal note") + '</a>]';
486                             }
487
488                             var vendor_note = row.vendor_note;
489                             if ( vendor_note != null && vendor_note != '' ) {
490                                 result += '<p class="ordernote"><strong>'
491                                             + _("Vendor note: ")
492                                             + '</strong>' + escape_str(vendor_note) + '</p>';
493                             }
494                             else {
495                                 result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
496                                             + encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
497                                             + '&type=vendor">' + _("Add vendor note") + '</a>]';
498                             }
499
500                             return result;
501                         },
502                         "orderable": false,
503                     },
504                     {
505                         "data": "",
506                         "render": function(data, type, row, meta) {
507                             var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '" class="previewData">' + _("Order") + '</a><br>'
508                                 + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("MARC") + '</a><br>'
509                                 + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("Card") + '</a>';
510                             return result;
511                         },
512                         "orderable": false,
513                         "searchable": false
514                     },
515                     {
516                         "data": "replacement_price",
517                         "render": function(data, type, row, meta) {
518                             return escape_price(row.replacement_price);
519                         },
520                     },
521                     {
522                         "data": "quantity",
523                         "orderable": true
524                     },
525                     {
526                         "data": "ecost",
527                         "render": function(data, type, row, meta) {
528                             return escape_price(row.ecost);
529                         },
530                     },
531                     {
532                         "data": "",
533                         "render": function(data, type, row, meta) {
534                             return escape_price(row.quantity * row.ecost);
535                         },
536                         "orderable": false, // FIXME: How can we do it in DBIC?
537                         "searchable": false
538                     },
539                     {
540                         "data": "fund.name",
541                         "render": function(data, type, row, meta) {
542                             if (type != 'display') return escape_str(data);
543                             return escape_str(row.fund.name);
544                         }
545                     },
546                     {
547                         "data": "",
548                         "render": function(data, type, row, meta) {
549                             return '<a href="orderreceive.pl?ordernumber='
550                                     + encodeURIComponent(row.order_id) + '&amp;invoiceid=[% invoiceid | uri %]' + '">'
551                                     + _("Receive") + '</a><br/>'
552                                     + '<a href="#" onclick="transfer_order_popup(' + escape_str(row.order_id) + '); return false;">'
553                                     + _("Transfer") + '</a>';
554                         },
555                         "orderable": false,
556                         "searchable": false
557                     },
558                     {
559                         "data": "",
560                         "render": function(data, type, row, meta) {
561                             var result = "";
562
563                             if ( row.current_holds_count > 0 ) {
564                                 result += '<span class="button" title="'
565                                         + _("Can't cancel order, (%s) holds are linked with this order. Cancel holds first").format( escape_str(row.holds_count) ) + '">'
566                                         + _("Can't cancel order") + '</span><br/>';
567                             }
568                             else {
569                                 result += '<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber='
570                                             + encodeURIComponent(row.order_id)
571                                             + '&biblionumber=' + encodeURIComponent(row.biblio_id)
572                                             + '&referrer=/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">'
573                                             + _("Cancel order") + '</a><br/>';
574                             }
575
576                             if ( row.biblio != null ) {
577                                 if ( row.biblio.items_count - row.items.length > 0 ||
578                                     row.biblio.active_orders_count > 1 ||
579                                     row.biblio.subscriptions_count > 0 ||
580                                     row.biblio.holds_count > 0 ) { // biblio can be deleted
581                                     result += '<span class="button" title="'
582                                             + _("Can't delete catalog record, see constraints below") + '">'
583                                             + _("Can't cancel order and delete catalog record") + '</span><br>';
584                                 }
585                                 else {
586                                     result += '<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber='
587                                             + encodeURIComponent(row.order_id) + '&biblionumber=' + encodeURIComponent(row.biblio_id)
588                                             + '&del_biblio=1&referrer="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[$ invoiceid | uri ]">'
589                                             + _("Cancel order and catalog record") + '</a><br/>';
590                                 }
591
592                                 if ( row.biblio.items_count - row.items.length > 0 ) {
593                                     result += '<strong title="'
594                                             + _("Can't delete catalog record, because of %s existing item(s)").format(row.items.length)
595                                             +'">' + (row.biblio.items_count - row.items.length) + _(" item(s) left") + '</strong><br/>';
596                                 }
597
598                                 if ( row.biblio.active_orders_count > 1 ) {
599                                     result += '<strong title="'
600                                             + _("Can't delete catalog record, delete other orders linked to it first") + '">'
601                                             + (row.biblio.active_orders_count - 1) + _(" order(s) left") + '</strong><br/>';
602                                 }
603
604                                 if ( row.biblio.subscriptions_count > 0 ) {
605                                     result += '<strong title="' + _("Can't delete catalog record, delete subscriptions first") + '">'
606                                             + _("%s subscription(s) left").format(row.biblio.subscriptions_count)
607                                             + '</strong><br>';
608                                 }
609
610                                 if ( row.biblio.holds_count > 0 ) {
611                                     result += '<strong title="' + _("Can't delete catalog record or order, cancel holds first") + '">'
612                                             + _("%s hold(s) left").format(row.biblio.holds_count) + '</strong>';
613                                 }
614                             }
615
616                             return result;
617                         },
618                         "orderable": false,
619                         "searchable": false
620                     }
621                 ]
622             }, {}, 1, {"basket.vendor_id": [% booksellerid | html %]});
623
624             $(".previewData").on("click", function(e){
625                 e.preventDefault();
626                 var ltitle = $(this).text();
627                 var page = $(this).attr("href");
628                 $("#dataPreviewLabel").text(ltitle);
629                 $("#dataPreview .modal-body").load(page + " div");
630                 $('#dataPreview').modal({show:true});
631             });
632
633             $("#dataPreview").on("hidden.bs.modal", function(){
634                 $("#dataPreviewLabel").html("");
635                 $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
636             });
637         });
638
639         // Case-insensitive version of jquery's contains function
640         jQuery.extend(jQuery.expr[':'], {
641             icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
642         });
643
644         // Contains exactly function
645         jQuery.extend(jQuery.expr[':'], {
646             containsExactly: "$(a).text() == m[3]"
647         });
648
649         function transfer_order_popup(ordernumber) {
650         var url = "/cgi-bin/koha/acqui/transferorder.pl?"
651             + "ordernumber=" + ordernumber
652             window.open(url, 'TransferOrder');
653         }
654     </script>
655 [% END %]
656
657 [% INCLUDE 'intranet-bottom.inc' %]