From: Janusz Dobrowolski Date: Thu, 6 Sep 2012 17:43:33 +0000 (+0200) Subject: Fixed get_sales_order_header and get_debtor_trans queries to avoid errors on empty... X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=5e25da5cf753ae323f6cb3cc7075d39315adf4e1;p=textcart.git Fixed get_sales_order_header and get_debtor_trans queries to avoid errors on empty ship_via field. --- diff --git a/sales/includes/db/cust_trans_db.inc b/sales/includes/db/cust_trans_db.inc index bf28fe6..c68d378 100644 --- a/sales/includes/db/cust_trans_db.inc +++ b/sales/includes/db/cust_trans_db.inc @@ -140,7 +140,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 @@ -149,8 +151,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 "; } @@ -168,8 +169,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 "; } diff --git a/sales/includes/db/sales_order_db.inc b/sales/includes/db/sales_order_db.inc index ab7f560..c1e7ad5 100644 --- a/sales/includes/db/sales_order_db.inc +++ b/sales/includes/db/sales_order_db.inc @@ -288,19 +288,17 @@ function get_sales_order_header($order_no, $trans_type) ."tax_group.name AS tax_group_name , " ."tax_group.id AS tax_group_id, " ."cust.tax_id " - ."FROM ".TB_PREF."sales_orders sorder, " + ."FROM ".TB_PREF."sales_orders sorder LEFT JOIN ".TB_PREF."shippers ship ON ship.shipper_id = sorder.ship_via," .TB_PREF."debtors_master cust," .TB_PREF."sales_types stype, " .TB_PREF."tax_groups tax_group, " .TB_PREF."cust_branch branch," - .TB_PREF."locations loc, " - .TB_PREF."shippers ship + .TB_PREF."locations loc WHERE sorder.order_type=stype.id AND branch.branch_code = sorder.branch_code AND branch.tax_group_id = tax_group.id AND sorder.debtor_no = cust.debtor_no AND loc.loc_code = sorder.from_stk_loc - AND ship.shipper_id = sorder.ship_via AND sorder.trans_type = " . db_escape($trans_type) ." AND sorder.order_no = " . db_escape($order_no ); diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index 309f602..2341013 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -249,6 +249,7 @@ function copy_to_cart() $cart->document_date = $_POST['OrderDate']; $newpayment = false; + if (isset($_POST['payment']) && ($cart->payment != $_POST['payment'])) { $cart->payment = $_POST['payment']; $cart->payment_terms = get_payment_terms($_POST['payment']); @@ -258,7 +259,7 @@ function copy_to_cart() if ($newpayment) { $cart->due_date = $cart->document_date; $cart->phone = $cart->cust_ref = $cart->delivery_address = ''; - $cart->ship_via = 1; + $cart->ship_via = 0; $cart->deliver_to = ''; } } else { @@ -732,6 +733,7 @@ if ($customer_error == "") { } else { display_error($customer_error); } + end_form(); end_page(); ?> \ No newline at end of file