protected function handlePhoneLookUpRestoreEvent($entityData, $moduleName)
 {
     $recordid = $entityData->getId();
     //To get the record model of the restored record
     $recordmodel = Vtiger_Record_Model::getInstanceById($recordid, $moduleName);
     $values['crmid'] = $recordid;
     $values['setype'] = $moduleName;
     $recordModel = new PBXManager_Record_Model();
     $moduleInstance = Vtiger_Module_Model::getInstance($moduleName);
     $fieldsModel = $moduleInstance->getFieldsByType('phone');
     foreach ($fieldsModel as $field => $fieldName) {
         $fieldName = $fieldName->get('name');
         $values[$fieldName] = $recordmodel->get($fieldName);
         if ($values[$fieldName]) {
             $recordModel->receivePhoneLookUpRecord($fieldName, $values, true);
         }
     }
 }
Esempio n. 2
0
 /**
  * Returns crm user extension assigned to caller number or null if not assigned user for caller number
  * 
  * @param string $callerNumber
  * @return string
  */
 private function getCrmUserExtension($callerNumber)
 {
     $crmUserExtension = null;
     $callerUserInfo = PBXManager_Record_Model::lookUpRelatedWithNumber($callerNumber);
     if ($callerUserInfo) {
         $callerRecordModel = Vtiger_Record_Model::getInstanceById($callerUserInfo['id']);
         $assignedUser = Users_Record_Model::getInstanceById($callerRecordModel->get('assigned_user_id'), "Users");
         $crmUserExtension = $assignedUser->get('phone_crm_extension');
     }
     return $crmUserExtension;
 }
Esempio n. 3
0
 /**
  * Function to process Incoming call request
  * @params <array> incoming call details
  * return Response object
  */
 function processStartupCall($request)
 {
     $connector = $this->getConnector();
     $temp = $request->get('channel');
     $temp = explode("-", $temp);
     $temp = explode("/", $temp[0]);
     $callerNumber = $request->get('callerIdNumber');
     $userInfo = PBXManager_Record_Model::getUserInfoWithNumber($callerNumber);
     if (!$userInfo) {
         $callerNumber = $temp[1];
         if (is_numeric($callerNumber)) {
             $userInfo = PBXManager_Record_Model::getUserInfoWithNumber($callerNumber);
         }
     }
     if ($userInfo) {
         // Outbound Call
         $request->set('Direction', 'outbound');
         if ($request->get('callerIdNumber') == $temp[1]) {
             $to = $request->get('callerIdName');
         } else {
             if ($request->get('callerIdNumber')) {
                 $to = $request->get('callerIdNumber');
             } else {
                 if ($request->get('callerId')) {
                     $to = $request->get('callerId');
                 }
             }
         }
         $request->set('to', $to);
         $customerInfo = PBXManager_Record_Model::lookUpRelatedWithNumber($to);
         $connector->handleStartupCall($request, $userInfo, $customerInfo);
     } else {
         // Inbound Call
         $request->set('Direction', 'inbound');
         $customerInfo = PBXManager_Record_Model::lookUpRelatedWithNumber($request->get('callerIdNumber'));
         $request->set('from', $request->get('callerIdNumber'));
         $connector->handleStartupCall($request, $userInfo, $customerInfo);
     }
 }
Esempio n. 4
0
 /**
  * Function to user details with number
  * @param <string> $number
  */
 public static function getUserInfoWithNumber($number)
 {
     $db = PearDatabase::getInstance();
     if (empty($number)) {
         return false;
     }
     $query = PBXManager_Record_Model::buildSearchQueryWithUIType(11, $number, 'Users');
     $result = $db->pquery($query, array());
     if ($db->num_rows($result) > 0) {
         $user['id'] = $db->query_result($result, 0, 'id');
         $user['name'] = $db->query_result($result, 0, 'name');
         $user['setype'] = 'Users';
         return $user;
     }
     return;
 }
Esempio n. 5
0
 /**
  * Function to respond for incoming calls
  * @param <Vtiger_Request> $details 
  */
 public function respondToIncomingCall($details)
 {
     $current_user = vglobal('current_user');
     self::$NUMBERS = PBXManager_Record_Model::getUserNumbers();
     header("Content-type: text/xml; charset=utf-8");
     $response = '<?xml version="1.0" encoding="utf-8"?>';
     $response .= '<Response><Dial><Authentication>';
     $response .= 'Success</Authentication>';
     if (self::$NUMBERS) {
         foreach (self::$NUMBERS as $userId => $number) {
             $userInstance = Users_Privileges_Model::getInstanceById($userId);
             $current_user = $userInstance;
             $callPermission = Users_Privileges_Model::isPermitted('PBXManager', 'ReceiveIncomingCalls');
             if ($number != $details->get('callerIdNumber') && $callPermission) {
                 if (preg_match("/sip/", $number) || preg_match("/@/", $number)) {
                     $number = trim($number, "/sip:/");
                     $response .= '<Number>SIP/';
                     $response .= $number;
                     $response .= '</Number>';
                 } else {
                     $response .= '<Number>SIP/';
                     $response .= $number;
                     $response .= '</Number>';
                 }
             }
         }
     } else {
         $response .= '<ConfiguredNumber>empty</ConfiguredNumber>';
         $date = date('Y/m/d H:i:s');
         $params['callstatus'] = 'no-answer';
         $params['starttime'] = $date;
         $params['endtime'] = $date;
         $recordModel = PBXManager_Record_Model::getInstanceBySourceUUID($details->get('callUUID'));
         $recordModel->updateCallDetails($params);
     }
     $response .= '</Dial></Response>';
     echo $response;
 }
Esempio n. 6
0
 public function process(Vtiger_Request $request)
 {
     $pbxRecordModel = PBXManager_Record_Model::getInstanceById($request->get('record'));
     header("Location: " . $pbxRecordModel->get('recordingurl'));
     die;
 }
Esempio n. 7
0
 $recordModel = Settings_PBXManager_Record_Model::getCleanInstance();
 $recordModel->set('gateway', $qualifiedModuleName);
 $connector = new PBXManager_PBXManager_Connector();
 foreach ($connector->getSettingsParameters() as $field => $type) {
     $fieldValue = "";
     if ($field == "webappurl") {
         $fieldValue = "http://" . $server . ":";
     }
     if ($field == "vtigersecretkey") {
         $fieldValue = uniqid(rand());
     }
     $recordModel->set($field, $fieldValue);
 }
 $recordModel->save();
 $modules = array('Contacts', 'Accounts', 'Leads');
 $recordModel = new PBXManager_Record_Model();
 foreach ($modules as $module) {
     $moduleInstance = CRMEntity::getInstance($module);
     $query = $moduleInstance->buildSearchQueryForFieldTypes(array('11'));
     $result = $adb->pquery($query, array());
     $rows = $adb->num_rows($result);
     for ($i = 0; $i < $rows; $i++) {
         $row = $adb->query_result_rowdata($result, $i);
         $crmid = $row['id'];
         foreach ($row as $name => $value) {
             $values = array();
             $values['crmid'] = $crmid;
             $values['setype'] = $module;
             if ($name != 'name' && !empty($value) && $name != 'id' && !is_numeric($name) && $name != 'firstname' && $name != 'lastname') {
                 $values[$name] = $value;
                 $recordModel->receivePhoneLookUpRecord($name, $values, true);
 public function getCallStatus($request)
 {
     $phonecallsid = $request->get('callid');
     $recordModel = PBXManager_Record_Model::getInstanceById($phonecallsid);
     $response = new Vtiger_Response();
     $response->setResult($recordModel->get('callstatus'));
     $response->emit();
 }
Esempio n. 9
0
 /**
  * Function to retrieve display value for a field
  * @param $fieldName
  * @param bool $recordId
  * @return bool|string <String>
  * @internal param $ <String> $fieldName - field name for which values need to get
  */
 public function getDisplayValue($fieldName, $recordId = false)
 {
     if (empty($recordId)) {
         $recordId = $this->getId();
     }
     $fieldModel = $this->getModule()->getField($fieldName);
     if (!$fieldModel) {
         return false;
     }
     // Replace RecordingUrl by Icon
     if ($fieldName == 'recordingurl') {
         $value = $fieldModel->getDisplayValue($this->get($fieldName), $recordId, $this);
         $recordingUrl = explode('>', $value);
         $url = explode('<', $recordingUrl[1]);
         if ($url[0] != '' && $this->get('callstatus') == 'completed') {
             // SalesPlatform.ru begin
             return '<audio src="index.php?module=PBXManager&action=ListenRecord&record=' . $recordId . '" controls>
                 <a href="index.php?module=PBXManager&action=ListenRecord&record=' . $recordId . '" ><i class="icon-volume-up"></i></a>
             </audio>';
             //return $recordingUrl[0] . '>' . '<i class="icon-volume-up"></i>' . '</a>';
             // SalesPlatform.ru end
         } else {
             return '';
         }
     }
     // Display custom call status
     if ($fieldName == 'callstatus') {
         $callStatus = '';
         $value = $fieldModel->getDisplayValue($this->get($fieldName), $recordId, $this);
         $recordInstance = PBXManager_Record_Model::getInstanceById($recordId);
         if ($recordInstance->get('direction') == 'outbound') {
             if ($this->get('callstatus') == 'ringing' || $this->get('callstatus') == 'in-progress') {
                 $callStatus = '<span class="label label-info"><i class="icon-arrow-up icon-white"></i>&nbsp;' . vtranslate($value, $this->getModuleName()) . '</span>';
             } else {
                 if ($this->get('callstatus') == 'completed') {
                     $callStatus = '<span class="label label-success"><i class="icon-arrow-up icon-white"></i>&nbsp;' . vtranslate($value, $this->getModuleName()) . '</span>';
                 } else {
                     if ($this->get('callstatus') == 'no-answer') {
                         $callStatus = '<span class="label label-important"><i class="icon-arrow-up icon-white"></i>&nbsp;' . vtranslate($value, $this->getModuleName()) . '</span>';
                     } else {
                         $callStatus = '<span class="label label-warning"><i class="icon-arrow-up icon-white"></i>&nbsp;' . vtranslate($value, $this->getModuleName()) . '</span>';
                     }
                 }
             }
         } else {
             if ($recordInstance->get('direction') == 'inbound') {
                 if ($this->get('callstatus') == 'ringing' || $this->get('callstatus') == 'in-progress') {
                     $callStatus = '<span class="label label-info"><i class="icon-arrow-down icon-white"></i>&nbsp;' . vtranslate($value, $this->getModuleName()) . '</span>';
                 } else {
                     if ($this->get('callstatus') == 'completed') {
                         $callStatus = '<span class="label label-success"><i class="icon-arrow-down icon-white"></i>&nbsp;' . vtranslate($value, $this->getModuleName()) . '</span>';
                     } else {
                         if ($this->get('callstatus') == 'no-answer') {
                             $callStatus = '<span class="label label-important"><i class="icon-arrow-down icon-white"></i>&nbsp;' . vtranslate($value, $this->getModuleName()) . '</span>';
                         } else {
                             $callStatus = '<span class="label label-warning"><i class="icon-arrow-down icon-white"></i>&nbsp;' . vtranslate($value, $this->getModuleName()) . '</span>';
                         }
                     }
                 }
             }
         }
         return $callStatus;
     }
     return $fieldModel->getDisplayValue($this->get($fieldName), $recordId, $this);
 }