Example #1
0
             $activityFields['CAN_DELETE'] = CCrmActivity::CheckDeletePermission($ownerTypeID, $ownerID, $userPermissions);
         } else {
             $activityFields['CAN_EDIT'] = $activityFields['CAN_DELETE'] = true;
         }
     }
     $responsibleID = isset($activityFields['~RESPONSIBLE_ID']) ? intval($activityFields['~RESPONSIBLE_ID']) : 0;
     $activityFields['~RESPONSIBLE_ID'] = $responsibleID;
     if ($responsibleID <= 0) {
         $activityFields['RESPONSIBLE_FULL_NAME'] = '';
         $activityFields['PATH_TO_RESPONSIBLE'] = '';
     } elseif (!in_array($responsibleID, $responsibleIDs, true)) {
         $responsibleIDs[] = $responsibleID;
     }
     $activityFields['REFERENCE_TITLE'] = $ownerTypeID > 0 && $ownerID > 0 && ($ownerTypeID === CCrmOwnerType::Lead || $ownerTypeID === CCrmOwnerType::Deal) ? CCrmOwnerType::GetCaption($ownerTypeID, $ownerID, false) : '';
     $activityFields['CLIENT_TITLE'] = '';
     if (isset($activityFields['~DEADLINE']) && CCrmDateTimeHelper::IsMaxDatabaseDate($activityFields['~DEADLINE'])) {
         $activityFields['~DEADLINE'] = $activityFields['DEADLINE'] = '';
     }
     $activities[$itemID] =& $activityFields;
     unset($activityFields);
 }
 if (!empty($activities)) {
     $clientInfos = CCrmActivity::PrepareClientInfos(array_keys($activities));
     foreach ($clientInfos as $itemID => &$clientInfo) {
         $ttl = isset($clientInfo['TITLE']) ? $clientInfo['TITLE'] : '';
         if ($ttl === '') {
             $ttl = CCrmOwnerType::GetCaption($clientInfo['ENTITY_TYPE_ID'], $clientInfo['ENTITY_ID']);
         }
         $activities[$itemID]['CLIENT_TITLE'] = $ttl;
     }
     unset($clientInfo);
Example #2
0
    public static function RenderNearestActivity($arParams)
    {
        $gridManagerID = isset($arParams['GRID_MANAGER_ID']) ? $arParams['GRID_MANAGER_ID'] : '';
        $mgrID = strtolower($gridManagerID);
        $entityTypeName = isset($arParams['ENTITY_TYPE_NAME']) ? strtolower($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");
        $ID = isset($arParams['ACTIVITY_ID']) ? intval($arParams['ACTIVITY_ID']) : 0;
        if ($ID > 0) {
            $subject = isset($arParams['ACTIVITY_SUBJECT']) ? $arParams['ACTIVITY_SUBJECT'] : '';
            $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 = isset($arParams['ACTIVITY_EXPIRED']) ? $arParams['ACTIVITY_EXPIRED'] : $timestamp <= time() + CTimeZone::GetOffset();
            $result = '<div class="crm-nearest-activity-wrapper"><div class="crm-list-deal-date crm-nearest-activity-time' . ($isExpired ? '-expiried' : '') . '"><a class="crm-link" target = "_self" href = "#"
				onclick="BX.CrmInterfaceGridManager.viewActivity(\'' . CUtil::JSEscape($gridManagerID) . '\', ' . $ID . ', { enableEditButton:' . ($allowEdit ? 'true' : 'false') . ' }); return false;">' . htmlspecialcharsbx($timeFormatted) . '</a></div><div class="crm-nearest-activity-subject">' . htmlspecialcharsbx($subject) . '</div>';
            if ($allowEdit && !empty($menuItems)) {
                $result .= '<div class="crm-nearest-activity-plus" onclick="BX.CrmInterfaceGridManager.showMenu(\'' . $menuID . '\', this);"></div>
					<script type="text/javascript">BX.CrmInterfaceGridManager.createMenu("' . $menuID . '", ' . CUtil::PhpToJSObject($menuItems) . ');</script>';
            }
            $result .= '</div>';
            $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 .= '<div class="crm-list-deal-responsible"><span class="crm-list-deal-responsible-grey">' . htmlspecialcharsbx(GetMessage('CRM_ENTITY_ACTIVITY_FOR_RESPONSIBLE')) . '</span><a class="crm-list-deal-responsible-name" target="_blank" href="' . htmlspecialcharsbx($responsibleShowUrl) . '">' . htmlspecialcharsbx($responsibleFullName) . '</a></div>';
            }
            return $result;
        } elseif ($allowEdit && !empty($menuItems)) {
            return '<span class="crm-activity-add-hint">' . htmlspecialcharsbx(GetMessage('CRM_ENTITY_ADD_ACTIVITY_HINT')) . '</span>
				<a class="crm-activity-add" onclick="BX.CrmInterfaceGridManager.showMenu(\'' . $menuID . '\', this); return false;">' . htmlspecialcharsbx(GetMessage('CRM_ENTITY_ADD_ACTIVITY')) . '</a>
				<script type="text/javascript">BX.CrmInterfaceGridManager.createMenu("' . $menuID . '", ' . CUtil::PhpToJSObject($menuItems) . ');</script>';
        }
        return '';
    }
Example #3
0
    $descriptionType = isset($arRes['DESCRIPTION_TYPE']) ? intval($arRes['DESCRIPTION_TYPE']) : CCrmContentType::PlainText;
    if ($descriptionType === CCrmContentType::BBCode) {
        $arRes['DESCRIPTION_HTML'] = $bbCodeParser->convertText($description);
        $arRes['DESCRIPTION_RAW'] = strip_tags(preg_replace('/(<br[^>]*>)+/is' . BX_UTF_PCRE_MODIFIER, "\n", $arRes['DESCRIPTION_HTML']));
        $arRes['ENABLE_DESCRIPTION_CUT'] = false;
    } elseif ($descriptionType === CCrmContentType::Html) {
        //Already sanitaized
        $arRes['DESCRIPTION_HTML'] = $description;
        $arRes['DESCRIPTION_RAW'] = html_entity_decode(strip_tags(preg_replace('/(<br[^>]*>)+/is' . BX_UTF_PCRE_MODIFIER, "\n", $description)));
        $arRes['ENABLE_DESCRIPTION_CUT'] = false;
    } else {
        $arRes['DESCRIPTION_HTML'] = preg_replace("/[\r\n]+/" . BX_UTF_PCRE_MODIFIER, "<br/>", htmlspecialcharsbx($description));
        $arRes['DESCRIPTION_RAW'] = $description;
        $arRes['ENABLE_DESCRIPTION_CUT'] = true;
    }
    if (isset($arRes['~DEADLINE']) && CCrmDateTimeHelper::IsMaxDatabaseDate($arRes['~DEADLINE'])) {
        $arRes['~DEADLINE'] = $arRes['DEADLINE'] = '';
    }
    $items[$itemID] = $arRes;
}
if ($displayClient && !empty($items)) {
    $clientInfos = CCrmActivity::PrepareClientInfos(array_keys($items));
    foreach ($clientInfos as $itemID => &$clientInfo) {
        $items[$itemID]['CLIENT_INFO'] = $clientInfo;
    }
    unset($clientInfo);
}
$arResult['ITEMS'] = array_values($items);
$responsibleInfos = array();
if (!empty($responsibleIDs)) {
    $dbUsers = CUser::GetList($by = 'ID', $order = 'ASC', array('ID' => implode('||', $responsibleIDs)), array('FIELDS' => array('ID', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'LOGIN')));