2

I am using SugarCRM 6.5.20 CE

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.

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;

    }

}
?>
Josh Whitlow
  • 481
  • 6
  • 25

2 Answers2

1

You have another option to display custom field on detail view:

Lets consider your custom modules detailviewdefs.php looks like:

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

Now assign the custom value as below:

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();
}
Sachin I
  • 1,500
  • 3
  • 10
  • 29
  • This did not work, the echo is needless, the value that "$this->bean->amount" brings back is always '1' regardless of what value is actually there. – Josh Whitlow Apr 22 '16 at 16:33
0

I ended up simply using jquery instead.

$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;
Josh Whitlow
  • 481
  • 6
  • 25