Bug 8037: (follow-up) fix undefined variable warning during template processing
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / parcel.tt
index c3b169d..db6783b 100644 (file)
@@ -1,31 +1,83 @@
+[% USE currency = format('%.2f') -%]
 [% 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" />
 [% INCLUDE 'doc-head-close.inc' %]
+[% INCLUDE 'datatables.inc' %]
+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
 [% INCLUDE 'greybox.inc' %]
-<script type="text/javascript" src="[% yuipath %]/json/json-min.js"></script>
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
 <script type="text/javascript">
 //<![CDATA[
 
-    var rowsToCollapse = 5;
-
-       $.tablesorter.addParser({
-           id: 'articles',
-           is: function(s) {return false;  },
-           format: function(s) { return s.toLowerCase().replace(/^(the|an|a) /,''); },
-           type: 'text'
-       });
+    dt_overwrite_html_sorting_localeCompare();
 
     $(document).ready(function(){
-    $("#pendingt").tablesorter({
-               headers: { 2: { sorter: 'articles' },3: { sorter: false },7:{sorter:false}}
-    });
+      if ( $("#pendingt").length ) {
+        var pendingt = $("#pendingt").dataTable($.extend(true, {}, dataTablesDefaults, {
+            "bStateSave": true,
+            "iCookieDuration": 60*60*24*1000, // 1000 days
+            "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 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,
+            ],
+            'bAutoWidth': false,
+            "sPaginationType": "four_button"
+        } )
+        ).columnFilter({
+            sPlaceHolder: "head:after",
+            aoColumns: [
+                { type: "text" },
+                { type: "text" },
+                { type: "text" },
+                null,
+                { type: "text" },
+                { type: "text" },
+                { type: "text" },
+                { type: "text" },
+                null,
+                null
+            ]
+        });
+      }
+
+      if ( $("#receivedt").length ) {
+        var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
+            "bStateSave": true,
+            "iCookieDuration": 60*60*24*1000, // 1000 days
+            "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
+            "aoColumnDefs": [
+                { "aTargets": [ 4, -1 ], "bSortable": false, "bSearchable": false },
+            ],
+            "aoColumns": [
+                { "sType": "num-html" },
+                { "sType": "num-html" },
+                { "sType": "html" },
+                { "sType": "html" },
+                null,
+                null,
+                null,
+                null,
+                null,
+                null,
+                null
+            ],
+            "sPaginationType": "four_button"
+        } ) );
+      }
 
-       rowCountPending  = $("#pendingt tbody.filterclass tr").length;
-       rowCountReceived = $("#receivedt tbody.filterclass tr").length;
-       if (rowCountPending  > rowsToCollapse) { pendingCollapse(); }
-       if (rowCountReceived > rowsToCollapse) { receivedCollapse(); }
     });
 
      // Case-insensitive version of jquery's contains function
           containsExactly: "$(a).text() == m[3]"
      });
 
-
-    // Collapse pending items table
-    function pendingCollapse() {
-       $("#pendingcollapserow").remove();
-    $("#pendingt tr").show();
-       $("#pendingt tbody.filterclass tr:gt(" + (rowsToCollapse-1) + ")").hide();
-       $("#pendingt").before("<p id=\"pendingcollapserow\">" + _("Only the first ")  + rowsToCollapse +  _(" items are displayed.") + "<a href=\"javascript:pendingExpand();\">" + _("Click here to show all ")  + rowCountPending + _(" items") + "<\/a>.<\/p>");
-
-    }
-
-    // Expend pending items table
-    function pendingExpand() {
-       $("#pendingcollapserow").remove();
-       $("#pendingt tr").show();
-    $("#pendingt tbody.filterclass tr.orderfound").remove();
-       $("#pendingt").before("<p id=\"pendingcollapserow\">" + rowCountPending + _(" items are displayed.") + "<a href=\"javascript:pendingCollapse();\">" + _("Click here to show only the first ") + rowsToCollapse + _(" items") + "<\/a>.<\/p>");
-    }
-
-    // Collapse already received items table
-    function receivedCollapse() {
-       $("#receivedcollapserow").remove();
-       $("#receivedt tbody.filterclass tr:gt(" + (rowsToCollapse-1) + ")").hide();
-       $("#receivedt").before("<p id=\"receivedcollapserow\">" + _("Only the first ") + rowsToCollapse + _(" items are displayed.") + "<a href=\"javascript:receivedExpand();\">" + _("Click here to show all ") + rowCountReceived + _(" items") + "<\/a>.<\/p>");
-    }
-
-    // Expand already received items table
-    function receivedExpand() {
-       $("#receivedcollapserow").remove();
-       $("#receivedt tr").show();
-       $("#receivedt").before("<p id=\"receivedcollapserow\">" + _("All ") + rowCountReceived + _(" items are displayed.") + "<a href=\"javascript:receivedCollapse();\">" + _("Click here to show only the first ") + rowsToCollapse + _(" items") + "<\/a>.<\/p>");
-    }
-
-    // Launch filtering
-    function filter() {
-
-    var summaryStatus = jQuery.trim($("#summaryfilter").val());
-       var basketStatus  = $("#basketfilter").val();
-       var orderStatus   = $("#orderfilter").val();
-    var eanStatus     = $("#eanfilter").val() || '';
-
-    if (summaryStatus == '' && basketStatus == '' && orderStatus == '' && eanStatus == '') { clearFilters(); return false; }
-
-       var filtered = "table#pendingt tbody.filterclass tr";
-
-       // We hide everything
-       $("#nothingfoundrow").remove();
-       $(filtered).hide();
-
-       // Do the search
-       var callback =  {
-               success: function(o) {
-                       var jsonString = o.responseText;
-                       var gst = "[% gst %]";
-                       try {
-                               var orders = YAHOO.lang.JSON.parse(jsonString);
-                               var foundCount = orders.length;
-
-                               for( i = 0 ; i < orders.length ; i++){
-                                       order = orders[i];
-                                       $('<tr class="orderfound">'
-                       + '<td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=' + order.basketno + '">' + order.basketno + '</a></td>'
-                       + '<td class="orderfilterclass"> <a href="neworderempty.pl?ordernumber=' + order.ordernumber + '&booksellerid=' + order.booksellerid + '">' + order.ordernumber + ' </a></td>'
-                       + '<td class="summaryfilterclass">'
-                       + '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + order.biblionumber + '">' + order.title + '</a>' + _(" by ") + order.author + '&nbsp;&ndash;&nbsp;' + order.isbn + '</td>'
-                       + '<td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + order.biblionumber + '" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + order.biblionumber + '" title="MARC" rel="gb_page_center[600,500]">Card</a></td>'
-                       + '<td>' + order.quantity + '</td>'
-                       + '<td>' + order.ecost + '</td>'
-                       + '<td>' + order.ordertotal + '</td>'
-                       + '<td>'
-                       + '<a href="orderreceive.pl?ordernumber=' + order.ordernumber + '&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]&amp;gst=' + gst + '&amp;freight=' + order.freight + '&amp;booksellerid=[% booksellerid %]">Receive</a> /'
-                       + '<a href="parcel.pl?type=intra&amp;ordernumber=' + order.ordernumber + '&amp;biblionumber=' + order.biblionumber + '&amp;action=cancelorder&amp;booksellerid=[% booksellerid %]&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]" onclick="return confirm(\'' + _('Are you sure you want to cancel this order?') + '\');">Cancel</a>'
-                       + '</td></tr>').appendTo("table#pendingt");
-                               }
-
-                               // If nothing has been found, we tell the user so
-                               if (orders.length == 0) {
-                                   $("<tr><td id=\"nothingfoundrow\" colspan=\"8\">No items match your criteria.<\/tr>").appendTo("#pendingt");
-                               }
-                       }catch(e){alert(e);}
-               }
-       }
-    var transaction = YAHOO.util.Connect.asyncRequest('GET', '/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% booksellerid %]&search='+summaryStatus+'&basketno='+basketStatus+'&orderno='+orderStatus+'&ean='+eanStatus+'&format=json', callback, null);
-
-       return false;
-    }
-
-    // Clear already applied filters
-    function clearFilters() {
-       $("#nothingfoundrow").remove();
-        $("#pendingt tbody.filterclass tr").show();
-        //$("#pendingt tbody.filterclass tr.orderfound").remove();
-       pendingExpand();
-    }
-
 //]]>
 </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 ?'));
+                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;
+                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber+"&invoiceid=[% invoiceid %]";
                 }
             }
             
-            function confirm_delete_biblio(ordernumber, biblionumber) {
-                var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
+            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";
+                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber+"&delbiblio=1&invoiceid=[% invoiceid %]";
                     }
             }
 
+            function transfer_order_popup(ordernumber) {
+                var url = "/cgi-bin/koha/acqui/transferorder.pl?"
+                    + "ordernumber=" + ordernumber
+                window.open(url, 'TransferOrder');
+            }
+
 //]]>
 </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 ( invoice ) %]<i>[ [% invoice %] ]</i>[% END %] on <i>[% formatteddatereceived %]</i>
-        [% ELSE %]
-            Receive orders from [% name %]
-        [% END %]</div>
+<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 ( invoice ) %]
+            <i>[ [% invoice %] ]</i>
+        [% END %]
+        on <i>[% formatteddatereceived %]</i>
+    [% ELSE %]
+        Receive orders from [% name %]
+    [% END %]
+</div>
 
 <div id="doc3" class="yui-t2">
 
        [% END %]
     [% END %]
 
+    [% IF (error_cancelling_receipt) %]
+      <div class="dialog error">
+      Cannot cancel receipt. Possible reasons :
+      <ul>
+        <li>
+          The order line you trying to cancel was created from a partial receipt
+          of another order line which is already received. Try to cancel this
+          one first and retry.
+        </li>
+        <li>
+          The order line you trying to cancel was created from a partial receipt
+          of another order line which has been deleted. Cancellation is not
+          possible.
+        </li>
+      </ul>
+      </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>
-       <!-- TODO: Add date picker, change rcv date. -->
 </div>
-<div id="acqui_receive_search">
+[% UNLESS (invoiceclosedate) %]
+  <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>Order line search</th>
+            <th>Summary search</th>
+            <th>&nbsp;</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>Order line</th>
             <th>Summary</th>
-        <th>View record</th>
+            <th>View record</th>
             <th>Quantity</th>
             <th>Unit cost</th>
             <th>Order cost</th>
+            <th>Fund</th>
             <th>&nbsp;</th>
             <th>&nbsp;</th>
-        </tr>
-    </thead>
-               <tfoot>
-            <tr><td colspan="4" class="total">TOTAL</td>
-                <td> [% totalPquantity %] </td>
-                               <td>&nbsp;</td>
-                <td>[% ordergrandtotal %]</td>
-                               <td>&nbsp;</td>
-                               <td>&nbsp;</td>
-            </tr>
-               </tfoot>
-    <tbody class="filterclass">
+          </tr>
+        </thead>
+        <tbody class="filterclass">
         [% FOREACH loop_order IN loop_orders %]
-       [% UNLESS ( loop.odd ) %]
-            <tr class="highlight">
-        [% ELSE %]
             <tr>
-        [% END %]
-                <td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno %]">[% loop_order.basketno %]</a></td>
+                <td class="basketfilterclass">[% loop_order.basketname %] (<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="summaryfilterclass">
                   <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_order.biblionumber %]">[% loop_order.title |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>
+                    <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%3Finvoiceid=[% invoiceid %]">Change note</a>]</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 %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Add 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="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]&amp;gst=[% loop_order.gst %]&amp;freight=[% loop_order.freight %]&amp;booksellerid=[% loop_order.booksellerid %]">Receive</a>
-                                   
+                              <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;invoiceid=[% invoiceid %]">Receive</a>
+                    <br />
+                    <a href="#" onclick="transfer_order_popup([% loop_order.ordernumber %]); 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>
-                    [% ELSE %]
-                    <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.basketno %],[% loop_order.biblionumber %])" class="button">Delete 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>
-                    [% ELSE %]
-                    <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and 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>
-                    [% 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>
-                    [% END %]
-                    [% IF ( loop_order.left_subscription ) %]
-                    <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] 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>
-                    [% END %]
-                               </td>
-            </tr>
+                        [% 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>
+                        [% ELSE %]
+                        <a href="javascript:confirm_delete_item([% loop_order.ordernumber %], [% loop_order.basketno %], [% loop_order.biblionumber %])" class="button">Delete 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>
+                        [% ELSE %]
+                        <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and 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>
+                        [% 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>
+                        [% END %]
+                        [% IF ( loop_order.left_subscription ) %]
+                        <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] 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>
+                        [% 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?type=intra&amp;booksellerid=[% booksellerid %]&amp;startfrom=[% prevstartfrom %][% IF ( datereceived ) %]&amp;datereceived=[% datereceived %][% END %][% IF ( invoice ) %]&amp;invoice=[% invoice %][% END %][% 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?type=intra&amp;booksellerid=[% booksellerid %]&amp;startfrom=[% number.startfrom %][% IF ( datereceived ) %]&amp;datereceived=[% datereceived %][% END %][% IF ( invoice ) %]&amp;invoice=[% invoice %][% END %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">[% number.number %]</a>
-               [% END %]
-       [% END %]
-       [% IF ( displaynext ) %]
-               <a href="parcel.pl?type=intra&amp;booksellerid=[% booksellerid %]&amp;startfrom=[% nextstartfrom %][% IF ( datereceived ) %]&amp;datereceived=[% datereceived %][% END %][% IF ( invoice ) %]&amp;invoice=[% invoice %][% END %][% 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>.
+    </p>
+[% END %]
+
 <div id="acqui_receive_receivelist">
     <h3>Already received</h3>
 
+
    [% IF ( loop_received ) %]
+       [% SET funds = {} %]
+       [% SET estimated_total = 0 %]
+
+       [% FOREACH loop_receive IN loop_received %]
+           [% IF (funds.${ loop_receive.budget.budget_name }.estimated == '') %]
+              [% SET funds.${ loop_receive.budget.budget_name }.estimated = 0 %]
+           [% END %]
+           [% IF (funds.${ loop_receive.budget.budget_name }.actual == '') %]
+              [% SET funds.${ loop_receive.budget.budget_name }.actual = 0 %]
+           [% END %]
+           [% SET estimated_total = estimated_total + ( loop_receive.ecost * loop_receive.quantityreceived ) %]
+           [% SET funds.${ loop_receive.budget.budget_name }.estimated = funds.${ loop_receive.budget.budget_name }.estimated + ( loop_receive.ecost * loop_receive.quantityreceived )%]
+           [% SET funds.${ loop_receive.budget.budget_name }.actual = funds.${ loop_receive.budget.budget_name }.actual + loop_receive.total %]
+       [% END %]
+
    <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>Basket</th>
+                <th>Order Line</th>
+                <th>Holds</th>
+                <th>Summary</th>
+                <th>View record</th>
+                <th>Quantity</th>
+                <th>Fund</th>
+                <th>Est cost</th>
+                <th>Actual cost</th>
+                <th>TOTAL</th>
+        <th></th>
            </tr>
-       </thead>
-<tfoot>
-           <tr>
-               <td colspan="4" class="total">SUBTOTAL</td>
-               <td colspan="2">&nbsp;</td>
-               <td>[% totalprice %]</td>
-               <td>[% tototal %]</td>
-           </tr>
-             
-             [% IF ( totalfreight ) %]
-                   <tr>
-                       <td colspan="6">&nbsp;
-               </td>
-                           <td>Shipping</td>
-               <td>[% totalfreight %]</td>
-               </tr> 
-           [% END %]
-             [% IF ( gst ) %]
-                   <tr>
-                       <td colspan="6">
-               <p class="message">
-                           <b>HELP</b><br />
-                   The total at the bottom of the page should be within a few cents of the total for the invoice.
-               </p>
-               </td>
-                           <td><b>Tax rate</b></td>
-               <td>[% gst %]</td>
-               </tr> 
-           [% END %]
-           <tr>
-           <td colspan="4" class="total">TOTAL</td>
-               <td>[% totalquantity %]</td>
-               <td colspan="2">&nbsp;</td>
-               <td>[% grandtot %]</td>
-           </tr>
-    </tfoot>
-       <tbody class="filterclass">
-           [% FOREACH loop_receive IN loop_received %]
-        [% UNLESS ( loop.odd ) %]
-            <tr class="highlight">
-        [% ELSE %]
+    </thead>
+    <tfoot>
+        [% FOREACH key IN funds.keys.sort %]
             <tr>
+                <td colspan="6" class="total">(Tax exc.)</td>
+                <td><i>Subtotal for</i> [% key %]</td>
+                <td>[% currency( funds.$key.estimated ) %]</td>
+                <td>[% currency( funds.$key.actual ) %]</td>
+                <td>&nbsp;</td>
+                <td>&nbsp;</td>
+            </tr>
         [% END %]
-                <td><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_receive.basketno %]">[% loop_receive.basketno %]</a></td>
+        <tr>
+            <th colspan="9" class="total">Total tax exc.</th>
+            <th>[% total_gste %]</th>
+            <th></th>
+        </tr>
+        [% FOREACH book_foot IN book_foot_loop %]
+            <tr>
+                <th colspan="9">Total (GST [% book_foot.gstrate * 100 | format ("%.1f") %]%)</th>
+                <th>[% book_foot.value %]</th>
+                <th></th>
+            </tr>
+        [% END %]
+        <tr>
+            <th colspan="9" class="total">Total tax inc.</th>
+            <th>[% total_gsti %]</th>
+            <th></th>
+        </tr>
+    </tfoot>
+    <tbody class="filterclass">
+        [% FOREACH loop_receive IN loop_received %]
+            <tr>
+                <td>[% loop_receive.basketname %] (<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>
+                  [% IF loop_receive.holds > 0 %]
+                    <span class="error"><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% loop_receive.biblionumber %]">[% loop_receive.holds %]</a></span>
+                  [% ELSE %]
+                    0
+                  [% END %]
+                </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 %]
                 </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.budget.budget_name %]</td>
                 <td>[% loop_receive.ecost %]</td>
                 <td>[% loop_receive.unitprice %]</td>
                 <td>[% loop_receive.total %]</td>
+                <td>
+                    [% 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
+                            already received. Try cancelling this one first and
+                            retry.
+                        [% END %]
+                        <span title="[% span_title | collapse %]">
+                            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>
+                    [% END %]
+                </td>
             </tr>
            [% END %]
        </tbody>
        [% ELSE %]There are no received orders.[% END %]
 </div>
 
-<!--<form action="/cgi-bin/koha/acqui/parcels.pl?booksellerid=[% booksellerid %]" method="post">-->
-<form action="parcels.pl?booksellerid=[% booksellerid %]" method="post">
-    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
-    <fieldset class="action">
-        <input type="submit" value="Finish receiving" />
-    </fieldset>
-</form>
+[% IF (invoiceclosedate) %]
+    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">View invoice</a>
+[% ELSE %]
+    <form action="/cgi-bin/koha/acqui/invoice.pl" method="get">
+        <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
+        <fieldset class="action">
+            <input type="submit" value="Finish receiving" />
+        </fieldset>
+    </form>
+[% END %]
+
+[% END %]
 
 </div>
 </div>
-<div class="yui-b">
-<form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" onsubmit="return filter();">
-        <fieldset class="brief">
-
-            <h4>Filter</h4>
-
-           <ol>
-
-               <li>
-                   <label for="summaryfilter">ISBN, author or title :</label>
-                   <input type="text" name="summaryfilter" id="summaryfilter" />
-               </li>
 
-               <li>
-                   <label for="basketfilter">Basket :</label>
-                   <input type="text" name="basketfilter" id="basketfilter" />
-               </li>
 
-               <li>
-            <label for="orderfilter">Order line :</label>
-                   <input type="text" name="orderfilter" id="orderfilter" />
-               </li>
-                [% IF (UNIMARC) %]
+<div class="yui-b">
+<form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" method="post">
+  <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 %]"/>
+      </li>
+      <li>
+        <label for="basketfilter">Basket :</label>
+        <input type="text" name="basketfilter" id="basketfilter" value="[% basketfilter %]"/>
+      </li>
+      <li>
+          <label for="basketgroupnamefilter">Basket group name :</label>
+          <input type="text" name="basketgroupnamefilter" id="basketgroupnamefilter" value="[% basketgroupnamefilter %]" />
+      </li>
+      <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" />
+          <label for="eanfilter">EAN :</label>
+          <input type="text" name="eanfilter" id="eanfilter" value="[% eanfilter %]"/>
         </li>
-                [% END %]
-           </ol>
-               <fieldset class="action">
-                   <input type="submit" value="Filter" />
-                   <a href="#" onclick="clearFilters();">Clear</a>
-               </fieldset>
-
-
-        </fieldset>
-    </form>
+      [% 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>
+  </fieldset>
+</form>
 [% INCLUDE 'acquisitions-menu.inc' %]
 </div>
 </div>
 [% INCLUDE 'intranet-bottom.inc' %]