• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/helpers/admin/blocks/orderbuyer.php
  • Класс: BitrixSaleHelpersAdminBlocksOrderBuyer
  • Вызов: OrderBuyer::getProfileValuesFromUser
static function getProfileValuesFromUser($userId, $personTypeId)
{
	if(intval($personTypeId) <= 0)
		throw new ArgumentNullException('userId');

	if(intval($personTypeId) <= 0)
		throw new ArgumentNullException('personTypeId');

	$uRes = UserTable::getById($userId);

	if(!$user= $uRes->fetch())
		return array();

	$result = array();

	$pRes = OrderPropsTable::getList(array(
		'filter' => array(
			'PERSON_TYPE_ID' => $personTypeId,
			'ACTIVE' => 'Y',
			'USER_PROPS' => 'Y'
		)
	));

	while($prop = $pRes->fetch())
	{
		if($prop['DEFAULT_VALUE'] <> '')
		{
			$result[$prop['ID']] = $prop['DEFAULT_VALUE'];

		}
		elseif($prop['IS_EMAIL'] == 'Y' && !empty($user['EMAIL']))
		{
			$result[$prop['ID']] = $user['EMAIL'];
		}
		elseif($prop['IS_PAYER'] == 'Y')
		{
			$name = '';

			if(!empty($user['LAST_NAME']))
				$name .= $user['LAST_NAME'];

			if(!empty($user['NAME']))
				$name .= $user['NAME'];

			if(!empty($user['SECOND_NAME']))
				$name .= $user['SECOND_NAME'];

			if($name <> '')
				$result[$prop['ID']] = $name;
		}
		elseif($prop['IS_PHONE'] == 'Y' && !empty($user['PERSONAL_MOBILE']))
		{
			$result[$prop['ID']] = $user['PERSONAL_MOBILE'];
		}
		elseif($prop['IS_ADDRESS'] == 'Y')
		{
			$address = '';

			if(!empty($user['PERSONAL_STREET']))
				$address .= $user['PERSONAL_STREET'];

			if(!empty($user['PERSONAL_CITY']))
				$address .= $user['PERSONAL_CITY'];

			if(!empty($user['PERSONAL_STATE']))
				$address .= $user['PERSONAL_STATE'];

			if(!empty($user['PERSONAL_ZIP']))
				$address .= $user['PERSONAL_ZIP'];

			if(!empty($user['PERSONAL_COUNTRY']))
				$address .= $user['PERSONAL_COUNTRY'];

			$result[$prop['ID']] = $address;
		}
	}

	return $result;
}