- Модуль: voximplant
- Путь к файлу: ~/bitrix/modules/voximplant/classes/general/vi_crm_helper.php
- Класс: CVoxImplantCrmHelper
- Вызов: CVoxImplantCrmHelper::RegisterEntity
static function RegisterEntity($params)
{
if (!CModule::IncludeModule('crm'))
{
return false;
}
$originId = $params['ORIGIN_ID'];
if (mb_substr($originId, 0, 3) == 'VI_')
{
$callId = mb_substr($originId, 3);
}
else
{
return false;
}
$call = VICall::load($callId);
if ($call)
{
$crmData = CVoxImplantCrmHelper::getCrmEntities($call);
$call->updateCrmEntities($crmData);
$activityBindings = CVoxImplantCrmHelper::getActivityBindings($call);
if(is_array($activityBindings))
{
$call->updateCrmBindings($activityBindings);
}
CVoxImplantHistory::WriteToLog(Array($callId, $call), 'CRM ATTACH INIT CALL');
}
else
{
$res = VIStatisticTable::getList(Array(
'filter' => Array('=CALL_ID' => $callId),
));
if ($history = $res->fetch())
{
$history['USER_ID'] = $history['PORTAL_USER_ID'];
$history['DATE_CREATE'] = $history['CALL_START_DATE'];
CVoxImplantCrmHelper::AddCall($history);
CVoxImplantCrmHelper::AttachRecordToCall(Array(
'CALL_ID' => $history['CALL_ID'],
'CALL_WEBDAV_ID' => $history['CALL_WEBDAV_ID'],
'CALL_RECORD_ID' => $history['CALL_RECORD_ID'],
));
CVoxImplantHistory::WriteToLog(Array($callId), 'CRM ATTACH FULL CALL');
}
}
return true;
}