Esempio n. 1
0
 function CheckCurrency($currency)
 {
     global $CML2_CURRENCY;
     if ($currency == $this->mess["IBLOCK_XML2_RUB"]) {
         $currency = "RUB";
     } elseif (!preg_match("/^[a-zA-Z]+\$/", $currency)) {
         if (is_array($CML2_CURRENCY) && isset($CML2_CURRENCY[$currency]) && is_string($CML2_CURRENCY[$currency]) && preg_match("/^[a-zA-Z0-9]+\$/", $CML2_CURRENCY[$currency])) {
             $currency = $CML2_CURRENCY[$currency];
         } else {
             $currency = "RUB";
             $this->LAST_ERROR = GetMessage("IBLOCK_XML2_CURRENCY_ERROR");
         }
     }
     if (!isset($this->arCurrencyCache[$currency])) {
         if ($this->bCatalog && CModule::IncludeModule('currency')) {
             CCurrency::Add(array("CURRENCY" => $currency));
         }
         $this->arCurrencyCache[$currency] = true;
     }
     return $currency;
 }
Esempio n. 2
0
 public static function Add($arFields)
 {
     if (!CModule::IncludeModule('currency')) {
         self::$LAST_ERROR = GetMessage('CRM_CURRERCY_MODULE_IS_NOT_INSTALLED');
         return false;
     }
     global $APPLICATION;
     $ID = isset($arFields['CURRENCY']) ? $arFields['CURRENCY'] : '';
     if (!self::CheckFields('ADD', $arFields, $ID)) {
         return false;
     }
     $ID = CCurrency::Add($arFields);
     if (!$ID) {
         $ex = $APPLICATION->GetException();
         if ($ex) {
             self::$LAST_ERROR = $ex->GetString();
         }
         return false;
     }
     self::ClearCache();
     return $ID;
 }
Esempio n. 3
0
 }
 $strAction = $ID ? 'UPDATE' : 'ADD';
 $langSettings = array();
 foreach ($langID as &$oneLang) {
     if (isset($_POST['LANG_' . $oneLang])) {
         $langSettings[$oneLang] = $_POST['LANG_' . $oneLang];
     }
 }
 unset($oneLang);
 $arFields['LANG'] = $langSettings;
 unset($langSettings);
 $DB->StartTransaction();
 if ($ID) {
     $res = CCurrency::Update($ID, $arFields);
 } else {
     $ID = (string) CCurrency::Add($arFields);
     $res = $ID !== '';
 }
 if (!$res) {
     $DB->Rollback();
     if ($ex = $APPLICATION->GetException()) {
         $errorMessage[] = $ex->GetString();
     } else {
         $errorMessage[] = ($ID ? str_replace('#ID#', $ID, GetMessage('BT_CURRENCY_EDIT_ERR_UPDATE')) : GetMessage('BT_CURRENCY_EDIT_ERR_ADD')) . "<br>";
     }
 } else {
     $DB->Commit();
     if (empty($_POST['apply'])) {
         LocalRedirect('/bitrix/admin/currencies.php?lang=' . LANGUAGE_ID);
     }
     LocalRedirect('/bitrix/admin/currency_edit.php?ID=' . $ID . '&lang=' . LANGUAGE_ID . '&' . $tabControl->ActiveTabParam());
Esempio n. 4
0
            CCurrency::Add($arFields);
            $dbLangs = CLanguage::GetList($b, $o, array("ACTIVE" => "Y"));
            while ($arLangs = $dbLangs->Fetch()) {
                IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/currency/install_lang.php", $arLangs["LID"]);
                $arFields = array("LID" => $arLangs["LID"], "CURRENCY" => "UAH", "FORMAT_STRING" => GetMessage("CUR_INSTALL_UAH_FORMAT_STRING") ? GetMessage("CUR_INSTALL_UAH_FORMAT_STRING") : "", "FULL_NAME" => GetMessage("CUR_INSTALL_UAH_FULL_NAME"), "DEC_POINT" => GetMessage("CUR_INSTALL_UAH_DEC_POINT"), "THOUSANDS_VARIANT" => GetMessage("CUR_INSTALL_UAH_THOUSANDS_SEP"), "THOUSANDS_SEP" => false, "DECIMALS" => 2, "HIDE_ZERO" => "Y");
                if (!empty($arFields)) {
                    CCurrencyLang::Add($arFields);
                }
            }
        }
        break;
    case 'bl':
        $iblockXMLFilePrices = WIZARD_SERVICE_RELATIVE_PATH . "/xml/" . LANGUAGE_ID . "/catalog_prices_bl.xml";
        if (!CCurrency::GetByID('BYR')) {
            $arFields = array("CURRENCY" => "BYR", "AMOUNT" => 36.72, "AMOUNT_CNT" => 10000, "SORT" => 500);
            CCurrency::Add($arFields);
            $dbLangs = CLanguage::GetList($b, $o, array("ACTIVE" => "Y"));
            while ($arLangs = $dbLangs->Fetch()) {
                IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/currency/install_lang.php", $arLangs["LID"]);
                $arFields = array("LID" => $arLangs["LID"], "CURRENCY" => "BYR", "FORMAT_STRING" => GetMessage("CUR_INSTALL_BYR_FORMAT_STRING") ? GetMessage("CUR_INSTALL_BYR_FORMAT_STRING") : "", "FULL_NAME" => GetMessage("CUR_INSTALL_BYR_FULL_NAME"), "DEC_POINT" => GetMessage("CUR_INSTALL_BYR_DEC_POINT"), "THOUSANDS_VARIANT" => GetMessage("CUR_INSTALL_BYR_THOUSANDS_SEP"), "THOUSANDS_SEP" => false, "DECIMALS" => 2, "HIDE_ZERO" => "Y");
                if (!empty($arFields)) {
                    CCurrencyLang::Add($arFields);
                }
            }
        }
        break;
    default:
        $iblockXMLFilePrices = WIZARD_SERVICE_RELATIVE_PATH . "/xml/" . LANGUAGE_ID . "/catalog_prices.xml";
        break;
}
$iblockCode = "clothes_" . WIZARD_SITE_ID;
Esempio n. 5
0
 function InstallDB()
 {
     global $DB, $DBType, $APPLICATION;
     global $stackCacheManager;
     global $CACHE_MANAGER;
     $this->errors = false;
     if (!$DB->Query("SELECT COUNT(CURRENCY) FROM b_catalog_currency", true)) {
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/currency/install/db/" . $DBType . "/install.sql");
     }
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("", $this->errors));
         return false;
     }
     RegisterModule("currency");
     $stackCacheManager->Clear("currency_currency_lang");
     $CACHE_MANAGER->Clean("currency_currency_list");
     $CACHE_MANAGER->Clean("currency_base_currency");
     $stackCacheManager->Clear("currency_rate");
     if (CModule::IncludeModule("currency")) {
         $dbCurrency = CCurrency::GetList($by = "sort", $order = "asc");
         if (!$dbCurrency->Fetch()) {
             $rsLang = CLanguage::GetByID("ru");
             if ($arLang = $rsLang->Fetch()) {
                 $arFields = array("CURRENCY" => "RUB", "AMOUNT" => 1, "AMOUNT_CNT" => 1, "SORT" => 100);
                 CCurrency::Add($arFields);
                 $arFields = array("CURRENCY" => "USD", "AMOUNT" => 30.33, "AMOUNT_CNT" => 1, "SORT" => 200);
                 CCurrency::Add($arFields);
                 $arFields = array("CURRENCY" => "EUR", "AMOUNT" => 38.98, "AMOUNT_CNT" => 1, "SORT" => 300);
                 CCurrency::Add($arFields);
                 $arFields = array("CURRENCY" => "UAH", "AMOUNT" => 3.77, "AMOUNT_CNT" => 1, "SORT" => 400);
                 CCurrency::Add($arFields);
                 $arCurrency = array("RUB", "USD", "EUR", "UAH");
             } else {
                 $rsLang = CLanguage::GetByID("de");
                 if ($arLang = $rsLang->Fetch()) {
                     $arFields = array("CURRENCY" => "USD", "AMOUNT" => 0.78, "AMOUNT_CNT" => 1, "SORT" => 200);
                     CCurrency::Add($arFields);
                     $arFields = array("CURRENCY" => "EUR", "AMOUNT" => 1, "AMOUNT_CNT" => 1, "SORT" => 100);
                     CCurrency::Add($arFields);
                     $arCurrency = array("USD", "EUR");
                 } else {
                     $arFields = array("CURRENCY" => "USD", "AMOUNT" => 1, "AMOUNT_CNT" => 1, "SORT" => 100);
                     CCurrency::Add($arFields);
                     $arFields = array("CURRENCY" => "EUR", "AMOUNT" => 1.26, "AMOUNT_CNT" => 1, "SORT" => 200);
                     CCurrency::Add($arFields);
                     $arCurrency = array("USD", "EUR");
                 }
             }
             $dbLangs = CLanguage::GetList($b = "", $o = "", array("ACTIVE" => "Y"));
             while ($arLangs = $dbLangs->Fetch()) {
                 $CACHE_MANAGER->Clean("currency_currency_list_" . $arLangs["LID"]);
                 IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/currency/install_lang.php", $arLangs["LID"]);
                 foreach ($arCurrency as $val) {
                     $arFields = array();
                     if ($val == "USD") {
                         $arFields = array("LID" => $arLangs["LID"], "CURRENCY" => "USD", "FORMAT_STRING" => GetMessage("CUR_INSTALL_USD_FORMAT_STRING"), "FULL_NAME" => GetMessage("CUR_INSTALL_USD_FULL_NAME"), "DEC_POINT" => GetMessage("CUR_INSTALL_USD_DEC_POINT"), "THOUSANDS_VARIANT" => GetMessage("CUR_INSTALL_USD_THOUSANDS_SEP"), "THOUSANDS_SEP" => false, "DECIMALS" => 2);
                     } elseif ($val == "EUR") {
                         $arFields = array("LID" => $arLangs["LID"], "CURRENCY" => "EUR", "FORMAT_STRING" => GetMessage("CUR_INSTALL_EUR_FORMAT_STRING"), "FULL_NAME" => GetMessage("CUR_INSTALL_EUR_FULL_NAME"), "DEC_POINT" => GetMessage("CUR_INSTALL_EUR_DEC_POINT"), "THOUSANDS_VARIANT" => GetMessage("CUR_INSTALL_EUR_THOUSANDS_SEP"), "THOUSANDS_SEP" => false, "DECIMALS" => 2);
                     } elseif ($val == "RUB") {
                         $arFields = array("LID" => $arLangs["LID"], "CURRENCY" => "RUB", "FORMAT_STRING" => GetMessage("CUR_INSTALL_RUB_FORMAT_STRING"), "FULL_NAME" => GetMessage("CUR_INSTALL_RUB_FULL_NAME"), "DEC_POINT" => GetMessage("CUR_INSTALL_RUB_DEC_POINT"), "THOUSANDS_VARIANT" => GetMessage("CUR_INSTALL_RUB_THOUSANDS_SEP"), "THOUSANDS_SEP" => false, "DECIMALS" => 2);
                     } elseif ($val == "UAH") {
                         $arFields = array("LID" => $arLangs["LID"], "CURRENCY" => "UAH", "FORMAT_STRING" => GetMessage("CUR_INSTALL_UAH_FORMAT_STRING"), "FULL_NAME" => GetMessage("CUR_INSTALL_UAH_FULL_NAME"), "DEC_POINT" => GetMessage("CUR_INSTALL_UAH_DEC_POINT"), "THOUSANDS_VARIANT" => GetMessage("CUR_INSTALL_UAH_THOUSANDS_SEP"), "THOUSANDS_SEP" => false, "DECIMALS" => 2);
                     }
                     CCurrencyLang::Add($arFields);
                 }
             }
         }
     }
     $stackCacheManager->Clear("currency_currency_lang");
     $CACHE_MANAGER->Clean("currency_currency_list");
     $CACHE_MANAGER->Clean("currency_base_currency");
     $stackCacheManager->Clear("currency_rate");
     return true;
 }