Merged changes from stable branch up to 2.3.12
[fa-stable.git] / sales / includes / db / cust_trans_db.inc
index 1d6ffd79833d579edba5c10afa5c7a4d571d38a2..1458b82279ee5d4894dc0646619c9067ed571ea1 100644 (file)
@@ -146,7 +146,9 @@ function get_customer_trans($trans_id, $trans_type)
                .TB_PREF."tax_groups.id AS tax_group_id ";
        }
 
-       $sql .= " FROM ".TB_PREF."debtor_trans trans, ".TB_PREF."debtors_master cust";
+       $sql .= " FROM ".TB_PREF."debtor_trans trans LEFT JOIN ".TB_PREF."comments com ON trans.type=com.type AND trans.trans_no=com.id
+                                       LEFT JOIN ".TB_PREF."shippers ON ".TB_PREF."shippers.shipper_id=trans.ship_via, 
+                                       ".TB_PREF."debtors_master cust";
 
        if ($trans_type == ST_CUSTPAYMENT) {
                // it's a payment so also get the bank account
@@ -155,8 +157,7 @@ function get_customer_trans($trans_id, $trans_type)
 
        if ($trans_type == ST_SALESINVOICE || $trans_type == ST_CUSTCREDIT || $trans_type == ST_CUSTDELIVERY) {
                // it's an invoice so also get the shipper, salestypes
-               $sql .= ", ".TB_PREF."shippers, "
-               .TB_PREF."sales_types, "
+               $sql .= ", ".TB_PREF."sales_types, "
                .TB_PREF."cust_branch branch, "
                .TB_PREF."tax_groups ";
        }
@@ -174,8 +175,7 @@ function get_customer_trans($trans_id, $trans_type)
        }
        if ($trans_type == ST_SALESINVOICE || $trans_type == ST_CUSTCREDIT || $trans_type == ST_CUSTDELIVERY) {
                // it's an invoice so also get the shipper
-               $sql .= " AND ".TB_PREF."shippers.shipper_id=trans.ship_via
-                       AND ".TB_PREF."sales_types.id = trans.tpe
+               $sql .= " AND ".TB_PREF."sales_types.id = trans.tpe
                        AND branch.branch_code = trans.branch_code
                        AND branch.tax_group_id = ".TB_PREF."tax_groups.id ";
        }