• Модуль: voximplant
  • Путь к файлу: ~/bitrix/modules/voximplant/lib/call.php
  • Класс: BitrixVoximplantCall
  • Вызов: Call::create
static function create(array $fields): Call
{
	static::checkFields($fields);

	$config = null;
	if($fields['CONFIG_ID'] ?? null)
	{
		$config = CVoxImplantConfig::GetConfig($fields['CONFIG_ID']);
	}

	if(!$fields['DATE_CREATE'])
	{
		$fields['DATE_CREATE'] = new DateTime();
	}
	if(!$fields['LAST_PING'])
	{
		$fields['LAST_PING'] = new DateTime();
	}

	$fields['CRM'] = 'Y';

	if(!$fields['QUEUE_ID'] && (int)$fields['INCOMING'] !== CVoxImplantMain::CALL_OUTGOING)
	{
		if(isset($config['QUEUE_ID']))
		{
			$fields['QUEUE_ID'] = $config['QUEUE_ID'];
		}
		else
		{
			$fields['QUEUE_ID'] = CVoxImplantMain::getDefaultGroupId();
		}
	}

	$instance = new static();
	$instance->config = $config;
	$instance->fromArray($fields);
	$instance->save();
	static::$instances[$fields['CALL_ID']] = $instance;
	return $instance;
}