/** * This function calculates any requested discount from the various formulas */ protected function calculateDiscountPrice() { if (!empty($this->pricing_formula) || !empty($this->cost_price) || !empty($this->list_price) || !empty($this->discount_price) || !empty($this->pricing_factor) || !empty($this->discount_amount) || !empty($this->discount_select)) { require_once 'modules/ProductTemplates/Formulas.php'; refresh_price_formulas(); global $price_formulas; if (isset($price_formulas[$this->pricing_formula])) { include_once $price_formulas[$this->pricing_formula]; $formula = new $this->pricing_formula(); $this->discount_price = $formula->calculate_price($this->cost_price, $this->list_price, $this->discount_price, $this->pricing_factor); } } }
} /* * Your installation or use of this SugarCRM file is subject to the applicable * terms available at * http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/. * If you do not agree to all of the applicable terms or do not have the * authority to bind the entity as an authorized representative, then do not * install or use this SugarCRM file. * * Copyright (C) SugarCRM Inc. All rights reserved. */ /********************************************************************************* * Description: ********************************************************************************/ require_once 'modules/ProductTemplates/Formulas.php'; refresh_price_formulas(); require_once 'include/formbase.php'; $focus = BeanFactory::getBean('ProductTemplates', $_REQUEST['record']); foreach ($focus->column_fields as $field) { if (isset($_REQUEST[$field])) { $focus->{$field} = $_REQUEST[$field]; } } foreach ($focus->additional_column_fields as $field) { if (isset($_REQUEST[$field])) { $value = $_REQUEST[$field]; $focus->{$field} = $value; } } $focus = populateFromPost('', $focus); $focus->unformat_all_fields();
function getPricingFormula($focus, $field = 'pricing_formula', $value, $view = 'DetailView') { require_once 'modules/ProductTemplates/Formulas.php'; refresh_price_formulas(); if ($view == 'EditView' || $view == 'MassUpdate') { global $app_list_strings; $html = "<select id=\"{$field}\" name=\"{$field}\""; if ($view != 'MassUpdate') { $html .= " language=\"javascript\" onchange=\"show_factor(); set_discount_price(this.form);\""; } $html .= ">"; $html .= get_select_options_with_id($app_list_strings['pricing_formula_dom'], $focus->pricing_formula); $html .= "</select>"; $html .= "<input type=\"hidden\" name=\"pricing_factor\" id=\"pricing_factor\" value=\"1\">"; $formulas = get_formula_details($focus->pricing_factor); $html .= get_edit($formulas, $focus->pricing_formula); return $html; } return get_detail($focus->pricing_formula, $focus->pricing_factor); }