public static function Complete($callId, $device = 'WEBRTC') { $res = VI\CallTable::getList(array('select' => array('ID', 'CALL_ID', 'CRM_LEAD', 'CALLER_ID', 'USER_ID', 'TRANSFER_USER_ID', 'ACCESS_URL', 'CRM', 'CONFIG_ID'), 'filter' => array('=CALL_ID' => $callId))); $call = $res->fetch(); if (!$call) { return false; } VI\CallTable::update($call['ID'], array('USER_ID' => $call['TRANSFER_USER_ID'], 'TRANSFER_USER_ID' => 0)); CVoxImplantHistory::TransferMessage($call['USER_ID'], $call['TRANSFER_USER_ID'], $call['CALLER_ID']); self::SendPullEvent(array('COMMAND' => 'completeTransfer', 'USER_ID' => $call['USER_ID'], 'TRANSFER_USER_ID' => $call['TRANSFER_USER_ID'], 'CALL_ID' => $call['CALL_ID'])); $crmDataSend = false; if ($call['CRM'] == 'Y' && $call['CONFIG_ID'] > 0) { $config = CVoxImplantConfig::GetConfig($call['CONFIG_ID']); if (isset($config['CRM_TRANSFER_CHANGE']) && $config['CRM_TRANSFER_CHANGE'] == 'Y') { if ($call['CRM_LEAD'] > 0) { $crmData = array('LEAD_DATA' => array('ID' => $call['CRM_LEAD'], 'ASSIGNED_BY_ID' => 0)); } else { $crmData = CVoxImplantCrmHelper::GetDataForPopup($call['CALL_ID'], $call['CALLER_ID']); } if (isset($crmData['LEAD_DATA']) && $crmData['LEAD_DATA']['ASSIGNED_BY_ID'] >= 0 && $call['TRANSFER_USER_ID'] > 0 && $crmData['LEAD_DATA']['ASSIGNED_BY_ID'] != $call['TRANSFER_USER_ID']) { CVoxImplantCrmHelper::UpdateLead($crmData['LEAD_DATA']['ID'], array('ASSIGNED_BY_ID' => $call['TRANSFER_USER_ID'])); $crmDataSend = CVoxImplantCrmHelper::GetDataForPopup($call['CALL_ID'], $call['CALLER_ID'], $call['TRANSFER_USER_ID']); } } } self::SendPullEvent(array('COMMAND' => 'completeTransfer', 'USER_ID' => $call['TRANSFER_USER_ID'], 'TRANSFER_USER_ID' => $call['TRANSFER_USER_ID'], 'CALL_DEVICE' => $device, 'CALL_ID' => $call['CALL_ID'], 'CRM' => $crmDataSend)); return true; }
public static function CallStart($callId, $userId, $callDevice = 'WEBRTC', $external = false) { // TODO check $callId, $userId $res = Bitrix\Voximplant\CallTable::getList(array('select' => array('ID', 'CALL_ID', 'CALLER_ID', 'DATE_CREATE', 'CRM_LEAD', 'PORTAL_USER_ID'), 'filter' => array('=CALL_ID' => $callId))); if ($call = $res->fetch()) { $crmData = false; if ($call['CRM_LEAD'] > 0) { CVoxImplantCrmHelper::UpdateLead($call['CRM_LEAD'], array('ASSIGNED_BY_ID' => $userId)); $crmData = CVoxImplantCrmHelper::GetDataForPopup($call['CALL_ID'], $call['CALLER_ID'], $userId); } Bitrix\Voximplant\CallTable::update($call['ID'], array('USER_ID' => $userId, 'STATUS' => Bitrix\Voximplant\CallTable::STATUS_CONNECTED)); foreach (GetModuleEvents("voximplant", "onCallStart", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array(array('CALL_ID' => $call['CALL_ID'], 'USER_ID' => $userId))); } $pushUser = array($userId); if ($call['PORTAL_USER_ID'] > 0) { $pushUser[] = $call['PORTAL_USER_ID']; } foreach ($pushUser as $userId) { self::SendPullEvent(array('COMMAND' => 'start', 'USER_ID' => $userId, 'CALL_ID' => $callId, 'CALL_DEVICE' => $callDevice, 'EXTERNAL' => $external ? true : false, 'CRM' => $crmData)); } } }