Invoice Prepaid Orders: Added new payments column for direct review of order invoicin...
[fa-stable.git] / sales / includes / db / sales_order_db.inc
index a6bb878cfa2f673127c266aea975cf3c543ed7f2..9b790ce65861573f8bd9e803455c41d5256eb44d 100644 (file)
@@ -89,6 +89,8 @@ function delete_sales_order($order_no, $trans_type)
        begin_transaction();
        hook_db_prevoid($trans_type, $order_no);
 
+       $order = get_sales_order_header($order_no, $trans_type);
+       
        $sql = "DELETE FROM ".TB_PREF."sales_orders WHERE order_no=" . db_escape($order_no) 
                . " AND trans_type=".db_escape($trans_type);
 
@@ -98,7 +100,7 @@ function delete_sales_order($order_no, $trans_type)
                .db_escape($order_no) . " AND trans_type=".db_escape($trans_type);
        db_query($sql, "order Detail Delete");
 
-       add_audit_trail($trans_type, $order_no, Today(), _("Deleted."));
+       add_audit_trail($trans_type, $order_no, sql2date($order['ord_date']), _("Deleted."));
        commit_transaction();
 }
 
@@ -491,7 +493,8 @@ function get_sql_for_sales_orders_view($trans_type, $trans_no, $filter,
                        allocs.ord_payments,
                        inv.inv_payments,
                        sorder.total,
-                       sorder.trans_type
+                       sorder.trans_type,
+                       sorder.debtor_no
                FROM ".TB_PREF."sales_orders as sorder
                LEFT JOIN (SELECT trans_no_to, sum(amt) ord_payments FROM ".TB_PREF."cust_allocations WHERE trans_type_to=".ST_SALESORDER." GROUP BY trans_no_to)
                         allocs ON sorder.trans_type=".ST_SALESORDER." AND allocs.trans_no_to=sorder.order_no
@@ -644,6 +647,6 @@ function last_sales_order_detail($order, $field)
 
         $last_query=db_query($sql, "Could not retrieve last order detail");
         $row = db_fetch_row($last_query);
-        return $row[0];
+        return $row == false ? false : $row[0];
 }