Smaller technical fixes.
[fa-stable.git] / sales / includes / sales_db.inc
index e9d7a95ef9b6372f1a4f4ba150ddba87bcf89726..0503abd3c2a94e3a321800c14fc20814c2bf1ea6 100644 (file)
@@ -239,14 +239,7 @@ function set_document_parent($cart)
 }
 
 //--------------------------------------------------------------------------------------------------
-function get_parent_type($type)
-{
-       $parent_types = array( ST_CUSTCREDIT => ST_SALESINVOICE, ST_SALESINVOICE => ST_CUSTDELIVERY, ST_CUSTDELIVERY => ST_SALESORDER );
-       return isset($parent_types[$type]) ?  $parent_types[$type] : 0;
-}
-
-//--------------------------------------------------------------------------------------------------
-function update_parent_line($doc_type, $line_id, $qty_dispatched)
+function update_parent_line($doc_type, $line_id, $qty_dispatched, $auto=false)
 {
        $doc_type = get_parent_type($doc_type);
 
@@ -255,9 +248,13 @@ function update_parent_line($doc_type, $line_id, $qty_dispatched)
                return false;
        else {
                if ($doc_type==ST_SALESORDER)
+               {
                        $sql = "UPDATE ".TB_PREF."sales_order_details
-                               SET qty_sent = qty_sent + $qty_dispatched
-                               WHERE id=".db_escape($line_id);
+                               SET qty_sent = qty_sent + $qty_dispatched";
+                       if ($auto)
+                               $sql .= ", quantity = quantity + $qty_dispatched";
+                       $sql .= " WHERE id=".db_escape($line_id);
+               }               
                else
                        $sql = "UPDATE ".TB_PREF."debtor_trans_details
                                SET qty_done = qty_done + $qty_dispatched
@@ -313,7 +310,7 @@ function read_sales_trans($doc_type, $trans_no, &$cart)
                        $myrow["curr_code"], $myrow["discount"], $myrow["payment_terms"]);
 
                $cart->set_branch($myrow["branch_code"], $myrow["tax_group_id"],
-                       $myrow["tax_group_name"],       $myrow["phone"], $myrow["email"]);
+                       $myrow["tax_group_name"]);
 
                $cart->reference = $myrow["reference"];
                $cart->order_no = $myrow["order_"];