• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/delivery/services/automatic_profile.php
  • Класс: BitrixSaleDeliveryServicesAutomaticProfile
  • Вызов: AutomaticProfile::getConfigStructure
protected function getConfigStructure()
{
	static $profiles = null;

	if($profiles === null)
	{
		$profiles = array("" => "");

		foreach($this->parentHandlerInitParams["PROFILES"] as $profileId => $profileParams)
			if($profileParams["TITLE"] <> '')
				$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" => "STRING",
					"NAME" => "PROFILE_ID",
					"HIDDEN" => true,
					"DEFAULT" => $this->profileId
				),
				"PROFILE_NAME" => array(
					"TYPE" => "STRING",
					"NAME" => Loc::getMessage("SALE_DLVR_HANDL_AUTP_CONF_MAIN_PROFILE_ID"),
					"DEFAULT" => $profiles[$this->profileId] ?? '',
					"READONLY" => true
				)
			)
		)
	);

	$serviceCurrency = $this->currency;

	if(BitrixMainLoader::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($this->profileId <> '' && 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 (!isset($params["CONFIG"]))
				{
					unset($oldAutoConfig["CONFIG"][$key]);
				}
				elseif ($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;
}