当前位置: 首页>>代码示例>>PHP>>正文


PHP Vtiger_Functions::getAllCurrency方法代码示例

本文整理汇总了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);
 }
开发者ID:vovpff,项目名称:YetiForceCRM,代码行数:8,代码来源:Currency.php

示例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);
    }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:82,代码来源:Module.php


注:本文中的Vtiger_Functions::getAllCurrency方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。