Beispiel #1
0
 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;
 }