/** * Return currencies list. * * @return array Currencies list. * @throws SystemException * @throws \Bitrix\Main\LoaderException */ public static function getCurrenciesList() { static $currencies = null; if ($currencies === null) { $currencies = array(); if (!\Bitrix\Main\Loader::includeModule('currency')) { throw new SystemException("Can't include module \"Currency\"!"); } $currencies = Currency\CurrencyManager::getCurrencyList(); } return $currencies; }
protected function getConfigStructure() { static $handlers = null; $initedHandlers = self::getRegisteredHandlers("SID"); sortByColumn($initedHandlers, array(strtoupper("NAME") => SORT_ASC)); if ($handlers === null) { $handlers = array("" => ""); foreach ($initedHandlers as $handler) { $handlers[$handler["SID"]] = $handler["NAME"] . " [" . $handler["SID"] . "]"; } } if (strlen($this->handlerInitParams["SID"]) <= 0 || $this->id <= 0) { $result = array("MAIN" => array("TITLE" => Loc::getMessage("SALE_DLVR_HANDL_AUT_HANDLER_SETTINGS"), "DESCRIPTION" => Loc::getMessage("SALE_DLVR_HANDL_AUT_HANDLER_SETTINGS_DSCR"), "ITEMS" => array("SID" => array("TYPE" => "ENUM", "NAME" => Loc::getMessage("SALE_DLVR_HANDL_AUT_HANDLER_CHOOSE"), "OPTIONS" => $handlers, "ONCHANGE" => "top.BX.showWait(); if(this.form.elements['NAME'].value == '') this.form.elements['NAME'].value = this.selectedOptions[0].innerHTML.replace(/\\s*\\[.*\\]/g,''); this.form.submit();")))); } else { $handler = $this->handlerInitParams["SID"]; $result = array("MAIN" => array("TITLE" => Loc::getMessage("SALE_DLVR_HANDL_AUT_HANDLER_SETTINGS"), "DESCRIPTION" => Loc::getMessage("SALE_DLVR_HANDL_AUT_HANDLER_SETTINGS_DSCR"), "ITEMS" => array("SID" => array("TYPE" => "DELIVERY_READ_ONLY", "NAME" => Loc::getMessage("SALE_DLVR_HANDL_AUT_HANDLER_CHOOSE"), "VALUE" => $handler, "VALUE_VIEW" => $handlers[$handler]), "DESCRIPTION_INNER" => array("TYPE" => "DELIVERY_READ_ONLY", "NAME" => Loc::getMessage("SALE_DLVR_HANDL_AUT_DESCRIPTION_INNER"), "VALUE" => $this->handlerInitParams["DESCRIPTION_INNER"])))); } $serviceCurrency = $this->currency; if (\Bitrix\Main\Loader::includeModule('currency')) { $currencyList = CurrencyManager::getCurrencyList(); if (isset($currencyList[$this->currency])) { $serviceCurrency = $currencyList[$this->currency]; } unset($currencyList); } $marginTypes = array("%" => "%", "CURRENCY" => $serviceCurrency); $result["MAIN"]["ITEMS"]["MARGIN_VALUE"] = array("TYPE" => "STRING", "NAME" => Loc::getMessage("SALE_DLVR_HANDL_AUT_MARGIN_VALUE"), "DEFAULT" => 0); $result["MAIN"]["ITEMS"]["MARGIN_TYPE"] = array("TYPE" => "ENUM", "NAME" => Loc::getMessage("SALE_DLVR_HANDL_AUT_MARGIN_TYPE"), "DEFAULT" => "%", "OPTIONS" => $marginTypes); if (strlen($this->sid) > 0) { $configProfileIds = array_keys($this->handlerInitParams["PROFILES"]); } else { $configProfileIds = array(); } if (isset($this->oldConfig["CONFIG_GROUPS"])) { $groupProfileIds = array_keys($this->oldConfig["CONFIG_GROUPS"]); $intersect = array_intersect($groupProfileIds, $configProfileIds); foreach ($intersect as $pid) { unset($this->oldConfig["CONFIG_GROUPS"][$pid]); } } $oldConfig = $this->convertOldConfigToNew($this->oldConfig); if (!empty($oldConfig)) { if (isset($oldConfig["CONFIG_GROUPS"]["MAIN"])) { $oldConfig["CONFIG_GROUPS"]["MAIN_OLD"] = $oldConfig["CONFIG_GROUPS"]["MAIN"]; unset($oldConfig["CONFIG_GROUPS"]["MAIN"]); } $result = array_merge($result, $oldConfig); } return $result; }
public function CheckFields($strAction, &$arFields, $intID = 0) { global $APPLICATION; global $DB; global $USER; $strAction = strtoupper($strAction); if ('UPDATE' != $strAction && 'ADD' != $strAction) { return false; } $intID = (int) $intID; $arCurrencyList = Currency\CurrencyManager::getCurrencyList(); $boolResult = true; $arMsg = array(); $clearFields = array('ID', '~ID', 'UNPACK', '~UNPACK', '~CONDITIONS', 'CONDITIONS', 'USE_COUPONS', '~USE_COUPONS', 'HANDLERS', '~HANDLERS', '~TYPE', '~RENEWAL', '~PRIORITY', '~LAST_DISCOUNT', '~VERSION', 'TIMESTAMP_X', 'DATE_CREATE', '~DATE_CREATE', '~MODIFIED_BY', '~CREATED_BY'); if ($strAction == 'UPDATE') { $clearFields[] = 'CREATED_BY'; } $arFields = array_filter($arFields, 'CCatalogDiscountSave::clearFields'); foreach ($clearFields as &$fieldName) { if (isset($arFields[$fieldName])) { unset($arFields[$fieldName]); } } unset($fieldName, $clearFields); $arFields['TYPE'] = self::ENTITY_ID; $arFields["RENEWAL"] = 'N'; $arFields['PRIORITY'] = 1; $arFields['LAST_DISCOUNT'] = 'Y'; $arFields['VERSION'] = Catalog\DiscountTable::ACTUAL_VERSION; if ((is_set($arFields, "SITE_ID") || $strAction == "ADD") && empty($arFields["SITE_ID"])) { $arMsg[] = array('id' => 'SITE_ID', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_EMPTY_SITE')); $boolResult = false; } else { $rsSites = CSite::GetByID($arFields['SITE_ID']); if (!($arSite = $rsSites->Fetch())) { $arMsg[] = array('id' => 'SITE_ID', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_SITE')); $boolResult = false; } } if ((is_set($arFields, "NAME") || $strAction == "ADD") && strlen(trim($arFields["NAME"])) <= 0) { $arMsg[] = array('id' => 'NAME', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_EMPTY_NAME')); $boolResult = false; } if ((is_set($arFields, "ACTIVE") || $strAction == "ADD") && $arFields["ACTIVE"] != "N") { $arFields["ACTIVE"] = "Y"; } if ((is_set($arFields, 'SORT') || $strAction == 'ADD') && intval($arFields['SORT']) <= 0) { $arFields['SORT'] = 500; } if ((is_set($arFields, "CURRENCY") || $strAction == "ADD") && empty($arFields["CURRENCY"])) { $arMsg[] = array('id' => 'CURRENCY', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_EMPTY_CURRENCY')); $boolResult = false; } if ((is_set($arFields, "ACTIVE_FROM") || $strAction == "ADD") && !$DB->IsDate($arFields["ACTIVE_FROM"], false, LANGUAGE_ID, "FULL")) { $arFields["ACTIVE_FROM"] = false; } if ((is_set($arFields, "ACTIVE_TO") || $strAction == "ADD") && !$DB->IsDate($arFields["ACTIVE_TO"], false, LANGUAGE_ID, "FULL")) { $arFields["ACTIVE_TO"] = false; } if ((is_set($arFields, 'COUNT_SIZE') || $strAction == 'ADD') && intval($arFields['COUNT_SIZE']) < 0) { $arFields['COUNT_SIZE'] = 0; } if ((is_set($arFields, 'COUNT_TYPE') || $strAction == 'ADD') && !in_array($arFields['COUNT_TYPE'], array('D', 'M', 'Y'))) { $arFields['COUNT_TYPE'] = 'Y'; } if ((is_set($arFields, "COUNT_FROM") || $strAction == "ADD") && !$DB->IsDate($arFields["COUNT_FROM"], false, LANGUAGE_ID, "FULL")) { $arFields["COUNT_FROM"] = false; } if ((is_set($arFields, "COUNT_TO") || $strAction == "ADD") && !$DB->IsDate($arFields["COUNT_TO"], false, LANGUAGE_ID, "FULL")) { $arFields["COUNT_TO"] = false; } if (is_set($arFields, 'COUNT_PERIOD')) { unset($arFields['COUNT_PERIOD']); } $strCountPeriod = self::COUNT_TIME_ALL; if (is_set($arFields, 'COUNT_SIZE') && intval($arFields['COUNT_SIZE']) > 0) { $strCountPeriod = self::COUNT_TIME_PERIOD; } if (!empty($arFields["COUNT_FROM"]) || !empty($arFields["COUNT_TO"])) { $strCountPeriod = self::COUNT_TIME_INTERVAL; } $arFields['COUNT_PERIOD'] = $strCountPeriod; if ((is_set($arFields, 'ACTION_SIZE') || $strAction == 'ADD') && intval($arFields['ACTION_SIZE']) < 0) { $arFields['ACTION_SIZE'] = 0; } if ((is_set($arFields, 'ACTION_TYPE') || $strAction == 'ADD') && !in_array($arFields['ACTION_TYPE'], array('D', 'M', 'Y'))) { $arFields['ACTION_TYPE'] = 'Y'; } $intUserID = 0; $boolUserExist = CCatalog::IsUserExists(); if ($boolUserExist) { $intUserID = (int) $USER->GetID(); } $strDateFunction = $DB->GetNowFunction(); $arFields['~TIMESTAMP_X'] = $strDateFunction; if ($boolUserExist) { if (!array_key_exists('MODIFIED_BY', $arFields) || (int) $arFields["MODIFIED_BY"] <= 0) { $arFields["MODIFIED_BY"] = $intUserID; } } if ('ADD' == $strAction) { $arFields['~DATE_CREATE'] = $strDateFunction; if ($boolUserExist) { if (!array_key_exists('CREATED_BY', $arFields) || (int) $arFields["CREATED_BY"] <= 0) { $arFields["CREATED_BY"] = $intUserID; } } } if (is_set($arFields, 'RANGES') || $strAction == 'ADD') { if (!is_array($arFields['RANGES']) || empty($arFields['RANGES'])) { $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_EMPTY_RANGES')); $boolResult = false; } else { $boolRepeat = false; $arRangeList = array(); foreach ($arFields['RANGES'] as &$arRange) { if (!is_array($arRange) || empty($arRange)) { $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE')); $boolResult = false; } else { if (empty($arRange['TYPE']) || $arRange['TYPE'] != self::TYPE_FIX) { $arRange['TYPE'] = self::TYPE_PERCENT; } if (isset($arRange['VALUE'])) { $arRange["VALUE"] = str_replace(",", ".", $arRange["VALUE"]); $arRange["VALUE"] = doubleval($arRange["VALUE"]); if (!(0 < $arRange["VALUE"])) { $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE_VALUE')); $boolResult = false; } elseif (self::TYPE_PERCENT == $arRange['TYPE'] && 100 < $arRange["VALUE"]) { $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE_VALUE')); $boolResult = false; } } else { $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE_VALUE')); $boolResult = false; } if (isset($arRange['RANGE_FROM'])) { $arRange["RANGE_FROM"] = str_replace(",", ".", $arRange["RANGE_FROM"]); $arRange["RANGE_FROM"] = doubleval($arRange["RANGE_FROM"]); if (0 > $arRange["RANGE_FROM"]) { $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE_FROM')); $boolResult = false; } else { if (in_array($arRange["RANGE_FROM"], $arRangeList)) { $boolRepeat = true; } else { $arRangeList[] = $arRange["RANGE_FROM"]; } } } else { $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE_FROM')); $boolResult = false; } } } if (isset($arRange)) { unset($arRange); } if ($boolRepeat) { $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_DUP_RANGE_FROM')); $boolResult = false; } } } if (isset($arFields['GROUP_IDS']) || $strAction == 'ADD') { if (!empty($arFields['GROUP_IDS'])) { if (!is_array($arFields['GROUP_IDS'])) { $arFields['GROUP_IDS'] = array($arFields['GROUP_IDS']); } $arValid = array(); foreach ($arFields['GROUP_IDS'] as &$intGroupID) { $intGroupID = (int) $intGroupID; if (0 < $intGroupID && 2 != $intGroupID) { $arValid[] = $intGroupID; } } if (isset($intGroupID)) { unset($intGroupID); } $arFields['GROUP_IDS'] = array_unique($arValid); } if (empty($arFields['GROUP_IDS'])) { $arMsg[] = array('id' => 'GROUP_IDS', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_EMPTY_GROUP_IDS')); $boolResult = false; } } if ($boolResult) { $cond = new CCatalogCondTree(); $boolCond = $cond->Init(BT_COND_MODE_GENERATE, BT_COND_BUILD_CATALOG, array()); if (!$boolCond) { $boolResult = false; } else { $arFields['CONDITIONS'] = $cond->GetDefaultConditions(); $arFields['UNPACK'] = $cond->Generate($arFields['CONDITIONS'], array()); $arFields['CONDITIONS'] = serialize($arFields['CONDITIONS']); } } if (!$boolResult) { $obError = new CAdminException($arMsg); $APPLICATION->ResetException(); $APPLICATION->ThrowException($obError); } return $boolResult; }
<?php /** @global CUser $USER */ use Bitrix\Main; use Bitrix\Currency; if ($USER->CanDoOperation('catalog_read') || $USER->CanDoOperation('catalog_price') || $USER->CanDoOperation('catalog_view')) { IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/catalog/templates/product_edit.php'); $currencyList = array(); foreach (Currency\CurrencyManager::getCurrencyList() as $currency => $currencyName) { $currencyList[$currency] = array('CURRENCY' => $currency, 'FULL_NAME' => htmlspecialcharsex($currencyName), 'FULL_NAME_JS' => CUtil::JSEscape(htmlspecialcharsbx($currencyName))); } unset($currency, $currencyName); $IBLOCK_ID = (int) $IBLOCK_ID; if ($IBLOCK_ID <= 0) { return; } $MENU_SECTION_ID = (int) $MENU_SECTION_ID; $PRODUCT_ID = $ID > 0 ? CIBlockElement::GetRealElement($ID) : 0; $arBaseProduct = false; $periodTimeTypes = array(); if ($arMainCatalog['SUBSCRIPTION'] == 'Y') { $arDefProduct = array('QUANTITY' => '', 'QUANTITY_RESERVED' => '', 'VAT_ID' => 0, 'VAT_INCLUDED' => 'N', 'QUANTITY_TRACE_ORIG' => 'D', 'CAN_BUY_ZERO_ORIG' => 'D', 'PRICE_TYPE' => '', 'RECUR_SCHEME_TYPE' => '', 'RECUR_SCHEME_LENGTH' => '', 'TRIAL_PRICE_ID' => '', 'WITHOUT_ORDER' => '', 'PURCHASING_PRICE' => '', 'PURCHASING_CURRENCY' => '', 'BARCODE_MULTI' => '', 'SUBSCRIBE_ORIG' => 'D'); $periodTimeTypes = CCatalogProduct::GetTimePeriodTypes(true); } else { $arDefProduct = array('QUANTITY' => '', 'QUANTITY_RESERVED' => '', 'WEIGHT' => '', 'WIDTH' => '', 'LENGTH' => '', 'HEIGHT' => '', 'MEASURE' => '', 'VAT_ID' => 0, 'VAT_INCLUDED' => 'N', 'QUANTITY_TRACE_ORIG' => 'D', 'CAN_BUY_ZERO_ORIG' => 'D', 'PURCHASING_PRICE' => '', 'PURCHASING_CURRENCY' => '', 'BARCODE_MULTI' => '', 'SUBSCRIBE_ORIG' => 'D'); } if ($PRODUCT_ID > 0) { $bReadOnly = !($USER->CanDoOperation('catalog_price') && CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $PRODUCT_ID, "element_edit_price")); if ($arMainCatalog['SUBSCRIPTION'] == 'Y') { $arProductSelect = array('ID', 'QUANTITY', 'QUANTITY_RESERVED', 'QUANTITY_TRACE_ORIG', 'VAT_ID', 'VAT_INCLUDED', 'CAN_BUY_ZERO_ORIG', 'PRICE_TYPE', 'RECUR_SCHEME_TYPE', 'RECUR_SCHEME_LENGTH', 'TRIAL_PRICE_ID', 'WITHOUT_ORDER', 'PURCHASING_PRICE', 'PURCHASING_CURRENCY', 'BARCODE_MULTI', 'SUBSCRIBE_ORIG', 'TYPE'); } else {
?> &mid=<?php echo $module_id; ?> " name="currency_settings"> <?php echo bitrix_sessid_post(); $tabControl->BeginNextTab(); ?> <tr> <td width="40%"><?php echo Loc::getMessage('BASE_CURRENCY'); ?> </td> <td width="60%"><select name="BASE_CURRENCY"><?php $currencyList = Currency\CurrencyManager::getCurrencyList(); if (!empty($currencyList)) { foreach ($currencyList as $currency => $title) { ?> <option value="<?php echo $currency; ?> "<?php echo $currency == $baseCurrency ? ' selected' : ''; ?> ><?php echo htmlspecialcharsex($title); ?> </option><?php } unset($title, $currency);
); $arComponentParameters["PARAMETERS"]['CONVERT_CURRENCY'] = array( 'PARENT' => 'PRICES', 'NAME' => GetMessage('CP_BCS_CONVERT_CURRENCY'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'N', 'REFRESH' => 'Y', ); if (isset($arCurrentValues['CONVERT_CURRENCY']) && $arCurrentValues['CONVERT_CURRENCY'] == 'Y') { $arComponentParameters['PARAMETERS']['CURRENCY_ID'] = array( 'PARENT' => 'PRICES', 'NAME' => GetMessage('CP_BCS_CURRENCY_ID'), 'TYPE' => 'LIST', 'VALUES' => Currency\CurrencyManager::getCurrencyList(), 'DEFAULT' => Currency\CurrencyManager::getBaseCurrency(), "ADDITIONAL_VALUES" => "Y", ); } } if (empty($offers)) { unset($arComponentParameters["PARAMETERS"]["OFFERS_FIELD_CODE"]); unset($arComponentParameters["PARAMETERS"]["OFFERS_PROPERTY_CODE"]); unset($arComponentParameters["PARAMETERS"]["OFFERS_SORT_FIELD"]); unset($arComponentParameters["PARAMETERS"]["OFFERS_SORT_ORDER"]); unset($arComponentParameters["PARAMETERS"]["OFFERS_SORT_FIELD2"]); unset($arComponentParameters["PARAMETERS"]["OFFERS_SORT_ORDER2"]); }
$arPrice = array(); if ($catalogIncluded) { $arPrice = CCatalogIBlockParameters::getPriceTypesList(); } $arProperty_UF = array(); $arSProperty_LNS = array(); if ($iblockExists) { $arUserFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("IBLOCK_" . $arCurrentValues["IBLOCK_ID"] . "_SECTION"); foreach ($arUserFields as $FIELD_NAME => $arUserField) { $arProperty_UF[$FIELD_NAME] = $arUserField["LIST_COLUMN_LABEL"] ? $arUserField["LIST_COLUMN_LABEL"] : $FIELD_NAME; if ($arUserField["USER_TYPE"]["BASE_TYPE"] == "string") { $arSProperty_LNS[$FIELD_NAME] = $arProperty_UF[$FIELD_NAME]; } } unset($arUserFields, $FIELD_NAME, $arUserField); } $arComponentParameters = array("GROUPS" => array("PRICES" => array("NAME" => GetMessage("CP_BCSF_PRICES")), "XML_EXPORT" => array("NAME" => GetMessage("CP_BCSF_GROUP_XML_EXPORT"))), "PARAMETERS" => array("SEF_MODE" => array(), "SEF_RULE" => array("VALUES" => array("SECTION_ID" => array("TEXT" => GetMessage("CP_BCSF_SECTION_ID"), "TEMPLATE" => "#SECTION_ID#", "PARAMETER_LINK" => "SECTION_ID", "PARAMETER_VALUE" => '={$_REQUEST["SECTION_ID"]}'), "SECTION_CODE" => array("TEXT" => GetMessage("CP_BCSF_SECTION_CODE"), "TEMPLATE" => "#SECTION_CODE#", "PARAMETER_LINK" => "SECTION_CODE", "PARAMETER_VALUE" => '={$_REQUEST["SECTION_CODE"]}'), "SECTION_CODE_PATH" => array("TEXT" => GetMessage("CP_BCSF_SECTION_CODE_PATH"), "TEMPLATE" => "#SECTION_CODE_PATH#", "PARAMETER_LINK" => "SECTION_CODE_PATH", "PARAMETER_VALUE" => '={$_REQUEST["SECTION_CODE_PATH"]}'), "SMART_FILTER_PATH" => array("TEXT" => GetMessage("CP_BCSF_SMART_FILTER_PATH"), "TEMPLATE" => "#SMART_FILTER_PATH#", "PARAMETER_LINK" => "SMART_FILTER_PATH", "PARAMETER_VALUE" => '={$_REQUEST["SMART_FILTER_PATH"]}'))), "IBLOCK_TYPE" => array("PARENT" => "DATA_SOURCE", "NAME" => GetMessage("CP_BCSF_IBLOCK_TYPE"), "TYPE" => "LIST", "ADDITIONAL_VALUES" => "Y", "VALUES" => $arIBlockType, "REFRESH" => "Y"), "IBLOCK_ID" => array("PARENT" => "DATA_SOURCE", "NAME" => GetMessage("CP_BCSF_IBLOCK_ID"), "TYPE" => "LIST", "ADDITIONAL_VALUES" => "Y", "VALUES" => $arIBlock, "REFRESH" => "Y"), "SECTION_ID" => array("PARENT" => "DATA_SOURCE", "NAME" => GetMessage("CP_BCSF_SECTION_ID"), "TYPE" => "STRING", "DEFAULT" => '={$_REQUEST["SECTION_ID"]}'), "SECTION_CODE" => array("PARENT" => "DATA_SOURCE", "NAME" => GetMessage("CP_BCSF_SECTION_CODE"), "TYPE" => "STRING", "DEFAULT" => ''), "FILTER_NAME" => array("PARENT" => "DATA_SOURCE", "NAME" => GetMessage("CP_BCSF_FILTER_NAME"), "TYPE" => "STRING", "DEFAULT" => "arrFilter"), "PRICE_CODE" => array("PARENT" => "PRICES", "NAME" => GetMessage("CP_BCSF_PRICE_CODE"), "TYPE" => "LIST", "MULTIPLE" => "Y", "VALUES" => $arPrice), "CACHE_TIME" => array("DEFAULT" => 36000000), "CACHE_GROUPS" => array("PARENT" => "CACHE_SETTINGS", "NAME" => GetMessage("CP_BCSF_CACHE_GROUPS"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y"), "SAVE_IN_SESSION" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("CP_BCSF_SAVE_IN_SESSION"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "INSTANT_RELOAD" => array("PARENT" => "ADDITIONAL_SETTINGS", "NAME" => GetMessage("CP_BCSF_INSTANT_RELOAD"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "XML_EXPORT" => array("PARENT" => "XML_EXPORT", "NAME" => GetMessage("CP_BCSF_XML_EXPORT"), "TYPE" => "CHECKBOX", "DEFAULT" => "N"), "SECTION_TITLE" => array("PARENT" => "XML_EXPORT", "NAME" => GetMessage("CP_BCSF_SECTION_TITLE"), "TYPE" => "LIST", "MULTIPLE" => "N", "DEFAULT" => "-", "VALUES" => array_merge(array("-" => " ", "NAME" => GetMessage("IBLOCK_FIELD_NAME")), $arSProperty_LNS)), "SECTION_DESCRIPTION" => array("PARENT" => "XML_EXPORT", "NAME" => GetMessage("CP_BCSF_SECTION_DESCRIPTION"), "TYPE" => "LIST", "MULTIPLE" => "N", "DEFAULT" => "-", "VALUES" => array_merge(array("-" => " ", "NAME" => GetMessage("IBLOCK_FIELD_NAME"), "DESCRIPTION" => GetMessage("IBLOCK_FIELD_DESCRIPTION")), $arSProperty_LNS)))); if ($arCurrentValues["SEF_MODE"] == "Y") { $arComponentParameters["PARAMETERS"]["SECTION_CODE_PATH"] = array("NAME" => GetMessage("CP_BCSF_SECTION_CODE_PATH"), "TYPE" => "STRING", "DEFAULT" => ""); $arComponentParameters["PARAMETERS"]["SMART_FILTER_PATH"] = array("NAME" => GetMessage("CP_BCSF_SMART_FILTER_PATH"), "TYPE" => "STRING", "DEFAULT" => ""); } if ($catalogIncluded) { $arComponentParameters["PARAMETERS"]['HIDE_NOT_AVAILABLE'] = array('PARENT' => 'DATA_SOURCE', 'NAME' => GetMessage('CP_BCSF_HIDE_NOT_AVAILABLE'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'N'); $arComponentParameters["PARAMETERS"]['CONVERT_CURRENCY'] = array('PARENT' => 'PRICES', 'NAME' => GetMessage('CP_BCSF_CONVERT_CURRENCY'), 'TYPE' => 'CHECKBOX', 'DEFAULT' => 'N', 'REFRESH' => 'Y'); if (isset($arCurrentValues['CONVERT_CURRENCY']) && $arCurrentValues['CONVERT_CURRENCY'] == 'Y') { $arComponentParameters['PARAMETERS']['CURRENCY_ID'] = array('PARENT' => 'PRICES', 'NAME' => GetMessage('CP_BCSF_CURRENCY_ID'), 'TYPE' => 'LIST', 'VALUES' => Currency\CurrencyManager::getCurrencyList(), 'DEFAULT' => Currency\CurrencyManager::getBaseCurrency(), "ADDITIONAL_VALUES" => "Y"); } } if (empty($arPrice)) { unset($arComponentParameters["PARAMETERS"]["PRICE_CODE"]); }
protected function getConfigStructure() { static $profiles = null; if ($profiles === null) { $profiles = array("" => ""); foreach ($this->parentHandlerInitParams["PROFILES"] as $profileId => $profileParams) { $profiles[$profileId] = $profileParams["TITLE"] . " [" . $profileId . "]"; } } $result = array("MAIN" => array("TITLE" => Loc::getMessage("SALE_DLVR_HANDL_AUTP_CONF_MAIN_TITLE"), "DESCRIPTION" => Loc::getMessage("SALE_DLVR_HANDL_AUTP_CONF_MAIN_DESCR"), "ITEMS" => array("PROFILE_ID" => array("TYPE" => "ENUM", "NAME" => Loc::getMessage("SALE_DLVR_HANDL_AUTP_CONF_MAIN_PROFILE_ID"), "OPTIONS" => $profiles, "ONCHANGE" => "top.BX.showWait(); this.form.submit(); /* elements.apply.click();*/")))); $serviceCurrency = $this->currency; if (\Bitrix\Main\Loader::includeModule('currency')) { $currencyList = CurrencyManager::getCurrencyList(); if (isset($currencyList[$this->currency])) { $serviceCurrency = $currencyList[$this->currency]; } unset($currencyList); } $marginTypes = array("%" => "%", "CURRENCY" => $serviceCurrency); $result["MAIN"]["ITEMS"]["MARGIN_VALUE"] = array("TYPE" => "STRING", "NAME" => Loc::getMessage("SALE_DLVR_HANDL_AUT_MARGIN_VALUE"), "DEFAULT" => 0); $result["MAIN"]["ITEMS"]["MARGIN_TYPE"] = array("TYPE" => "ENUM", "NAME" => Loc::getMessage("SALE_DLVR_HANDL_AUT_MARGIN_TYPE"), "DEFAULT" => "%", "OPTIONS" => $marginTypes); $configProfileIds = array_keys($this->parentHandlerInitParams["PROFILES"]); if (strlen($this->profileId) > 0 && in_array($this->profileId, $configProfileIds)) { $oldAutoConfig = $this->parentAutomatic->getOldConfig(); if ($oldAutoConfig && isset($oldAutoConfig["CONFIG_GROUPS"]) && is_array($oldAutoConfig["CONFIG_GROUPS"])) { foreach ($oldAutoConfig["CONFIG_GROUPS"] as $key => $groupId) { if ($this->profileId != $groupId) { unset($oldAutoConfig["CONFIG_GROUPS"][$key]); } } foreach ($oldAutoConfig["CONFIG"] as $key => $params) { if ($this->profileId != $params["CONFIG"]) { unset($oldAutoConfig["CONFIG"][$key]); } } } $oldConfig = Automatic::convertOldConfigToNew($oldAutoConfig); if (!empty($oldConfig)) { if (isset($oldConfig["CONFIG_GROUPS"]["MAIN"])) { $oldConfig["CONFIG_GROUPS"]["MAIN_OLD"] = $oldConfig["CONFIG_GROUPS"]["MAIN"]; unset($oldConfig["CONFIG_GROUPS"]["MAIN"]); } $result = array_merge($result, $oldConfig); } } return $result; }
public static function SelectBox($sFieldName, $sValue, $sDefaultValue = '', $bFullName = true, $JavaFunc = '', $sAdditionalParams = '') { $s = '<select name="' . $sFieldName . '"'; if ('' != $JavaFunc) { $s .= ' onchange="' . $JavaFunc . '"'; } if ('' != $sAdditionalParams) { $s .= ' ' . $sAdditionalParams . ' '; } $s .= '>'; $s1 = ''; $found = false; $currencyList = Currency\CurrencyManager::getCurrencyList(); if (!empty($currencyList) && is_array($currencyList)) { foreach ($currencyList as $currency => $title) { $found = $currency == $sValue; $s1 .= '<option value="' . $currency . '"' . ($found ? ' selected' : '') . '>' . ($bFullName ? htmlspecialcharsex($title) : $currency) . '</option>'; } } if ('' != $sDefaultValue) { $s .= '<option value=""' . ($found ? '' : ' selected') . '>' . htmlspecialcharsex($sDefaultValue) . '</option>'; } return $s . $s1 . '</select>'; }
/** * @return array * @throws \Exception */ protected function getConfigStructure() { $currency = $this->currency; if (Loader::includeModule('currency')) { $currencyList = Currency\CurrencyManager::getCurrencyList(); if (isset($currencyList[$this->currency])) { $currency = $currencyList[$this->currency]; } unset($currencyList); } return array("MAIN" => array("TITLE" => Loc::getMessage("SALE_DLVR_HANDL_CONF_TITLE"), "DESCRIPTION" => Loc::getMessage("SALE_DLVR_HANDL_CONF_DESCRIPTION"), "ITEMS" => array("CURRENCY" => array("TYPE" => "DELIVERY_READ_ONLY", "NAME" => Loc::getMessage("SALE_DLVR_HANDL_CONF_CURRENCY"), "VALUE" => $this->currency, "VALUE_VIEW" => $currency), "PRICE" => array("TYPE" => "NUMBER", "MIN" => 0, "NAME" => Loc::getMessage("SALE_DLVR_HANDL_CONF_PRICE")), "PERIOD" => array("TYPE" => "DELIVERY_PERIOD", "NAME" => Loc::getMessage("SALE_DLVR_HANDL_CONF_PERIOD_DLV"), "ITEMS" => array("FROM" => array("TYPE" => "NUMBER", "MIN" => 0, "NAME" => ""), "TO" => array("TYPE" => "NUMBER", "MIN" => 0, "NAME" => " - "), "TYPE" => array("TYPE" => "ENUM", "OPTIONS" => array("H" => Loc::getMessage("SALE_DLVR_HANDL_CONF_PERIOD_HOUR"), "D" => Loc::getMessage("SALE_DLVR_HANDL_CONF_PERIOD_DAY"), "M" => Loc::getMessage("SALE_DLVR_HANDL_CONF_PERIOD_MONTH")))))))); }
$boolPriceInc = true; } } if (is_array($arCatGroup) && !empty($arCatGroup)) { foreach ($arCatGroup as &$CatalogGroups) { if (in_array("CATALOG_GROUP_" . $CatalogGroups["ID"], $arSelectedFields)) { $arFilter["CATALOG_SHOP_QUANTITY_" . $CatalogGroups["ID"]] = 1; $boolPriceInc = true; } } unset($CatalogGroups); } if ($boolPriceInc) { $boolSubCurrency = Loader::includeModule('currency'); if ($boolSubCurrency) { $arCurrencyList = array_keys(Currency\CurrencyManager::getCurrencyList()); } } unset($boolPriceInc); } $arSelectedFieldsMap = array(); foreach ($arSelectedFields as $field) { $arSelectedFieldsMap[$field] = true; } $measureList = array(0 => ' '); if (isset($arSelectedFieldsMap['CATALOG_MEASURE'])) { $measureIterator = CCatalogMeasure::getList(array(), array(), false, false, array('ID', 'MEASURE_TITLE', 'SYMBOL_RUS')); while ($measure = $measureIterator->Fetch()) { $measureList[$measure['ID']] = $measure['SYMBOL_RUS'] != '' ? $measure['SYMBOL_RUS'] : $measure['MEASURE_TITLE']; } unset($measure, $measureIterator);
<?php use Bitrix\Conversion\Config; use Bitrix\Currency\CurrencyManager; use Bitrix\Main\Loader; use Bitrix\Main\Localization\Loc; Loc::loadMessages($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/options.php'); Loc::loadMessages(__FILE__); if (!$USER->IsAdmin()) { return; } $modules = Config::getModules(); // TODO all modules with attributes must be active unset($modules['conversion'], $modules['abtest'], $modules['sender'], $modules['seo']); $currency = Config::getBaseCurrency(); if (!(Loader::includeModule('currency') && ($currencies = CurrencyManager::getCurrencyList()))) { $currencies = array($currency => $currency); } if ($REQUEST_METHOD == 'POST' && strlen($Update . $Apply . $RestoreDefaults) > 0 && check_bitrix_sessid()) { if (strlen($RestoreDefaults) > 0) { Config::setBaseCurrency(null); $currency = Config::getBaseCurrency(); Config::setModules(array()); $modules = Config::getModules(); } else { if ($currencies[$_POST['CURRENCY']]) { $currency = $_POST['CURRENCY']; Config::setBaseCurrency($currency); } foreach ($modules as $name => $config) { $modules[$name]['ACTIVE'] = isset($_POST['MODULE'][$name]['ACTIVE']);
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } /** @var array $arCurrentValues */ use Bitrix\Main\Loader; use Bitrix\Currency; if (!Loader::includeModule('currency')) { return; } $arComponentParameters = array("PARAMETERS" => array("arrCURRENCY_FROM" => array("NAME" => GetMessage("CURRENCY_FROM"), "TYPE" => "LIST", "MULTIPLE" => "Y", "ADDITIONAL_VALUES" => "N", "VALUES" => Currency\CurrencyManager::getCurrencyList(), "GROUP" => "BASE"), "CURRENCY_BASE" => array("NAME" => GetMessage("CURRENCY_BASE"), "TYPE" => "LIST", "MULTIPLE" => "N", "ADDITIONAL_VALUES" => "N", "VALUES" => Currency\CurrencyManager::getCurrencyList(), "DEFAULT" => Currency\CurrencyManager::getBaseCurrency(), "GROUP" => "BASE"), "RATE_DAY" => array("NAME" => GetMessage("CURRENCY_RATE_DAY"), "TYPE" => "STRING", "GROUP" => "ADDITIONAL_PARAMETERS"), "SHOW_CB" => array("NAME" => GetMessage("T_CURRENCY_CBRF"), "TYPE" => "CHECKBOX", "MULTIPLE" => "N", "DEFAULT" => "N", "ADDITIONAL_VALUES" => "N", "GROUP" => "ADDITIONAL_PARAMETERS"), "CACHE_TIME" => array("DEFAULT" => "86400")));
/** * @return array * @throws \Exception */ protected function getConfigStructure() { $currency = $this->currency; if (Loader::includeModule('currency')) { $currencyList = CurrencyManager::getCurrencyList(); if (isset($currencyList[$this->currency])) { $currency = $currencyList[$this->currency]; } unset($currencyList); } $result = array("MAIN" => array("TITLE" => Loc::getMessage("SALE_DLVR_HANDL_SMPL_TAB_MAIN"), "DESCRIPTION" => Loc::getMessage("SALE_DLVR_HANDL_SMPL_TAB_MAIN_DESCR"), "ITEMS" => array("CURRENCY" => array("TYPE" => "DELIVERY_READ_ONLY", "NAME" => Loc::getMessage("SALE_DLVR_HANDL_SMPL_CURRENCY"), "VALUE" => $this->currency, "VALUE_VIEW" => $currency), 0 => array("TYPE" => "NUMBER", "MIN" => 0, "NAME" => Loc::getMessage("SALE_DLVR_HANDL_SMPL_DEFAULT"))))); foreach (self::getLocationGroups() as $groupId => $groupName) { $result["MAIN"]["ITEMS"][$groupId] = array("TYPE" => "NUMBER", "MIN" => 0, "NAME" => $groupName); } return $result; }