Paged transaction inquiries optimized for maximum links in Sales and Purchasing.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 18 Jul 2019 22:29:39 +0000 (00:29 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 18 Jul 2019 22:29:39 +0000 (00:29 +0200)
purchasing/includes/db/po_db.inc
purchasing/inquiry/po_search.php
purchasing/inquiry/po_search_completed.php
sales/inquiry/customer_inquiry.php
sales/inquiry/sales_orders_view.php

index 0afbe1626292c98bac2236a586afdabf2948e650..a904c2ff4b396cf47135975c05b31b6362a7dd61 100644 (file)
@@ -294,6 +294,8 @@ function get_sql_for_po_search_completed($from, $to, $supplier_id=ALL_TEXT, $loc
                porder.ord_date, 
                supplier.curr_code, 
                Sum(line.unit_price*line.quantity_ordered) AS OrderValue,
+               Sum(line.delivery_date < '". date2sql(Today()) ."'
+               AND (line.quantity_ordered > line.quantity_received)) As OverDue,
                porder.into_stock_location,
                chk.isopen
                FROM ".TB_PREF."purch_orders as porder
index 9e77d7104d038d8379f93ec974a29f5febaa30cb..efd650752943570cc799e37c4fe2154021840b2d 100644 (file)
@@ -123,8 +123,8 @@ $cols = array(
                _("Currency") => array('align'=>'center'), 
                _("Order Total") => 'amount',
                array('insert'=>true, 'fun'=>'edit_link'),
-               array('insert'=>true, 'fun'=>'prt_link'),
-               array('insert'=>true, 'fun'=>'receive_link')
+               array('insert'=>true, 'fun'=>'receive_link'),
+               array('insert'=>true, 'fun'=>'prt_link')
 );
 
 if (get_post('StockLocation') != ALL_TEXT) {
index 8c939aba7717cc474867caf8750512813b3b150f..4046424e69f39b5b0a0d504bdd9a97092800f1dd 100644 (file)
@@ -38,6 +38,15 @@ function edit_link($row)
                trans_editor_link(ST_PURCHORDER, $row["order_no"]);
 }
 
+function receive_link($row) 
+{
+       global $page_nested;
+       
+       return $page_nested || !$row['OverDue'] ? '' :
+               pager_link( _("Receive"),
+                       "/purchasing/po_receive_items.php?PONumber=" . $row["order_no"], ICON_RECEIVE);
+}
+
 function prt_link($row)
 {
        return print_document_link($row['order_no'], _("Print"), true, ST_PURCHORDER, ICON_PRINT);
@@ -116,7 +125,8 @@ $cols = array(
                _("Currency") => array('align'=>'center'), 
                _("Order Total") => 'amount',
                array('insert'=>true, 'fun'=>'edit_link'),
-               array('insert'=>true, 'fun'=>'prt_link'),
+               array('insert'=>true, 'fun'=>'receive_link'),
+               array('insert'=>true, 'fun'=>'prt_link')
 );
 
 if (get_post('StockLocation') != ALL_TEXT) {
index eb98d3dad278b040f247b8df3a2f75d7d4dd7bb7..4674989f729a5309669e483c321ed1ea2f9f473b 100644 (file)
@@ -70,9 +70,15 @@ function credit_link($row)
 
        if ($page_nested)
                return '';
-       return $row['type'] == ST_SALESINVOICE && $row["Outstanding"] > 0 ?
-               pager_link(_("Credit This") ,
-                       "/sales/customer_credit_invoice.php?InvoiceNumber=". $row['trans_no'], ICON_CREDIT):'';
+       if ($row["Outstanding"] > 0)
+       {
+               if ($row['type'] == ST_CUSTDELIVERY)
+                       return pager_link(_('Invoice'), "/sales/customer_invoice.php?DeliveryNumber=" 
+                               .$row['trans_no'], ICON_DOC);
+               else if ($row['type'] == ST_SALESINVOICE)
+                       return pager_link(_("Credit This") ,
+                       "/sales/customer_credit_invoice.php?InvoiceNumber=". $row['trans_no'], ICON_CREDIT);
+       }       
 }
 
 function edit_link($row)
index 2241e1f9dc05a7fe9c157f64d8e738280ec16a9c..bc2c15f93258a7cc442efcbe44fec00cced2cf94 100644 (file)
@@ -114,14 +114,19 @@ function edit_link($row)
 
 function dispatch_link($row)
 {
-       global $trans_type;
+       global $trans_type, $page_nested;
 
        if ($row['ord_payments'] + $row['inv_payments'] < $row['prep_amount'])
                return '';
 
        if ($trans_type == ST_SALESORDER)
-               return pager_link( _("Dispatch"),
-                       "/sales/customer_delivery.php?OrderNumber=" .$row['order_no'], ICON_DOC);
+       {
+               if ($row['TotDelivered'] < $row['TotQuantity'] && !$page_nested)
+                       return pager_link( _("Dispatch"),
+                               "/sales/customer_delivery.php?OrderNumber=" .$row['order_no'], ICON_DOC);
+               else
+                       return '';
+       }               
        else
                return pager_link( _("Sales Order"),
                        "/sales/sales_order_entry.php?OrderNumber=" .$row['order_no'], ICON_DOC);
@@ -302,6 +307,7 @@ if ($_POST['order_view_mode'] == 'OutstandingOnly') {
 } elseif ($trans_type == ST_SALESORDER) {
         array_append($cols,array(
                        _("Tmpl") => array('insert'=>true, 'fun'=>'tmpl_checkbox'),
+                                       array('insert'=>true, 'fun'=>'dispatch_link'),
                                        array('insert'=>true, 'fun'=>'edit_link'),
                                        array('insert'=>true, 'fun'=>'prt_link')));
 };