Added customer search in Search not invoiced Deliveries.
[fa-stable.git] / sales / includes / db / cust_trans_db.inc
index 0b9663507e0d5c9d559ae56ddcb79d9f73b1f11d..19cdaea7b466509e4435e482dd037a5e116a0138 100644 (file)
@@ -125,7 +125,7 @@ function get_customer_trans($trans_id, $trans_type)
                ."cust.tax_id, "
                ."com.memo_";
 
-       if ($trans_type == ST_CUSTPAYMENT) {
+       if ($trans_type == ST_CUSTPAYMENT || $trans_type == ST_BANKDEPOSIT) {
                // it's a payment so also get the bank account
                // Chaitanya : Added bank_act to support Customer Payment Edit
                $sql .= ",bank_act,".TB_PREF."bank_accounts.bank_name, ".TB_PREF."bank_accounts.bank_account_name,
@@ -150,7 +150,7 @@ function get_customer_trans($trans_id, $trans_type)
                                        LEFT JOIN ".TB_PREF."shippers ON ".TB_PREF."shippers.shipper_id=trans.ship_via, 
                                        ".TB_PREF."debtors_master cust";
 
-       if ($trans_type == ST_CUSTPAYMENT) {
+       if ($trans_type == ST_CUSTPAYMENT || $trans_type == ST_BANKDEPOSIT) {
                // it's a payment so also get the bank account
                $sql .= ", ".TB_PREF."bank_trans, ".TB_PREF."bank_accounts";
        }
@@ -166,7 +166,7 @@ function get_customer_trans($trans_id, $trans_type)
                AND trans.type=".db_escape($trans_type)."
                AND trans.debtor_no=cust.debtor_no";
 
-       if ($trans_type == ST_CUSTPAYMENT) {
+       if ($trans_type == ST_CUSTPAYMENT || $trans_type == ST_BANKDEPOSIT) {
                // it's a payment so also get the bank account
                $sql .= " AND ".TB_PREF."bank_trans.trans_no =".db_escape($trans_id)."
                        AND ".TB_PREF."bank_trans.type=$trans_type
@@ -361,7 +361,7 @@ function get_sql_for_customer_inquiry()
        return $sql;
 }
 
-function get_sql_for_sales_deliveries_view($selected_customer, $selected_stock_item=null)
+function get_sql_for_sales_deliveries_view($selected_customer, $selected_stock_item=null, $customer_id=ALL_TEXT)
 {
        $sql = "SELECT trans.trans_no,
                        debtor.name,
@@ -415,6 +415,9 @@ function get_sql_for_sales_deliveries_view($selected_customer, $selected_stock_i
 
                if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != ALL_TEXT)
                        $sql .= " AND sorder.from_stk_loc = ".db_escape($_POST['StockLocation'])." ";
+               
+               if ($customer_id != ALL_TEXT)
+                       $sql .= " AND sorder.debtor_no = ".db_escape($customer_id) . " AND trans.debtor_no = ".db_escape($customer_id);         
 
                $sql .= " GROUP BY trans.trans_no ";