Topic: contact_name from crm_persons table
The file sales/includes/db/branches_db.inc has the following function:
function get_sql_for_customer_branches()
{
$sql = "SELECT "
."b.branch_code, "
."b.branch_ref, "
."b.br_name, "
."p.name as contact_name, "
."s.salesman_name, "
."a.description, "
."p.phone, "
."p.fax, "
."p.email, "
."t.name AS tax_group_name, "
."b.inactive
FROM ".TB_PREF."cust_branch b "
. "LEFT JOIN ".TB_PREF."crm_contacts c
ON c.entity_id=b.branch_code AND c.type='cust_branch' AND c.action='general'
LEFT JOIN ".TB_PREF."crm_persons p on c.person_id=p.id,"
.TB_PREF."areas a, "
.TB_PREF."salesman s, "
.TB_PREF."tax_groups t
WHERE b.tax_group_id=t.id
AND b.area=a.area_code
AND b.salesman=s.salesman_code
AND b.debtor_no = ".db_escape($_POST['customer_id']);
if (!get_post('show_inactive')) $sql .= " AND !b.inactive";
$sql .= " GROUP BY b.branch_code ORDER BY branch_ref";
return $sql;
}
The above function is called only in sales/manage/customer_branches.php.
The #_cust_branch table already contains a contact_name field that does not seem to be used here in FA now.
The name field from the #_crm_persons table seems be to be the preferred source of Contact Name in FA.
Is this the intended design?
If we now refrain from populating the #_cust_branch table's contact_name field, then it's use in the reports will suffer.
The #_cust_branch.contact_name field is used in rep103.php and rep106.php still in get_customer_details_for_report() in the former and in GetSalesmanTrans() and print_salesman_list() in the latter.