/**
  * getRegionsList
  * @return array regions (locations) list
  */
 public static function getRegionsList($countryId = 0, $bFlip = false)
 {
     static $arRegions = array();
     $flipIndex = intval($bFlip);
     if (isset($arRegions[$countryId][$flipIndex])) {
         return $arRegions[$countryId][$flipIndex];
     }
     if (CSaleLocation::isLocationProMigrated()) {
         $types = array();
         $res = \Bitrix\Sale\Location\TypeTable::getList(array('select' => array('ID', 'CODE')));
         while ($item = $res->fetch()) {
             $types[$item['CODE']] = $item['ID'];
         }
         $filter = array(array('LOGIC' => 'OR', array('=TYPE_ID' => $types['CITY'], '=NAME.LANGUAGE_ID' => LANGUAGE_ID, array('LOGIC' => 'OR', array('=PARENT.TYPE_ID' => $types['COUNTRY']), array('=PARENT.TYPE_ID' => $types['COUNTRY_DISTRICT']), array('=PARENT_ID' => '0'))), array('=TYPE_ID' => $types['REGION'])));
         if (intval($countryId)) {
             $filter['=PARENTS.TYPE_ID'] = $types['COUNTRY'];
             $filter['=PARENTS.ID'] = $countryId;
         }
         $dbRegionList = \Bitrix\Sale\Location\LocationTable::getList(array('filter' => $filter, 'select' => array('ID', 'CODE', 'NAME_LANG' => 'NAME.NAME'), 'order' => array('NAME.NAME' => 'asc')));
     } else {
         $arFilterRegion = array();
         if (intval($countryId) > 0) {
             $arFilterRegion["COUNTRY_ID"] = $countryId;
         }
         $dbRegionList = CSaleLocation::GetRegionList(array("NAME_LANG" => "ASC"), $arFilterRegion, LANGUAGE_ID);
     }
     $key = 'ID';
     while ($arRegionList = $dbRegionList->Fetch()) {
         if ($key == 'ID' && isset($arRegionList['CODE'])) {
             $key = 'CODE';
         }
         if ($key == 'CODE' && strlen($arRegionList['CODE']) <= 0) {
             continue;
         }
         $arRegions[$countryId][0][$arRegionList[$key]] = $arRegionList["NAME_LANG"];
         // $bFlip == false
         $arRegions[$countryId][1][$arRegionList["NAME_LANG"]] = $arRegionList[$key];
         // $bFlip == true
     }
     return isset($arRegions[$countryId][$flipIndex]) ? $arRegions[$countryId][$flipIndex] : array();
 }
Esempio n. 2
0
 public static function getTypes($params = array('LANGUAGE_ID' => LANGUAGE_ID))
 {
     if (!is_array($params)) {
         $params = array();
     }
     if (!isset($params['LANGUAGE_ID'])) {
         $params['LANGUAGE_ID'] = LANGUAGE_ID;
     }
     $result = array();
     $lang = ToLower($params['LANGUAGE_ID']);
     $langMapped = static::mapLanguage($lang);
     $res = \Bitrix\Sale\Location\TypeTable::getList(array('select' => array('*', 'TNAME' => 'NAME.NAME', 'TLANGUAGE_ID' => 'NAME.LANGUAGE_ID'), 'order' => array('SORT' => 'asc', 'NAME.NAME' => 'asc')));
     while ($item = $res->fetch()) {
         if (!isset($result[$item['CODE']])) {
             $result[$item['CODE']] = array('CODE' => $item['CODE'], 'ID' => $item['ID'], 'NAME' => array());
         }
         $result[$item['CODE']]['NAME'][$item['TLANGUAGE_ID']] = $item['TNAME'];
     }
     foreach ($result as $code => &$data) {
         if ((string) $data['NAME'][$lang] != '') {
             $name = $data['NAME'][$lang];
         } else {
             if ((string) $data['NAME'][$langMapped] != '') {
                 $name = $data['NAME'][$langMapped];
             } else {
                 $name = $data['NAME']['en'];
             }
         }
         $data['NAME_CURRENT'] = $name;
     }
     return $result;
 }
Esempio n. 3
0
 public static function validateUpdateRequest(&$data)
 {
     $errors = parent::validateUpdateRequest($data);
     // if type is set in data and not empty, it must exist
     $typeError = false;
     if (intval($data['TYPE_ID'])) {
         $type = Location\TypeTable::getList(array('select' => array('ID'), 'filter' => array('=ID' => intval($data['TYPE_ID']))))->fetch();
         if (!$type) {
             $typeError = true;
         }
     } else {
         $typeError = true;
     }
     if ($typeError) {
         $errors[] = Loc::getMessage('SALE_LOCATION_ADMIN_LOCATION_HELPER_ENTITY_TYPE_ID_UNKNOWN_ERROR');
     }
     // formally check service ids in EXTERNAL parameter
     if (is_array($data['EXTERNAL']) && !empty($data['EXTERNAL'])) {
         $services = self::getExternalServicesList();
         foreach ($data['EXTERNAL'] as $external) {
             if (!isset($services[$external['SERVICE_ID']])) {
                 $errors[] = Loc::getMessage('SALE_LOCATION_ADMIN_LOCATION_HELPER_ENTITY_UNKNOWN_EXTERNAL_SERVICE_ID_ERROR');
                 break;
             }
         }
     }
     return $errors;
 }
Esempio n. 4
0
 public function __construct($parameters = array())
 {
     $this->resetProcess();
     if (is_array($parameters['TYPES']) && !empty($parameters['TYPES'])) {
         $this->procData['ALLOWED_TYPES'] = array_unique($parameters['TYPES']);
     }
     $typeSort = array();
     $res = Location\TypeTable::getList(array('select' => array('ID', 'CODE', 'SORT')));
     while ($item = $res->fetch()) {
         if (!is_array($this->procData['ALLOWED_TYPES']) || is_array($this->procData['ALLOWED_TYPES']) && in_array($item['ID'], $this->procData['ALLOWED_TYPES'])) {
             $this->procData['TYPES'][$item['CODE']] = $item['ID'];
         }
         $this->procData['TYPE_SORT'][$item['ID']] = $item['SORT'];
     }
     $this->procData['TYPES_BACK'] = array_flip($this->procData['TYPES']);
     $this->initInsertHandles();
 }
Esempio n. 5
0
 public static function reInitData()
 {
     static::cleanUp();
     $offset = 0;
     $stat = array();
     $types = array();
     $typeSort = array();
     $res = Location\TypeTable::getList(array('select' => array('ID', 'CODE', 'SORT')));
     while ($item = $res->fetch()) {
         if ($item['CODE'] == 'CITY' || $item['CODE'] == 'VILLAGE' || $item['CODE'] == 'STREET') {
             $types[$item['CODE']] = $item['ID'];
         }
         $typeSort[$item['ID']] = $item['SORT'];
     }
     $typesBack = array_flip($types);
     //_print_r($types);
     //_print_r($typeSort);
     while (true) {
         $res = Location\LocationTable::getList(array('select' => array('ID', 'TYPE_ID'), 'filter' => array('=TYPE_ID' => array_values($types)), 'limit' => self::STEP_SIZE, 'offset' => $offset));
         $cnt = 0;
         while ($item = $res->fetch()) {
             $resPath = Location\LocationTable::getPathToNode($item['ID'], array('select' => array('ID', 'TYPE_ID'), 'filter' => array('=TYPE_ID' => array_values($types))));
             $path = array();
             while ($pItem = $resPath->fetch()) {
                 $path[$typesBack[$pItem['TYPE_ID']]] = $pItem['ID'];
             }
             //_print_r($path);
             $data = array('CITY_ID' => isset($path['CITY']) ? $path['CITY'] : 0, 'VILLAGE_ID' => isset($path['VILLAGE']) ? $path['VILLAGE'] : 0, 'STREET_ID' => isset($path['STREET']) ? $path['STREET'] : 0, 'TYPE_SORT' => $typeSort[$item['TYPE_ID']], 'LOCATION_ID' => $item['ID']);
             //_print_r($data);
             foreach ($data as &$value) {
                 $value = "'" . $value . "'";
             }
             //static::add($data);
             $GLOBALS['DB']->query("insert into " . static::getTableName() . " (CITY_ID, VILLAGE_ID, STREET_ID, TYPE_SORT, LOCATION_ID) values (" . implode(', ', $data) . ")");
             $cnt++;
         }
         if (!$cnt) {
             break;
         }
         $offset += self::STEP_SIZE;
     }
 }
Esempio n. 6
0
	protected function obtainDataLocationTypes(&$cachedData)
	{
		$res = Location\TypeTable::getList(array(
			'select' => array(
				'*',
				'LNAME' => 'NAME.NAME'
			),
			'filter' => array(
				'NAME.LANGUAGE_ID' => LANGUAGE_ID
			),
			'order' => array(
				'SORT' => 'asc',
				'NAME.NAME' => 'asc'
			)
		));
		$res->addReplacedAliases(array('LNAME' => 'NAME'));
		$types = array();
		while($item = $res->fetch())
			$types[$item['ID']] = $item;

		$cachedData['TYPES'] = $types;
	}
Esempio n. 7
0
	public static function getTypeCodeIdMapCached()
	{
		static $types;

		if($types == null)
		{
			$res = \Bitrix\Sale\Location\TypeTable::getList(array(
				'select' => array(
					'ID', 'CODE'
				)
			));

			$types = array();
			while($item = $res->Fetch())
			{
				$types['ID2CODE'][intval($item['ID'])] = $item['CODE'];
				$types['CODE2ID'][$item['CODE']] = intval($item['ID']);
			}
		}

		return $types;
	}
Esempio n. 8
0
 public static function resetLegacyPath()
 {
     $dbConnection = Main\HttpApplication::getConnection();
     $locTable = static::getTableName();
     $types = array();
     $res = TypeTable::getList(array('filter' => array('CODE' => array('COUNTRY', 'REGION', 'CITY')), 'select' => array('ID', 'CODE')));
     while ($item = $res->fetch()) {
         $types[$item['CODE']] = $item['ID'];
     }
     if (!empty($types)) {
         if (!$dbConnection->isTableExists('b_sale_loc_rebind')) {
             $dbConnection->query("create table b_sale_loc_rebind (TARGET_ID " . Helper::getSqlForDataType('int') . ", LOCATION_ID " . Helper::getSqlForDataType('int') . ")");
         } else {
             $dbConnection->query("truncate table b_sale_loc_rebind");
         }
         $sqlWhere = array();
         foreach ($types as $code => $id) {
             $sqlWhere[] = "'" . intval($id) . "'";
         }
         $dbConnection->query("update " . $locTable . " set COUNTRY_ID = NULL, REGION_ID = NULL, CITY_ID = NULL where TYPE_ID in (" . implode(', ', $sqlWhere) . ")");
         if (intval($types['REGION']) && intval($types['COUNTRY'])) {
             // countries for regions
             $dbConnection->query("insert into b_sale_loc_rebind (TARGET_ID, LOCATION_ID) select A.ID as ONE, B.ID as TWO from " . $locTable . " A inner join " . $locTable . " B on A.TYPE_ID = '" . intval($types['REGION']) . "' and B.TYPE_ID = '" . intval($types['COUNTRY']) . "' and B.LEFT_MARGIN <= A.LEFT_MARGIN and B.RIGHT_MARGIN >= A.RIGHT_MARGIN");
             Helper::mergeTables($locTable, 'b_sale_loc_rebind', array('COUNTRY_ID' => 'LOCATION_ID'), array('ID' => 'TARGET_ID'));
             $dbConnection->query("truncate table b_sale_loc_rebind");
         }
         if (intval($types['REGION']) && intval($types['CITY'])) {
             // regions for cities
             $dbConnection->query("insert into b_sale_loc_rebind (TARGET_ID, LOCATION_ID) select A.ID as ONE, B.ID as TWO from " . $locTable . " A inner join " . $locTable . " B on A.TYPE_ID = '" . intval($types['CITY']) . "' and B.TYPE_ID = '" . intval($types['REGION']) . "' and B.LEFT_MARGIN <= A.LEFT_MARGIN and B.RIGHT_MARGIN >= A.RIGHT_MARGIN");
             Helper::mergeTables($locTable, 'b_sale_loc_rebind', array('REGION_ID' => 'LOCATION_ID'), array('ID' => 'TARGET_ID'));
             $dbConnection->query("truncate table b_sale_loc_rebind");
         }
         if (intval($types['COUNTRY']) && intval($types['CITY'])) {
             // countries for cities
             $dbConnection->query("insert into b_sale_loc_rebind (TARGET_ID, LOCATION_ID) select A.ID as ONE, B.ID as TWO from " . $locTable . " A inner join " . $locTable . " B on A.TYPE_ID = '" . intval($types['CITY']) . "' and B.TYPE_ID = '" . intval($types['COUNTRY']) . "' and B.LEFT_MARGIN <= A.LEFT_MARGIN and B.RIGHT_MARGIN >= A.RIGHT_MARGIN");
             Helper::mergeTables($locTable, 'b_sale_loc_rebind', array('COUNTRY_ID' => 'LOCATION_ID'), array('ID' => 'TARGET_ID'));
         }
         Helper::dropTable('b_sale_loc_rebind');
         if (intval($types['COUNTRY'])) {
             $dbConnection->query("update " . $locTable . " set COUNTRY_ID = ID where TYPE_ID = '" . intval($types['COUNTRY']) . "'");
         }
         if (intval($types['REGION'])) {
             $dbConnection->query("update " . $locTable . " set REGION_ID = ID where TYPE_ID = '" . intval($types['REGION']) . "'");
         }
         if (intval($types['CITY'])) {
             $dbConnection->query("update " . $locTable . " set CITY_ID = ID where TYPE_ID = '" . intval($types['CITY']) . "'");
         }
     }
 }
	public static function getTypeList()
	{
		static $types;

		if($types == null)
		{
			$res = Location\TypeTable::getList(array(
				'filter' => array(
					'NAME.LANGUAGE_ID' => LANGUAGE_ID,
				),
				'select' => array(
					'ID',
					'LNAME' => 'NAME.NAME'
				),
				'order' => array(
					'SORT' => 'asc',
					'NAME.NAME' => 'asc'
				)
			));
			$res->addReplacedAliases(array('LNAME' => 'NAME'));

			$types = array();
			while($item = $res->Fetch())
				$types[intval($item['ID'])] = htmlspecialcharsbx($item['NAME']);
		}

		return $types;
	}
Esempio n. 10
0
									'=CODE' => $countryCode,
									'=TYPE.CODE' => 'COUNTRY'
								),
								'select' => array(
									'ID'
								)
							))->fetch();

							// country found
							if($item)
								$countryId = $item['ID'];
						}

						// at this point types must exist
						$types = array();
						$res = \Bitrix\Sale\Location\TypeTable::getList();
						while($item = $res->fetch())
							$types[$item['CODE']] = $item['ID'];

						if(isset($types['COUNTRY']) && isset($types['CITY']))
						{
							if(!$countryId)
							{
								// such country were not found, create it

								$data = array(
									'CODE' => 'demo_country_'.WIZARD_SITE_ID,
									'TYPE_ID' => $types['COUNTRY'],
									'NAME' => array()
								);
								foreach($arLanguages as $langID)
Esempio n. 11
0
 public static function getExistedTypes()
 {
     $existed = array();
     $res = Location\TypeTable::getList(array('select' => array('ID', 'CODE', 'SORT')));
     while ($item = $res->fetch()) {
         $existed[$item['CODE']] = $item['ID'];
     }
     return $existed;
 }
Esempio n. 12
0
 /**
  * <p>Метод возвращает языконезависимые параметры города с кодом ID. Метод динамичный.</p>
  *
  *
  * @param int $ID  Код города.
  *
  * @return array <p>Возвращается ассоциативный массив с ключами:</p> <table class="tnormal"
  * width="100%"> <tr> <th width="15%">Ключ</th> <th>Описание</th> </tr> <tr> <td>ID</td> <td>Код
  * города.</td> </tr> <tr> <td>NAME</td> <td>Языконезависимое название города.</td>
  * </tr> <tr> <td>SHORT_NAME</td> <td>Языконезависимое короткое название города.</td>
  * </tr> <tr> <td>REGION_ID</td> <td>Код региона.</td> </tr> </table> <br><br>
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalelocation/csalelocation__getcitybyid.fb724f2b.php
  * @author Bitrix
  */
 public static function GetCityByID($ID)
 {
     if (self::isLocationProMigrated()) {
         static $regionId;
         try {
             if (!$regionId) {
                 $params = array('select' => array());
                 $res = \Bitrix\Sale\Location\TypeTable::getList(array('filter' => array('=CODE' => 'REGION'), 'select' => array('ID')))->fetch();
                 if ($res['ID']) {
                     $regionId = $res['ID'];
                 }
             }
             if ($regionId) {
                 $params['runtime'] = array('P' => array('data_type' => '\\Bitrix\\Sale\\Location\\Location', 'reference' => array('<=ref.LEFT_MARGIN' => 'this.LEFT_MARGIN', '>=ref.RIGHT_MARGIN' => 'this.RIGHT_MARGIN', '=ref.TYPE_ID' => array('?', $regionId)), 'join_type' => "left"));
                 $params['select']['PREGION_ID'] = 'P.ID';
             }
             $params['filter'] = array('=TYPE.CODE' => 'CITY', '=ID' => intval($ID), '=NAME.LANGUAGE_ID' => 'en');
             $params['select'] = array_merge($params['select'], array('ID', 'LNAME' => 'NAME.NAME', 'SHORT_NAME' => 'NAME.SHORT_NAME'));
             $res = \Bitrix\Sale\Location\LocationTable::getList($params);
             $res->addReplacedAliases(array('LNAME' => 'NAME', 'PREGION_ID' => 'REGION_ID'));
             $item = $res->fetch();
             if ($item) {
                 return $item;
             }
             return false;
         } catch (Exception $e) {
             return false;
         }
     } else {
         global $DB;
         $ID = IntVal($ID);
         $strSql = "SELECT * " . "FROM b_sale_location_city " . "WHERE ID = " . $ID . " ";
         $db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($res = $db_res->Fetch()) {
             return $res;
         }
         return False;
     }
 }
Esempio n. 13
0
 protected static function getTypesFromDb()
 {
     $typesFromDb = array();
     $res = Location\TypeTable::getList(array('select' => array('ID')));
     while ($item = $res->fetch()) {
         $typesFromDb[intval($item['ID'])] = true;
     }
     return $typesFromDb;
 }
Esempio n. 14
0
 public static function reInitData($parameters = array())
 {
     static::createTables();
     $offset = 0;
     $stat = array();
     $types = array();
     $typeSort = array();
     $res = Location\TypeTable::getList(array('select' => array('ID', 'CODE', 'SORT')));
     $allowedTypes = array('REGION', 'SUBREGION', 'CITY', 'VILLAGE', 'STREET');
     while ($item = $res->fetch()) {
         if (in_array($item['CODE'], $allowedTypes)) {
             $types[$item['CODE']] = $item['ID'];
         }
         $typeSort[$item['ID']] = $item['SORT'];
     }
     $typesBack = array_flip($types);
     //print_r($types);
     //_print_r($typeSort);
     $wordChain = array();
     $pathChain = array();
     //_dump_r('GO!');
     $prevDepth = 0;
     while (true) {
         $res = Location\LocationTable::getList(array('select' => array('ID', 'TYPE_ID', 'LNAME' => 'NAME.NAME', 'DEPTH_LEVEL', 'SORT'), 'filter' => array('=TYPE_ID' => array_values($types), '=NAME.LANGUAGE_ID' => LANGUAGE_ID), 'order' => array('LEFT_MARGIN' => 'asc'), 'limit' => self::STEP_SIZE, 'offset' => $offset));
         $cnt = 0;
         while ($item = $res->fetch()) {
             if ($item['DEPTH_LEVEL'] < $prevDepth) {
                 //print('DROP to '.$item['DEPTH_LEVEL'].'<br />');
                 // drop chain to DEPTH_LEVEL inclusively
                 $newWC = array();
                 $newPC = array();
                 foreach ($wordChain as $dl => $name) {
                     if ($dl >= $item['DEPTH_LEVEL']) {
                         break;
                     }
                     $newWC[$dl] = $name;
                 }
                 $wordChain = $newWC;
                 foreach ($pathChain as $dl => $id) {
                     if ($dl >= $item['DEPTH_LEVEL']) {
                         break;
                     }
                     $newPC[$dl] = $id;
                 }
                 $pathChain = $newPC;
             }
             $wordChain[$item['DEPTH_LEVEL']] = $item['LNAME'];
             $pathChain[$item['DEPTH_LEVEL']] = array('TYPE' => $item['TYPE_ID'], 'ID' => $item['ID']);
             $prevDepth = $item['DEPTH_LEVEL'];
             //print($item['DEPTH_LEVEL'].' - '.implode(' ', WordStatTable::parseQuery(implode(' ', $wordChain))).'<br />');
             $parsed = WordStatTable::parseQuery(implode(' ', $wordChain));
             $wordMap = array();
             $i = 1;
             foreach ($parsed as $word) {
                 $wordMap['W_' . $i] = $word;
                 $i++;
             }
             $pathMap = array();
             foreach ($pathChain as $elem) {
                 $pathMap[$typesBack[$elem['TYPE']] . '_ID'] = $elem['ID'];
             }
             $data = array_merge($wordMap, $pathMap, array('LOCATION_ID' => $item['ID'], 'TYPE_ID' => $item['TYPE_ID'], 'TYPE_SORT' => $typeSort[$item['TYPE_ID']], 'SORT' => $item['SORT'], 'WORD_COUNT' => count($wordMap)));
             //print('<pre>');
             //print('</pre>');
             try {
                 static::add($data);
             } catch (\Exception $e) {
                 _dump_r('Cant add ' . implode(' ', $wordChain) . ' (' . count($wordMap) . ')<br />');
                 // duplicate or smth
             }
             $cnt++;
         }
         if (!$cnt) {
             break;
         }
         $offset += self::STEP_SIZE;
     }
 }
Esempio n. 15
0
	public static function getTypes()
	{
		$types = array();
		$res = Location\TypeTable::getList();
		while($item = $res->fetch())
			$types[$item['CODE']] = $item['ID'];

		return $types;
	}
Esempio n. 16
0
	protected function obtainDataLocationTypes(&$cachedData)
	{
		$res = Location\TypeTable::getList(array('select' => array('ID', 'CODE'), 'order' => array('SORT' => 'asc')));
		while($item = $res->fetch())
		{
			$id = $item['ID'];
			unset($item['ID']);
			$cachedData['TYPES'][$id] = $item;
		}
	}
Esempio n. 17
0
			{
				include($_SERVER["DOCUMENT_ROOT"].$templateFolder."/confirm.php");
			}
		}
		else
		{
			echo '<div class="page-title">'.GetMessage("SOA_TEMPL_HEADER").'</div><div class="row"><div class="col l7">';
			echo '<p class="page-note-text">'.GetMessage("ORDER_NOTICE").'</p>';
			?>
			<script type="text/javascript">

			<?if(CSaleLocation::isLocationProEnabled()):?>

				<?
				// spike: for children of cities we place this prompt
				$city = \Bitrix\Sale\Location\TypeTable::getList(array('filter' => array('=CODE' => 'CITY'), 'select' => array('ID')))->fetch();
				?>

				BX.saleOrderAjax.init(<?php 
echo CUtil::PhpToJSObject(array('source' => $this->__component->getPath() . '/get.php', 'cityTypeId' => intval($city['ID']), 'messages' => array('otherLocation' => '--- ' . GetMessage('SOA_OTHER_LOCATION'), 'moreInfoLocation' => '--- ' . GetMessage('SOA_NOT_SELECTED_ALT'), 'notFoundPrompt' => '<div class="-bx-popup-special-prompt">' . GetMessage('SOA_LOCATION_NOT_FOUND') . '.<br />' . GetMessage('SOA_LOCATION_NOT_FOUND_PROMPT', array('#ANCHOR#' => '<a href="javascript:void(0)" class="-bx-popup-set-mode-add-loc">', '#ANCHOR_END#' => '</a>')) . '</div>')));
?>
);

			<?endif?>

			var BXFormPosting = false;
			function submitForm(val)
			{
				if (BXFormPosting === true)
					return true;
Esempio n. 18
0
 private function grabTree()
 {
     $this->data['LOC'] = array();
     $auxIndex = array('COUNTRY' => array(), 'REGION' => array(), 'CITY' => array());
     $this->data['LOC'] = array('COUNTRY' => array(), 'REGION' => array(), 'CITY' => array());
     // level 1: country
     $res = \CSaleLocation::GetList(array(), array('!COUNTRY_ID' => false, 'REGION_ID' => false, 'CITY_ID' => false, 'LID' => 'en'));
     while ($item = $res->Fetch()) {
         if (!isset($this->data['LOC']['COUNTRY'][$item['ID']])) {
             $this->data['LOC']['COUNTRY'][$item['ID']] = array('SUBJ_ID' => $item['COUNTRY_ID'], 'PARENT_ID' => false, 'PARENT_TYPE' => false);
             $auxIndex['COUNTRY'][$item['COUNTRY_ID']] = $item['ID'];
         }
     }
     // level 2: country - region
     $res = \CSaleLocation::GetList(array(), array('!REGION_ID' => false, 'CITY_ID' => false, 'LID' => 'en'));
     while ($item = $res->Fetch()) {
         if (!isset($this->data['LOC']['REGION'][$item['ID']])) {
             $this->data['LOC']['REGION'][$item['ID']] = array('SUBJ_ID' => $item['REGION_ID'], 'PARENT_ID' => $auxIndex['COUNTRY'][$item['COUNTRY_ID']], 'PARENT_TYPE' => 'COUNTRY');
             $auxIndex['REGION'][$item['REGION_ID']] = $item['ID'];
         }
     }
     // level 2: country - city
     $res = \CSaleLocation::GetList(array(), array('REGION_ID' => false, '!CITY_ID' => false, 'LID' => 'en'));
     while ($item = $res->Fetch()) {
         if (!isset($this->data['LOC']['CITY'][$item['ID']])) {
             $this->data['LOC']['CITY'][$item['ID']] = array('SUBJ_ID' => $item['CITY_ID'], 'PARENT_ID' => $auxIndex['COUNTRY'][$item['COUNTRY_ID']], 'PARENT_TYPE' => 'COUNTRY');
         }
     }
     // level 3: country - region - city
     $res = \CSaleLocation::GetList(array(), array('!REGION_ID' => false, '!CITY_ID' => false, 'LID' => 'en'));
     while ($item = $res->Fetch()) {
         if (!isset($this->data['LOC']['CITY'][$item['ID']])) {
             $this->data['LOC']['CITY'][$item['ID']] = array('SUBJ_ID' => $item['CITY_ID'], 'PARENT_ID' => $auxIndex['REGION'][$item['REGION_ID']], 'PARENT_TYPE' => 'REGION');
         }
     }
     // language list
     $a = false;
     $b = false;
     $lang = new \CLanguage();
     $res = $lang->GetList($a, $b);
     $this->data['LANG'] = array();
     while ($item = $res->Fetch()) {
         $this->data['LANG'][] = $item['LID'];
     }
     // type list
     $res = Location\TypeTable::getList();
     while ($item = $res->Fetch()) {
         $this->data['TYPE'][$item['CODE']] = $item['ID'];
     }
 }