Prefixing telephone numbers

Hi,

I need to prefix numbers displayed with a 3 digit number designating which outside line to use (caller id). I have setup a custom module called partners which has a 1 to many relationship with accounts. the partners module has a field called outside_line which signifies which prefix (outside line) should be used for outgoing calls to all accounts associated with this partner. The PBX will automatically determine the caller id to use based on the 3 digit prefix.

I would ideally like the following:

Accounts views - prefix any telephone number with the partners.outside_line value of the partner associated with the account. If no partner is associated with the account then use a default value (say 300).
Contacts views - prefix any telephone number with the partners.outside_line value of the partner associated with the account that the contact is associated with. If no account is is associated the contact or no partner is associated with the account then use a default value (say 300).

I guess it could either be done by editing the different listviews and detailviews, but this might cause an issue because I would want the data displayed not to show the prefix, just the normal number.

The other way would be modifying ‘custom/include/Smarty/plugins/function.sugar_phone.php’ which I have done anyway to show the number as a link with a ‘tel:’ prefix, but I’m not altering the ‘params’ data sent to it. This way would seem to be more complex though.
The changes I made were:

if (isset($params['value'])) {
    $outbound = "300";
    return '<a href="tel:'.$outbound.''.str_replace(' ', '', $params['value']).'">'.$params['value'].'</a>';
}
return $params['value'];

Am I over thinking this or is there an easier way to achieve this?

Thanks,

James

Hi @james_k,

For the detail view, I think it can be solved by adding some javascript to the predisplay function

For the list view you can add a process_record logic hook to conditionally format your records and display them the way you want:

Hope it gives you some ideas on how to solve your issue.

Thanks,

BrozTechnologies

Thanks, I will investigate!