Я использую SugarCRM 6.5.20 CEКак изменить валюту поля на DetailView с помощью сахара Bean - SugarCRM
Задача: Добавить знак «$» перед тем полям, которые содержат валюту.
Решение: $this->bean->final_sale_amount_c = '$' . $this->bean->final_sale_amount_c;
Это решение работает на всех полях, текстовые поля. Он изменит «75 .00» до «$ 75,00». Но в полях, которые являются валютными полями, вывод в 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;
}
}
?>
Это не сработало, эхо ненужно, значение, которое «$ this-> bean-> amount» возвращает всегда, равно «1» независимо от того, какое значение на самом деле там. –