fieldsMapping; } public function process() { if (!$this->pbxManagerModel->getId() && !$this->canCreatePBXRecord()) { return; } $voipModel = $this->getVoipRecordModelFromNotificationModel(); $voipModel->save(); } protected function getSourceUUId() { return $this->get('session_id'); } protected function getEventDatetime($timestamp) { return date('Y-m-d H:i:s', $timestamp); } /** * Returns call duration in seconds * @param type $startTime * @param type $endTime * @return type */ public function getTotalDurationTime($startTime, $endTime) { $start = strtotime($startTime); $end = strtotime($endTime); $totalDutation = intval($end) - intval($start); if ($totalDutation > 0) { return $totalDutation; } return 0; } /** * Find user in CRM by internal or external numbers * @param type $number * @return type */ public static function getUserByNumber($number) { $db = \PearDatabase::getInstance(); $result = $db->pquery("SELECT id FROM vtiger_users WHERE sp_rostelecom_extension=? or sp_rostelecom_extension_internal=?", array($number, $number)); $userModel = null; if ($result && $resRow = $db->fetchByAssoc($result)) { $userModel = \Users_Record_Model::getInstanceById($resRow['id'], 'Users'); } return $userModel; } }