Как изменить валютные поля в DetailView с помощью Sugar Bean - SugarCRM
Я использую SugarCRM 6.5.20 CE
Проблема: добавьте знак "$" перед полями, которые содержат валюту.
Решение: $this->bean->final_sale_amount_c = '$' . $this->bean->final_sale_amount_c;
Это решение работает со всеми полями, которые являются текстовыми полями. Значение изменится с 75,00 на 75 долларов. Но в полях, которые оказываются валютными полями, выходные данные в DetailView просто "0,00".
Я также заметил, что <span>
класс равен 'sugar_field' на всех объектах, кроме полей валют, у которых нет класса.
я сделал
var_dump($this->bean->final_sale_amount_c);
И вернулся:
строка (12) "75000.000000"
Все поля кроме final_sale_amount_c
, initial_deposit_c
, а также amount
отлично работает
Полный код ниже:
<?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;
}
}
?>
2 ответа
Я просто использовал 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;
У вас есть еще одна опция для отображения настраиваемого поля в подробном представлении:
Давайте рассмотрим ваши пользовательские модули. Detailviewdefs.php выглядит так:
'panels' =>
array (
'default' =>
array (
0 =>
array (
0 => 'name',
1 =>
array (
'name' => 'status',
'studio' => 'visible',
'label' => 'LBL_STATUS',
'customCode' => '{$custom_value}',
),
),
1 =>
Теперь назначьте пользовательское значение, как показано ниже:
Путь к файлу: custom/modules/YOUR_MODULE/view.detail.php
function display(){
$this->dv->process();
$this->ss->assign('custom_value', '$'.$this->bean->amount);
echo $this->dv->display();
}