本文整理汇总了PHP中Vtiger_Functions::getAllCurrency方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Functions::getAllCurrency方法的具体用法?PHP Vtiger_Functions::getAllCurrency怎么用?PHP Vtiger_Functions::getAllCurrency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vtiger_Functions
的用法示例。
在下文中一共展示了Vtiger_Functions::getAllCurrency方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: typeValues
/**
* Getting value to display
* @return array
*/
public function typeValues()
{
return Vtiger_Functions::getAllCurrency(true);
}
示例2: getCRMConversionRate
public function getCRMConversionRate($from, $to, $date = '')
{
$db = PearDatabase::getInstance();
$mainCurrencyCode = Vtiger_Functions::getDefaultCurrencyInfo()['currency_code'];
$activeBankId = self::getActiveBankId();
$exchange = false;
if (is_numeric($from)) {
$from = Vtiger_Functions::getAllCurrency(true)[$from]['currency_code'];
}
if (is_numeric($to)) {
$to = Vtiger_Functions::getAllCurrency(true)[$to]['currency_code'];
}
// get present conversion rate from crm
if (empty($date)) {
$query = 'SELECT `conversion_rate` FROM `vtiger_currency_info` WHERE `currency_code` = ? LIMIT 1;';
$result = $db->pquery($query, [$to]);
$exchange = floatval($db->getSingleValue($result));
if ($from != $mainCurrencyCode) {
$convertToMainCurrency = 1 / $exchange;
$query = 'SELECT `conversion_rate` FROM `vtiger_currency_info` WHERE `currency_code` = ? LIMIT 1;';
$result = $db->pquery($query, [$from]);
$fromExchange = floatval($db->getSingleValue($result));
$exchange = 1 / ($fromExchange * $convertToMainCurrency);
}
} else {
$query = 'SELECT
COUNT(1) as num
FROM
`yetiforce_currencyupdate` yfc
INNER JOIN `vtiger_currency_info` cur
ON yfc.`currency_id` = cur.`id` AND cur.`deleted` = 0
WHERE
yfc.`exchange_date` = ? AND
yfc.`bank_id` = ? AND
cur.`currency_code` = ?
LIMIT 1;';
$result = $db->pquery($query, [$date, $activeBankId, $to]);
$num = floatval($db->getSingleValue($result));
// no exchange rate in archive, fetch new rates
if ($num == 0) {
self::fetchCurrencyRates($date);
}
$query = 'SELECT
yfc.`exchange`
FROM
`yetiforce_currencyupdate` yfc
INNER JOIN `vtiger_currency_info` cur
ON yfc.`currency_id` = cur.`id` AND cur.`deleted` = 0
WHERE
yfc.`exchange_date` = ? AND
yfc.`bank_id` = ? AND
cur.`currency_code` = ?
LIMIT 1;';
$result = $db->pquery($query, [$date, $activeBankId, $to]);
$exchange = floatval($db->getSingleValue($result));
if ($exchange > 0) {
$exchange = 1 / $exchange;
}
if ($from != $mainCurrencyCode) {
$convertToMainCurrency = $exchange == 0 ? 1 : 1 / $exchange;
$query = 'SELECT
yfc.`exchange`
FROM
`yetiforce_currencyupdate` yfc
INNER JOIN `vtiger_currency_info` cur
ON yfc.`currency_id` = cur.`id` AND cur.`deleted` = 0
WHERE
yfc.`exchange_date` = ? AND
yfc.`bank_id` = ? AND
cur.`currency_code` = ?
LIMIT 1;';
$result = $db->pquery($query, [$date, $activeBankId, $from]);
$fromExchange = floatval($db->getSingleValue($result));
if ($from != $mainCurrencyCode && $to != $mainCurrencyCode) {
$exchange = $fromExchange / $convertToMainCurrency;
} else {
$exchange = $fromExchange * $convertToMainCurrency;
}
}
}
return $exchange = round($exchange, 5);
}