Function to handle AGI event param Vtiger_Request details public funct

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Function to handle AGI event
* @param <Vtiger_Request> $details
*/
public function handleStartupCall($details, $userInfo, $customerInfo) {
global $current_user;
$params = $this->prepareParameters($details, self::RINGING_TYPE);
$direction = $details->get('Direction');
// To add customer and user information in params
$params['Customer'] = $customerInfo['id'];
$params['CustomerType'] = $customerInfo['setype'];
$params['User'] = $userInfo['id'];
if ($details->get('from')) {
$params['CustomerNumber'] = $details->get('from');
} else if ($details->get('to')) {
$params['CustomerNumber'] = $details->get('to');
}
$date = new DateTimeField( null );
$params['starttime'] = DateTimeField::convertToDBFormat($date->getDisplayDate()).' '.$date->getDisplayTime();
$params['callstatus'] = "ringing";
$user = CRMEntity::getInstance('Users');
$current_user = $user->getActiveAdminUser();
$recordModel = PBXManager_Record_Model::getCleanInstance();
$recordModel->saveRecordWithArrray($params);
if ($direction == self::INCOMING_TYPE)
$this->respondToIncomingCall($details);
else
$this->respondToOutgoingCall($params['CustomerNumber']);
}