I'd do the next:
- Create in /custom/modules/yourmodule/ the file logic_hooks.php only with this code:
Code:
$hook_version = 1;
$hook_array['before_save'][] = Array(1,"calculations","custom/modules/yourmodule/calculations_Hook.php","calculations_Hook","calculations");
- Create in /custom/modules/yourmodule/ the file calculations_Hook.php with this code:
PHP Code:
require_once("include/modules/yourmodule/yourmodule.php");
class calculations_Hook{
function calculations(&$bean, $event, $arguments){
global $current_user;
$oldOpp = new yourmodule.php();
$oldOpp->retrieve($bean->id);
if (empty($bean->fetched_row['id'])){ //if is true is because it is a new record
$bean->fielddestination = $bean->EAC * $bean->uplift;
//here I'd do calculations on depending of other field that I create of kind dropdown list
//with all kinds of currencies that the user can choose
if($bean->currency == 'pound') {
//calculations for currency 'pound'
}
}
}
}
- This will do the calculations in your module every time a new record of the module is created (not if is modified, only when is created)
- As you can see at the code, I'd create other field for the currency chosen by the user.
good luck chris
Bookmarks