public static function GetPortalNumbers() { $result = array(); $res = VI\ConfigTable::getList(); while ($row = $res->fetch()) { if ($row['SEARCH_ID'] == 'test') { continue; } if (strlen($row['PHONE_NAME']) <= 0) { $row['PHONE_NAME'] = substr($row['SEARCH_ID'], 0, 3) == 'reg' ? GetMessage('VI_CONFIG_SIP_CLOUD_DEF') : GetMessage('VI_CONFIG_SIP_OFFICE_DEF'); $row['PHONE_NAME'] = str_replace('#ID#', $row['ID'], $row['PHONE_NAME']); } $result[$row['SEARCH_ID']] = htmlspecialcharsbx($row['PHONE_NAME']); } $ViAccount = new CVoxImplantAccount(); $accountLang = $ViAccount->GetAccountLang(); if ($accountLang != 'ua') { $linkNumber = CVoxImplantPhone::GetLinkNumber(); $result['LINK_BASE_NUMBER'] = $linkNumber == '' ? GetMessage('VI_CONFIG_LINK_DEF') : '+' . $linkNumber; } return $result; }
public static function GetRecordLimit($mode = false) { $sipConnectorActive = CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP); $recordLimit = COption::GetOptionInt("voximplant", "record_limit"); if ($recordLimit > 0 && !CVoxImplantAccount::IsPro()) { if ($mode == CVoxImplantConfig::MODE_SIP && $sipConnectorActive) { $recordLimitEnable = false; } else { $recordLimitEnable = true; $recordLimitRemaining = $recordLimit - CGlobalCounter::GetValue('vi_records', CGlobalCounter::ALL_SITES); $result = array('ENABLE' => $recordLimitEnable, 'LIMIT' => $recordLimit, 'REMAINING' => $recordLimitRemaining); } } else { $recordLimitEnable = false; } if (!$recordLimitEnable) { $result = array('ENABLE' => $recordLimitEnable, 'DEMO' => CVoxImplantAccount::IsDemo() && !$sipConnectorActive); } return $result; }
} $arResult['LINK_TO_BUY'] = ''; if (IsModuleInstalled('bitrix24')) { if (LANGUAGE_ID != 'kz') { $arResult['LINK_TO_BUY'] = '/settings/license_phone_sip.php'; } } else { if (LANGUAGE_ID == 'ru') { $arResult['LINK_TO_BUY'] = 'http://www.1c-bitrix.ru/buy/intranet.php#tab-call-link'; } else { if (LANGUAGE_ID == 'ua') { $arResult['LINK_TO_BUY'] = 'http://www.1c-bitrix.ua/buy/intranet.php#tab-call-link'; } else { if (LANGUAGE_ID == 'kz') { } else { if (LANGUAGE_ID == 'de') { $arResult['LINK_TO_BUY'] = 'https://www.bitrix24.de/prices/calls.php'; } else { $arResult['LINK_TO_BUY'] = 'https://www.bitrix24.com/prices/calls.php'; } } } } } $viAccount = new CVoxImplantAccount(); $arResult['ACCOUNT_NAME'] = $viAccount->GetAccountName(); $arResult['SIP_NOTICE_OLD_CONFIG_OFFICE_PBX'] = CVoxImplantConfig::GetNoticeOldConfigOfficePbx(); if (!(isset($arParams['TEMPLATE_HIDE']) && $arParams['TEMPLATE_HIDE'] == 'Y')) { $this->IncludeComponentTemplate(); } return $arResult;
} echo CUtil::PhpToJsObject($arSend); } else { if ($_POST['VI_GET_PHONE_NUMBERS'] == 'Y') { $arSend['ERROR'] = ''; $result = CVoxImplantPhone::GetPhoneNumbers($_POST['COUNTRY_CODE'], $_POST['COUNTRY_REGION'], $_POST['COUNTRY_CATEGORY']); if ($result !== false) { $arSend['RESULT'] = $result; } else { $arSend['ERROR'] = 'ERROR'; } echo CUtil::PhpToJsObject($arSend); } else { if ($_POST['VI_RENT_NUMBER'] == 'Y') { $arSend['ERROR'] = ''; $ViAccount = new CVoxImplantAccount(); $accountBalance = $ViAccount->GetAccountBalance(true); $orm = Bitrix\Voximplant\ConfigTable::getList(array('filter' => array('=SEARCH_ID' => $_POST['CURRENT_NUMBER']))); if ($orm->fetch()) { $arSend['ERROR'] = 'ATTACHED'; } else { if (floatval($_POST['PRE_MONEY_CHECK']) <= $accountBalance) { $result = CVoxImplantPhone::AttachPhoneNumber($_POST['COUNTRY_CODE'], $_POST['REGION_ID'], $_POST['CURRENT_NUMBER'], $_POST['COUNTRY_STATE'], $_POST['COUNTRY_CATEGORY']); if (!empty($result)) { $arSend['RESULT'] = $result[0]; } else { $arSend['ERROR'] = 'ERROR'; } } else { $arSend['ERROR'] = 'NO_MONEY'; }
public function GetOneTimeKey($key) { $ViAccount = new CVoxImplantAccount(); $accountName = $ViAccount->GetAccountName(); if (!$accountName) { $this->error = new CVoxImplantError(__METHOD__, $ViAccount->GetError()->code, GetMessage('VI_GET_ACCOUNT_INFO', array('#CODE#' => $ViAccount->GetError()->code))); return false; } $ViUser = new CVoxImplantUser(); $userInfo = $ViUser->GetUserInfo($this->userId); if (!$userInfo) { $this->error = new CVoxImplantError(__METHOD__, $ViUser->GetError()->code, GetMessage('VI_GET_USER_INFO', array('#CODE#' => $ViUser->GetError()->code))); return false; } return md5($key . "|" . md5($userInfo['user_login'] . ":voximplant.com:" . $userInfo['user_password'])); }
$arResult['USERS'][$user["ID"]] = prepareUserData($user); } if ($_REQUEST['act'] == 'search' && !empty($_REQUEST['FILTER'])) { $arFilter = array("UF_PHONE_INNER" => $_REQUEST['FILTER'], 'ACTIVE' => 'Y'); $dbUsers = CUser::GetList($arSortArg['key'], $arSortArg['value'], $arFilter, $arParams); while ($user = $dbUsers->fetch()) { $arResult['USERS'][$user["ID"]] = prepareUserData($user); } } function prepareUserData($user) { $user['DETAIL_URL'] = COption::getOptionString('intranet', 'search_user_url', '/user/#ID#/'); $user['DETAIL_URL'] = str_replace(array('#ID#', '#USER_ID#'), array($user['ID'], $user['ID']), $user['DETAIL_URL']); $user['PHOTO_THUMB'] = '<img src="/bitrix/components/bitrix/main.user.link/templates/.default/images/nopic_30x30.gif" border="0" alt="" width="32" height="32">'; if (intval($user['PERSONAL_PHOTO']) > 0) { $imageFile = CFile::getFileArray($user['PERSONAL_PHOTO']); if ($imageFile !== false) { $arFileTmp = CFile::resizeImageGet($imageFile, array('width' => 42, 'height' => 42), BX_RESIZE_IMAGE_EXACT, false); $user['PHOTO_THUMB'] = CFile::showImage($arFileTmp['src'], 32, 32); } } return $user; } $arResult['NAV_OBJECT'] = $dbUsers; $arResult['NAV_OBJECT']->bShowAll = false; $viAccount = new CVoxImplantAccount(); $arResult["VI_BETA_ACCESS"] = $viAccount->GetAccountBetaAccess() ? "Y" : "N"; if (!(isset($arParams['TEMPLATE_HIDE']) && $arParams['TEMPLATE_HIDE'] == 'Y')) { $this->IncludeComponentTemplate(); } return $arResult;
public function GetUserInfo($userId, $getPhoneAccess = false) { $userId = intval($userId); if ($userId <= 0) { $this->error = new CVoxImplantError(__METHOD__, 'USER_ID_NULL', 'UserId is not correct'); return false; } $userPassword = ''; $userBackphone = ''; $phoneEnable = false; $phonePassword = ''; $arExtParams = array('FIELDS' => array("ID"), 'SELECT' => array('UF_VI_PASSWORD', 'UF_VI_BACKPHONE', 'UF_VI_PHONE', 'UF_VI_PHONE_PASSWORD', 'UF_PHONE_INNER', 'UF_DEPARTMENT')); $dbUsers = CUser::GetList($sort_by = '', $dummy = '', array('ID' => $userId), $arExtParams); if ($arUser = $dbUsers->Fetch()) { if (strlen($arUser['UF_VI_PASSWORD']) > 0) { $userPassword = $arUser['UF_VI_PASSWORD']; } if (strlen($arUser['UF_VI_PHONE_PASSWORD']) > 0) { $phonePassword = $arUser['UF_VI_PHONE_PASSWORD']; } $userInnerPhone = $arUser['UF_PHONE_INNER']; $userBackphone = $arUser['UF_VI_BACKPHONE']; if ($arUser['UF_VI_PHONE'] == 'Y') { $phoneEnable = true; $getPhoneAccess = true; } $arUser['IS_EXTRANET'] = self::IsExtranet($arUser); unset($arUser['UF_DEPARTMENT']); } if ($userPassword == '' || $getPhoneAccess && $phonePassword == '') { $result = $this->GetUser($userId, $getPhoneAccess, true); if (!$result || $this->GetError()->error) { $this->error = new CVoxImplantError(__METHOD__, $this->GetError()->code, $this->GetError()->msg); return false; } $userPassword = $result->result->user_password; $phonePassword = $result->result->phone_password; global $USER_FIELD_MANAGER; $USER_FIELD_MANAGER->Update("USER", $userId, array('UF_VI_PASSWORD' => $userPassword, 'UF_VI_PHONE_PASSWORD' => $phonePassword)); } if ($userBackphone) { $portalPhones = CVoxImplantConfig::GetPortalNumbers(); if (!isset($portalPhones[$userBackphone])) { $userBackphone = ''; } } if ($userBackphone == '') { $userBackphone = CVoxImplantConfig::GetPortalNumber(); if ($userBackphone == CVoxImplantConfig::LINK_BASE_NUMBER) { $userBackphone = ''; } } $viAccount = new CVoxImplantAccount(); return array('call_server' => str_replace('voximplant.com', 'bitrixphone.com', $viAccount->GetCallServer()), 'user_login' => 'user' . $userId, 'user_password' => $userPassword, 'user_backphone' => $userBackphone, 'user_innerphone' => $userInnerPhone, 'phone_enable' => $phoneEnable, 'phone_login' => $phonePassword ? 'phone' . $userId : "", 'phone_password' => $phonePassword, 'user_extranet' => $arUser['IS_EXTRANET']); }
if (!CModule::IncludeModule('voximplant')) { return; } $arResult['NUMBERS'] = CVoxImplantPhone::GetRentNumbers(); $arResult['PAID_BEFORE'] = array('TS' => 0, 'DATE' => '', 'PRICE' => 0, 'NOTICE' => false); foreach ($arResult['NUMBERS'] as $value) { if ($arResult['PAID_BEFORE']['TS'] > $value['PAID_BEFORE_TS'] || $arResult['PAID_BEFORE']['TS'] == 0) { $arResult['PAID_BEFORE']['TS'] = $value['PAID_BEFORE_TS']; $arResult['PAID_BEFORE']['DATE'] = $value['PAID_BEFORE']; $arResult['PAID_BEFORE']['PRICE'] = $value['PRICE']; } else { if ($arResult['PAID_BEFORE']['TS'] == $value['PAID_BEFORE_TS']) { $arResult['PAID_BEFORE']['PRICE'] += $value['PRICE']; } } } $ViAccount = new CVoxImplantAccount(); $arResult['BALANCE_CURRENCY'] = $ViAccount->GetAccountCurrency(); if ($arResult['PAID_BEFORE']['TS'] > 0) { $data = new Bitrix\Main\Type\DateTime(); if ($arResult['PAID_BEFORE']['TS'] <= $data->getTimestamp() + 604800) { $arResult['BALANCE'] = $ViAccount->GetAccountBalance(true); if ($arResult['BALANCE'] < $arResult['PAID_BEFORE']['PRICE']) { $arResult['PAID_BEFORE']['NOTICE'] = 'Y'; } } } if (count($arResult['NUMBERS']) > 0 && !(isset($arParams['TEMPLATE_HIDE']) && $arParams['TEMPLATE_HIDE'] == 'Y')) { $this->IncludeComponentTemplate(); } return $arResult;
} } } } } else { if ($params['BX_TYPE'] == 'B24' && CVoxImplantHttp::RequestSign($params['BX_TYPE'], md5(implode("|", $params) . "|" . BX24_HOST_NAME)) === $hash || $params['BX_TYPE'] == 'CP' && CVoxImplantHttp::RequestSign($params['BX_TYPE'], md5(implode("|", $params))) === $hash) { if ($params["BX_COMMAND"] != "add_history" && isset($params['PHONE_NUMBER']) && isset($params['ACCOUNT_SEARCH_ID'])) { $params['PHONE_NUMBER'] = $params['ACCOUNT_SEARCH_ID']; } if ($params["BX_COMMAND"] == "add_history") { CVoxImplantHistory::WriteToLog($params, 'PORTAL ADD HISTORY'); if (isset($params['PORTAL_NUMBER']) && isset($params['ACCOUNT_SEARCH_ID'])) { $params['PORTAL_NUMBER'] = $params['ACCOUNT_SEARCH_ID']; } CVoxImplantHistory::Add($params); $ViAccount = new CVoxImplantAccount(); $ViAccount->SetAccountBalance($params["balance"]); echo "200 OK"; } elseif ($params["COMMAND"] == "IncomingGetConfig") { $result = CVoxImplantIncoming::GetConfigBySearchId($params['PHONE_NUMBER']); CVoxImplantHistory::WriteToLog($result, 'PORTAL GET INCOMING CONFIG'); if ($result['ID']) { $result = CVoxImplantIncoming::RegisterCall($result, $params); } $isNumberInBlacklist = CVoxImplantIncoming::IsNumberInBlackList($params["CALLER_ID"]); $isBlacklistAutoEnable = Bitrix\Main\Config\Option::get("voximplant", "blacklist_auto", "N") == "Y"; if ($result["WORKTIME_SKIP_CALL"] == "Y" && !$isNumberInBlacklist && $isBlacklistAutoEnable) { $isNumberInBlacklist = CVoxImplantIncoming::CheckNumberForBlackList($params["CALLER_ID"]); } if ($isNumberInBlacklist) { $result["NUMBER_IN_BLACKLIST"] = "Y";
public static function Add($params) { if (strlen($params["CALL_ID"]) > 0) { $res = VI\CallTable::getList(array('select' => array('ID', 'DATE_CREATE', 'CRM', 'CONFIG_ID', 'USER_ID', 'TRANSFER_USER_ID'), 'filter' => array('=CALL_ID' => $params["CALL_ID"]))); if ($call = $res->fetch()) { VI\CallTable::delete($call['ID']); } } $arFields = array("ACCOUNT_ID" => $params["ACCOUNT_ID"], "APPLICATION_ID" => $params["APPLICATION_ID"], "APPLICATION_NAME" => $params["APPLICATION_NAME"], "INCOMING" => $params["INCOMING"], "CALL_START_DATE" => $call ? $call['DATE_CREATE'] : new Bitrix\Main\Type\DateTime(), "CALL_DURATION" => $params["CALL_DURATION"], "CALL_STATUS" => $params["CALL_STATUS"], "CALL_FAILED_CODE" => $params["CALL_FAILED_CODE"], "CALL_FAILED_REASON" => $params["CALL_FAILED_REASON"], "COST" => $params["COST_FINAL"], "COST_CURRENCY" => $params["COST_CURRENCY"], "CALL_VOTE" => intval($params["CALL_VOTE"]), "CALL_ID" => $params["CALL_ID"], "CALL_CATEGORY" => $params["CALL_CATEGORY"]); if (intval($params["PORTAL_USER_ID"]) > 0) { $arFields["PORTAL_USER_ID"] = intval($params["PORTAL_USER_ID"]); } if (strlen($params["PHONE_NUMBER"]) > 0) { $arFields["PHONE_NUMBER"] = $params["PHONE_NUMBER"]; } if (strlen($params["CALL_DIRECTION"]) > 0) { $arFields["CALL_DIRECTION"] = $params["CALL_DIRECTION"]; } if (strlen($params["PORTAL_NUMBER"]) > 0) { $arFields["PORTAL_NUMBER"] = $params["PORTAL_NUMBER"]; } if (strlen($params["ACCOUNT_SEARCH_ID"]) > 0) { $arFields["PORTAL_NUMBER"] = $params["ACCOUNT_SEARCH_ID"]; } if (strlen($params["CALL_LOG"]) > 0) { $arFields["CALL_LOG"] = $params["CALL_LOG"]; } $orm = Bitrix\VoxImplant\StatisticTable::add($arFields); if (!$orm) { return false; } if ($call && intval($arFields["PORTAL_USER_ID"]) <= 0) { $res = VI\QueueTable::getList(array('select' => array('ID', 'USER_ID'), 'order' => array('LAST_ACTIVITY_DATE' => 'asc'), 'filter' => array('=CONFIG_ID' => $call['CONFIG_ID']), 'limit' => 1)); $queueUser = $res->fetch(); if ($queueUser) { $arFields["PORTAL_USER_ID"] = $queueUser['USER_ID']; } } if (strlen($arFields["PHONE_NUMBER"]) > 0 && $arFields["PORTAL_USER_ID"] > 0 && $params["CALL_FAILED_CODE"] != 423) { $plusSymbol = strlen($arFields["PHONE_NUMBER"]) >= 10 ? '+' : ''; if ($arFields["INCOMING"] == CVoxImplantMain::CALL_OUTGOING) { if ($arFields['CALL_FAILED_CODE'] == '603-S') { $message = GetMessage('VI_OUT_CALL_DECLINE_SELF', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 603) { $message = GetMessage('VI_OUT_CALL_DECLINE', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 486) { $message = GetMessage('VI_OUT_CALL_BUSY', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 480) { $message = GetMessage('VI_OUT_CALL_UNAVAILABLE', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 404 || $arFields['CALL_FAILED_CODE'] == 484) { $message = GetMessage('VI_OUT_CALL_ERROR_NUMBER', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 402) { $message = GetMessage('VI_OUT_CALL_NO_MONEY', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { $message = GetMessage('VI_OUT_CALL_END', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"], '#INFO#' => '[PCH=' . $orm->getId() . ']' . GetMessage('VI_CALL_INFO') . '[/PCH]')); } } } } } } } else { if ($arFields['CALL_FAILED_CODE'] == 304) { if (strlen($params['URL']) > 0) { $subMessage = GetMessage('VI_CALL_VOICEMAIL', array('#LINK_START#' => '[PCH=' . $orm->getId() . ']', '#LINK_END#' => '[/PCH]')); } else { $subMessage = '[PCH=' . $orm->getId() . ']' . GetMessage('VI_CALL_INFO') . '[/PCH]'; } $message = GetMessage('VI_IN_CALL_SKIP', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"], '#INFO#' => $subMessage)); } else { $message = GetMessage('VI_IN_CALL_END', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"], '#INFO#' => '[PCH=' . $orm->getId() . ']' . GetMessage('VI_CALL_INFO') . '[/PCH]')); } } self::SendMessageToChat($arFields["PORTAL_USER_ID"], $arFields["PHONE_NUMBER"], $arFields["INCOMING"], $message); } if ($call['CRM'] == 'Y') { CVoxImplantCrmHelper::UpdateCall($arFields); } if (strlen($params['URL']) > 0) { $attachToCrm = $call['CRM'] == 'Y'; $startDownloadAgent = false; $recordLimit = COption::GetOptionInt("voximplant", "record_limit"); if ($recordLimit > 0 && !CVoxImplantAccount::IsPro()) { $sipConnectorActive = CVoxImplantConfig::GetModeStatus(CVoxImplantConfig::MODE_SIP); if ($params['PORTAL_TYPE'] == CVoxImplantConfig::MODE_SIP && $sipConnectorActive) { $startDownloadAgent = true; } else { $recordMonth = COption::GetOptionInt("voximplant", "record_month"); if (!$recordMonth) { $recordMonth = date('Ym'); COption::SetOptionInt("voximplant", "record_month", $recordMonth); } $recordCount = CGlobalCounter::GetValue('vi_records', CGlobalCounter::ALL_SITES); if ($recordCount < $recordLimit) { CGlobalCounter::Increment('vi_records', CGlobalCounter::ALL_SITES, false); $startDownloadAgent = true; } else { if ($recordMonth < date('Ym')) { COption::SetOptionInt("voximplant", "record_month", date('Ym')); CGlobalCounter::Set('vi_records', 1, CGlobalCounter::ALL_SITES, false); CGlobalCounter::Set('vi_records_skipped', 0, CGlobalCounter::ALL_SITES, false); $startDownloadAgent = true; } else { CGlobalCounter::Increment('vi_records_skipped', CGlobalCounter::ALL_SITES, false); } } CVoxImplantHistory::WriteToLog(array('limit' => $recordLimit, 'saved' => CGlobalCounter::GetValue('vi_records', CGlobalCounter::ALL_SITES), 'skipped' => CGlobalCounter::GetValue('vi_records_skipped', CGlobalCounter::ALL_SITES), 'save to portal' => $startDownloadAgent ? 'Y' : 'N'), 'STATUS OF RECORD LIMIT'); } } else { $startDownloadAgent = true; } if ($startDownloadAgent) { self::DownloadAgent($orm->getId(), $params['URL'], $attachToCrm); } } if (strlen($params["ACCOUNT_PAYED"]) > 0 && in_array($params["ACCOUNT_PAYED"], array('Y', 'N'))) { CVoxImplantAccount::SetPayedFlag($params["ACCOUNT_PAYED"]); } foreach (GetModuleEvents("voximplant", "onCallEnd", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array(array('CALL_ID' => $arFields['CALL_ID'], 'CALL_TYPE' => $arFields['INCOMING'], 'PHONE_NUMBER' => $arFields['PHONE_NUMBER'], 'PORTAL_NUMBER' => $arFields['PORTAL_NUMBER'], 'PORTAL_USER_ID' => $arFields['PORTAL_USER_ID'], 'CALL_DURATION' => $arFields['CALL_DURATION'], 'CALL_START_DATE' => $arFields['CALL_START_DATE'], 'COST' => $arFields['COST'], 'COST_CURRENCY' => $arFields['COST_CURRENCY'], 'CALL_FAILED_CODE' => $arFields['CALL_FAILED_CODE'], 'CALL_FAILED_REASON' => $arFields['CALL_FAILED_REASON']))); } return true; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $APPLICATION->SetAdditionalCSS("/bitrix/components/bitrix/voximplant.main/templates/.default/telephony.css"); use Bitrix\Voximplant as VI; $ViAccount = new CVoxImplantAccount(); $amount = $ViAccount->GetAccountBalance(true); $currency = $ViAccount->GetAccountCurrency(); $errorMessage = ''; if ($ViAccount->GetError()->error) { $amount = ''; $currency = ''; if ($ViAccount->GetError()->code == 'LICENCE_ERROR') { $errorMessage = GetMessage('VI_ERROR_LICENSE'); } else { $errorMessage = GetMessage('VI_ERROR'); } } function getBalance($amount) { $amount = round(floatval($amount), 2); $amount = $amount . ''; $str = ''; $amountCount = strlen($amount); for ($i = 0; $i < $amountCount; $i++) { if ($amount[$i] == '.') { $str .= '<span class="tel-num tel-num-point">.</span>'; } else { $str .= '<span class="tel-num tel-num-' . $amount[$i] . '">' . $amount[$i] . '</span>';
public static function Add($params) { if (strlen($params["CALL_ID"]) > 0) { $res = VI\CallTable::getList(array('select' => array('ID', 'DATE_CREATE', 'CRM', 'CONFIG_ID', 'USER_ID', 'TRANSFER_USER_ID'), 'filter' => array('=CALL_ID' => $params["CALL_ID"]))); if ($call = $res->fetch()) { VI\CallTable::delete($call['ID']); } } $arFields = array("ACCOUNT_ID" => $params["ACCOUNT_ID"], "APPLICATION_ID" => $params["APPLICATION_ID"], "APPLICATION_NAME" => $params["APPLICATION_NAME"], "INCOMING" => $params["INCOMING"], "CALL_START_DATE" => $call ? $call['DATE_CREATE'] : new Bitrix\Main\Type\DateTime(), "CALL_DURATION" => $params["CALL_DURATION"], "CALL_STATUS" => $params["CALL_STATUS"], "CALL_FAILED_CODE" => $params["CALL_FAILED_CODE"], "CALL_FAILED_REASON" => $params["CALL_FAILED_REASON"], "COST" => $params["COST_FINAL"], "COST_CURRENCY" => $params["COST_CURRENCY"], "CALL_ID" => $params["CALL_ID"]); if (intval($params["PORTAL_USER_ID"]) > 0) { $arFields["PORTAL_USER_ID"] = intval($params["PORTAL_USER_ID"]); } if (strlen($params["PHONE_NUMBER"]) > 0) { $arFields["PHONE_NUMBER"] = $params["PHONE_NUMBER"]; } if (strlen($params["CALL_DIRECTION"]) > 0) { $arFields["CALL_DIRECTION"] = $params["CALL_DIRECTION"]; } if (strlen($params["PORTAL_NUMBER"]) > 0) { $arFields["PORTAL_NUMBER"] = $params["PORTAL_NUMBER"]; } if (strlen($params["ACCOUNT_SEARCH_ID"]) > 0) { $arFields["PORTAL_NUMBER"] = $params["ACCOUNT_SEARCH_ID"]; } if (strlen($params["CALL_LOG"]) > 0) { $arFields["CALL_LOG"] = $params["CALL_LOG"]; } $orm = Bitrix\VoxImplant\StatisticTable::add($arFields); if (!$orm) { return false; } if ($call && intval($arFields["PORTAL_USER_ID"]) <= 0) { $res = VI\QueueTable::getList(array('select' => array('ID', 'USER_ID'), 'order' => array('LAST_ACTIVITY_DATE' => 'asc'), 'filter' => array('=CONFIG_ID' => $call['CONFIG_ID']), 'limit' => 1)); $queueUser = $res->fetch(); if ($queueUser) { $arFields["PORTAL_USER_ID"] = $queueUser['USER_ID']; } } if (strlen($arFields["PHONE_NUMBER"]) > 0 && $arFields["PORTAL_USER_ID"] > 0 && $params["CALL_FAILED_CODE"] != 423) { $plusSymbol = strlen($arFields["PHONE_NUMBER"]) >= 10 ? '+' : ''; if ($arFields["INCOMING"] == CVoxImplantMain::CALL_OUTGOING) { if ($arFields['CALL_FAILED_CODE'] == '603-S') { $message = GetMessage('VI_OUT_CALL_DECLINE_SELF', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 603) { $message = GetMessage('VI_OUT_CALL_DECLINE', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 486) { $message = GetMessage('VI_OUT_CALL_BUSY', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 480) { $message = GetMessage('VI_OUT_CALL_UNAVAILABLE', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 404 || $arFields['CALL_FAILED_CODE'] == 484) { $message = GetMessage('VI_OUT_CALL_ERROR_NUMBER', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { if ($arFields['CALL_FAILED_CODE'] == 402) { $message = GetMessage('VI_OUT_CALL_NO_MONEY', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"])); } else { $message = GetMessage('VI_OUT_CALL_END', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"], '#INFO#' => '[PCH=' . $orm->getId() . ']' . GetMessage('VI_CALL_INFO') . '[/PCH]')); } } } } } } } else { if ($arFields['CALL_FAILED_CODE'] == 304) { if (strlen($params['URL']) > 0) { $subMessage = GetMessage('VI_CALL_VOICEMAIL', array('#LINK_START#' => '[PCH=' . $orm->getId() . ']', '#LINK_END#' => '[/PCH]')); } else { $subMessage = '[PCH=' . $orm->getId() . ']' . GetMessage('VI_CALL_INFO') . '[/PCH]'; } $message = GetMessage('VI_IN_CALL_SKIP', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"], '#INFO#' => $subMessage)); } else { $message = GetMessage('VI_IN_CALL_END', array('#NUMBER#' => $plusSymbol . $arFields["PHONE_NUMBER"], '#INFO#' => '[PCH=' . $orm->getId() . ']' . GetMessage('VI_CALL_INFO') . '[/PCH]')); } } self::SendMessageToChat($arFields["PORTAL_USER_ID"], $arFields["PHONE_NUMBER"], $arFields["INCOMING"], $message); } if ($call['CRM'] == 'Y') { CVoxImplantCrmHelper::UpdateCall($arFields); } if (strlen($params['URL']) > 0) { $attachToCrm = $call['CRM'] == 'Y'; self::DownloadAgent($orm->getId(), $params['URL'], $attachToCrm); } if (strlen($params["ACCOUNT_PAYED"]) > 0 && in_array($params["ACCOUNT_PAYED"], array('Y', 'N'))) { CVoxImplantAccount::SetPayedFlag($params["ACCOUNT_PAYED"]); } foreach (GetModuleEvents("voximplant", "onCallEnd", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array(array('CALL_ID' => $arFields['CALL_ID'], 'CALL_TYPE' => $arFields['INCOMING'], 'PHONE_NUMBER' => $arFields['PHONE_NUMBER'], 'PORTAL_NUMBER' => $arFields['PORTAL_NUMBER'], 'PORTAL_USER_ID' => $arFields['PORTAL_USER_ID'], 'CALL_DURATION' => $arFields['CALL_DURATION'], 'CALL_START_DATE' => $arFields['CALL_START_DATE'], 'COST' => $arFields['COST'], 'COST_CURRENCY' => $arFields['COST_CURRENCY'], 'CALL_FAILED_CODE' => $arFields['CALL_FAILED_CODE'], 'CALL_FAILED_REASON' => $arFields['CALL_FAILED_REASON']))); } return true; }
<?php if (!$USER->IsAdmin()) { return; } IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/modules/main/options.php'); IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/modules/voximplant/options.php'); CModule::IncludeModule('voximplant'); $aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("VI_TAB_SETTINGS"), "ICON" => "voximplant_config", "TITLE" => GetMessage("VI_TAB_TITLE_SETTINGS_2"))); $tabControl = new CAdminTabControl("tabControl", $aTabs); $ViAccount = new CVoxImplantAccount(); $ViAccount->UpdateAccountInfo(); if ($ViAccount->GetError()->error) { $accountName = '-'; $accountBalance = '-'; if ($ViAccount->GetError()->code == 'LICENCE_ERROR') { $errorMessage = GetMessage('VI_ACCOUNT_ERROR_LICENSE'); } else { $errorMessage = GetMessage('VI_ACCOUNT_ERROR'); } } else { $accountName = $ViAccount->GetAccountName(); $accountBalance = $ViAccount->GetAccountBalance() . ' ' . $ViAccount->GetAccountCurrency(); $errorMessage = ''; } if (strlen($_POST['Update']) > 0 && check_bitrix_sessid()) { if (strlen($_POST['PUBLIC_URL']) > 0 && strlen($_POST['PUBLIC_URL']) < 12) { $errorMessage = GetMessage('VI_ACCOUNT_ERROR_PUBLIC'); } else { if (strlen($_POST['Update']) > 0) { COption::SetOptionString("voximplant", "portal_url", $_POST['PUBLIC_URL']);
public static function GetPhoneNumbers($country, $regionId, $type = self::PHONE_TYPE_FIXED) { $arResult = array(); if (!in_array($type, array(self::PHONE_TYPE_FIXED, self::PHONE_TYPE_TOLLFREE, self::PHONE_TYPE_TOLLFREE804, self::PHONE_TYPE_MOBILE, self::PHONE_TYPE_MOSCOW495))) { return $arResult; } if ($country == 'RU' && $regionId == '15') { $type = 'MOSCOW495'; } $arResult = array(); $viAccount = new CVoxImplantAccount(); $currency = $viAccount->GetAccountCurrency(); $viHttp = new CVoxImplantHttp(); $result = $viHttp->GetNewPhoneNumbers($type, $country, $regionId); if ($result && !empty($result->result)) { foreach ($result->result as $value) { $arResult[$value->phone_number] = array('FULL_PRICE' => floatval($value->phone_price) + floatval($value->can_list_phone_numbers), 'INSTALLATION_PRICE' => $value->can_list_phone_numbers, 'MONTH_PRICE' => $value->phone_price, 'PHONE_NUMBER' => $value->phone_number, 'COUNTRY_CODE' => $country, 'REGION_ID' => $regionId, 'CURRENCY' => $currency); } } return $arResult; }