I created this custom field to calculate an amount from a price & a Quantity. I based this process on this Tutorial, from Sugar University: http://developers.sugarcrm.com/tutor...AgingField.pdf
So my custom vardef is :
It includes a custom file called custom/CustomCode.php.PHP Code:'amount' =>
array (
'required' => false,
'name' => 'amount',
'vname' => 'LBL_AMOUNT',
'type' => 'float',
'CustomCode' => 'array('name'=>'getAmount', 'returns'=>'html', 'include'=>'custom/CustomCode.php'),
'len' => '6',
'comment' => 'Calculated total amount',
'massupdate' => 0,
'comments' => '',
'help' => '',
'duplicate_merge' => 'enabled',
'duplicate_merge_dom_value' => '1',
'audited' => 1,
'reportable' => 0,
'len' => '18',
'precision' => '4,
),
The Customcode.php file is:
First of all the Amount doesn't appear in the "Amount" field, but rather at the top of the page, below the header.PHP Code:function getAmount($bean,$field,$value) {
$price=($bean->price);
$quantity=($bean->quantity);
$amount = ($quantity * $price);
//
return ($amount);
Then, although it does display an amount, the result is wrong.
I know it's probably basic, but can anyone comment on this code? It would greatly help me comprehend php better.


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks