- add_crm_person($_POST['CustName'], $_POST['cust_ref'], '', $_POST['address'],
+ add_crm_person($_POST['cust_ref'], $_POST['CustName'], '', $_POST['address'],
$_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], '', '');
$_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);
text_row(_("GSTNo:"), 'tax_id', null, 40, 40);
text_row(_("GSTNo:"), 'tax_id', null, 40, 40);
- if (!$selected_id || is_new_customer($selected_id))
+ if (!$selected_id || is_new_customer($selected_id) || (!key_in_foreign_table($selected_id, 'debtor_trans', 'debtor_no') &&
+ !key_in_foreign_table($selected_id, 'sales_orders', 'debtor_no')))
unset($_POST['_tabs_sel']); // force settings tab for new customer
tabbed_content_start('tabs', array(
'settings' => array(_('&General settings'), $selected_id),
'contacts' => array(_('&Contacts'), $selected_id),
unset($_POST['_tabs_sel']); // force settings tab for new customer
tabbed_content_start('tabs', array(
'settings' => array(_('&General settings'), $selected_id),
'contacts' => array(_('&Contacts'), $selected_id),
- 'transactions' => array(_('&Transactions'), $selected_id),
+ 'transactions' => array(_('&Transactions'),
+ ($_SESSION["wa_current_user"]->can_access_page('SA_SALESTRANSVIEW') ? $selected_id : null)),