/** @deprecated */ public static function getBaseCurrencyUnit() { static $unit; if (!$unit) { $unit = Config::getBaseCurrency(); if (LANGUAGE_ID == 'ru' && Loader::includeModule('currency')) { switch ($unit) { case 'RUB': case 'BYR': case 'UAH': if ($row = CurrencyLangTable::getByPrimary(array('CURRENCY' => $unit, 'LID' => LANGUAGE_ID))->fetch()) { $unit = trim(str_replace('#', '', $row['FORMAT_STRING'])); } break; } } } return $unit; }
function InstallDB() { global $DB, $APPLICATION; global $stackCacheManager; global $CACHE_MANAGER; $this->errors = false; $bitrix24Path = $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/bitrix24/'; $bitrix24 = file_exists($bitrix24Path) && is_dir($bitrix24Path); unset($bitrix24Path); if (!$DB->Query("SELECT COUNT(CURRENCY) FROM b_catalog_currency", true)): $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/currency/install/db/".strtolower($DB->type)."/install.sql"); endif; if ($this->errors !== false) { $APPLICATION->ThrowException(implode("", $this->errors)); return false; } RegisterModule("currency"); $stackCacheManager->Clear("currency_currency_lang"); $CACHE_MANAGER->Clean("currency_currency_list", 'b_catalog_currency'); $CACHE_MANAGER->Clean("currency_base_currency", 'b_catalog_currency'); $stackCacheManager->Clear("currency_rate"); if (Loader::includeModule("currency")) { $currencyIterator = CurrencyTable::getList(array( 'select' => array('CURRENCY'), 'limit' => 1 )); if (!($currency = $currencyIterator->fetch())) { $languageID = ''; $siteIterator = SiteTable::getList(array( 'select' => array('LID', 'LANGUAGE_ID'), 'filter' => array('DEF' => 'Y', 'ACTIVE' => 'Y') )); if ($site = $siteIterator->fetch()) { $languageID = (string)$site['LANGUAGE_ID']; } if (isset($site)) unset($site); unset($siteIterator); if ($languageID == '') $languageID = 'en'; $currencyList = array(); $currencySetID = ''; switch ($languageID) { case 'ua': case 'de': case 'en': $currencySetID = $languageID; break; case 'ru': if (!$bitrix24) { $languageIterator = LanguageTable::getList(array( 'select' => array('ID'), 'filter' => array('ID' => 'kz', 'ACTIVE' => 'Y') )); if ($existLanguage = $languageIterator->fetch()) { $currencySetID = $existLanguage['ID']; } if ($currencySetID == '') { $languageIterator = LanguageTable::getList(array( 'select' => array('ID'), 'filter' => array('ID' => 'ua', 'ACTIVE' => 'Y') )); if ($existLanguage = $languageIterator->fetch()) { $currencySetID = $existLanguage['ID']; } } } if ($currencySetID == '') { $currencySetID = $languageID; } break; default: $currencySetID = 'en'; break; } $datetimeEntity = new SqlExpression(Application::getConnection()->getSqlHelper()->getCurrentDateTimeFunction()); switch ($currencySetID) { case 'kz': $addCurrency = array( array('CURRENCY' => 'KZT', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'RUB', 'AMOUNT' => 1, 'AMOUNT_CNT' => 4.72, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 4.72), array('CURRENCY' => 'USD', 'AMOUNT' => 1, 'AMOUNT_CNT' => 154.52, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 154.52), array('CURRENCY' => 'EUR', 'AMOUNT' => 1, 'AMOUNT_CNT' => 212.73, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 212.73) ); break; case 'ua': $addCurrency = array( array('CURRENCY' => 'UAH', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'RUB', 'AMOUNT' => 2.54, 'AMOUNT_CNT' => 10, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.254), array('CURRENCY' => 'USD', 'AMOUNT' => 799.3, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 7.993), array('CURRENCY' => 'EUR', 'AMOUNT' => 1083.37, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 10.8337) ); break; case 'ru': $addCurrency = array( array('CURRENCY' => 'RUB', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'AMOUNT' => 32.30, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 32.30), array('CURRENCY' => 'EUR', 'AMOUNT' => 43.80, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 43.80), array('CURRENCY' => 'UAH', 'AMOUNT' => 39.41, 'AMOUNT_CNT' => 10, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 3.941), array('CURRENCY' => 'BYR', 'AMOUNT' => 36.72, 'AMOUNT_CNT' => 10000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.003672) ); break; case 'de': $addCurrency = array( array('CURRENCY' => 'EUR', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'AMOUNT' => 0.74, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.74) ); break; default: case 'en': $addCurrency = array( array('CURRENCY' => 'USD', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'EUR', 'AMOUNT' => 1.36, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 1.36) ); break; } foreach ($addCurrency as &$fields) { $fields['CREATED_BY'] = null; $fields['MODIFIED_BY'] = null; $fields['DATE_CREATE'] = $datetimeEntity; $fields['DATE_UPDATE'] = $datetimeEntity; $currencyResult = CurrencyTable::add($fields); if ($currencyResult->isSuccess()) $currencyList[] = $fields['CURRENCY']; } unset($currencyResult, $fields); if (!empty($currencyList)) { Option::set('currency', 'installed_currencies', implode(',', $currencyList), ''); $languageIterator = LanguageTable::getList(array( 'select' => array('ID'), 'filter' => array('ACTIVE' => 'Y') )); while ($existLanguage = $languageIterator->fetch()) { $CACHE_MANAGER->Clean('currency_currency_list_'.$existLanguage['ID']); $messList = Loc::loadLanguageFile($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/currency/install_lang.php', $existLanguage['ID']); foreach($currencyList as &$oneCurrency) { $fields = array( 'LID' => $existLanguage['ID'], 'CURRENCY' => $oneCurrency, 'THOUSANDS_SEP' => false, 'DECIMALS' => 2, 'HIDE_ZERO' => 'Y', 'FORMAT_STRING' => $messList['CUR_INSTALL_'.$oneCurrency.'_FORMAT_STRING'], 'FULL_NAME' => $messList['CUR_INSTALL_'.$oneCurrency.'_FULL_NAME'], 'DEC_POINT' => $messList['CUR_INSTALL_'.$oneCurrency.'_DEC_POINT'], 'THOUSANDS_VARIANT' => $messList['CUR_INSTALL_'.$oneCurrency.'_THOUSANDS_SEP'], 'CREATED_BY' => null, 'MODIFIED_BY' => null, 'DATE_CREATE' => $datetimeEntity, 'TIMESTAMP_X' => $datetimeEntity ); $resultCurrencyLang = CurrencyLangTable::add($fields); } unset($oneCurrency); } unset($existLanguage, $languageIterator); if (!$bitrix24) { $checkDate = DateTime::createFromTimestamp(strtotime('tomorrow 00:01:00'));; CAgent::AddAgent('\Bitrix\Currency\CurrencyTable::currencyBaseRateAgent();', 'currency', 'Y', 86400, '', 'Y', $checkDate->toString(), 100, false, true); } } } } $stackCacheManager->Clear("currency_currency_lang"); $CACHE_MANAGER->Clean("currency_currency_list", 'b_catalog_currency'); $CACHE_MANAGER->Clean("currency_base_currency", 'b_catalog_currency'); $stackCacheManager->Clear("currency_rate"); return true; }
protected function installCurrencies() { if (!Loader::includeModule('currency')) { return; } $bitrix24Path = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/bitrix24/'; $bitrix24 = file_exists($bitrix24Path) && is_dir($bitrix24Path); unset($bitrix24Path); $currencyIterator = \Bitrix\Currency\CurrencyTable::getList(array('select' => array('CURRENCY'), 'limit' => 1)); $currency = $currencyIterator->fetch(); if (!empty($currency)) { return; } $languageID = ''; $siteIterator = SiteTable::getList(array('select' => array('LID', 'LANGUAGE_ID'), 'filter' => array('=DEF' => 'Y', '=ACTIVE' => 'Y'))); if ($site = $siteIterator->fetch()) { $languageID = (string) $site['LANGUAGE_ID']; } unset($site, $siteIterator); if ($languageID == '') { $languageID = 'en'; } $currencyList = array(); $currencySetID = ''; switch ($languageID) { case 'ua': case 'de': case 'en': case 'la': case 'tc': case 'sc': case 'in': $currencySetID = $languageID; break; case 'ru': if (!$bitrix24) { $languageIterator = LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ID' => 'kz', '=ACTIVE' => 'Y'))); if ($existLanguage = $languageIterator->fetch()) { $currencySetID = $existLanguage['ID']; } if ($currencySetID == '') { $languageIterator = LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ID' => 'ua', '=ACTIVE' => 'Y'))); if ($existLanguage = $languageIterator->fetch()) { $currencySetID = $existLanguage['ID']; } } unset($existLanguage, $languageIterator); } if ($currencySetID == '') { $currencySetID = $languageID; } break; default: $currencySetID = 'en'; break; } $datetimeEntity = new Main\DB\SqlExpression(Main\Application::getConnection()->getSqlHelper()->getCurrentDateTimeFunction()); switch ($currencySetID) { case 'kz': $addCurrency = array(array('CURRENCY' => 'KZT', 'NUMCODE' => '398', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 4.4, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 4.4), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 283.17, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 283.17), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 310.78, 'AMOUNT_CNT' => 1, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 310.78)); break; case 'ua': $addCurrency = array(array('CURRENCY' => 'UAH', 'NUMCODE' => '980', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 3.61, 'AMOUNT_CNT' => 10, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.361), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 2322.93, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 23.2293), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 2548.19, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 25.4819)); break; case 'ru': $addCurrency = array(array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 64.36, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 64.36), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 70.59999999999999, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 70.59999999999999), array('CURRENCY' => 'UAH', 'NUMCODE' => '980', 'AMOUNT' => 27.69, 'AMOUNT_CNT' => 10, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 2.769), array('CURRENCY' => 'BYR', 'NUMCODE' => '974', 'AMOUNT' => 36.9, 'AMOUNT_CNT' => 10000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.00369)); break; case 'de': case 'la': $addCurrency = array(array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 0.91, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.91), array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 14.35, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1435), array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 23.21, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.2321), array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 13.97, 'AMOUNT_CNT' => 1000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.01397)); break; case 'tc': case 'sc': $addCurrency = array(array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 6.36, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 6.36), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 6.97, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 6.97), array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 1.61, 'AMOUNT_CNT' => 1, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 1.61), array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 9.74, 'AMOUNT_CNT' => 100, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.09737)); break; case 'in': $addCurrency = array(array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 65.31, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 65.31), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 71.56, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 71.56), array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 10.27, 'AMOUNT_CNT' => 1, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 10.27), array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 16.56, 'AMOUNT_CNT' => 1, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 16.56)); break; case 'br': $addCurrency = array(array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 3.9, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 3.9), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 4.29, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 4.29), array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 61.44, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.6143999999999999), array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 5.99, 'AMOUNT_CNT' => 100, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.0599)); break; default: case 'en': $addCurrency = array(array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 1.1, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 1.1), array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 15.73, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1573), array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 25.35, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.2535), array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 15.31, 'AMOUNT_CNT' => 1000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.01531)); break; } foreach ($addCurrency as &$fields) { $fields['CREATED_BY'] = null; $fields['MODIFIED_BY'] = null; $fields['DATE_CREATE'] = $datetimeEntity; $fields['DATE_UPDATE'] = $datetimeEntity; $currencyResult = \Bitrix\Currency\CurrencyTable::add($fields); if ($currencyResult->isSuccess()) { $currencyList[] = $fields['CURRENCY']; } } unset($currencyResult, $fields); if (!empty($currencyList)) { Option::set('currency', 'installed_currencies', implode(',', $currencyList), ''); $languageIterator = LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ACTIVE' => 'Y'))); while ($existLanguage = $languageIterator->fetch()) { $messList = Loc::loadLanguageFile($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/currency/install_lang.php', $existLanguage['ID']); foreach ($currencyList as &$oneCurrency) { $fields = array('LID' => $existLanguage['ID'], 'CURRENCY' => $oneCurrency, 'THOUSANDS_SEP' => false, 'DECIMALS' => 2, 'HIDE_ZERO' => 'Y', 'FORMAT_STRING' => $messList['CUR_INSTALL_' . $oneCurrency . '_FORMAT_STRING'], 'FULL_NAME' => $messList['CUR_INSTALL_' . $oneCurrency . '_FULL_NAME'], 'DEC_POINT' => $messList['CUR_INSTALL_' . $oneCurrency . '_DEC_POINT'], 'THOUSANDS_VARIANT' => $messList['CUR_INSTALL_' . $oneCurrency . '_THOUSANDS_SEP'], 'CREATED_BY' => null, 'MODIFIED_BY' => null, 'DATE_CREATE' => $datetimeEntity, 'TIMESTAMP_X' => $datetimeEntity); $resultCurrencyLang = \Bitrix\Currency\CurrencyLangTable::add($fields); unset($resultCurrencyLang); } unset($oneCurrency, $messList); } unset($existLanguage, $languageIterator); if (!$bitrix24) { $checkDate = Main\Type\DateTime::createFromTimestamp(strtotime('tomorrow 00:01:00')); CAgent::AddAgent('\\Bitrix\\Currency\\CurrencyTable::currencyBaseRateAgent();', 'currency', 'Y', 86400, '', 'Y', $checkDate->toString(), 100, false, true); unset($checkDate); } \Bitrix\Currency\CurrencyManager::clearCurrencyCache(); } unset($datetimeEntity); }
protected function installCurrencies() { if (!Loader::includeModule('currency')) return; $bitrix24Path = $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/bitrix24/'; $bitrix24 = file_exists($bitrix24Path) && is_dir($bitrix24Path); unset($bitrix24Path); $currencyIterator = \Bitrix\Currency\CurrencyTable::getList(array( 'select' => array('CURRENCY'), 'limit' => 1 )); $currency = $currencyIterator->fetch(); if (!empty($currency)) return; $languageID = ''; $siteIterator = SiteTable::getList(array( 'select' => array('LID', 'LANGUAGE_ID'), 'filter' => array('=DEF' => 'Y', '=ACTIVE' => 'Y') )); if ($site = $siteIterator->fetch()) $languageID = (string)$site['LANGUAGE_ID']; unset($site, $siteIterator); if ($languageID == '') $languageID = 'en'; $currencyList = array(); $currencySetID = ''; switch ($languageID) { case 'ua': case 'de': case 'en': case 'la': case 'tc': case 'sc': $currencySetID = $languageID; break; case 'ru': if (!$bitrix24) { $languageIterator = LanguageTable::getList(array( 'select' => array('ID'), 'filter' => array('=ID' => 'kz', '=ACTIVE' => 'Y') )); if ($existLanguage = $languageIterator->fetch()) $currencySetID = $existLanguage['ID']; if ($currencySetID == '') { $languageIterator = LanguageTable::getList(array( 'select' => array('ID'), 'filter' => array('=ID' => 'ua', '=ACTIVE' => 'Y') )); if ($existLanguage = $languageIterator->fetch()) $currencySetID = $existLanguage['ID']; } unset($existLanguage, $languageIterator); } if ($currencySetID == '') $currencySetID = $languageID; break; default: $currencySetID = 'en'; break; } $datetimeEntity = new Main\DB\SqlExpression(Main\Application::getConnection()->getSqlHelper()->getCurrentDateTimeFunction()); switch ($currencySetID) { case 'kz': $addCurrency = array( array('CURRENCY' => 'KZT', 'NUMCODE' => '398', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 1, 'AMOUNT_CNT' => 3.09, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 3.09), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 1, 'AMOUNT_CNT' => 185.5, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 185.5), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 1, 'AMOUNT_CNT' => 198.13, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 198.13) ); break; case 'ua': $addCurrency = array( array('CURRENCY' => 'UAH', 'NUMCODE' => '980', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 4.00, 'AMOUNT_CNT' => 10, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.4), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 2355.70, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 23.557), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 2579.49, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 25.7949) ); break; case 'ru': $addCurrency = array( array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 57.39, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 57.39), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 62.77, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 62.77), array('CURRENCY' => 'UAH', 'NUMCODE' => '980', 'AMOUNT' => 24.53, 'AMOUNT_CNT' => 10, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 2.453), array('CURRENCY' => 'BYR', 'NUMCODE' => '974', 'AMOUNT' => 39.44, 'AMOUNT_CNT' => 10000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.003944) ); break; case 'de': case 'la': $addCurrency = array( array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 0.91, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.91), array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 14.65, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1465), array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 29.12, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.2912), array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 14.59, 'AMOUNT_CNT' => 1000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.01459) ); break; case 'tc': case 'sc': $addCurrency = array( array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 6.21, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1610), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 6.75, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1482), array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 1.93, 'AMOUNT_CNT' => 1, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.5181), array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 9,94, 'AMOUNT_CNT' => 100, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.0994) ); break; default: case 'en': $addCurrency = array( array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 1.09, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 1.09), array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 16.09, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1609), array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 31.24, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.3124), array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 16.02, 'AMOUNT_CNT' => 1000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.01602) ); break; } foreach ($addCurrency as &$fields) { $fields['CREATED_BY'] = null; $fields['MODIFIED_BY'] = null; $fields['DATE_CREATE'] = $datetimeEntity; $fields['DATE_UPDATE'] = $datetimeEntity; $currencyResult = \Bitrix\Currency\CurrencyTable::add($fields); if ($currencyResult->isSuccess()) $currencyList[] = $fields['CURRENCY']; } unset($currencyResult, $fields); if (!empty($currencyList)) { Option::set('currency', 'installed_currencies', implode(',', $currencyList), ''); $languageIterator = LanguageTable::getList(array( 'select' => array('ID'), 'filter' => array('=ACTIVE' => 'Y') )); while ($existLanguage = $languageIterator->fetch()) { $messList = Loc::loadLanguageFile($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/currency/install_lang.php', $existLanguage['ID']); foreach($currencyList as &$oneCurrency) { $fields = array( 'LID' => $existLanguage['ID'], 'CURRENCY' => $oneCurrency, 'THOUSANDS_SEP' => false, 'DECIMALS' => 2, 'HIDE_ZERO' => 'Y', 'FORMAT_STRING' => $messList['CUR_INSTALL_'.$oneCurrency.'_FORMAT_STRING'], 'FULL_NAME' => $messList['CUR_INSTALL_'.$oneCurrency.'_FULL_NAME'], 'DEC_POINT' => $messList['CUR_INSTALL_'.$oneCurrency.'_DEC_POINT'], 'THOUSANDS_VARIANT' => $messList['CUR_INSTALL_'.$oneCurrency.'_THOUSANDS_SEP'], 'CREATED_BY' => null, 'MODIFIED_BY' => null, 'DATE_CREATE' => $datetimeEntity, 'TIMESTAMP_X' => $datetimeEntity ); $resultCurrencyLang = \Bitrix\Currency\CurrencyLangTable::add($fields); unset($resultCurrencyLang); } unset($oneCurrency, $messList); } unset($existLanguage, $languageIterator); if (!$bitrix24) { $checkDate = Main\Type\DateTime::createFromTimestamp(strtotime('tomorrow 00:01:00'));; CAgent::AddAgent('\Bitrix\Currency\CurrencyTable::currencyBaseRateAgent();', 'currency', 'Y', 86400, '', 'Y', $checkDate->toString(), 100, false, true); unset($checkDate); } \Bitrix\Currency\CurrencyManager::clearCurrencyCache(); } unset($datetimeEntity); }