dougu2006 2012-12-21 08:19
浏览 41
已采纳

如何在视图中格式化dotProject电话号码字段

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,

  • 写回答

2条回答 默认 最新

  • doulianqi3870 2012-12-28 23:24
    关注

    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)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂