/**
  * 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();
 }
Example #2
0
 protected static function getUpperCityId($locationId)
 {
     if (strlen($locationId) <= 0) {
         return 0;
     }
     $res = LocationTable::getList(array('filter' => array(array('LOGIC' => 'OR', '=CODE' => $locationId, '=ID' => $locationId), '=PARENTS.TYPE.CODE' => 'CITY'), 'select' => array('ID', 'CODE', 'PID' => 'PARENTS.ID')));
     if ($loc = $res->fetch()) {
         return $loc['PID'];
     }
     return 0;
 }
Example #3
0
 public static function isLocationsCreated()
 {
     if (CSaleLocation::isLocationProMigrated()) {
         $res = Location\LocationTable::getList(array('select' => array('CNT')))->fetch();
         return $res['CNT'] > 0;
     }
     $dbResultList = CSaleLocation::GetList();
     if ($dbResultList->Fetch()) {
         return true;
     }
     return false;
 }
Example #4
0
	protected function obtainDataTreeTrunk(&$cachedData)
	{
		// check for static tree
		$forkItemFilter = false;

		$res = Location\LocationTable::getList(array(
			'group' => array('DEPTH_LEVEL'),
			'select' => array('DEPTH_LEVEL', 'CNT'),
			'order' => array('DEPTH_LEVEL' => 'asc')
		));
		$forkAtLevel = 0;
		while($item = $res->fetch())
		{
			if($item['CNT'] < 2)
				$forkAtLevel = $item['DEPTH_LEVEL'];
			else
				break;
		}

		if($forkAtLevel > 0)
			$forkItemFilter = array('DEPTH_LEVEL' => $forkAtLevel);

		// check for tree filtered by site

		if($this->filterBySite && is_array($cachedData['TEMP']['CONNECTORS']) && !empty($cachedData['TEMP']['CONNECTORS']))
		{
			$dcp = Location\LocationTable::getDeepestCommonParent($cachedData['TEMP']['CONNECTORS'], array('select' => array('ID')))->fetch();

			if(is_array($dcp) && intval($dcp['ID']))
				$forkItemFilter = array('ID' => intval($dcp['ID']));
		}

		$cachedData['TREE_TRUNK'] = array();
		if(is_array($forkItemFilter) && !empty($forkItemFilter)) // get fork item id
		{
			$res = Location\LocationTable::getPathToNodeByCondition($forkItemFilter, array(
				'select' => array_merge($this->getNodeSelectFields(), array('LNAME' => 'NAME.NAME')),
				'filter' => array('=NAME.LANGUAGE_ID' => LANGUAGE_ID)
			));
			$res->addReplacedAliases(array('LNAME' => 'NAME'));
			while($item = $res->fetch())
			{
				$cachedData['TREE_TRUNK'][] = $item;
			}
		}
	}
Example #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;
     }
 }
Example #6
0
 private static function AddLocationPart($creat, $type, $parent, $sort)
 {
     $langs = self::getLanguages();
     $types = self::getTypes();
     $creatFlds = array();
     if (is_numeric($creat)) {
         // check whether location exists...
         $res = Location\LocationTable::getList(array('filter' => array('=' . $type . '_ID' => $creat, 'TYPE_ID' => $types[$type]), 'select' => array('ID'), 'limit' => 1))->fetch();
         if ($res['ID']) {
             $parent = intval($res['ID']);
         } else {
             if ($type == 'COUNTRY') {
                 $res = self::GetCountryByID($creat);
             } elseif ($type == 'REGION') {
                 $res = self::GetRegionByID($creat);
             } elseif ($type == 'CITY') {
                 $res = self::GetCityByID($creat);
             }
             //!!!
             if (!$res) {
                 // no such type exists, smth strange
                 throw new Exception('No such ' . $type);
             }
             // create location using type found
             $creatFlds[$type . '_ID'] = $res['ID'];
             $creatFlds['NAME'] = array();
             foreach ($langs as $lid) {
                 if ($type == 'COUNTRY') {
                     $name = self::GetCountryLangByID($res['ID'], $lid);
                 } elseif ($type == 'REGION') {
                     $name = self::GetRegionLangByID($res['ID'], $lid);
                 } elseif ($type == 'CITY') {
                     $name = self::GetCityLangByID($res['ID'], $lid);
                 }
                 //!!!
                 $creatFlds['NAME'][$lid] = array('NAME' => $name['NAME'], 'SHORT_NAME' => $name['SHORT_NAME']);
             }
         }
     } elseif (is_array($creat)) {
         $creatFlds[$type . '_ID'] = self::getFreeId($type);
         $creatFlds['NAME'] = array();
         foreach ($creat as $lid => $name) {
             $creatFlds['NAME'][$lid] = array('NAME' => $name['NAME'], 'SHORT_NAME' => $name['SHORT_NAME']);
         }
     }
     if (!empty($creatFlds)) {
         $creatFlds['PARENT_ID'] = $parent;
         $creatFlds['TYPE_ID'] = $types[$type];
         $creatFlds['CODE'] = rand(999, 99999999);
         if ($sort !== false) {
             $creatFlds['SORT'] = $sort;
         }
         $res = Location\LocationTable::add($creatFlds);
         if (!$res->isSuccess()) {
             throw new Exception('Cannot add location');
         }
         $parent = $res->getId();
         Location\LocationTable::update($parent, array('CODE' => $parent));
     }
     return $parent;
 }
Example #7
0
 /**
  * 
  * $parameters is an ORM`s getList compatible array of parameters
  * 
  * 
  */
 public static function find($parameters, $behaviour = array('FALLBACK_TO_NOINDEX_ON_NOTFOUND' => true, 'USE_INDEX' => true, 'USE_ORM' => true))
 {
     /////////////////////////////////
     // parameter check and process
     Assert::expectArray($parameters, '$parameters');
     if (!is_array($behaviour)) {
         $behaviour = array();
     }
     if (!isset($behaviour['FALLBACK_TO_NOINDEX_ON_NOTFOUND'])) {
         $behaviour['FALLBACK_TO_NOINDEX_ON_NOTFOUND'] = true;
     }
     if (!isset($behaviour['USE_INDEX'])) {
         $behaviour['USE_INDEX'] = true;
     }
     if (!isset($behaviour['USE_ORM'])) {
         $behaviour['USE_ORM'] = true;
     }
     if (!isset($parameters['select'])) {
         $parameters['select'] = array('ID');
     }
     Assert::expectArray($parameters['select'], '$parameters[select]');
     if (isset($parameters['filter'])) {
         Assert::expectArray($parameters['filter'], '$parameters[filter]');
         // spikes, refactor later
         if (isset($parameters['filter']['PHRASE']) || isset($parameters['filter']['=PHRASE'])) {
             $key = isset($parameters['filter']['PHRASE']) ? 'PHRASE' : '=PHRASE';
             $parameters['filter'][$key] = Assert::expectStringNotNull($parameters['filter'][$key], '$parameters[filter][' . $key . ']');
             $parameters['filter'][$key] = str_replace('%', '', $parameters['filter'][$key]);
             // cannot pass '%' to like
         }
         if (isset($parameters['filter']['SITE_ID']) || isset($parameters['filter']['=SITE_ID'])) {
             $key = isset($parameters['filter']['SITE_ID']) ? 'SITE_ID' : '=SITE_ID';
             $parameters['filter'][$key] = Assert::expectStringNotNull($parameters['filter'][$key], '$parameters[filter][' . $key . ']');
             // stronger here
             if (!Location\SiteLocationTable::checkLinkUsageAny($parameters['filter'][$key])) {
                 unset($parameters['filter'][$key]);
             }
         }
     }
     if (isset($parameters['limit'])) {
         $parameters['limit'] = Assert::expectIntegerNonNegative($parameters['limit'], '$parameters[limit]');
     }
     if (isset($parameters['offset'])) {
         $parameters['offset'] = Assert::expectIntegerNonNegative($parameters['offset'], '$parameters[offset]');
     }
     /////////////////////////////////
     if (isset($parameters['filter']['PHRASE']) || isset($parameters['filter']['SITE_ID']) || isset($parameters['filter']['=PHRASE']) || isset($parameters['filter']['=SITE_ID']) || $behaviour['USE_ORM'] === false) {
         if (static::checkIndexValid() && $behaviour['USE_INDEX']) {
             $result = static::findUsingIndex($parameters);
             if (!$behaviour['FALLBACK_TO_NOINDEX_ON_NOTFOUND']) {
                 return $result;
             } else {
                 $temporalBuffer = array();
                 while ($item = $result->fetch()) {
                     $temporalBuffer[] = $item;
                 }
                 if (empty($temporalBuffer)) {
                     return static::findNoIndex($parameters);
                 } else {
                     return new DB\ArrayResult($temporalBuffer);
                 }
             }
         } else {
             return static::findNoIndex($parameters);
         }
     } else {
         return Location\LocationTable::getList($parameters);
     }
 }
 private static function getLocationToCode($arLocationTo)
 {
     $code = self::getRegionCodeByOldName($arLocationTo['REGION_NAME_LANG']);
     // old location
     if (strlen($code) <= 0 && CSaleLocation::isLocationProMigrated()) {
         $dbRes = Location\LocationTable::getList(array('filter' => array('=TYPE.CODE' => 'REGION', '=REGION_ID' => intval($arLocationTo["REGION_ID"]), '=CITY_ID' => false), 'select' => array('ID', 'CODE', 'NAME')));
         if ($locReg = $dbRes->fetch()) {
             $code = $locReg["CODE"];
         }
     }
     return $code;
 }
Example #9
0
					}
				}
			}
		}
		elseif($_REQUEST['ACT'] == 'GET_ZIP_BY_LOC')
		{
			if(!intval($_REQUEST['LOC']))
				$result['ERRORS'] = array('No location id passed');
			else
			{
				$item = \Bitrix\Sale\Location\LocationTable::getList(
					array(
						'filter' => array(
							'=ID' => intval($_REQUEST['LOC']),
							'=EXTERNAL.SERVICE.CODE' => 'ZIP'
						),
						'select' => array(
							'ZIP' => 'EXTERNAL.XML_ID'
						)
					)
				)->fetch();

				if(strlen($item['ZIP']))
					$result['DATA']['ZIP'] = $item['ZIP'];
				else
					$result['ERRORS'] = array('None were found');
			}
		}

		header('Content-Type: application/x-javascript; charset='.LANG_CHARSET);
		print(CUtil::PhpToJSObject(array(
Example #10
0
 private static function calculatePackPrice($arPackage, $profile, $arConfig, $arLocationTo)
 {
     $arDebug = array();
     /*1 Land price
     		1.1 Base Price less 10 kg*/
     $code = self::getRegionCodeByOldName($arLocationTo['REGION_NAME_LANG']);
     // old location
     if (strlen($code) <= 0 && CSaleLocation::isLocationProMigrated()) {
         $dbRes = Location\LocationTable::getList(array('filter' => array('=TYPE.CODE' => 'REGION', '=REGION_ID' => intval($arLocationTo["REGION_ID"]), '=CITY_ID' => false), 'select' => array('ID', 'CODE', 'NAME')));
         if ($locReg = $dbRes->fetch()) {
             $code = $locReg["CODE"];
         }
     }
     if (strlen($code) <= 0) {
         throw new \Bitrix\Main\SystemException(GetMessage("SALE_DH_RP_ERROR_LOCATION_NOT_FOUND"));
     }
     $zoneTo = self::getConfValue($arConfig, 'REG_' . $code);
     $basePrice = floatval(self::getConfValue($arConfig, 'ZONE_RATE_MAIN_' . $zoneTo));
     $arDebug[] = 'Base Price less 500 g: ' . $basePrice;
     if ($arPackage['WEIGHT'] > self::$BASE_WEIGHT) {
         $addWeight = ceil($arPackage['WEIGHT'] / self::$BASE_WEIGHT - 1);
         $addPrice = floatval(self::getConfValue($arConfig, 'ZONE_RATE_ADD_' . $zoneTo));
         $arDebug[] = 'Price for additional weight more than 500 g: ' . $addWeight * $addPrice;
         $basePrice += $addWeight * $addPrice;
     }
     $totalPrice = $basePrice;
     /* 1.2 Service "heavy weight" 10 - 20 kg*/
     $hwPrice = 0;
     if ($arPackage['WEIGHT'] >= self::$MAX_WEIGHT) {
         $hwTarif = floatval(self::getConfValue($arConfig, 'service_' . self::$TARIF_HEAVY_WEIGHT . '_value'));
         $hwPrice += $totalPrice * $hwTarif / 100;
         $arDebug[] = 'Heavy weight: ' . $hwPrice;
         $totalPrice += $hwPrice;
     }
     /* 1.5 Service "fragile" */
     $fPrice = 0;
     if (self::isConfCheckedVal($arConfig, 'service_' . self::$TARIF_FRAGILE . '_enabled')) {
         $fTarif = floatval(self::getConfValue($arConfig, 'service_' . self::$TARIF_FRAGILE . '_value'));
         $fPrice += $totalPrice * $fTarif / 100;
         $arDebug[] = 'Fragile: ' . $fPrice;
         $totalPrice += $fPrice;
     }
     /* 4. Service "declared value" */
     $dvPrice = 0;
     if (self::isConfCheckedVal($arConfig, 'service_' . self::$TARIF_DECLARED_VAL . '_enabled')) {
         $dvTarif = floatval(self::getConfValue($arConfig, 'service_' . self::$TARIF_DECLARED_VAL . '_value'));
         $dvPrice += ($arPackage['PRICE'] + $totalPrice) * $dvTarif;
         $arDebug[] = 'Declared value: ' . $dvPrice;
         $totalPrice += $dvPrice;
     }
     if ($profile == 'avia') {
         $aviaPrice = 0;
         $aviaPrice = floatval(self::getConfValue($arConfig, 'tarif_avia_' . self::$TARIF_AVIA_STANDART . '_value'));
         $arDebug[] = 'avia price: ' . $aviaPrice;
         $totalPrice += $aviaPrice;
         $aviaHeavyPrice = 0;
         if ($arPackage['WEIGHT'] > self::$MAX_WEIGHT) {
             $aviaHeavyPrice = floatval(self::getConfValue($arConfig, 'tarif_avia_' . self::$TARIF_AVIA_HEAVY . '_value'));
             $arDebug[] = 'avia heavy price: ' . $aviaHeavyPrice;
             $totalPrice += $aviaHeavyPrice;
         }
     }
     return $totalPrice;
 }
Example #11
0
 protected function getSubpercentForStageCreateSearchIndex()
 {
     if ($this->getStep() == 0) {
         $this->data['OFFSET'] = 0;
     }
     if (!isset($this->data['INDEX_LOCATION_COUNT'])) {
         $item = Location\LocationTable::getList(array('select' => array('CNT'), 'filter' => ChainTable::getFilterForInitData(array('TYPES' => Finder::getIndexedTypes()))))->fetch();
         $this->data['INDEX_LOCATION_COUNT'] = intval($item['CNT']);
     }
     return $this->getSubPercentByTotalAndDone($this->data['INDEX_LOCATION_COUNT'], $this->data['OFFSET']);
 }
Example #12
0
 public static function importFile(&$descriptior)
 {
     $timeLimit = ini_get('max_execution_time');
     if ($timeLimit < $descriptior['TIME_LIMIT']) {
         set_time_limit($descriptior['TIME_LIMIT'] + 5);
     }
     $endTime = time() + $descriptior['TIME_LIMIT'];
     if ($descriptior['STEP'] == 'rebalance') {
         Location\LocationTable::resort();
         Location\LocationTable::resetLegacyPath();
         $descriptior['STEP'] = 'done';
     }
     if ($descriptior['STEP'] == 'import') {
         if (!isset($descriptior['DO_SYNC'])) {
             $res = \Bitrix\Sale\Location\LocationTable::getList(array('select' => array('CNT')))->fetch();
             $descriptior['DO_SYNC'] = intval($res['CNT'] > 0);
         }
         if (!isset($descriptior['TYPES'])) {
             $descriptior['TYPE_MAP'] = static::getTypeMap($descriptior['TYPE_FILE']);
             $descriptior['TYPES'] = static::createTypes($descriptior['TYPE_MAP']);
             $descriptior['SERVICE_MAP'] = static::getServiceMap($descriptior['SERVICE_FILE']);
             $descriptior['SERVICES'] = static::getExistedServices();
         }
         $csvReader = new CSVReader();
         $csvReader->LoadFile($descriptior['FILE']);
         while (time() < $endTime) {
             $block = $csvReader->ReadBlockLowLevel($descriptior['POS'], 100);
             if (!count($block)) {
                 break;
             }
             foreach ($block as $item) {
                 if ($descriptior['DO_SYNC']) {
                     $id = static::checkLocationCodeExists($item['CODE']);
                     if ($id) {
                         $descriptior['CODES'][$item['CODE']] = $id;
                         continue;
                     }
                 }
                 // type
                 $item['TYPE_ID'] = $descriptior['TYPES'][$item['TYPE_CODE']];
                 unset($item['TYPE_CODE']);
                 // parent id
                 if (strlen($item['PARENT_CODE'])) {
                     if (!isset($descriptior['CODES'][$item['PARENT_CODE']])) {
                         $descriptior['CODES'][$item['PARENT_CODE']] = static::checkLocationCodeExists($item['PARENT_CODE']);
                     }
                     $item['PARENT_ID'] = $descriptior['CODES'][$item['PARENT_CODE']];
                 }
                 unset($item['PARENT_CODE']);
                 // ext
                 if (is_array($item['EXT'])) {
                     foreach ($item['EXT'] as $code => $values) {
                         if (is_array($values) && !empty($values)) {
                             if (!isset($descriptior['SERVICES'][$code])) {
                                 $descriptior['SERVICES'][$code] = static::createService(array('CODE' => $code));
                             }
                             foreach ($values as $value) {
                                 if (!strlen($value)) {
                                     continue;
                                 }
                                 $item['EXTERNAL'][] = array('SERVICE_ID' => $descriptior['SERVICES'][$code], 'XML_ID' => $value);
                             }
                         }
                     }
                 }
                 unset($item['EXT']);
                 $res = Location\LocationTable::add($item, array('REBALANCE' => false, 'RESET_LEGACY' => false));
                 if (!$res->isSuccess()) {
                     throw new Main\SystemException('Cannot create location');
                 }
                 $descriptior['CODES'][$item['CODE']] = $res->getId();
             }
         }
         if (!count($block)) {
             unset($descriptior['CODES']);
             $descriptior['STEP'] = 'rebalance';
         }
     }
     return $descriptior['STEP'] == 'done';
 }
Example #13
0
}
$defCurrency = "EUR";
if ($lang == "ru") {
    $defCurrency = "RUB";
} elseif ($lang == "en") {
    $defCurrency = "USD";
}
$delivery = $wizard->GetVar("delivery");
$shopLocalization = $wizard->GetVar("shopLocalization");
WizardServices::IncludeServiceLang("step2.php", $lang);
if (COption::GetOptionString("eshop", "wizard_installed", "N", WIZARD_SITE_ID) != "Y") {
    $locationGroupID = 0;
    $arLocation4Delivery = array();
    $arLocationArr = array();
    if (\Bitrix\Main\Config\Option::get('sale', 'sale_locationpro_migrated', '') == 'Y') {
        $res = \Bitrix\Sale\Location\LocationTable::getList(array('filter' => array('=TYPE.CODE' => 'COUNTRY'), 'select' => array('ID')));
        while ($item = $res->fetch()) {
            $arLocation4Delivery[] = array("LOCATION_ID" => $item["ID"], "LOCATION_TYPE" => "L");
        }
    } else {
        $dbLocation = CSaleLocation::GetList(array(), array("LID" => $lang));
        while ($arLocation = $dbLocation->Fetch()) {
            $arLocation4Delivery[] = array("LOCATION_ID" => $arLocation["ID"], "LOCATION_TYPE" => "L");
            $arLocationArr[] = $arLocation["ID"];
        }
        $dbGroup = CSaleLocationGroup::GetList();
        if ($arGroup = $dbGroup->Fetch()) {
            $arLocation4Delivery[] = array("LOCATION_ID" => $arGroup["ID"], "LOCATION_TYPE" => "G");
        } else {
            $groupLang = array(array("LID" => "en", "NAME" => "Group 1"));
            if ($bRus) {
Example #14
0
		$arRes["LOCATION_ID"] = $vars["ID"];
	endwhile;
}
elseif(isset($_POST["getAddressData"])){
	include($_SERVER["DOCUMENT_ROOT"].'/local/components/zakrepi/sale.order.ajax/functions.php');
	$arResult = Array();
	getJsUserAddress($arResult, $USER->GetID());

	$arRes = $arResult["JS_USER_ADDRESS"];
}
elseif(isset($_POST["CITY_NAME"])&& CModule::IncludeModule("useraddress") && CModule::IncludeModule("sale")){
    
    $city_name = "%".$_POST["CITY_NAME"]."%";
    
    $res = \Bitrix\Sale\Location\LocationTable::getList(array(
        'filter' => array('=NAME.LANGUAGE_ID' => LANGUAGE_ID,"NAME_RU"=>$city_name,"!CITY_ID"=>''),
        'select' => array('*', 'NAME_RU' => 'NAME.NAME', 'TYPE_CODE' => 'TYPE.CODE')
    ));
  
		$arRes["LOCATION_ID"] = array();
        $i=0;
		while($item = $res->Fetch())
        {
			$ID = CSaleLocation::getLocationIDbyCODE($item['CODE']);
			$arVal = CSaleLocation::GetByID( $ID, LANGUAGE_ID); 
			
			//$arRes["LOCATION_ID"][$i] = $item;
			$arRes["LOCATION_ID"][$i]['ID'] = $item['CITY_ID'];
            $arRes["LOCATION_ID"][$i]['NAME'] = $item['NAME_RU'];
			$arRes["LOCATION_ID"][$i]['REGION'] = $arVal['REGION_NAME_LANG'];
            $i++;
        }
Example #15
0
 public function initializeData()
 {
     $dbConnection = Main\HttpApplication::getConnection();
     $res = Location\LocationTable::getList(array('select' => array('ID', 'TYPE_ID', 'DEPTH_LEVEL', 'SORT'), 'order' => array('LEFT_MARGIN' => 'asc'), 'limit' => self::STEP_SIZE, 'offset' => $this->procData['OFFSET']));
     $cnt = 0;
     while ($item = $res->fetch()) {
         $name = Location\Name\LocationTable::getList(array('select' => array('NAME'), 'filter' => array('=LOCATION_ID' => $item['ID'], '=LANGUAGE_ID' => 'ru')))->fetch();
         if ($item['DEPTH_LEVEL'] < $this->procData['DEPTH']) {
             $newPC = array();
             foreach ($this->procData['PATH'] as $dl => $id) {
                 if ($dl >= $item['DEPTH_LEVEL']) {
                     break;
                 }
                 $newPC[$dl] = $id;
             }
             $this->procData['PATH'] = $newPC;
         }
         $this->procData['PATH'][$item['DEPTH_LEVEL']] = array('TYPE' => $item['TYPE_ID'], 'ID' => $item['ID']);
         $this->procData['DEPTH'] = $item['DEPTH_LEVEL'];
         if (is_array($this->procData['ALLOWED_TYPES']) && in_array($item['TYPE_ID'], $this->procData['ALLOWED_TYPES'])) {
             $data = array('LOCATION_ID' => $item['ID'], 'RELEVANCY' => $this->procData['TYPE_SORT'][$item['TYPE_ID']]);
             $wordsAdded = array();
             $k = 1;
             foreach ($this->procData['PATH'] as &$pathItem) {
                 if (!isset($pathItem['WORDS'])) {
                     $sql = "\n\t\t\t\t\t\t\tselect WS.POSITION from " . WordTable::getTableNameWord2Location() . " WL\n\t\t\t\t\t\t\t\tinner join " . WordTable::getTableName() . " WS on WL.WORD_ID = WS.ID\n\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\tWL.LOCATION_ID = '" . intval($pathItem['ID']) . "'\n\t\t\t\t\t\t";
                     $wordRes = $dbConnection->query($sql);
                     $pathItem['WORDS'] = array();
                     while ($wordItem = $wordRes->fetch()) {
                         $pathItem['WORDS'][] = $wordItem['POSITION'];
                     }
                     $pathItem['WORDS'] = array_unique($pathItem['WORDS']);
                 }
                 foreach ($pathItem['WORDS'] as $position) {
                     if (!isset($wordsAdded[$position])) {
                         $this->indexInserter->insert(array_merge(array('POSITION' => $position), $data));
                         $wordsAdded[$position] = true;
                     }
                 }
             }
             unset($pathItem);
         }
         $cnt++;
     }
     $this->indexInserter->flush();
     $this->procData['OFFSET'] += self::STEP_SIZE;
     return !$cnt;
 }
Example #16
0
 static function convertOldToNew(array $property)
 {
     if (isset($property['REQUIED']) && !empty($property['REQUIED'])) {
         $property['REQUIRED'] = $property['REQUIED'];
     }
     $size1 = intval($property['SIZE1']);
     $size2 = intval($property['SIZE2']);
     $settings = array();
     // TODO remove sale/include.php - $GLOBALS["SALE_FIELD_TYPES"]
     switch ($property['TYPE']) {
         case 'TEXT':
             $property['TYPE'] = 'STRING';
             if ($size1 > 0) {
                 $settings['SIZE'] = $size1;
             }
             break;
         case 'TEXTAREA':
             $property['TYPE'] = 'STRING';
             $settings['MULTILINE'] = 'Y';
             if ($size1 > 0) {
                 $settings['COLS'] = $size1;
             }
             if ($size2 > 0) {
                 $settings['ROWS'] = $size2;
             }
             break;
         case 'CHECKBOX':
             $property['TYPE'] = 'Y/N';
             break;
         case 'RADIO':
             $property['TYPE'] = 'ENUM';
             $settings['MULTIELEMENT'] = 'Y';
             break;
         case 'SELECT':
             $property['TYPE'] = 'ENUM';
             if ($size1 > 0) {
                 $settings['SIZE'] = $size1;
             }
             break;
         case 'MULTISELECT':
             $property['TYPE'] = 'ENUM';
             $property['MULTIPLE'] = 'Y';
             if ($size1 > 0) {
                 $settings['SIZE'] = $size1;
             }
             break;
         case 'LOCATION':
             // ID came, should store CODE
             if (intval($property['DEFAULT_VALUE'])) {
                 $res = \Bitrix\Sale\Location\LocationTable::getList(array('filter' => array('=ID' => intval($property['DEFAULT_VALUE'])), 'select' => array('CODE')))->fetch();
                 if (is_array($res) && (string) $res['CODE'] != '') {
                     $property['DEFAULT_VALUE'] = $res['CODE'];
                 }
             }
             if ($size1 > 0) {
                 $settings['SIZE'] = $size1;
             }
             break;
     }
     $property['SETTINGS'] = $settings;
     return $property;
 }
Example #17
0
 public function initializeData()
 {
     $dbConnection = Main\HttpApplication::getConnection();
     $res = Location\LocationTable::getList(array('select' => array('ID', 'TYPE_ID', 'DEPTH_LEVEL', 'SORT'), 'order' => array('LEFT_MARGIN' => 'asc'), 'limit' => self::STEP_SIZE, 'offset' => $this->procData['OFFSET']));
     $this->procData['TYPE_SORT'] = $this->rarefact($this->procData['TYPE_SORT']);
     $cnt = 0;
     while ($item = $res->fetch()) {
         // tmp!!!!
         //$name = Location\Name\LocationTable::getList(array('select' => array('NAME'), 'filter' => array('=LOCATION_ID' => $item['ID'], '=LANGUAGE_ID' => 'ru')))->fetch();
         if ($item['DEPTH_LEVEL'] < $this->procData['DEPTH']) {
             $newPC = array();
             foreach ($this->procData['PATH'] as $dl => $id) {
                 if ($dl >= $item['DEPTH_LEVEL']) {
                     break;
                 }
                 $newPC[$dl] = $id;
             }
             $this->procData['PATH'] = $newPC;
         }
         $this->procData['PATH'][$item['DEPTH_LEVEL']] = array('TYPE' => $item['TYPE_ID'], 'ID' => $item['ID']);
         if (is_array($this->procData['ALLOWED_TYPES']) && in_array($item['TYPE_ID'], $this->procData['ALLOWED_TYPES'])) {
             $data = array('LOCATION_ID' => $item['ID'], 'RELEVANCY' => $this->procData['TYPE_SORT'][$item['TYPE_ID']] + $item['SORT']);
             $wordsAdded = array();
             /*
             _dump_r('############################');
             _dump_r('LOCATION: '.$name['NAME']);
             _dump_r('TYPE RELEVANCY: '.$data['RELEVANCY']);
             _dump_r('PATH:');
             _dump_r($this->procData['PATH']);
             */
             $this->procData['DEPTH'] = $item['DEPTH_LEVEL'];
             // pre-load missing words
             $wordCount = 0;
             foreach ($this->procData['PATH'] as &$pathItem) {
                 if (!isset($pathItem['WORDS'])) {
                     $sql = "\n\t\t\t\t\t\t\tselect WS.POSITION from " . WordTable::getTableNameWord2Location() . " WL\n\t\t\t\t\t\t\t\tinner join " . WordTable::getTableName() . " WS on WL.WORD_ID = WS.ID\n\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\tWL.LOCATION_ID = '" . intval($pathItem['ID']) . "'\n\t\t\t\t\t\t";
                     $wordRes = $dbConnection->query($sql);
                     $pathItem['WORDS'] = array();
                     while ($wordItem = $wordRes->fetch()) {
                         $pathItem['WORDS'][] = $wordItem['POSITION'];
                     }
                     $pathItem['WORDS'] = array_unique($pathItem['WORDS']);
                 }
                 $wordCount += count($pathItem['WORDS']);
             }
             // count words
             //_dump_r('Words total: '.$wordCount);
             $wOffset = 0;
             foreach ($this->procData['PATH'] as &$pathItem) {
                 foreach ($pathItem['WORDS'] as $i => $position) {
                     $wordWeight = $wordCount - $wOffset;
                     $tmpData = $data;
                     $tmpData['RELEVANCY'] += $wordWeight;
                     //_dump_r('	Word relevancy: '.$data['RELEVANCY'].' ==>> '.$tmpData['RELEVANCY']);
                     if (!isset($wordsAdded[$position])) {
                         $this->indexInserter->insert(array_merge(array('POSITION' => $position), $tmpData));
                         $wordsAdded[$position] = true;
                     }
                     $wOffset++;
                 }
             }
             unset($pathItem);
         }
         $cnt++;
     }
     $this->indexInserter->flush();
     $this->procData['OFFSET'] += self::STEP_SIZE;
     return !$cnt;
 }
Example #18
0
 public static function getCountries(array $filter = null)
 {
     if (!Main\Loader::includeModule('sale')) {
         return array();
     }
     $listFilter = array('=TYPE.CODE' => 'COUNTRY', '=NAME.LANGUAGE_ID' => LANGUAGE_ID);
     if (is_array($filter) && !empty($filter)) {
         $caption = isset($filter['CAPTION']) ? $filter['CAPTION'] : '';
         if ($caption !== '') {
             $listFilter['%NAME.NAME'] = $caption;
         }
     }
     $dbResult = Sale\Location\LocationTable::getList(array('filter' => $listFilter, 'select' => array('CODE', 'CAPTION' => 'NAME.NAME')));
     $result = array();
     while ($fields = $dbResult->fetch()) {
         $result[] = $fields;
     }
     return $result;
 }
<?php

$res = \Bitrix\Sale\Location\LocationTable::getList(array('filter' => array('=ID' => $arEntity["UF"]['UF_REG_PLACE']['VALUE'], '=PARENTS.NAME.LANGUAGE_ID' => LANGUAGE_ID, '=PARENTS.TYPE.NAME.LANGUAGE_ID' => LANGUAGE_ID), 'select' => array('I_ID' => 'PARENTS.ID', 'I_NAME_RU' => 'PARENTS.NAME.NAME', 'I_TYPE_CODE' => 'PARENTS.TYPE.CODE', 'I_TYPE_NAME_RU' => 'PARENTS.TYPE.NAME.NAME'), 'order' => array('PARENTS.DEPTH_LEVEL' => 'asc')));
$arrAdressData = [];
while ($item = $res->fetch()) {
    $arrAdressData[] = $item;
}
Example #20
0
			$paySystem = $arGeneralInfo["paySystem"]["sber"][$personType];
		elseif(IntVal($arGeneralInfo["paySystem"]["paypal"][$personType]) > 0 )
			$paySystem = $arGeneralInfo["paySystem"]["paypal"][$personType];
		else
		{
			$dbPS = CSalePaySystem::GetList(Array(), Array("LID" => WIZARD_SITE_ID));
			if($arPS = $dbPS->Fetch())
				$paySystem = $arPS["ID"];
		}

		if(\Bitrix\Main\Config\Option::get('sale', 'sale_locationpro_migrated', '') == 'Y')
		{
			if(!strlen($location))
			{
				// get first found
				$item = \Bitrix\Sale\Location\LocationTable::getList(array('limit' => 1, 'select' => array('CODE')))->fetch();
				if($item)
					$location = $item['CODE'];
			}
		}
		else
		{
			if(IntVal($location) <= 0)
			{
				$dbLocation = CSaleLocation::GetList(Array("ID" => "ASC"), Array("LID" => $lang));
				if($arLocation = $dbLocation->Fetch())
				{
					$location = $arLocation["ID"];
				}
			}
		}
Example #21
0
	protected static function processSearchGetAdditional($result)
	{
		$data = array(
			'ITEMS' => $result,
			'ETC' => array()
		);

		if(!empty($result))
		{
			###################################
			# Additional extras
			###################################

			// show path to each found node
			static::processSearchGetAdditionalPathNodes($data);

			// show item count based on filter, but only when the first page called (it may be useful for calculating client-side pager)
			if(intval($_REQUEST['PAGE_SIZE']) && !intval($_REQUEST['PAGE']) && $_REQUEST['SHOW']['ITEM_COUNT'])
			{
				$filter = static::processSearchGetFilter();
				// spike! spike! spike!
				// we hope we can make filter compatible with ORM by replacing getListFast with smth cleverer, but for now we got only option:
				unset($filter['LANGUAGE_ID']);

				$res = Location\LocationTable::getList(array(
					'runtime' => array(
						'CNT' => array(
							'data_type' => 'integer',
							'expression' => array('COUNT(*)')
						)
					),
					'select' => array('CNT'),
					'filter' => $filter
				))->fetch();

				$data['ETC']['TOTAL_ITEM_COUNT'] = intval($res['CNT']);
			}
		}

		return $data;
	}
Example #22
0
 protected static function processSearchRequestV2GetAdditional(&$data, $parameters)
 {
     if (!empty($data['ITEMS']) && is_array($parameters['additionals'])) {
         if (in_array('PATH', $parameters['additionals'])) {
             // show path to each found node
             static::processSearchRequestV2GetAdditionalPathNodes($data, $parameters);
         }
         // show common count of items by current filter
         if (in_array('CNT_BY_FILTER', $parameters['additionals']) && is_array($parameters['filter'])) {
             $item = Location\LocationTable::getList(array('select' => array('CNT'), 'filter' => $parameters['filter']))->fetch();
             $data['ETC']['CNT_BY_FILTER'] = $item['CNT'];
         }
         // show parent item in case of PARENT_ID condition in filter
         if (in_array('PARENT_ITEM', $parameters['additionals'])) {
             $id = false;
             if (intval($parameters['filter']['=PARENT_ID'])) {
                 $id = intval($parameters['filter']['=PARENT_ID']);
             } elseif (intval($parameters['filter']['PARENT_ID'])) {
                 $id = intval($parameters['filter']['PARENT_ID']);
             }
             if ($id !== false) {
                 $path = array();
                 $data['ETC']['PATH_ITEMS'] = array();
                 $res = Location\LocationTable::getPathToNode($id, array('select' => array('VALUE' => 'ID', 'CODE', 'TYPE_ID', 'DISPLAY' => 'NAME.NAME'), 'filter' => array('=NAME.LANGUAGE_ID' => strlen($parameters['filter']['=NAME.LANGUAGE_ID']) ? $parameters['filter']['=NAME.LANGUAGE_ID'] : LANGUAGE_ID)));
                 $node = array();
                 while ($item = $res->fetch()) {
                     $path[] = intval($item['VALUE']);
                     $data['ETC']['PATH_ITEMS'][$item['VALUE']] = $item;
                     $node = $item;
                 }
                 $node['PATH'] = array_reverse($path);
                 $data['ETC']['PARENT_ITEM'] = $node;
             }
         }
     }
     return $data;
 }
Example #23
0
 /**
  * Check if location is connected with entity
  * 
  * @param $entityPrimary mixed Entity being checked
  * @param $locationPrimary mixed Location being checked. Could be a value of ID or CODE depending on what connection type is selected (see below)
  * @param $behaviour mixed[] A set of flags that modify function behaviour
  * 		<li> LOCATION_LINK_TYPE string One of: ID, CODE, AUTO. 
  * 			If ID, than match by ID is used (default, for compatibility), if CODE than match by CODE. 
  * 			In case of AUTO the target field value depends on entity connect type.
  * 
  * @return boolean
  */
 public static function checkConnectionExists($entityPrimary, $locationPrimary, array $behaviour = array('LOCATION_LINK_TYPE' => 'ID'))
 {
     $entityPrimary = Assert::expectStringNotNull($entityPrimary, '$entityPrimary');
     $locationPrimary = Assert::expectStringNotNull($locationPrimary, '$locationPrimary');
     if (!isset($behaviour['LOCATION_LINK_TYPE'])) {
         $behaviour['LOCATION_LINK_TYPE'] = 'ID';
     } else {
         $behaviour['LOCATION_LINK_TYPE'] = Assert::expectEnumerationMember($behaviour['LOCATION_LINK_TYPE'], array('AUTO', 'ID', 'CODE'), '$behaviour[LOCATION_LINK_TYPE]');
     }
     if (!static::checkLinkUsageAny($entityPrimary)) {
         return true;
     }
     if ($behaviour['LOCATION_LINK_TYPE'] == 'AUTO') {
         $field = static::getUseCodes() ? 'CODE' : 'ID';
     } else {
         $field = $behaviour['LOCATION_LINK_TYPE'];
     }
     $node = LocationTable::getList(array('filter' => array('=' . $field => $locationPrimary), 'select' => array('ID', 'LEFT_MARGIN', 'RIGHT_MARGIN'), 'limit' => 1))->fetch();
     if (!intval($node['ID'])) {
         throw new \Bitrix\Sale\Location\Tree\NodeNotFoundException(false, array('INFO' => array($field => $locationPrimary)));
     }
     $result = static::getLinkStatusForMultipleNodes(array($node), $entityPrimary);
     return $result[$node['ID']] == self::LSTAT_IS_CONNECTOR || $result[$node['ID']] == self::LSTAT_BELOW_CONNECTOR;
 }
Example #24
0
	protected function obtainDataLevelOneLocations(&$cachedData)
	{
		// here we require a tag cache

		$res = Location\LocationTable::getList(
			array(
				'filter' => array('PARENT_ID' => 0, 'NAME.LANGUAGE_ID' => LANGUAGE_ID),
				'select' => array('LNAME' => 'NAME.NAME', 'CODE', 'ID', 'CHILD_CNT')
			)
		);
		$res->addReplacedAliases(array('LNAME' => 'NAME'));
		$cachedData['LOCATIONS'] = array();
		while($item = $res->fetch())
		{
			$cachedData['LOCATIONS'][] = array(
				'ID' => $item['ID'],
				'NAME' => $item['NAME'],
				'IS_PARENT' => $item['CHILD_CNT'] > 0
			);
		}
	}
Example #25
0
 private static function checkLocationIsInLinkedPart($locationId, $siteId)
 {
     $types = \CSaleLocation::getTypes();
     $class = self::CONN_ENTITY_NAME . 'Table';
     if (!$class::checkLinkUsageAny($siteId)) {
         return true;
     }
     if ((string) $locationId == '') {
         return false;
     }
     $node = \Bitrix\Sale\Location\LocationTable::getList(array('filter' => array('=ID' => $locationId), 'select' => array('ID', 'LEFT_MARGIN', 'RIGHT_MARGIN')))->fetch();
     if (!is_array($node)) {
         return false;
     }
     $stat = $class::getLinkStatusForMultipleNodes(array($node), $siteId);
     return $stat[$node['ID']] !== $class::LSTAT_IN_NOT_CONNECTED_BRANCH;
 }
Example #26
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;
     }
 }
Example #27
0
 /**
  * @param \Bitrix\Sale\Shipment|null $shipment
  * @return CalculationResult
  * @throws \Bitrix\Main\ArgumentException
  */
 protected function calculateConcrete(\Bitrix\Sale\Shipment $shipment = null)
 {
     $result = new CalculationResult();
     $result->setDeliveryPrice(roundEx($this->config["MAIN"]["0"], SALE_VALUE_PRECISION));
     $order = $shipment->getCollection()->getOrder();
     if (!($props = $order->getPropertyCollection())) {
         return $result;
     }
     if (!($locationProp = $props->getDeliveryLocation())) {
         return $result;
     }
     if (!($locationCode = $locationProp->getValue())) {
         return $result;
     }
     $res = \Bitrix\Sale\Location\LocationTable::getList(array('runtime' => array(new \Bitrix\Main\Entity\ReferenceField('PARENT_GROUP', '\\Bitrix\\Sale\\Location\\GroupLocationTable', array('=this.PARENTS.ID' => 'ref.LOCATION_ID'), array("join_type" => 'inner'))), 'filter' => array('=CODE' => $locationCode), 'select' => array('CLOSEST_GROUP_ID' => 'PARENT_GROUP.LOCATION_GROUP_ID'), 'order' => array('PARENTS.DEPTH_LEVEL' => 'desc'), 'limit' => 1));
     if ($group = $res->fetch()) {
         if (isset($this->config["MAIN"][$group['CLOSEST_GROUP_ID']])) {
             $result->setDeliveryPrice(roundEx(floatval($this->config["MAIN"][$group['CLOSEST_GROUP_ID']]), SALE_VALUE_PRECISION));
         }
     }
     return $result;
 }