Bug 18639: Add replacementprice field to acquisitions workflow
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / parcel.tt
index f867d6c..3eff906 100644 (file)
+[% USE raw %]
+[% USE Asset %]
+[% USE Koha %]
+[% USE KohaDates %]
+[% USE Price %]
+[% USE currency = format('%.2f') -%]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( date ) %]
-            Receipt summary for [% name %] [% IF ( invoice ) %]invoice [% invoice %][% END %] on [% formatteddatereceived %][% ELSE %]Receive orders from [% name %][% END %]</title>
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+            Receipt summary for [% name | html %] [% IF ( invoice ) %]invoice [% invoice | html %][% END %] on [% datereceived | $KohaDates %][% ELSE %]Receive orders from [% name | html %][% END %]</title>
+[% Asset.css("css/datatables.css") | $raw %]
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-[% INCLUDE 'datatables-strings.inc' %]
-<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
-[% INCLUDE 'greybox.inc' %]
-<script type="text/javascript" src="[% yuipath %]/json/json-min.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-
-    dt_overwrite_html_sorting_localeCompare();
-
-    $(document).ready(function(){
-        var pendingt = $("#pendingt").dataTable($.extend(true, {}, dataTablesDefaults, {
-            "bStateSave": true,
-            "iCookieDuration": 60*60*24*1000, // 1000 days
-            "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
-            "aoColumnDefs": [
-                { "aTargets": [ 3, 8, 9 ], "bSortable": false, "bSearchable": false },
-            ],
-            "aoColumns": [
-                { "sType": "num-html" },
-                { "sType": "num-html" },
-                { "sType": "html" },
-                null,
-                null,
-                null,
-                null,
-                null,
-                null,
-                null,
-            ],
-            "sPaginationType": "four_button"
-        } ) );
-        var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
-            "bStateSave": true,
-            "iCookieDuration": 60*60*24*1000, // 1000 days
-            "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
-            "aoColumnDefs": [
-                { "aTargets": [ 3, -1 ], "bSortable": false, "bSearchable": false },
-            ],
-            "aoColumns": [
-                { "sType": "num-html" },
-                { "sType": "num-html" },
-                { "sType": "html" },
-                null,
-                null,
-                null,
-                null,
-                null,
-                null
-            ],
-            "sPaginationType": "four_button"
-        } ) );
-/*
-    $("#pendingt").tablesorter({
-               headers: { 2: { sorter: 'articles' },3: { sorter: false },8:{sorter:false}}
-    });
-*/
-
-    });
-
-     // Case-insensitive version of jquery's contains function
-     jQuery.extend(jQuery.expr[':'], {
-           icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
-     });
-
-     // Contains exactly function
-     jQuery.extend(jQuery.expr[':'], {
-          containsExactly: "$(a).text() == m[3]"
-     });
-
-//]]>
-</script>
-<script type="text/javascript">
-//<![CDATA[
-            function confirm_delete_item(ordernumber, basketno, biblionumber) {
-                var is_confirmed = confirm(_('Are you sure you want to delete this order ?'));
-                if (is_confirmed) {
-                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber;
-                }
-            }
-            
-            function confirm_delete_biblio(ordernumber, basketno, biblionumber) {
-                var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
-                if (is_confirmed) {
-                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber+"&delbiblio=1";
-                    }
-            }
-//]]>
-</script>
 </head>
+
 <body id="acq_parcel" class="acq">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'acquisitions-search.inc' %]
 
 <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;
-    [% IF ( datereceived ) %]
-        Receipt summary for <i>[% name %]</i>
+    [% IF datereceived %]
+        Receipt summary for <i>[% name | html %]</i>
         [% IF ( invoice ) %]
-            <i>[ [% invoice %] ]</i>
+            <i>[ [% invoice | html %] ]</i>
         [% END %]
-        on <i>[% formatteddatereceived %]</i>
+        on <i>[% datereceived | $KohaDates %]</i>
     [% ELSE %]
-        Receive orders from [% name %]
+        Receive orders from [% name | html %]
     [% END %]
 </div>
 
-<div id="doc3" class="yui-t2">
 
-   <div id="bd">
-       <div id="yui-main">
-       <div class="yui-b">
+<div class="main container-fluid">
+    <div class="row">
+        <div class="col-sm-10 col-sm-push-2">
+            <main>
+
        [% IF ( receive_error ) %]
        <div class="dialog alert">
        <h3>Error adding items:</h3>
        <ul>
        [% FOREACH error_loo IN error_loop %]
-               <li>[% error_loo.error_param %][% IF ( error_loo.error_duplicate_barcode ) %]Duplicate Barcode[% END %] <!-- todo: other error conditions come here. --></li>
+               <li>[% error_loo.error_param | html %][% IF ( error_loo.error_duplicate_barcode ) %]Duplicate Barcode[% END %] <!-- todo: other error conditions come here. --></li>
        [% END %]
        </ul>
        </div>
        [% END %]
     <h1>
-        [% IF ( datereceived ) %]
-            Receipt summary for <i>[% name %]</i> [% IF ( invoice ) %] <i> [ [% invoice %] ] </i>[% END %] on <i>[% formatteddatereceived %]</i>
+        [% IF datereceived %]
+            Receipt summary for <i>[% name | html %]</i> [% IF ( invoice ) %] <i> [ [% invoice | html %] ] </i>[% END %] on <i>[% datereceived | $KohaDates %]</i>
         [% ELSE %]
-            Receive orders from [% name %]
+            Receive orders from [% name | html %]
         [% END %]
     </h1>
 
     [% END %]
 
     [% IF (error_cancelling_receipt) %]
-      <div class="error">
+      <div class="dialog error">
       Cannot cancel receipt. Possible reasons :
       <ul>
         <li>
       </div>
     [% END %]
 
+    [% IF error_invoice_not_known %]
+        <div class="dialog error">
+            The invoice referenced by this invoiceid does not exist.
+        </div>
+    [% END %]
+
+[% UNLESS no_orders_to_display %]
 <div id="acqui_receive_summary">
-<p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
+<p><strong>Invoice number:</strong> [% invoice | html %] <strong>Received by:</strong> [% logged_in_user.userid | html %]<strong>On:</strong> [% datereceived | $KohaDates %]</p>
 </div>
 [% UNLESS (invoiceclosedate) %]
-<div id="acqui_receive_search">
+  <div id="acqui_receive_search">
     <h3>Pending orders</h3>
 
- [% IF ( loop_orders ) %]<table id="pendingt">
-    <thead>
-        <tr>
+    [% IF ( loop_orders ) %]
+      <table id="pendingt">
+        <thead>
+          <tr>
+            <th>Basket search</th>
+            <th>Basket group search</th>
+            <th>Order line search</th>
+            <th>Summary search</th>
+            <th>&nbsp;</th>
+            <th>Replacement price search</th>
+            <th>Quantity search</th>
+            <th>Unit cost search</th>
+            <th>Order cost search</th>
+            <th>Fund search</th>
+            <th>&nbsp;</th>
+            <th>&nbsp;</th>
+          </tr>
+          <tr>
             <th>Basket</th>
+            <th>Basket group</th>
             <th>Order line</th>
             <th>Summary</th>
-            <th>View record</th>
+            <th>More</th>
+            <th>Replacement price</th>
             <th>Quantity</th>
             <th>Unit cost</th>
             <th>Order cost</th>
             <th>Fund</th>
             <th>&nbsp;</th>
             <th>&nbsp;</th>
-        </tr>
-    </thead>
-    <tbody class="filterclass">
+          </tr>
+        </thead>
+        <tbody class="filterclass">
         [% FOREACH loop_order IN loop_orders %]
             <tr>
-                <td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno %]">[% loop_order.basketno %]</a></td>
-                <td class="orderfilterclass"><a href="neworderempty.pl?ordernumber=[% loop_order.ordernumber %]&amp;booksellerid=[% loop_order.booksellerid %]">[% loop_order.ordernumber %]</a></td>
+                <td class="basketfilterclass">[% loop_order.basketname | html %] (<a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno | html %]">[% loop_order.basketno | html %]</a>)</td>
+                <td>
+                  [% IF loop_order.basketgroupid %]
+                    [% loop_order.basketgroupname | html %] (<a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% loop_order.booksellerid | html %]">[% loop_order.basketgroupid | html %]</a>)
+                  [% ELSE %]
+                    No basket group
+                  [% END %]
+                </td>
+                <td class="orderfilterclass"><a href="neworderempty.pl?ordernumber=[% loop_order.ordernumber | html %]&amp;booksellerid=[% loop_order.booksellerid | html %]">[% loop_order.ordernumber | html %]</a></td>
                 <td class="summaryfilterclass">
-                  <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_order.biblionumber %]">[% loop_order.title |html %]</a>
-                [% IF ( loop_order.author ) %] by [% loop_order.author %][% END %]
-                [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn %][% END %]
-                [% IF ( loop_order.publishercode ) %]<br />Publisher :[% loop_order.publishercode %][% END %]
+                  <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_order.biblionumber | html %]">[% loop_order.title | html %]</a>
+                [% IF ( loop_order.author ) %] by [% loop_order.author | html %][% END %]
+                [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn | html %][% END %]
+                [% IF ( loop_order.publishercode ) %]
+                    <br />Publisher: [% loop_order.publishercode | html %]
+                    [%- IF    ( loop_order.publicationyear > 0) -%], [% loop_order.publicationyear | html %]
+                    [%- ELSIF ( loop_order.copyrightdate   > 0) -%] [% loop_order.copyrightdate | html %]
+                    [% END %]
+                [% END %]
                 [% IF ( loop_order.suggestionid ) %]
                     <br/>
-                    Suggested by: [% loop_order.surnamesuggestedby %][% IF ( loop_order.firstnamesuggestedby ) %], [% loop_order.firstnamesuggestedby %] [% END %]
-                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid %]&amp;op=show">suggestion #[% loop_order.suggestionid %]</a>)
+                    Suggested by: [% loop_order.surnamesuggestedby | html %][% IF ( loop_order.firstnamesuggestedby ) %], [% loop_order.firstnamesuggestedby | html %] [% END %]
+                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid | html %]&amp;op=show">suggestion #[% loop_order.suggestionid | html %]</a>)
                 [% END %]
                 <br />
-                [% IF ( loop_order.notes ) %]
-                    <p class="ordernote"><strong>Note: </strong>[% loop_order.notes|html %] [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Fbooksellerid=[% loop_order.booksellerid %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]">Change note</a>]</p>
+                [% IF ( loop_order.order_internalnote ) %]
+                    <p class="ordernote"><strong>Internal note: </strong>[% loop_order.order_internalnote | html %] [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber | html %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | html %]&type=internal">Change internal note</a>]</p>
+                [% ELSE %]
+                    [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber | html %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | html %]&type=internal">Add internal note</a>]
+                [% END %]
+                [% IF ( loop_order.order_vendornote ) %]
+                    <p class="ordernote"><strong>Vendor note: </strong>[% loop_order.order_vendornote | html %]</p>
                 [% ELSE %]
-                    [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Fbooksellerid=[% loop_order.booksellerid %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]">Add note</a>]
+                    [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber | html %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | html %]&type=vendor">Add vendor note</a>]
                 [% END %]
                 </td>
-                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
-                <td>[% loop_order.quantity %]</td>
-                <td>[% loop_order.ecost %]</td>
-                <td>[% loop_order.ordertotal %]</td>
-                <td>[% loop_order.budget_name %]</td>
+                <td>
+                  <a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=[% loop_order.ordernumber | html %]" class="previewData">Order</a><br>
+                  <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber | html %]" class="previewData">MARC</a><br>
+                  <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber | html %]" class="previewData">Card</a>
+                </td>
+                <td>[% loop_order.replacementprice | $Price | html %]</td>
+                <td>[% loop_order.quantity | html %]</td>
+                <td>[% loop_order.ecost | $Price | html %]</td>
+                <td>[% loop_order.total | $Price | html %]</td>
+                <td>[% loop_order.budget_name | html %]</td>
                                <td>
-                              <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;invoiceid=[% invoiceid %]">Receive</a>
+                              <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber | html %]&amp;invoiceid=[% invoiceid | html %]">Receive</a>
+                    <br />
+                    <a href="#" onclick="transfer_order_popup([% loop_order.ordernumber | html %]); return false;">Transfer</a>
                                </td>
                                <td>
                         [% IF ( loop_order.left_holds_on_order ) %]
-                        <span class="button" title="Can't delete order, ([% loop_order.holds_on_order %]) holds are linked with this order cancel holds first">Can't delete order</span><br>
+                        <span class="button" title="Can't cancel order, ([% loop_order.holds_on_order | html %]) holds are linked with this order cancel holds first">Can't cancel order</span><br>
                         [% ELSE %]
-                        <a href="javascript:confirm_delete_item([% loop_order.ordernumber %], [% loop_order.basketno %], [% loop_order.biblionumber %])" class="button">Delete order</a><br>
+                        <a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% loop_order.ordernumber | html %]&biblionumber=[% loop_order.biblionumber | html %]&referrer=[% "/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid" | uri %]">Cancel order</a><br />
                         [% END %]
                         [% IF ( loop_order.can_del_bib ) %]
-                        <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %], [% loop_order.basketno %], [% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
+                        <a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% loop_order.ordernumber | html %]&biblionumber=[% loop_order.biblionumber | html %]&del_biblio=1&referrer=[% "/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid" | uri %]">Cancel order and catalog record</a><br />
                         [% ELSE %]
-                        <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
+                        <span class="button" title="Can't delete catalog record, see constraints below">Can't cancel order and delete catalog record</span><br>
                         [% END %]
                         [% IF ( loop_order.left_item ) %]
-                        <b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
+                        <b title="Can't delete catalog record, because of [% loop_order.items | html %] existing item(s)" >[% loop_order.items | html %] item(s) left</b><br>
                         [% END %]
                         [% IF ( loop_order.left_biblio ) %]
-                        <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
+                        <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios | html %] order(s) left</b><br>
                         [% END %]
                         [% IF ( loop_order.left_subscription ) %]
-                        <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
+                        <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions | html %] subscription(s) left</b><br>
                         [% END %]
                         [% IF ( loop_order.left_holds ) %]
-                        <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
+                        <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds | html %] hold(s) left</b>
                         [% END %]
                     </td>
                 </tr>
-            [% END %]
-        </tbody>
-         </table>[% ELSE %]There are no pending orders.[% END %]
-       <div id="resultnumber">
-        <!-- Row of numbers corresponding to search result pages -->
-        [% IF ( displayprev ) %]
-            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% prevstartfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">&lt;&lt; Previous</a>
         [% END %]
-        [% FOREACH number IN numbers %]
-            [% IF ( number.highlight ) %]
-            <span class="current">[% number.number %]</span>
-            [% ELSE %]
-            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% number.startfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">[% number.number %]</a>
-            [% END %]
-        [% END %]
-        [% IF ( displaynext ) %]
-            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% nextstartfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">Next &gt;&gt;</a>
-        [% END %]
-        </div>
-    </div>
+        </tbody>
+      </table>
+    [% ELSE %]There are no pending orders.[% END %]
+  </div>
 [% ELSE %]
     <p>
         Invoice is closed, so you can't receive orders anymore.
-        <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]&referer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Reopen it</a>.
+        <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid | html %]&referer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | html %]">Reopen it</a>.
     </p>
 [% END %]
 
 <div id="acqui_receive_receivelist">
     <h3>Already received</h3>
 
-
    [% IF ( loop_received ) %]
    <form action="/cgi-bin/koha/acqui/parcel.pl" method="get" name="orderform">
     <table id="receivedt">
-        <thead>
-           <tr>
-               <th>Basket</th>
-        <th>Order line</th>
-               <th>Summary</th>
-        <th>View record</th>
-               <th>Quantity</th>  
-               <th>Est cost</th>
-               <th>Actual cost</th>
-               <th>TOTAL</th>
-        <th></th>
-           </tr>
-    </thead>
+      <thead>
+        <tr>
+          <th>Basket</th>
+          <th>Basket group</th>
+          <th>Order line</th>
+          <th title="Item holds / Total holds">Holds</th>
+          <th>Summary</th>
+          <th>More</th>
+          <th>Replacement price</th>
+          <th>Quantity</th>
+          <th>Fund</th>
+          <th>Est cost</th>
+          <th>Actual cost</th>
+          <th>TOTAL</th>
+          <th></th>
+        </tr>
+      </thead>
     <tfoot>
+        [% FOREACH key IN subtotal_for_funds.keys.sort %]
+            <tr>
+                [% IF invoiceincgst %]
+                    <td colspan="6" class="total">(Tax inc.)</td>
+                [% ELSE %]
+                    <td colspan="6" class="total">(Tax exc.)</td>
+                [% END %]
+                <td colspan="2"><i>Subtotal for</i> [% key | html %]</td>
+                <td>[% subtotal_for_funds.$key.ecost | $Price | html %]</td>
+                <td>[% subtotal_for_funds.$key.unitprice | $Price | html %]</td>
+                <td>&nbsp;</td>
+                <td>&nbsp;</td>
+            </tr>
+        [% END %]
         <tr>
-            <th colspan="7" class="total">Total tax exc.</th>
-            <th>[% total_gste %]</th>
+            <th colspan="10" class="total">Total tax exc.</th>
+            <th>[% total_tax_excluded | $Price | html %]</th>
             <th></th>
         </tr>
         [% FOREACH book_foot IN book_foot_loop %]
             <tr>
-                <th colspan="7">Total (GST [% book_foot.gstrate * 100 | format ("%.1f") %]%)</th>
-                <th>[% book_foot.value %]</th>
+                <th colspan="10">Total (GST [% book_foot.tax_rate * 100 | html %]%)</th>
+                <th>[% book_foot.tax_value | $Price | html %]</th>
                 <th></th>
             </tr>
         [% END %]
         <tr>
-            <th colspan="7" class="total">Total tax inc.</th>
-            <th>[% total_gsti %]</th>
+            <th colspan="10" class="total">Total tax inc.</th>
+            <th>[% total_tax_included | $Price | html %]</th>
             <th></th>
         </tr>
     </tfoot>
-       <tbody class="filterclass">
-           [% FOREACH loop_receive IN loop_received %]
+    <tbody class="filterclass">
+        [% FOREACH order IN loop_received %]
             <tr>
-                <td><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_receive.basketno %]">[% loop_receive.basketno %]</a></td>
-                <td><a href="neworderempty.pl?ordernumber=[% loop_receive.ordernumber %]&amp;booksellerid=[% booksellerid %]">[% loop_receive.ordernumber %]</a></td>
-                <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_receive.biblionumber %]">[% loop_receive.title |html %]</a>
-                [% IF ( loop_receive.author ) %] / [% loop_receive.author %][% END %]
-                [% IF ( loop_receive.isbn ) %] - [% loop_receive.isbn %][% END %]
-                [% IF ( loop_receive.publishercode ) %]<br />Publisher :[% loop_receive.publishercode %][% END %]
-                [% IF ( loop_receive.suggestionid ) %]
+                <td>[% order.basketname | html %] (<a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% order.basketno | html %]">[% order.basketno | html %]</a>)</td>
+                <td>
+                  [% IF order.basketgroupid %]
+                    [% order.basketgroupname | html %] (<a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% order.booksellerid | html %]">[% order.basketgroupid | html %]</a>)
+                  [% ELSE %]
+                    No basket group
+                  [% END %]
+                </td>
+                <td>
+                  <a href="neworderempty.pl?ordernumber=[% order.ordernumber | html %]&amp;booksellerid=[% booksellerid | html %]">[% order.ordernumber | html %]</a>
+                  [% IF (order.parent_ordernumber && (order.parent_ordernumber != order.ordernumber)) %]
+                    (<a href="neworderempty.pl?ordernumber=[% order.parent_ordernumber | html %]&amp;booksellerid=[% booksellerid | html %]" title="Original order line">[% order.parent_ordernumber | html %]</a>)
+                  [% END %]
+                </td>
+                <td>
+                  [% IF order.total_holds > 0 %]
+                    [% IF order.item_holds > 0 %]
+                      <span class="error"><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% order.biblionumber | html %]">[% order.item_holds | html %]</a></span>
+                    [% ELSE %]
+                      0
+                    [% END %]
+                    /
+                    <span class="error"><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% order.biblionumber | html %]">[% order.total_holds | html %]</a></span>
+                  [% ELSE %]
+                    0
+                  [% END %]
+                </td>
+                <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% order.biblionumber | html %]">[% order.title | html %]</a>
+                [% IF ( order.author ) %] / [% order.author | html %][% END %]
+                [% IF ( order.isbn ) %] - [% order.isbn | html %][% END %]
+                [% IF ( order.publishercode ) %]
+                    <br />Publisher: [% order.publishercode | html %]
+                    [%- IF    ( order.publicationyear > 0) -%], [% order.publicationyear | html %]
+                    [%- ELSIF ( order.copyrightdate   > 0) -%] [% order.copyrightdate | html %]
+                    [% END %]
+                [% END %]
+                [% IF ( order.suggestionid ) %]
                     <br/>
-                    Suggested by: [% loop_receive.surnamesuggestedby %][% IF ( loop_receive.firstnamesuggestedby ) %], [% loop_receive.firstnamesuggestedby %] [% END %]
-                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_receive.suggestionid %]&amp;op=show">suggestion #[% loop_receive.suggestionid %]</a>)
+                    Suggested by: [% order.surnamesuggestedby | html %][% IF ( order.firstnamesuggestedby ) %], [% order.firstnamesuggestedby | html %] [% END %]
+                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% order.suggestionid | html %]&amp;op=show">suggestion #[% order.suggestionid | html %]</a>)
                 [% END %]
                 </td>
-                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
-                <td>[% loop_receive.quantityreceived %]</td>
-                <td>[% loop_receive.ecost %]</td>
-                <td>[% loop_receive.unitprice %]</td>
-                <td>[% loop_receive.total %]</td>
                 <td>
-                    [% IF (loop_receive.cannot_cancel) %]
+                  <a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=[% order.ordernumber | html %]" class="previewData">Order</a><br>
+                  <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% order.biblionumber | html %]" class="previewData">MARC</a><br>
+                  <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% order.biblionumber | html %]" class="previewData">Card</a>
+                </td>
+                <td>[% order.replacementprice | $Price | html %]</td>
+                <td>[% order.quantityreceived | html %]</td>
+                <td>[% order.budget.budget_name | html %]</td>
+                <td>[% order.ecost | $Price | html %]</td>
+                <td>[% order.unitprice | $Price | html %]</td>
+                <td>[% order.total | $Price | html %]</td>
+                <td>
+                    [% IF loop_receive.cannot_cancel or ( order.basket.effective_create_items == "receiving" and loop_receive.holds > 0 ) %]
+                      [% IF loop_receive.cannot_cancel %]
                         [% span_title = BLOCK %]
                             Cannot cancel receipt of this order line because it
                             was created from a partial receipt of order line no.
-                            [% loop_receive.parent_ordernumber %], which is
+                            [% order.parent_ordernumber | html %], which is
                             already received. Try cancelling this one first and
                             retry.
                         [% END %]
-                        <span title="[% span_title | collapse %]">
-                            Can't cancel receipt
-                        </span>
+                      [% ELSE %]
+                        [%# FIXME Here we block the cancellation if holds exist. Actually it could be possible if items will be exist after the deletion %]
+                        [%# Some additional checks should be added in the pl file %]
+                        [% span_title = BLOCK %]
+                          Cannot cancel receipt of this order line because at least one reservation exists on the records.
+                        [% END %]
+                      [% END %]
+                      <span title="[% span_title | collapse | html %]">
+                          Can't cancel receipt
+                      </span>
                     [% ELSE %]
-                        <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]&op=cancelreceipt&ordernumber=[% loop_receive.ordernumber %]">Cancel receipt</a>
+                        <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]&op=cancelreceipt&ordernumber=[% order.ordernumber | html %]">Cancel receipt</a>
                     [% END %]
                 </td>
             </tr>
        </tbody>
     </table>
     </form>
+
        [% ELSE %]There are no received orders.[% END %]
 </div>
 
-<!--<form action="/cgi-bin/koha/acqui/parcels.pl?booksellerid=[% booksellerid %]" method="post">-->
+<div id="dataPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
+    <div class="modal-dialog">
+    <div class="modal-content">
+    <div class="modal-header">
+        <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
+        <h3 id="dataPreviewLabel">MARC preview</h3>
+    </div>
+    <div class="modal-body">
+        <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
+    </div>
+    <div class="modal-footer">
+        <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
+    </div>
+    </div>
+    </div>
+</div>
+
 [% IF (invoiceclosedate) %]
-    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">View invoice</a>
+    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid | html %]">View invoice</a>
 [% ELSE %]
     <form action="/cgi-bin/koha/acqui/invoice.pl" method="get">
-        <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
+        <input type="hidden" name="invoiceid" value="[% invoiceid | html %]" />
         <fieldset class="action">
             <input type="submit" value="Finish receiving" />
         </fieldset>
     </form>
 [% END %]
 
-</div>
-</div>
-<div class="yui-b">
+[% END %]
+
+</main>
+</div> <!-- /.col-sm-10.col-sm-push-2 -->
+
+<div class="col-sm-2 col-sm-pull-10">
+<aside>
+
 <form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" method="post">
-        <fieldset class="brief">
+  <fieldset class="brief">
+    <h4>Filter</h4>
+    <ol>
+      <li>
+        <label for="summaryfilter">ISBN, author or title :</label>
+        <input type="text" name="summaryfilter" id="summaryfilter" value="[% summaryfilter | html %]"/>
+      </li>
+      <li>
+        <label for="basketfilter">Basket :</label>
+        <input type="text" name="basketfilter" id="basketfilter" value="[% basketfilter | html %]"/>
+      </li>
+      <li>
+          <label for="basketgroupnamefilter">Basket group name :</label>
+          <input type="text" name="basketgroupnamefilter" id="basketgroupnamefilter" value="[% basketgroupnamefilter | html %]" />
+      </li>
+      <li>
+        <label for="orderfilter">Order line :</label>
+        <input type="text" name="orderfilter" id="orderfilter" value="[% orderfilter | html %]"/>
+      </li>
+      [% IF (UNIMARC) %]
+        <li>
+          <label for="eanfilter">EAN :</label>
+          <input type="text" name="eanfilter" id="eanfilter" value="[% eanfilter | html %]"/>
+        </li>
+      [% END %]
+    </ol>
+    <fieldset class="action">
+      <input type="hidden" value="search" name="op" />
+      <input type="hidden" value="[% invoiceid | html %]" name="invoiceid" />
+      <input type="submit" value="Filter" />
+      <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]">Clear</a>
+    </fieldset>
+  </fieldset>
+</form>
+[% INCLUDE 'acquisitions-menu.inc' %]
+    </aside>
+</div> <!-- /.col-sm-2.col-sm-pull-10 -->
+</div> <!-- /.row -->
 
-            <h4>Filter</h4>
+[% MACRO jsinclude BLOCK %]
+    [% Asset.js("js/acquisitions-menu.js") | $raw %]
+    [% INCLUDE 'datatables.inc' %]
+    [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
+    [% Asset.js("lib/jquery/plugins/jquery.cookie.min.js") | $raw %]
+    <style>#dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }</style>
+    <script>
+        dt_overwrite_html_sorting_localeCompare();
+        var sticky_filters = [% sticky_filters | html %];
 
-           <ol>
+        $(document).ready(function(){
+          if ( $("#pendingt").length ) {
+            var pendingt = $("#pendingt").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "bStateSave": true,
+                "iCookieDuration": 60*60*24*1000, // 1000 days
+                "iDisplayLength": 10,
+                "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
+                "aoColumnDefs": [
+                    { "aTargets": [ 4, 9, 10 ], "bSortable": false, "bSearchable": false },
+                ],
+                "aoColumns": [
+                    { "sType": "html" },
+                    { "sType": "html" },
+                    { "sType": "num-html" },
+                    { "sType": "anti-the" },
+                    null,
+                    null,
+                    null,
+                    null,
+                    null,
+                    null,
+                    null,
+                    null,
+                ],
+                'bAutoWidth': false,
+                "sPaginationType": "four_button"
+            } )
+            ).columnFilter({
+                sPlaceHolder: "head:after",
+                aoColumns: [
+                    { type: "text" },
+                    { type: "text" },
+                    { type: "text" },
+                    { type: "text" },
+                    null,
+                    { type: "text" },
+                    { type: "text" },
+                    { type: "text" },
+                    { type: "text" },
+                    { type: "text" },
+                    null,
+                    null
+                ]
+            });
+          }
 
-               <li>
-                   <label for="summaryfilter">ISBN, author or title :</label>
-            <input type="text" name="summaryfilter" id="summaryfilter" value="[% summaryfilter %]"/>
-               </li>
+          if ( $("#receivedt").length ) {
+            var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "bStateSave": true,
+                "iCookieDuration": 60*60*24*1000, // 1000 days
+                "iDisplayLength": 10,
+                "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
+                "aoColumnDefs": [
+                    { "aTargets": [ 5, -1 ], "bSortable": false, "bSearchable": false },
+                ],
+                "aoColumns": [
+                    { "sType": "html" },
+                    { "sType": "html" },
+                    { "sType": "html" },
+                    { "sType": "num-html" },
+                    { "sType": "anti-the" },
+                    null,
+                    null,
+                    null,
+                    null,
+                    null,
+                    null,
+                    null
+                ],
+                "sPaginationType": "four_button"
+            }));
+          }
 
-               <li>
-                   <label for="basketfilter">Basket :</label>
-            <input type="text" name="basketfilter" id="basketfilter" value="[% basketfilter %]"/>
-               </li>
+          // Keep filters from finishreceive.pl to parcel.pl
+          $.cookie("filter_parcel_summary", $("#summaryfilter").val());
+          $.cookie("filter_parcel_basketname", $("#basketfilter").val());
+          $.cookie("filter_parcel_orderno", $("#orderfilter").val());
+          $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
+          $.cookie("filter_parcel_ean", $("#eanfilter").val());
 
-               <li>
-            <label for="orderfilter">Order line :</label>
-            <input type="text" name="orderfilter" id="orderfilter" value="[% orderfilter %]"/>
-               </li>
-                [% IF (UNIMARC) %]
-        <li>
-            <label for="eanfilter">EAN :</label>
-            <input type="text" name="eanfilter" id="eanfilter" value="[% eanfilter %]"/>
-        </li>
-                [% END %]
-           </ol>
-               <fieldset class="action">
-        <input type="hidden" value="search" name="op" />
-        <input type="hidden" value="[% invoiceid %]" name="invoiceid" />
-        <input type="submit" value="Filter" />
-        <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Clear</a>
-               </fieldset>
+          $("#filterform").on('submit', function(){
+            $.cookie("filter_parcel_summary", $("#summaryfilter").val());
+            $.cookie("filter_parcel_basketname", $("#basketfilter").val());
+            $.cookie("filter_parcel_orderno", $("#orderfilter").val());
+            $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
+            $.cookie("filter_parcel_ean", $("#eanfilter").val());
+          });
 
+            $(".previewData").on("click", function(e){
+                e.preventDefault();
+                var ltitle = $(this).text();
+                var page = $(this).attr("href");
+                $("#dataPreviewLabel").text(ltitle);
+                $("#dataPreview .modal-body").load(page + " div");
+                $('#dataPreview').modal({show:true});
+            });
+            $("#dataPreview").on("hidden", function(){
+                $("#dataPreviewLabel").html("");
+                $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
+            });
+
+        });
+
+         // Case-insensitive version of jquery's contains function
+         jQuery.extend(jQuery.expr[':'], {
+           icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
+         });
+
+         // Contains exactly function
+         jQuery.extend(jQuery.expr[':'], {
+              containsExactly: "$(a).text() == m[3]"
+         });
+
+         function transfer_order_popup(ordernumber) {
+            var url = "/cgi-bin/koha/acqui/transferorder.pl?"
+                + "ordernumber=" + ordernumber
+                window.open(url, 'TransferOrder');
+         }
+    </script>
+[% END %]
 
-        </fieldset>
-    </form>
-[% INCLUDE 'acquisitions-menu.inc' %]
-</div>
-</div>
 [% INCLUDE 'intranet-bottom.inc' %]