<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — contact_name from crm_persons table]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=5376&amp;type=atom" />
	<updated>2014-12-08T19:25:00Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=5376</id>
		<entry>
			<title type="html"><![CDATA[contact_name from crm_persons table]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=21708#p21708" />
			<content type="html"><![CDATA[<p>The file <strong>sales/includes/db/branches_db.inc</strong> has the following function:<br /></p><div class="codebox"><pre><code>function get_sql_for_customer_branches()
{
    $sql = &quot;SELECT &quot;
        .&quot;b.branch_code, &quot;
        .&quot;b.branch_ref, &quot;
        .&quot;b.br_name, &quot;
        .&quot;p.name as contact_name, &quot;
        .&quot;s.salesman_name, &quot;
        .&quot;a.description, &quot;
        .&quot;p.phone, &quot;
        .&quot;p.fax, &quot;
        .&quot;p.email, &quot;
        .&quot;t.name AS tax_group_name, &quot;
        .&quot;b.inactive
        FROM &quot;.TB_PREF.&quot;cust_branch b &quot;
        . &quot;LEFT JOIN &quot;.TB_PREF.&quot;crm_contacts c
            ON c.entity_id=b.branch_code AND c.type=&#039;cust_branch&#039; AND c.action=&#039;general&#039;
            LEFT JOIN &quot;.TB_PREF.&quot;crm_persons p on c.person_id=p.id,&quot;
            .TB_PREF.&quot;areas a, &quot;
            .TB_PREF.&quot;salesman s, &quot;
            .TB_PREF.&quot;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 = &quot;.db_escape($_POST[&#039;customer_id&#039;]);

    if (!get_post(&#039;show_inactive&#039;)) $sql .= &quot; AND !b.inactive&quot;;
    $sql .= &quot; GROUP BY b.branch_code ORDER BY branch_ref&quot;;

    return $sql;
}</code></pre></div><p>The above function is called only in <strong>sales/manage/customer_branches.php</strong>.<br />The <strong>#_cust_branch</strong> table already contains a <strong>contact_name</strong> field that does not seem to be used here in FA now.<br />The <strong>name</strong> field from the <strong>#_crm_persons</strong> table seems be to be the preferred source of Contact Name in FA.</p><p>Is this the intended design?<br />If we now refrain from populating the <strong>#_cust_branch</strong> table&#039;s <strong>contact_name</strong> field, then it&#039;s use in the reports will suffer.</p><p>The <strong>#_cust_branch.contact_name</strong> field is used in <strong>rep103.php</strong> and <strong>rep106.php</strong> still in get_customer_details_for_report() in the former and in GetSalesmanTrans() and print_salesman_list() in the latter.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2014-12-08T19:25:00Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=21708#p21708</id>
		</entry>
</feed>
