- Модуль: voximplant
- Путь к файлу: ~/bitrix/modules/voximplant/classes/general/vi_phone.php
- Класс: CVoxImplantPhone
- Вызов: CVoxImplantPhone::GetPhoneRegions
static function GetPhoneRegions($country, $category, $countryState = '', $bundleSize = 0)
{
$arResult = Array();
if (!in_array($category, self::GetCategories()))
return $arResult;
$viHttp = new CVoxImplantHttp();
$result = $viHttp->GetPhoneNumberRegions($category, $country, $countryState);
if ($result && !empty($result->result))
{
foreach ($result->result as $value)
{
$regionName = '';
if ($country == 'RU' || $country == 'KZ')
{
$regionName = GetMessage('VI_PHONE_CODE_'.$country.'_'.$value->phone_region_code);
if ($regionName != '')
$regionName = $regionName.' ('.$value->phone_region_code.')';
}
if ($regionName == '')
{
$regionName = $value->phone_region_name != $value->phone_region_code? $value->phone_region_name.' ('.$value->phone_region_code.')': $value->phone_region_name;
}
if($bundleSize > 0)
{
if(is_array($value->multiple_numbers_price))
{
$bundle = null;
foreach ($value->multiple_numbers_price as $multiplePriceFields)
{
if($multiplePriceFields->count == $bundleSize)
{
$bundle = $multiplePriceFields;
break;
}
}
if($bundle)
{
$monthPrice = $bundle->price;
$installationPrice = $bundle->installation_price;
$phoneCount = $value->phone_count;
}
else
{
$monthPrice = 0;
$installationPrice = 0;
$phoneCount = 0;
}
}
}
else
{
$monthPrice = $value->phone_price;
$installationPrice = $value->phone_installation_price;
$phoneCount = $value->phone_count;
}
$arResult[$value->phone_region_id] = [
'REGION_ID' => $value->phone_region_id,
'REGION_NAME' => $regionName,
'REGION_CODE' => $value->phone_region_code,
'PHONE_COUNT' => $phoneCount,
'MONTH_PRICE' => $monthPrice,
'INSTALLATION_PRICE' => $installationPrice,
'REQUIRED_VERIFICATION' =>
property_exists($value, 'required_verification') ? $value->required_verification : '',
'IS_NEED_REGULATION_ADDRESS' => $value->is_need_regulation_address ?: false,
'REGULATION_ADDRESS_TYPE' => $value->regulation_address_type ?? '',
];
}
}
return $arResult;
}