如何使用 Sugar Bean 更改 DetailView 上的货币字段 - SugarCRM

How to change Currency Fields on the DetailView using the Sugar Bean - SugarCRM

我正在使用 SugarCRM 6.5.20 CE

问题:在包含货币的字段前添加“$”符号。

解决方案:$this->bean->final_sale_amount_c = '$' . $this->bean->final_sale_amount_c;

此解决方案适用于所有文本字段。它会将“75.00”更改为“$75.00”。但是在恰好是货币字段的字段上,DetailView 上的输出只是“0.00”。

我还注意到 <span> class 在除了没有 class.

的货币字段之外的所有内容上都等于 'sugar_field'

我做到了

var_dump($this->bean->final_sale_amount_c);

然后回来了:

string(12) "75000.000000"

final_sale_amount_cinitial_deposit_camount 之外的所有字段都可以正常工作。

完整代码如下:

<?php 
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 

require_once('include/MVC/View/views/view.detail.php'); 
require_once('custom/include/utilities.php');

class OpportunitiesViewDetail extends ViewDetail {

    // function displaySubPanels() {
    //  return '';
    // }


    function display(){

        var_dump($this->bean->final_sale_amount_c);

        $this->bean->initial_deposit_c = '$' . $this->bean->initial_deposit_c;
        $this->bean->fees_escrowed_c = '$' . $this->bean->fees_escrowed_c;
        $this->bean->amount = '$' . $this->bean->amount;

        $this->bean->final_sale_amount_c = '$' . $this->bean->final_sale_amount_c;
        $this->bean->a_deposit_c = ($this->bean->a_deposit_c * 100) . '%';
        $this->bean->b_deposit_c = ($this->bean->b_deposit_c * 100) . '%';
        $this->bean->c_deposit_c = ($this->bean->c_deposit_c * 100) . '%';

        $this->bean->a_quarterly_hosting_fees_c = '$' . $this->bean->a_quarterly_hosting_fees_c;
        $this->bean->b_quarterly_hosting_fees_c = '$' . $this->bean->b_quarterly_hosting_fees_c;
        $this->bean->c_quarterly_hosting_fees_c = '$' . $this->bean->c_quarterly_hosting_fees_c;

        $js = <<<JS

                <script src="custom/include/javascript/js.cookie.js?version=1" type="text/javascript"></script>
                <script src="custom/include/javascript/utilities.js" type="text/javascript"></script>
                <script type="text/javascript">
                var $ = jQuery.noConflict();




                </script>


JS;
        parent::display();
        echo $js;

    }

}
?>

您还有另一个选项可以在详细信息视图中显示自定义字段:

让我们考虑一下您的自定义模块 detailviewdefs.php 看起来像:

'panels' =>
   array (
     'default' =>
     array (
       0 =>
       array (
         0 => 'name',
         1 =>
         array (
           'name' => 'status',
           'studio' => 'visible',
           'label' => 'LBL_STATUS',
           'customCode' => '{$custom_value}',
         ),
       ),
       1 =>

现在按如下方式分配自定义值:

File path: custom/modules/YOUR_MODULE/view.detail.php

function display(){
    $this->dv->process();
    $this->ss->assign('custom_value', '$'.$this->bean->amount);
    echo $this->dv->display();
}

我最终只是简单地使用了 jquery。

$js = <<<JS

<script src="custom/include/javascript/js.cookie.js?version=1" type="text/javascript"></script>
<script src="custom/include/javascript/utilities.js" type="text/javascript"></script>
<script type="text/javascript">

   $("#final_sale_amount_c").prepend("$ ");


</script>

JS;
    parent::display();
    echo $js;