public static function isEnabled() { if (self::$ENABLE_VOX_IMPLANT === null) { self::$ENABLE_VOX_IMPLANT = IsModuleInstalled('voximplant') && CModule::IncludeModule('voximplant'); } return self::$ENABLE_VOX_IMPLANT; }
function GetCrmActivityCommunications($ID) { $communications = CCrmActivity::GetCommunications($ID); $communicationData = array(); if (is_array($communications)) { foreach ($communications as &$comm) { CCrmActivity::PrepareCommunicationInfo($comm); $datum = array('id' => $comm['ID'], 'type' => $comm['TYPE'], 'value' => $comm['VALUE'], 'entityId' => $comm['ENTITY_ID'], 'entityType' => CCrmOwnerType::ResolveName($comm['ENTITY_TYPE_ID']), 'entityTitle' => $comm['TITLE'], 'entityUrl' => CCrmOwnerType::GetShowUrl($comm['ENTITY_TYPE_ID'], $comm['ENTITY_ID'])); if ($datum['type'] === 'PHONE' && CCrmSipHelper::checkPhoneNumber($datum['value'])) { $datum['enableSip'] = true; } $communicationData[] =& $datum; unset($datum); } unset($comm); } return array('DATA' => array('ID' => $ID, 'COMMUNICATIONS' => $communicationData)); }
public function showField($arField, $arUF = array()) { $strResult = ""; switch ($arField["FORMAT"]) { case "LEAD_PROGRESS": if (!empty($arField["VALUE"])) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding crm-feed-info-bar-cont">'; $strResult .= CCrmViewHelper::RenderLeadStatusControl(array('ENTITY_TYPE_NAME' => CCrmOwnerType::Lead, 'REGISTER_SETTINGS' => true, 'PREFIX' => "", 'ENTITY_ID' => CCrmLiveFeedEntity::Lead, 'CURRENT_ID' => $arField["VALUE"], 'READ_ONLY' => true)); $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "DEAL_PROGRESS": if (!empty($arField["VALUE"])) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding crm-feed-info-bar-cont">'; $strResult .= CCrmViewHelper::RenderDealStageControl(array('ENTITY_TYPE_NAME' => CCrmOwnerType::Deal, 'REGISTER_SETTINGS' => true, 'PREFIX' => "", 'ENTITY_ID' => CCrmLiveFeedEntity::Deal, 'CURRENT_ID' => $arField["VALUE"], 'READ_ONLY' => true)); $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "INVOICE_PROGRESS": if (!empty($arField["VALUE"])) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding crm-feed-info-bar-cont">'; $strResult .= CCrmViewHelper::RenderInvoiceStatusControl(array('ENTITY_TYPE_NAME' => CCrmOwnerType::Invoice, 'REGISTER_SETTINGS' => true, 'PREFIX' => "", 'ENTITY_ID' => CCrmLiveFeedEntity::Invoice, 'CURRENT_ID' => $arField["VALUE"], 'READ_ONLY' => true)); $strResult .= "</span>"; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "LEAD_STATUS": $infos = CCrmStatus::GetStatus('STATUS'); if (!empty($arField["VALUE"]) && array_key_exists($arField["VALUE"], $infos)) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; $strResult .= $infos[$arField["VALUE"]]["NAME"]; $strResult .= "</span>"; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "PERSON_NAME": if (is_array($arField["VALUE"])) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; $strResult .= CUser::FormatName(CSite::GetNameFormat(), $arField["VALUE"]); $strResult .= "</span>"; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "PERSON_ID": if (intval($arField["VALUE"]) > 0) { $dbUser = CUser::GetByID(intval($arField["VALUE"])); if ($arUser = $dbUser->GetNext()) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; if ($arUser["PERSONAL_PHOTO"] > 0) { $arFileTmp = CFile::ResizeImageGet($arUser["PERSONAL_PHOTO"], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false); } $strUser = ""; $strUser .= '<div class="feed-com-avatar crm-feed-company-avatar">'; if (is_array($arFileTmp) && isset($arFileTmp['src'])) { if (strlen($this->params["PATH_TO_USER"]) > 0) { $strUser .= '<a target="_blank" href="' . str_replace(array("#user_id#", "#USER_ID#"), intval($arField["VALUE"]), $this->params["PATH_TO_USER"]) . '"><img src="' . $arFileTmp['src'] . '" alt=""/></a>'; } else { $strUser .= '<img src="' . $arFileTmp['src'] . '" alt=""/>'; } } $strUser .= '</div>'; if (strlen($this->params["PATH_TO_USER"]) > 0) { $strUser .= '<a class="crm-detail-info-resp-name" target="_blank" href="' . str_replace(array("#user_id#", "#USER_ID#"), intval($arField["VALUE"]), $this->params["PATH_TO_USER"]) . '">' . CUser::FormatName(CSite::GetNameFormat(), $arUser, true, false) . '</a>'; } else { $strUser .= '<span class="crm-detail-info-resp-name">' . CUser::FormatName(CSite::GetNameFormat(), $arUser, true, false) . '</span>'; } if (strlen($arUser["WORK_POSITION"]) > 0) { $strUser .= '<span class="crm-detail-info-resp-descr">' . $arUser["WORK_POSITION"] . '</span>'; } $strResult .= '<span class="crm-detail-info-resp">' . $strUser . '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } } break; case "COMPANY_ID": if (intval($arField["VALUE"]) > 0) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => $arField["VALUE"], 'PREFIX' => "", 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N')); $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "COMPANY_TYPE": $infos = CCrmStatus::GetStatusListEx('COMPANY_TYPE'); if (!empty($arField["VALUE"]) && array_key_exists($arField["VALUE"], $infos)) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; $strResult .= $infos[$arField["VALUE"]]; $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "CONTACT_ID": if (intval($arField["VALUE"]) > 0) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<div class="crm-feed-client-block">'; $strResult .= '<span class="feed-com-avatar crm-feed-user-avatar">'; $dbRes = CCrmContact::GetListEx(array(), array('=ID' => $arField["VALUE"], 'CHECK_PERMISSIONS' => 'N'), false, false, array('PHOTO')); if (($arRes = $dbRes->Fetch()) && intval($arRes["PHOTO"]) > 0) { $arFileTmp = CFile::ResizeImageGet($arRes["PHOTO"], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false); if (is_array($arFileTmp) && isset($arFileTmp["src"])) { $strResult .= '<img width="39" height="39" src="' . $arFileTmp['src'] . '" alt="">'; } } $strResult .= '</span>'; $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Contact, 'ENTITY_ID' => $arField["VALUE"], 'PREFIX' => "", 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N')); $strResult .= '</div>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "COMBI_CLIENT": if (is_array($arField["VALUE"]) && (array_key_exists("CONTACT_ID", $arField["VALUE"]) && intval($arField["VALUE"]["CONTACT_ID"]) > 0 || array_key_exists("CONTACT_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_NAME"]) > 0 || array_key_exists("CONTACT_LAST_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_LAST_NAME"]) > 0 || array_key_exists("COMPANY_ID", $arField["VALUE"]) && intval($arField["VALUE"]["COMPANY_ID"]) > 0)) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; if (array_key_exists("CONTACT_ID", $arField["VALUE"]) && intval($arField["VALUE"]["CONTACT_ID"]) > 0 || array_key_exists("CONTACT_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_NAME"]) > 0 || array_key_exists("CONTACT_LAST_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_LAST_NAME"]) > 0) { if (array_key_exists("CONTACT_ID", $arField["VALUE"]) && intval($arField["VALUE"]["CONTACT_ID"]) > 0) { $strResult .= '<div class="crm-feed-client-block">'; $strResult .= '<span class="feed-com-avatar crm-feed-user-avatar">'; $dbRes = CCrmContact::GetListEx(array(), array('=ID' => $arField["VALUE"]["CONTACT_ID"], 'CHECK_PERMISSIONS' => 'N'), false, false, array('PHOTO', 'COMPANY_ID')); if ($arRes = $dbRes->Fetch()) { $contactCompanyID = $arRes['COMPANY_ID']; if (intval($arRes["PHOTO"]) > 0) { $arFileTmp = CFile::ResizeImageGet($arRes["PHOTO"], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false); if (is_array($arFileTmp) && isset($arFileTmp["src"])) { $strResult .= '<img width="39" height="39" src="' . $arFileTmp['src'] . '" alt="">'; } } } $strResult .= '</span>'; $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Contact, 'ENTITY_ID' => $arField["VALUE"]["CONTACT_ID"], 'PREFIX' => '', 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N')); } else { $strResult .= '<div class="crm-feed-client-block">'; $strResult .= '<span class="feed-com-avatar crm-feed-user-avatar">'; if (intval($arField['VALUE']['PHOTO_ID']) > 0) { $arFileTmp = CFile::ResizeImageGet($arField['VALUE']['PHOTO_ID'], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false); if (is_array($arFileTmp) && isset($arFileTmp["src"])) { $strResult .= '<img width="39" height="39" src="' . $arFileTmp['src'] . '" alt="">'; } } $strResult .= '</span>'; if (array_key_exists("ENTITY_ID", $arField["VALUE"]) && intval($arField["VALUE"]["ENTITY_ID"]) > 0) { $url = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Contact, $arField["VALUE"]["ENTITY_ID"], true); } $clientName = CCrmContact::PrepareFormattedName(array('HONORIFIC' => isset($arField['VALUE']['HONORIFIC']) ? $arField['VALUE']['HONORIFIC'] : '', 'NAME' => isset($arField['VALUE']['CONTACT_NAME']) ? $arField['VALUE']['CONTACT_NAME'] : '', 'LAST_NAME' => isset($arField['VALUE']['CONTACT_LAST_NAME']) ? $arField['VALUE']['CONTACT_LAST_NAME'] : '', 'SECOND_NAME' => isset($arField['VALUE']['CONTACT_SECOND_NAME']) ? $arField['VALUE']['CONTACT_SECOND_NAME'] : '')); $strResult .= strlen($url) > 0 ? '<a href="' . $url . '" class="crm-feed-client-name">' . $clientName . '</a>' : $clientName; } $strResult .= '<span class="crm-feed-client-company">'; $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => array_key_exists("COMPANY_ID", $arField["VALUE"]) && intval($arField["VALUE"]["COMPANY_ID"]) > 0 ? $arField["VALUE"]["COMPANY_ID"] : intval($contactCompanyID), 'PREFIX' => '', 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N')); $strResult .= '</span>'; $strResult .= '</div>'; } else { $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => $arField["VALUE"]["COMPANY_ID"], 'PREFIX' => "", 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N')); } $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "COMBI_COMPANY": if (is_array($arField["VALUE"]) && (array_key_exists("TITLE", $arField["VALUE"]) && strlen($arField["VALUE"]["TITLE"]) > 0)) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $url = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Company, $arField["VALUE"]["ENTITY_ID"]); if (intval($arField['VALUE']['LOGO_ID']) > 0) { $arFileTmp = CFile::ResizeImageGet($arField['VALUE']['LOGO_ID'], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false); } if (is_array($arFileTmp) && isset($arFileTmp['src'])) { $strResult .= '<a class="crm-feed-user-block" href="' . $url . '">'; $strResult .= '<span class="feed-com-avatar crm-feed-company-avatar">'; $strResult .= '<img width="39" height="39" alt="" src="' . $arFileTmp['src'] . '">'; $strResult .= '</span>'; $strResult .= '<span class="crm-feed-user-name">' . $arField["VALUE"]["TITLE"] . '</span>'; $strResult .= '</a>'; } else { $strResult .= '<a class="crm-feed-info-link" href="' . $url . '">' . $arField["VALUE"]["TITLE"] . '</a>'; } $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "COMBI_CLIENT_NAME": if (is_array($arField["VALUE"]) && (array_key_exists("CONTACT_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_NAME"]) > 0 || array_key_exists("CONTACT_LAST_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_LAST_NAME"]) > 0 || array_key_exists("COMPANY_TITLE", $arField["VALUE"]) && strlen($arField["VALUE"]["COMPANY_TITLE"]) > 0)) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; if (array_key_exists("CONTACT_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_NAME"]) > 0 || array_key_exists("CONTACT_LAST_NAME", $arField["VALUE"]) && strlen($arField["VALUE"]["CONTACT_LAST_NAME"]) > 0) { $strResult .= '<div class="crm-feed-client-block">'; $strResult .= '<span class="feed-com-avatar crm-feed-user-avatar"></span>'; $strResult .= CCrmContact::PrepareFormattedName(array("HONORIFIC" => $arField["VALUE"]["HONORIFIC"], "NAME" => $arField["VALUE"]["CONTACT_NAME"], "LAST_NAME" => $arField["VALUE"]["CONTACT_LAST_NAME"], "SECOND_NAME" => $arField["VALUE"]["CONTACT_SECOND_NAME"])); $strResult .= '<span class="crm-feed-client-company">' . (strlen($arField["VALUE"]["COMPANY_TITLE"]) > 0 ? $arField["VALUE"]["COMPANY_TITLE"] : "") . '</span>'; $strResult .= '</div>'; } else { $strResult .= $arField["VALUE"]["COMPANY_TITLE"]; } $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "DEAL_ID": if (intval($arField["VALUE"]) > 0) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; $strResult .= CCrmViewHelper::PrepareEntityBaloonHtml(array('ENTITY_TYPE_ID' => CCrmOwnerType::Deal, 'ENTITY_ID' => $arField["VALUE"], 'PREFIX' => "", 'CLASS_NAME' => '', 'CHECK_PERMISSIONS' => 'N')); $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "COMMUNICATIONS": if (is_array($arField["VALUE"]) && count($arField["VALUE"]) > 0) { $arCommunication = $arField["VALUE"][0]; $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<div class="crm-feed-client-block">'; if (in_array($arCommunication["ENTITY_TYPE_ID"], array(CCrmOwnerType::Company, CCrmOwnerType::Contact, CCrmOwnerType::Lead))) { $strResult .= '<span class="feed-com-avatar crm-feed-user-avatar">'; if ($arCommunication["ENTITY_TYPE_ID"] == CCrmOwnerType::Contact) { $dbRes = CCrmContact::GetListEx(array(), array('=ID' => $arCommunication["ENTITY_ID"], 'CHECK_PERMISSIONS' => 'N'), false, false, array('PHOTO')); if (($arRes = $dbRes->Fetch()) && intval($arRes["PHOTO"]) > 0) { $arFileTmp = CFile::ResizeImageGet($arRes["PHOTO"], array('width' => 39, 'height' => 39), BX_RESIZE_IMAGE_EXACT, false); if (is_array($arFileTmp) && isset($arFileTmp["src"])) { $strResult .= '<img width="39" height="39" src="' . $arFileTmp['src'] . '" alt="">'; } } } elseif ($arCommunication["ENTITY_TYPE_ID"] == CCrmOwnerType::Company) { $dbRes = CCrmCompany::GetListEx(array(), array('=ID' => $arCommunication["ENTITY_ID"], 'CHECK_PERMISSIONS' => 'N'), false, false, array('LOGO')); if (($arRes = $dbRes->Fetch()) && intval($arRes["LOGO"]) > 0) { $arFileTmp = CFile::ResizeImageGet($arRes["LOGO"], array('width' => 30, 'height' => 30), BX_RESIZE_IMAGE_EXACT, false); if (is_array($arFileTmp) && isset($arFileTmp["src"])) { $strResult .= '<img width="30" height="30" src="' . $arFileTmp['src'] . '" alt="">'; } } } $strResult .= '</span>'; } $arBaloonFields = array('ENTITY_TYPE_ID' => $arCommunication["ENTITY_TYPE_ID"], 'ENTITY_ID' => $arCommunication["ENTITY_ID"], 'PREFIX' => "", 'CLASS_NAME' => 'crm-feed-client-name', 'CHECK_PERMISSIONS' => 'N'); if ($arCommunication["ENTITY_TYPE_ID"] == CCrmOwnerType::Lead && is_array($arCommunication["ENTITY_SETTINGS"])) { $arBaloonFields["TITLE"] = isset($arCommunication["ENTITY_SETTINGS"]["LEAD_TITLE"]) ? htmlspecialcharsback($arCommunication["ENTITY_SETTINGS"]["LEAD_TITLE"]) : ""; $arBaloonFields["NAME"] = isset($arCommunication["ENTITY_SETTINGS"]["NAME"]) ? htmlspecialcharsback($arCommunication["ENTITY_SETTINGS"]["NAME"]) : ""; $arBaloonFields["LAST_NAME"] = isset($arCommunication["ENTITY_SETTINGS"]["LAST_NAME"]) ? htmlspecialcharsback($arCommunication["ENTITY_SETTINGS"]["LAST_NAME"]) : ""; $arBaloonFields["SECOND_NAME"] = isset($arCommunication["ENTITY_SETTINGS"]["SECOND_NAME"]) ? htmlspecialcharsback($arCommunication["ENTITY_SETTINGS"]["SECOND_NAME"]) : ""; } $strResult .= '<div>' . CCrmViewHelper::PrepareEntityBaloonHtml($arBaloonFields) . '</div>'; switch ($arCommunication["TYPE"]) { case 'EMAIL': $strResult .= '<div><a href="mailto:' . $arCommunication["VALUE"] . '" class="crm-feed-client-phone">' . $arCommunication["VALUE"] . '</div>'; break; case 'PHONE': if (CCrmSipHelper::isEnabled()) { ob_start(); ?> <script type="text/javascript"> if (typeof (window.bSipManagerUrlDefined_<?php echo $arCommunication["ENTITY_TYPE_ID"]; ?> ) === 'undefined') { window.bSipManagerUrlDefined_<?php echo $arCommunication["ENTITY_TYPE_ID"]; ?> = true; BX.ready( function() { var mgr = BX.CrmSipManager.getCurrent(); mgr.setServiceUrl( "CRM_<?php echo CUtil::JSEscape(CCrmOwnerType::ResolveName($arCommunication["ENTITY_TYPE_ID"])); ?> ", "<?php echo CUtil::JSEscape($this->arSipServiceUrl[$arCommunication["ENTITY_TYPE_ID"]]); ?> " ); if(typeof(BX.CrmSipManager.messages) === 'undefined') { BX.CrmSipManager.messages = { "unknownRecipient": "<?php echo GetMessageJS('CRM_LF_SIP_MGR_UNKNOWN_RECIPIENT'); ?> ", "enableCallRecording": "<?php echo GetMessageJS('CRM_LF_SIP_MGR_ENABLE_CALL_RECORDING'); ?> ", "makeCall": "<?php echo GetMessageJS('CCRM_LF_SIP_MGR_MAKE_CALL'); ?> " }; } } ); } </script> <?php $strResult .= ob_get_contents(); ob_end_clean(); } $strResult .= '<div><span class="crm-feed-num-block">' . CCrmViewHelper::PrepareMultiFieldHtml('PHONE', array('VALUE' => $arCommunication["VALUE"], 'VALUE_TYPE_ID' => 'WORK'), array('ENABLE_SIP' => true, 'SIP_PARAMS' => array('ENTITY_TYPE' => 'CRM_' . CCrmOwnerType::ResolveName($arCommunication["ENTITY_TYPE_ID"]), 'ENTITY_ID' => $arCommunication["ENTITY_ID"]))) . '</span></div>'; if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->RegisterTag("CRM_CALLTO_SETTINGS"); } break; } $strResult .= '<span class="crm-feed-client-company">' . (is_array($arCommunication["ENTITY_SETTINGS"]) && isset($arCommunication["ENTITY_SETTINGS"]["COMPANY_TITLE"]) ? $arCommunication["ENTITY_SETTINGS"]["COMPANY_TITLE"] : "") . '</span>'; $strResult .= '</div>'; $moreCnt = count($arField["VALUE"]) - 1; if ($moreCnt > 0) { $strResult .= "#clients_more_link#"; } $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "AVATAR_ID": if (intval($arField["VALUE"]) > 0) { $arFileTmp = CFile::ResizeImageGet($arField["VALUE"], array('width' => $this->params["AVATAR_SIZE"], 'height' => $this->params["AVATAR_SIZE"]), BX_RESIZE_IMAGE_EXACT, false); $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; $strResult .= '<img src="' . $arFileTmp["src"] . '" border="0" alt="' . $this->params["AVATAR_SIZE"] . '" width="" height="' . $this->params["AVATAR_SIZE"] . '">'; $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "SUM": if (intval($arField["VALUE"]["VALUE"]) > 0) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; $strResult .= '<span class="crm-feed-info-sum">' . CCrmCurrency::MoneyToString($arField["VALUE"]["VALUE"], $arField["VALUE"]["CURRENCY"]) . '</span>'; $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "PHONE": case "EMAIL": if (!empty($arField["VALUE"])) { $infos = CCrmFieldMulti::GetEntityTypes(); $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; $strResult .= CCrmViewHelper::PrepareFirstMultiFieldHtml($arField["FORMAT"], $arField["VALUE"], $infos[$arField["FORMAT"]]); if (count($arField["VALUE"]) > 1 || !empty($arField["VALUE"]["WORK"]) && count($arField["VALUE"]["WORK"]) > 1 || !empty($arField["VALUE"]["MOBILE"]) && count($arField["VALUE"]["MOBILE"]) > 1 || !empty($arField["VALUE"]["FAX"]) && count($arField["VALUE"]["FAX"]) > 1 || !empty($arField["VALUE"]["PAGER"]) && count($arField["VALUE"]["PAGER"]) > 1 || !empty($arField["VALUE"]["OTHER"]) && count($arField["VALUE"]["OTHER"]) > 1) { $anchorID = strtolower($arField["FORMAT"]); $strResult .= '<span style="margin-left: 10px;" class="crm-item-tel-list" id="' . htmlspecialcharsbx($anchorID) . '"' . ' onclick="' . CCrmViewHelper::PrepareMultiFieldValuesPopup($anchorID, $anchorID, $arField["FORMAT"], $arField["VALUE"], $infos[$arField["FORMAT"]]) . '"></span>'; } $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; if ($arField["FORMAT"] == "PHONE" && defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->RegisterTag("CRM_CALLTO_SETTINGS"); } } break; case "TEXT_FORMATTED": case "TEXT_FORMATTED_BOLD": if ($arField["VALUE"] != CCrmLiveFeed::UntitledMessageStub) { $text_formatted = $this->ParseText(htmlspecialcharsback($arField["VALUE"]), $arUF, $arParams["PARAMS"]); if (strlen($text_formatted) > 0) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_colspan2#"; if ($arField["FORMAT"] == "TEXT_FORMATTED_BOLD") { $strResult .= "<b>" . $text_formatted . "</b>"; } else { $strResult .= $text_formatted; } $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } } break; case "COMBI_TITLE": if (is_array($arField["VALUE"]) && array_key_exists("TITLE", $arField["VALUE"]) && strlen($arField["VALUE"]["TITLE"]) > 0) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; if (array_key_exists("URL", $arField["VALUE"]) && strlen($arField["VALUE"]["URL"]) > 0) { $strResult .= '<a href="' . $arField["VALUE"]["URL"] . '">' . $arField["VALUE"]["TITLE"] . '</a>'; } elseif (array_key_exists("ONCLICK", $arField["VALUE"]) && strlen($arField["VALUE"]["ONCLICK"]) > 0) { $strResult .= '<a href="javascript:void(0)" onclick="' . $arField["VALUE"]["ONCLICK"] . '">' . $arField["VALUE"]["TITLE"] . '</a>'; } else { $strResult .= $arField["VALUE"]["TITLE"]; } $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "COMBI_TITLE_ID": if (is_array($arField["VALUE"]) && array_key_exists("TITLE", $arField["VALUE"]) && strlen($arField["VALUE"]["TITLE"]) > 0 && array_key_exists("ID", $arField["VALUE"]) && strlen($arField["VALUE"]["ID"]) > 0) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; if (array_key_exists("URL", $arField["VALUE"]) && strlen($arField["VALUE"]["URL"]) > 0) { $strResult .= '<a href="' . $arField["VALUE"]["URL"] . '">' . GetMessage("C_CRM_LF_COMBI_TITLE_ID_VALUE", array("#ID#" => $arField["VALUE"]["ID"], "#TITLE#" => $arField["VALUE"]["TITLE"])) . '</a>'; } else { $strResult .= GetMessage("C_CRM_LF_COMBI_TITLE_ID_VALUE", array("#ID#" => $arField["VALUE"]["ID"], "#TITLE#" => $arField["VALUE"]["TITLE"])); } $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "TEXT_ADD": if (strlen($arField["VALUE"]) > 0) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; $strResult .= '<span class="crm-feed-info-name">' . $arField["VALUE"] . '</span>'; $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } break; case "TEXT": default: if (strlen($arField["VALUE"]) > 0) { $strResult .= "#row_begin#"; $strResult .= "#cell_begin_left#"; $strResult .= $arField["TITLE"] . ":"; $strResult .= "#cell_end#"; $strResult .= "#cell_begin_right#"; $strResult .= '<span class="crm-feed-info-text-padding">'; $strResult .= $arField["VALUE"]; $strResult .= '</span>'; $strResult .= "#cell_end#"; $strResult .= "#row_end#"; } } return $strResult; }
public static function GetDataForPopup($callId, $phone, $userId = 0) { if (strlen($phone) <= 0 || !CModule::IncludeModule('crm')) { return false; } if ($userId > 0) { $findParams = array('USER_ID' => $userId); } else { $findParams = array('ENABLE_EXTENDED_MODE' => false); } $crm = CCrmSipHelper::findByPhoneNumber((string) $phone, $findParams); if ($crm) { $dealStatuses = CCrmViewHelper::GetDealStageInfos(); $entity = ''; $entityData = array(); $entities = array(); $arResult = array('FOUND' => 'Y', 'CONTACT' => array(), 'COMPANY' => array(), 'ACTIVITIES' => array(), 'DEALS' => array(), 'RESPONSIBILITY' => array()); if (isset($crm['CONTACT'])) { $entity = 'CONTACT'; $entityData = $crm[$entity][0]; $arResult['CONTACT'] = array('NAME' => $entityData['FORMATTED_NAME'], 'POST' => $entityData['POST'], 'PHOTO' => ''); if (intval($entityData['PHOTO']) > 0) { $arPhoto = CFile::ResizeImageGet($entityData['PHOTO'], array('width' => 37, 'height' => 37), BX_RESIZE_IMAGE_EXACT, false, false, true); $arResult['CONTACT']['PHOTO'] = $arPhoto['src']; } $arResult['COMPANY'] = $entityData['COMPANY_TITLE']; $arResult['CONTACT_DATA'] = array('ID' => $entityData['ID']); } else { if (isset($crm['LEAD'])) { $entity = 'LEAD'; $entityData = $crm[$entity][0]; $arResult['CONTACT'] = array('ID' => 0, 'NAME' => !empty($entityData['FORMATTED_NAME']) ? $entityData['FORMATTED_NAME'] : $entityData['TITLE'], 'POST' => $entityData['POST'], 'PHOTO' => ''); $arResult['COMPANY'] = $entityData['COMPANY_TITLE']; $arResult['LEAD_DATA'] = array('ID' => $entityData['ID'], 'ASSIGNED_BY_ID' => $entityData['ASSIGNED_BY_ID']); } else { if (isset($crm['COMPANY'])) { $entity = 'COMPANY'; $entityData = $crm[$entity][0]; $arResult['COMPANY'] = $entityData['TITLE']; $arResult['COMPANY_DATA'] = array('ID' => $entityData['ID']); } } } if ($entityData['ASSIGNED_BY_ID'] > 0) { $ar = Bitrix\Main\UserTable::getById($entityData['ASSIGNED_BY_ID']); if ($user = $ar->fetch()) { $arPhoto = CFile::ResizeImageGet($user['PERSONAL_PHOTO'], array('width' => 37, 'height' => 37), BX_RESIZE_IMAGE_EXACT, false, false, true); $arResult['RESPONSIBILITY'] = array('ID' => $user['ID'], 'NAME' => CUser::FormatName(CSite::GetNameFormat(false), $user, true, false), 'PHOTO' => $arPhoto ? $arPhoto['src'] : '', 'POST' => $user['WORK_POSITION']); } } if (isset($entityData['SHOW_URL'])) { $arResult['SHOW_URL'] = $entityData['SHOW_URL']; } if (isset($entityData['ACTIVITY_LIST_URL'])) { $arResult['ACTIVITY_URL'] = $entityData['ACTIVITY_LIST_URL']; } if (isset($entityData['INVOICE_LIST_URL'])) { $arResult['INVOICE_URL'] = $entityData['INVOICE_LIST_URL']; } if (isset($entityData['DEAL_LIST_URL'])) { $arResult['DEAL_URL'] = $entityData['DEAL_LIST_URL']; } $activityId = CCrmActivity::GetIDByOrigin('VI_' . $callId); if ($activityId) { $arResult['CURRENT_CALL_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Activity, $activityId); if ($arResult['CURRENT_CALL_URL'] !== '') { $arResult['CURRENT_CALL_URL'] = CCrmUrlUtil::AddUrlParams($arResult['CURRENT_CALL_URL'], array("disable_storage_edit" => 'Y')); } } if (isset($crm['CONTACT']) && isset($crm['COMPANY'])) { $entities = array('CONTACT', 'COMPANY', 'LEAD'); } else { if (isset($crm['CONTACT']) && isset($crm['LEAD']) && !isset($crm['COMPANY'])) { $entities = array('CONTACT', 'LEAD'); } else { if (isset($crm['LEAD']) && isset($crm['COMPANY']) && !isset($crm['CONTACT'])) { $entities = array('LEAD', 'COMPANY'); } else { $entities = array($entity); } } } foreach ($entities as $entity) { if (isset($crm[$entity][0]['ACTIVITIES'])) { foreach ($crm[$entity][0]['ACTIVITIES'] as $activity) { if ($activity['ID'] == $activityId) { continue; } $overdue = 'N'; if (strlen($activity['DEADLINE']) > 0 && MakeTimeStamp($activity['DEADLINE']) < time()) { $overdue = 'Y'; } $arResult['ACTIVITIES'][$activity['ID']] = array('TITLE' => $activity['SUBJECT'], 'DATE' => strlen($activity['DEADLINE']) > 0 ? $activity['DEADLINE'] : $activity['END_TIME'], 'OVERDUE' => $overdue, 'URL' => $activity['SHOW_URL']); } if (!empty($arResult['ACTIVITIES'])) { $arResult['ACTIVITIES'] = array_values($arResult['ACTIVITIES']); } } if (isset($crm[$entity][0]['DEALS'])) { foreach ($crm[$entity][0]['DEALS'] as $deal) { $opportunity = CCrmCurrency::MoneyToString($deal['OPPORTUNITY'], $deal['CURRENCY_ID']); if (strpos('&', $opportunity)) { $opportunity = CCrmCurrency::MoneyToString($deal['OPPORTUNITY'], $deal['CURRENCY_ID'], '#') . ' ' . $deal['CURRENCY_ID']; } $opportunity = str_replace('.00', '', $opportunity); $arResult['DEALS'][$deal['ID']] = array('ID' => $deal['ID'], 'TITLE' => $deal['TITLE'], 'STAGE' => $dealStatuses[$deal['STAGE_ID']]['NAME'], 'STAGE_COLOR' => $dealStatuses[$deal['STAGE_ID']]['COLOR'] ? $dealStatuses[$deal['STAGE_ID']]['COLOR'] : "#5fa0ce", 'OPPORTUNITY' => $opportunity, 'URL' => $deal['SHOW_URL']); } if (!empty($arResult['DEALS'])) { $arResult['DEALS'] = array_values($arResult['DEALS']); } } } } else { $arResult = array('FOUND' => 'N'); $userPermissions = CCrmPerms::GetUserPermissions($userId); if (CCrmLead::CheckCreatePermission($userPermissions)) { $arResult['LEAD_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Lead, 0); if ($arResult['LEAD_URL'] !== '') { $arResult['LEAD_URL'] = CCrmUrlUtil::AddUrlParams($arResult['LEAD_URL'], array("phone" => (string) $phone, 'origin_id' => 'VI_' . $callId)); } } if (CCrmContact::CheckCreatePermission($userPermissions)) { $arResult['CONTACT_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Contact, 0); if ($arResult['CONTACT_URL'] !== '') { $arResult['CONTACT_URL'] = CCrmUrlUtil::AddUrlParams($arResult['CONTACT_URL'], array("phone" => (string) $phone, 'origin_id' => 'VI_' . $callId)); } } } return $arResult; }
public static function PrepareSipCallHtml($phone, $params = null) { if (!CCrmSipHelper::checkPhoneNumber($phone)) { return ''; } $entityType = is_array($params) && isset($params['ENTITY_TYPE']) ? $params['ENTITY_TYPE'] : ''; $entityID = is_array($params) && isset($params['ENTITY_ID']) ? intval($params['ENTITY_ID']) : 0; return '<span class="crm-tel-btn" onclick="BX.CrmSipManager.startCall({ number:\'' . CUtil::JSEscape($phone) . '\', enableInfoLoading: true }, { ENTITY_TYPE: \'' . CUtil::JSEscape($entityType) . '\', ENTITY_ID: \'' . CUtil::JSEscape($entityID) . '\' }, true, this);"></span>'; }