Merged last changes from stable.
[fa-stable.git] / sales / manage / customers.php
index 7dbe8f57c1ba01f4a52cdd8bf0aa51fd16f96166..b7226e1fd9e350070ba94f721b08043cb90d60a4 100644 (file)
@@ -120,7 +120,10 @@ function handle_submit(&$selected_id)
                        add_crm_person($_POST['CustName'], $_POST['cust_ref'], '', $_POST['address'], 
                                $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], '', '');
 
-                       add_crm_contact('cust_branch', 'general', $selected_branch, db_insert_id());
+                       $pers_id = db_insert_id();
+                       add_crm_contact('cust_branch', 'general', $selected_branch, $pers_id);
+
+                       add_crm_contact('customer', 'general', $selected_id, $pers_id);
                }
                commit_transaction();
 
@@ -337,7 +340,7 @@ else
        hidden('customer_id');
 }
 
-if (!$selected_id)
+if (!$selected_id || list_updated('customer_id'))
        unset($_POST['_tabs_sel']); // force settings tab for new customer
 
 tabbed_content_start('tabs', array(