Changed voiding of Direct Invoice to automatically void 'auto' delivery and set SO...
[fa-stable.git] / sales / includes / sales_db.inc
index e9d7a95ef9b6372f1a4f4ba150ddba87bcf89726..3638ae0f4a0a560fe8292480e726e50fab78932a 100644 (file)
@@ -246,7 +246,7 @@ function get_parent_type($type)
 }
 
 //--------------------------------------------------------------------------------------------------
-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 +255,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