I'm currently using dotProject Version 2.1.3 for our company and I would like a little help with the phone number format in the view company view. Currently it allows you to place and group of numbers in any format. So I can type (619)555-1234 ext-123 and it will display that way. My problem is that I don't want the number to be stored in the database that way. I only want the database to store just the numbers as one whole number.
So what I'm working with is the following code. How to change this php page code to display the phone numbers in a visually pleasing format like from this 55512312125512 to this (555)123-1212 ext:5512? what the fields currently look like
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('
'); ?>:</td>
<td class="hilite"><?php echo @$obj->company_phone1; ?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Phone'); ?>2:</td>
<td class="hilite"><?php echo @$obj->company_phone2; ?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Fax'); ?>:</td>
<td class="hilite"><?php echo @$obj->company_fax; ?></td>
</tr>
for these 3 phone number fields to display in the format (555)123-4567 ext-any number of digits and still store in the database as continuous number like 555123456?
Any help would be greatly appreciated.
Thank you,
This works for dotProject Version 2.1.3 on the modules/companies/view.php page:
<tr> <td align="right" nowrap="nowrap"> <?php echo $AppUI->_('Phone'); ?>: </td> <td class="hilite"> <?php $data = @$obj->company_phone1; if(preg_match( '/^(\d{3})(\d{3})(\d{4})(\d*)$/', $data, $matches )) { if($matches[4] != '') $result = '(' . $matches[1] . ')' .$matches[2] . '-' . $matches[3] . ' ext.' . $matches[4]; else $result = '(' . $matches[1] . ')' .$matches[2] . '-' . $matches[3]; echo $result; } ?> </td> </tr> </code>
This was gratefully provided by (alex-sorin-dachin)