Example #1
0
 public static function GetLinkConfig()
 {
     $portalUrl = '';
     if (CVoxImplantHttp::GetPortalType() == CVoxImplantHttp::TYPE_BITRIX24) {
         $portalUrl = CVoxImplantHttp::GetServerAddress() . '/settings/info_receiver.php?b24_action=phone&b24_direct=y';
     } else {
         $portalUrl = CVoxImplantHttp::GetServerAddress() . '/services/telephony/info_receiver.php?b24_direct=y';
     }
     return array('PORTAL_MODE' => 'LINK', 'PORTAL_URL' => $portalUrl, 'PORTAL_SIGN' => CVoxImplantHttp::GetPortalSign(), 'SEARCH_ID' => CVoxImplantPhone::GetLinkNumber(), 'PHONE_NAME' => CVoxImplantPhone::GetLinkNumber(), 'RECORDING' => CVoxImplantConfig::GetLinkCallRecord() ? 'Y' : 'N', 'CRM' => CVoxImplantConfig::GetLinkCheckCrm() ? 'Y' : 'N', 'MELODY_HOLD' => CVoxImplantConfig::GetMelody('MELODY_HOLD'));
 }
Example #2
0
 public static function GetConfigBySearchId($searchId)
 {
     if (strlen($searchId) <= 0) {
         return array('ERROR' => 'Config is`t found for undefined number');
     }
     $orm = VI\ConfigTable::getList(array('filter' => array('=SEARCH_ID' => (string) $searchId)));
     $config = $orm->fetch();
     if (!$config) {
         $result = array('ERROR' => 'Config is`t found for number: ' . $searchId);
     } else {
         $result = $config;
         $result['PHONE_TITLE'] = $result['PHONE_NAME'];
         if ($result['PORTAL_MODE'] == self::MODE_SIP) {
             $viSip = new CVoxImplantSip();
             $sipResult = $viSip->Get($config["ID"]);
             $result['PHONE_NAME'] = preg_replace("/[^0-9\\#\\*]/i", "", $result['PHONE_NAME']);
             $result['PHONE_NAME'] = strlen($result['PHONE_NAME']) >= 4 ? $result['PHONE_NAME'] : '';
             $result['SIP_SERVER'] = $sipResult ? $sipResult['SERVER'] : '';
             $result['SIP_LOGIN'] = $sipResult ? $sipResult['LOGIN'] : '';
             $result['SIP_PASSWORD'] = $sipResult ? $sipResult['PASSWORD'] : '';
         }
         if (strlen($result['FORWARD_NUMBER']) > 0) {
             $result["FORWARD_NUMBER"] = NormalizePhone($result['FORWARD_NUMBER'], 1);
         }
         if (strlen($result['WORKTIME_DAYOFF_NUMBER']) > 0) {
             $result["WORKTIME_DAYOFF_NUMBER"] = NormalizePhone($result['WORKTIME_DAYOFF_NUMBER'], 1);
         }
         // check work time
         $result['WORKTIME_SKIP_CALL'] = 'N';
         if ($config['WORKTIME_ENABLE'] == 'Y') {
             $timezone = !empty($config["WORKTIME_TIMEZONE"]) ? new DateTimeZone($config["WORKTIME_TIMEZONE"]) : null;
             $numberDate = new Bitrix\Main\Type\DateTime(null, null, $timezone);
             if (!empty($config['WORKTIME_DAYOFF'])) {
                 $daysOff = explode(",", $config['WORKTIME_DAYOFF']);
                 $allWeekDays = array('MO' => 1, 'TU' => 2, 'WE' => 3, 'TH' => 4, 'FR' => 5, 'SA' => 6, 'SU' => 7);
                 $currentWeekDay = $numberDate->format('N');
                 foreach ($daysOff as $day) {
                     if ($currentWeekDay == $allWeekDays[$day]) {
                         $result['WORKTIME_SKIP_CALL'] = "Y";
                     }
                 }
             }
             if ($result['WORKTIME_SKIP_CALL'] !== "Y" && !empty($config['WORKTIME_HOLIDAYS'])) {
                 $holidays = explode(",", $config['WORKTIME_HOLIDAYS']);
                 $currentDay = $numberDate->format('d.m');
                 foreach ($holidays as $holiday) {
                     if ($currentDay == $holiday) {
                         $result['WORKTIME_SKIP_CALL'] = "Y";
                     }
                 }
             }
             if ($result['WORKTIME_SKIP_CALL'] !== "Y" && !empty($config['WORKTIME_FROM']) && !empty($config['WORKTIME_TO'])) {
                 $currentTime = $numberDate->format('G.i');
                 if (!($currentTime >= $config['WORKTIME_FROM'] && $currentTime <= $config['WORKTIME_TO'])) {
                     $result['WORKTIME_SKIP_CALL'] = "Y";
                 }
             }
             if ($result['WORKTIME_SKIP_CALL'] === "Y") {
                 $result['WORKTIME_DAYOFF_MELODY'] = CVoxImplantConfig::GetMelody('WORKTIME_DAYOFF_MELODY', $config['MELODY_LANG'], $config['WORKTIME_DAYOFF_MELODY']);
             }
         }
         if (CVoxImplantHttp::GetPortalType() == CVoxImplantHttp::TYPE_BITRIX24) {
             $result['PORTAL_URL'] = CVoxImplantHttp::GetServerAddress() . '/settings/info_receiver.php?b24_action=phone&b24_direct=y';
         } else {
             $result['PORTAL_URL'] = CVoxImplantHttp::GetServerAddress() . '/services/telephony/info_receiver.php?b24_direct=y';
         }
         $result['PORTAL_SIGN'] = CVoxImplantHttp::GetPortalSign();
         $result['MELODY_WELCOME'] = CVoxImplantConfig::GetMelody('MELODY_WELCOME', $config['MELODY_LANG'], $config['MELODY_WELCOME']);
         $result['MELODY_VOICEMAIL'] = CVoxImplantConfig::GetMelody('MELODY_VOICEMAIL', $config['MELODY_LANG'], $config['MELODY_VOICEMAIL']);
         $result['MELODY_HOLD'] = CVoxImplantConfig::GetMelody('MELODY_HOLD', $config['MELODY_LANG'], $config['MELODY_HOLD']);
         $result['MELODY_WAIT'] = CVoxImplantConfig::GetMelody('MELODY_WAIT', $config['MELODY_LANG'], $config['MELODY_WAIT']);
     }
     return $result;
 }
Example #3
0
 public static function GetPublicFolder()
 {
     return CVoxImplantHttp::GetPortalType() == CVoxImplantHttp::TYPE_BITRIX24 ? '/settings/telephony/' : '/services/telephony/';
 }