當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。