本文整理汇总了PHP中CurrencyField::convertFromMasterCurrency方法的典型用法代码示例。如果您正苦于以下问题:PHP CurrencyField::convertFromMasterCurrency方法的具体用法?PHP CurrencyField::convertFromMasterCurrency怎么用?PHP CurrencyField::convertFromMasterCurrency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CurrencyField
的用法示例。
在下文中一共展示了CurrencyField::convertFromMasterCurrency方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCreateViewUrl
public function getCreateViewUrl()
{
$createViewUrl = parent::getCreateViewUrl();
$currentUserModel = Users_Record_Model::getCurrentUserModel();
$parentRecordModel = $this->getParentRecordModel();
$currencyValue = $parentRecordModel->get('hdnGrandTotal');
$parentRecordModelCurrencyId = $parentRecordModel->get('currency_id');
if ($parentRecordModelCurrencyId == $currentUserModel->get('currency_id')) {
$amount = CurrencyField::convertToUserFormat($currencyValue, null, true);
} else {
$baseCurrencyId = CurrencyField::getDBCurrencyId();
$allCurrencies = getAllCurrencies();
foreach ($allCurrencies as $currencyInfo) {
if ($parentRecordModelCurrencyId == $currencyInfo['currency_id']) {
$currencyValue = CurrencyField::convertToDollar($currencyValue, $currencyInfo['conversionrate']);
}
}
foreach ($allCurrencies as $currencyInfo) {
if ($baseCurrencyId == $currencyInfo['currency_id']) {
$currencyValue = CurrencyField::convertFromMasterCurrency($currencyValue, $currencyInfo['conversionrate']);
}
}
$amount = CurrencyField::convertToUserFormat($currencyValue);
}
return $createViewUrl . '&relatedcontact=' . $parentRecordModel->get('contact_id') . '&relatedorganization=' . $parentRecordModel->get('account_id') . '&amount=' . $amount;
}
示例2: getPriceDetailsForProduct
/** Function used to get all the price details for different currencies which are associated to the given product
* @param int $productid - product id to which we want to get all the associated prices
* @param decimal $unit_price - Unit price of the product
* @param string $available - available or available_associated where as default is available, if available then the prices in the currencies which are available now will be returned, otherwise if the value is available_associated then prices of all the associated currencies will be retruned
* @return array $price_details - price details as a array with productid, curid, curname
*/
function getPriceDetailsForProduct($productid, $unit_price, $available = 'available', $itemtype = 'Products')
{
$adb = PearDatabase::getInstance();
$log = vglobal('log');
$log->debug("Entering into function getPriceDetailsForProduct({$productid})");
if ($productid != '') {
$product_currency_id = getProductBaseCurrency($productid, $itemtype);
$product_base_conv_rate = getBaseConversionRateForProduct($productid, 'edit', $itemtype);
// Detail View
if ($available == 'available_associated') {
$query = "select vtiger_currency_info.*, vtiger_productcurrencyrel.converted_price, vtiger_productcurrencyrel.actual_price\n\t\t\t\t\tfrom vtiger_currency_info\n\t\t\t\t\tinner join vtiger_productcurrencyrel on vtiger_currency_info.id = vtiger_productcurrencyrel.currencyid\n\t\t\t\t\twhere vtiger_currency_info.currency_status = 'Active' and vtiger_currency_info.deleted=0\n\t\t\t\t\tand vtiger_productcurrencyrel.productid = ? and vtiger_currency_info.id != ?";
$params = array($productid, $product_currency_id);
} else {
// Edit View
$query = "select vtiger_currency_info.*, vtiger_productcurrencyrel.converted_price, vtiger_productcurrencyrel.actual_price\n\t\t\t\t\tfrom vtiger_currency_info\n\t\t\t\t\tleft join vtiger_productcurrencyrel\n\t\t\t\t\ton vtiger_currency_info.id = vtiger_productcurrencyrel.currencyid and vtiger_productcurrencyrel.productid = ?\n\t\t\t\t\twhere vtiger_currency_info.currency_status = 'Active' and vtiger_currency_info.deleted=0";
$params = array($productid);
}
//Postgres 8 fixes
if ($adb->isPostgres()) {
$query = fixPostgresQuery($query, $log, 0);
}
$res = $adb->pquery($query, $params);
for ($i = 0; $i < $adb->num_rows($res); $i++) {
$price_details[$i]['productid'] = $productid;
$price_details[$i]['currencylabel'] = $adb->query_result($res, $i, 'currency_name');
$price_details[$i]['currencycode'] = $adb->query_result($res, $i, 'currency_code');
$price_details[$i]['currencysymbol'] = $adb->query_result($res, $i, 'currency_symbol');
$currency_id = $adb->query_result($res, $i, 'id');
$price_details[$i]['curid'] = $currency_id;
$price_details[$i]['curname'] = 'curname' . $adb->query_result($res, $i, 'id');
$cur_value = $adb->query_result($res, $i, 'actual_price');
// Get the conversion rate for the given currency, get the conversion rate of the product currency to base currency.
// Both together will be the actual conversion rate for the given currency.
$conversion_rate = $adb->query_result($res, $i, 'conversion_rate');
$actual_conversion_rate = $product_base_conv_rate * $conversion_rate;
$is_basecurrency = false;
if ($currency_id == $product_currency_id) {
$is_basecurrency = true;
}
if ($cur_value == null || $cur_value == '') {
$price_details[$i]['check_value'] = false;
if ($unit_price != null) {
$cur_value = CurrencyField::convertFromMasterCurrency($unit_price, $actual_conversion_rate);
} else {
$cur_value = '0';
}
} else {
if ($is_basecurrency) {
$price_details[$i]['check_value'] = true;
}
}
$price_details[$i]['curvalue'] = CurrencyField::convertToUserFormat($cur_value, null, true);
$price_details[$i]['conversionrate'] = $actual_conversion_rate;
$price_details[$i]['is_basecurrency'] = $is_basecurrency;
}
} else {
if ($available == 'available') {
// Create View
$current_user = vglobal('current_user');
$user_currency_id = fetchCurrency($current_user->id);
$query = "select vtiger_currency_info.* from vtiger_currency_info\n\t\t\t\t\twhere vtiger_currency_info.currency_status = 'Active' and vtiger_currency_info.deleted=0";
$params = array();
$res = $adb->pquery($query, $params);
for ($i = 0; $i < $adb->num_rows($res); $i++) {
$price_details[$i]['currencylabel'] = $adb->query_result($res, $i, 'currency_name');
$price_details[$i]['currencycode'] = $adb->query_result($res, $i, 'currency_code');
$price_details[$i]['currencysymbol'] = $adb->query_result($res, $i, 'currency_symbol');
$currency_id = $adb->query_result($res, $i, 'id');
$price_details[$i]['curid'] = $currency_id;
$price_details[$i]['curname'] = 'curname' . $adb->query_result($res, $i, 'id');
// Get the conversion rate for the given currency, get the conversion rate of the product currency(logged in user's currency) to base currency.
// Both together will be the actual conversion rate for the given currency.
$conversion_rate = $adb->query_result($res, $i, 'conversion_rate');
$user_cursym_convrate = getCurrencySymbolandCRate($user_currency_id);
$product_base_conv_rate = 1 / $user_cursym_convrate['rate'];
$actual_conversion_rate = $product_base_conv_rate * $conversion_rate;
$price_details[$i]['check_value'] = false;
$price_details[$i]['curvalue'] = '0';
$price_details[$i]['conversionrate'] = $actual_conversion_rate;
$is_basecurrency = false;
if ($currency_id == $user_currency_id) {
$is_basecurrency = true;
}
$price_details[$i]['is_basecurrency'] = $is_basecurrency;
}
} else {
$log->debug("Product id is empty. we cannot retrieve the associated prices.");
}
}
$log->debug("Exit from function getPriceDetailsForProduct({$productid})");
return $price_details;
}
示例3: pipeline_by_lead_source
/**
* Creates pie chart image of opportunities by lead_source.
* param $datax- the sales stage data to display in the x-axis
* param $datay- the sum of opportunity amounts for each opportunity in each sales stage
* to display in the y-axis
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
* All Rights Reserved..
* Contributor(s): ______________________________________..
*/
function pipeline_by_lead_source($legends = array('foo', 'bar'), $user_id = array('1'), $cache_file_name = 'a_file', $refresh = true, $width = 900, $height = 500)
{
global $log, $current_user;
$log->debug("Entering pipeline_by_lead_source(" . $legends . ") method ...");
global $app_strings, $lang_crm, $current_module_strings, $log, $charset, $tmp_dir;
global $theme;
include_once 'Image/Graph.php';
include_once 'Image/Canvas.php';
$font = calculate_font_name($lang_crm);
if (!file_exists($cache_file_name) || !file_exists($cache_file_name . '.map') || $refresh == true) {
$log =& LoggerManager::getLogger('opportunity charts');
$log->debug("starting pipeline chart");
$log->debug("legends is:");
$log->debug($legends);
$log->debug("user_id is: ");
$log->debug($user_id);
$log->debug("cache_file_name is: {$cache_file_name}");
//Now do the db queries
//query for opportunity data that matches $legends and $user
$where = "";
//build the where clause for the query that matches $datax
$count = count($legends);
if ($count > 0) {
$where .= " leadsource in ( ";
$ls_i = 0;
foreach ($legends as $key => $value) {
if ($ls_i != 0) {
$where .= ", ";
}
$where .= "'" . addslashes($key) . "'";
$ls_i++;
}
$where .= ")";
}
$opp = new Potentials();
$opp_list = $opp->get_full_list("vtiger_potential.amount DESC, vtiger_potential.closingdate DESC", $where);
//build pipeline by lead source data
$total = 0;
$count = array();
$sum = array();
if (isset($opp_list)) {
foreach ($opp_list as $record) {
if (!isset($sum[$record->column_fields['leadsource']])) {
$sum[$record->column_fields['leadsource']] = 0;
}
if (isset($record->column_fields['amount']) && isset($record->column_fields['leadsource'])) {
// Strip all non numbers from this string.
$amount = CurrencyField::convertFromMasterCurrency(preg_replace('/[^0-9]/', '', floor($record->column_fields['amount'])), $current_user->conv_rate);
$sum[$record->column_fields['leadsource']] = $sum[$record->column_fields['leadsource']] + $amount / 1000;
if (isset($count[$record->column_fields['leadsource']])) {
$count[$record->column_fields['leadsource']]++;
} else {
$count[$record->column_fields['leadsource']] = 1;
}
$total = $total + $amount / 1000;
}
}
}
$visible_legends = array();
$data = array();
$aTargets = array();
$aAlts = array();
foreach ($legends as $lead_source_key => $lead_source_translation) {
if (isset($sum[$lead_source_key])) {
array_push($data, $sum[$lead_source_key]);
if ($lead_source_key != '') {
array_push($visible_legends, $lead_source_translation);
} else {
// put none in if the vtiger_field is blank.
array_push($visible_legends, $current_module_strings['NTC_NO_LEGENDS']);
}
$cvid = getCvIdOfAll("Potentials");
array_push($aTargets, "index.php?module=Potentials&action=ListView&leadsource=" . urlencode($lead_source_key) . "&query=true&type=dbrd&viewname=" . $cvid);
array_push($aAlts, $count[$lead_source_key] . " " . $current_module_strings['LBL_OPPS_IN_LEAD_SOURCE'] . " {$lead_source_translation}\t");
}
}
$log->debug("sum is:");
$log->debug($sum);
$log->debug("count is:");
$log->debug($count);
$log->debug("total is: {$total}");
if ($total == 0) {
$log->debug("Exiting pipeline_by_lead_source method ...");
return $current_module_strings['ERR_NO_OPPS'];
}
if ($theme == "blue") {
$font_color = "#212473";
} else {
$font_color = "#000000";
}
$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
//.........这里部分代码省略.........