X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fdb%2Fsales_order_db.inc;h=ff61aaa5eef5b8c091a48ef38a43c2741131fa52;hb=7561718ee5113232ce917f63085d272884b0929c;hp=3344738038866627eaf0554aeb7fddb06dc96447;hpb=029cbb368afc037bc9116b022744ee05ac5086e6;p=fa-stable.git diff --git a/sales/includes/db/sales_order_db.inc b/sales/includes/db/sales_order_db.inc index 33447380..ff61aaa5 100644 --- a/sales/includes/db/sales_order_db.inc +++ b/sales/includes/db/sales_order_db.inc @@ -465,7 +465,7 @@ function get_branch_to_order($customer_id, $branch_id) { PrepaidOrders */ function get_sql_for_sales_orders_view($trans_type, $trans_no, $filter, - $stock_item=null, $from='', $to='', $ref='', $location='', $customer_id=ALL_TEXT) + $stock_item='', $from='', $to='', $ref='', $location=ALL_TEXT, $customer_id=ALL_TEXT) { $sql = "SELECT @@ -489,7 +489,8 @@ function get_sql_for_sales_orders_view($trans_type, $trans_no, $filter, prep_amount, allocs.ord_payments, inv.inv_payments, - sorder.total + sorder.total, + sorder.trans_type 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 @@ -515,8 +516,7 @@ function get_sql_for_sales_orders_view($trans_type, $trans_no, $filter, elseif ($ref != "") { // search orders with reference like - $number_like = "%".$ref."%"; - $sql .= " AND sorder.reference LIKE ".db_escape($number_like); + $sql .= " AND sorder.reference LIKE ".db_escape('%' . $ref . '%'); // ." GROUP BY sorder.order_no"; } else // ... or select inquiry constraints @@ -536,10 +536,10 @@ function get_sql_for_sales_orders_view($trans_type, $trans_no, $filter, //if ($selected_customer != -1) // $sql .= " AND sorder.debtor_no=".db_escape($selected_customer); - if (isset($stock_item)) + if ($stock_item != ALL_TEXT) $sql .= " AND line.stk_code=".db_escape($stock_item); - if ($location) + if ($location != ALL_TEXT) $sql .= " AND sorder.from_stk_loc = ".db_escape($location); if ($filter=='OutstandingOnly')