AnsweredAssumed Answered

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

Question asked by Joshua Whitlow on Apr 20, 2016
Latest reply on Apr 22, 2016 by Sohan Tirpude

I am using SugarCRM 6.5.20 CE. I have access to the database and all files associated with this installation.

Problem: Add the '$' sign before fields that contain currency.

Solution: $this->bean->final_sale_amount_c = '$' . $this->bean->final_sale_amount_c;

This solution works on all fields that are text fields. It will change '75.00' to '$75.00'. But on fields that happen to be currency fields, the output on the DetailView is simply '0.00'.

I also noticed that the <span> class is equal to 'sugar_field' on everything but the currency fields which have no class.

I did

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

And got back:

string(12) "75000.000000"

All fields except final_sale_amount_c, initial_deposit_c, and amount work fine.

 

Anyone know why this isn't working?

 

 

Full Code below:

<?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
;

  
}

}
?>

Outcomes