CCrmViewHelper::RenderNearestActivity

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmViewHelper
  4. RenderNearestActivity
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_view_helper.php
  • Класс: \CCrmViewHelper
  • Вызов: CCrmViewHelper::RenderNearestActivity
static function RenderNearestActivity($arParams)
{
	$gridManagerID = isset($arParams['GRID_MANAGER_ID']) ? $arParams['GRID_MANAGER_ID'] : '';
	$preparedGridId = htmlspecialcharsbx(CUtil::JSescape($gridManagerID));
	$mgrID = mb_strtolower($gridManagerID);

	$entityTypeName = isset($arParams['ENTITY_TYPE_NAME'])? mb_strtolower($arParams['ENTITY_TYPE_NAME']) : '';
	$entityTypeId = CCrmOwnerType::ResolveID($arParams['ENTITY_TYPE_NAME']);
	$entityID = isset($arParams['ENTITY_ID']) ? $arParams['ENTITY_ID'] : '';

	$allowEdit = isset($arParams['ALLOW_EDIT']) ? $arParams['ALLOW_EDIT'] : false;
	$menuItems = isset($arParams['MENU_ITEMS']) ? $arParams['MENU_ITEMS'] : array();
	$menuID = CUtil::JSEscape("bx_{$mgrID}_{$entityTypeName}_{$entityID}_activity_add");

	$useGridExtension = isset($arParams['USE_GRID_EXTENSION']) ? $arParams['USE_GRID_EXTENSION'] : false;

	$ID = isset($arParams['ACTIVITY_ID']) ? intval($arParams['ACTIVITY_ID']) : 0;
	if($ID > 0)
	{
		$subject = isset($arParams['ACTIVITY_SUBJECT']) ? $arParams['ACTIVITY_SUBJECT'] : '';
		$subject = \Bitrix\Main\Text\Emoji::decode($subject); // possible double decode is not a problem

		$time = isset($arParams['ACTIVITY_TIME']) ? $arParams['ACTIVITY_TIME'] : '';
		if($time !== '' && CCrmDateTimeHelper::IsMaxDatabaseDate($time))
		{
			$time = '';
		}

		$timestamp = $time !== '' ? MakeTimeStamp($time) : 0;
		$timeFormatted = $timestamp > 0 ? CCrmComponentHelper::TrimDateTimeString(FormatDate('FULL', $timestamp)) : GetMessage('CRM_ACTIVITY_TIME_NOT_SPECIFIED');
		$isExpired = $arParams['ACTIVITY_EXPIRED'] ?? ($timestamp <= (time() + CTimeZone::GetOffset()));
		$isDetailExist = true;
		if (isset($arParams['ACTIVITY_PROVIDER_ID']))
		{
			$provider = \CCrmActivity::GetProviderById($arParams['ACTIVITY_PROVIDER_ID']);
			if ($provider)
			{
				$isDetailExist = $provider::hasPlanner($arParams);
			}
		}

		$activityEl = '' . htmlspecialcharsbx($timeFormatted) . '';
		if ($isDetailExist)
		{
			$activityEl = $useGridExtension
				? '' . htmlspecialcharsbx($timeFormatted) . '
					'
				: '' . htmlspecialcharsbx($timeFormatted) . '
					';
		}

		$result = '
			
' . $activityEl . '
' . htmlspecialcharsbx($subject) . '
'; if($allowEdit && !empty($menuItems)) { if($useGridExtension) { if (\Bitrix\Crm\Settings\Crm::isUniversalActivityScenarioEnabled()) { $currentUser = CUtil::PhpToJSObject(static::getUserInfo(true, false)); $jsOnClick = "BX.CrmUIGridExtension.showActivityAddingPopup(this, '".$preparedGridId."', " . (int)$entityTypeId . ", " . (int)$entityID . ", " . $currentUser . ");"; } else { $menuID = htmlspecialcharsbx($menuID); $menuParams = "{offsetLeft: 30, autoHide: true, closeByEsc: true, angle: { position: 'top', offset: 10 }}"; $menuItems = array_map('array_change_key_case', $menuItems); $menuItems = CUtil::PhpToJSObject($menuItems); $jsOnClick = "BX.Main.MenuManager.show('{$menuID}', this, {$menuItems}, {$menuParams});"; } $result .= '
'; } else { $result .= '
'; } } $result .= '
'; $responsibleID = isset($arParams['ACTIVITY_RESPONSIBLE_ID']) ? intval($arParams['ACTIVITY_RESPONSIBLE_ID']) : 0; if($responsibleID > 0) { $nameTemplate = isset($arParams['NAME_TEMPLATE']) ? $arParams['NAME_TEMPLATE'] : ''; if($nameTemplate === '') { $nameTemplate = CSite::GetNameFormat(false); } $responsibleFullName = CUser::FormatName( $nameTemplate, array( 'LOGIN' => isset($arParams['ACTIVITY_RESPONSIBLE_LOGIN']) ? $arParams['ACTIVITY_RESPONSIBLE_LOGIN'] : '', 'NAME' => isset($arParams['ACTIVITY_RESPONSIBLE_NAME']) ? $arParams['ACTIVITY_RESPONSIBLE_NAME'] : '', 'LAST_NAME' => isset($arParams['ACTIVITY_RESPONSIBLE_LAST_NAME']) ? $arParams['ACTIVITY_RESPONSIBLE_LAST_NAME'] : '', 'SECOND_NAME' => isset($arParams['ACTIVITY_RESPONSIBLE_SECOND_NAME']) ? $arParams['ACTIVITY_RESPONSIBLE_SECOND_NAME'] : '' ), true, false ); $responsibleShowUrl = ''; $pathToUserProfile = isset($arParams['PATH_TO_USER_PROFILE']) ? $arParams['PATH_TO_USER_PROFILE'] : ''; if($pathToUserProfile !== '') { $responsibleShowUrl = CComponentEngine::MakePathFromTemplate( $pathToUserProfile, array('user_id' => $responsibleID) ); } $result .= '
'.htmlspecialcharsbx(GetMessage('CRM_ENTITY_ACTIVITY_FOR_RESPONSIBLE')).''.htmlspecialcharsbx($responsibleFullName).'
'; } return $result; } elseif($allowEdit && !empty($menuItems)) { $hintText = isset($arParams['HINT_TEXT']) && $arParams['HINT_TEXT'] !== '' ? $arParams['HINT_TEXT'] : GetMessage('CRM_ENTITY_ADD_ACTIVITY_HINT'); if($useGridExtension) { if (\Bitrix\Crm\Settings\Crm::isUniversalActivityScenarioEnabled()) { $currentUser = CUtil::PhpToJSObject(static::getUserInfo(true, false)); $jsOnClick = "BX.CrmUIGridExtension.showActivityAddingPopup(this, '".$preparedGridId."', " . (int)$entityTypeId . ", " . (int)$entityID . ", " . $currentUser . ");"; } else { $menuID = htmlspecialcharsbx($menuID); $menuParams = "{offsetLeft: 30, autoHide: true, closeByEsc: true, angle: { position: 'top', offset: 10 }}"; $menuItems = array_map('array_change_key_case', $menuItems); $menuItems = CUtil::PhpToJSObject($menuItems); $jsOnClick = "BX.Main.MenuManager.show('{$menuID}', this, {$menuItems}, {$menuParams});"; } return ''.htmlspecialcharsbx($hintText).' '.htmlspecialcharsbx(GetMessage('CRM_ENTITY_ADD_ACTIVITY')).' '; } else { return ''.htmlspecialcharsbx($hintText).' '.htmlspecialcharsbx(GetMessage('CRM_ENTITY_ADD_ACTIVITY')).' '; } } return ''; }

Добавить комментарий