Пример #1
0
 protected static function getContactInfo($contactID)
 {
     if ($contactID <= 0) {
         return array();
     }
     $result = array('FULL_NAME' => '', 'FULL_ADDRESS' => '', 'PHONE' => '', 'EMAIL' => '');
     $dbRes = \CCrmContact::GetListEx(array(), array('=ID' => $contactID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('NAME', 'SECOND_NAME', 'LAST_NAME', 'ADDRESS', 'ADDRESS_2', 'ADDRESS_CITY', 'ADDRESS_POSTAL_CODE', 'ADDRESS_REGION', 'ADDRESS_PROVINCE', 'ADDRESS_COUNTRY'));
     $fields = is_object($dbRes) ? $dbRes->Fetch() : null;
     if (is_array($fields)) {
         $result['FULL_NAME'] = \CCrmContact::PrepareFormattedName($fields);
         $result['FULL_ADDRESS'] = Format\ContactAddressFormatter::format($fields, array('SEPARATOR' => Format\AddressSeparator::NewLine));
         $dbRes = \CCrmFieldMulti::GetListEx(array('ID' => 'asc'), array('ENTITY_ID' => 'CONTACT', 'ELEMENT_ID' => $contactID, '@TYPE_ID' => array('PHONE', 'EMAIL')), false, false, array('TYPE_ID', 'VALUE'));
         while ($multiFields = $dbRes->Fetch()) {
             if ($result['PHONE'] === '' && $multiFields['TYPE_ID'] === 'PHONE') {
                 $result['PHONE'] = $multiFields['VALUE'];
             } elseif ($result['EMAIL'] === '' && $multiFields['TYPE_ID'] === 'EMAIL') {
                 $result['EMAIL'] = $multiFields['VALUE'];
             }
             if ($result['PHONE'] !== '' && $result['EMAIL'] !== '') {
                 break;
             }
         }
     }
     return $result;
 }
Пример #2
0
                    $totalTaskQty += $taskQty;
                    if ($totalTaskQty > 5) {
                        break;
                    }
                }
            }
            unset($arDocState);
            if (!$isInExportMode) {
                $arContact['BIZPROC_STATUS_HINT'] = '<span class=\'bizproc-item-title\'>' . GetMessage('CRM_BP_R_P') . ': <a href=\'' . $arContact['PATH_TO_BIZPROC_LIST'] . '\' title=\'' . GetMessage('CRM_BP_R_P_TITLE') . '\'>' . $docStatesQty . '</a></span>' . ($totalTaskQty === 0 ? '' : '<br /><span class=\'bizproc-item-title\'>' . GetMessage('CRM_TASKS') . ': <a href=\'' . $arContact['PATH_TO_USER_BP'] . '\' title=\'' . GetMessage('CRM_TASKS_TITLE') . '\'>' . $totalTaskQty . ($totalTaskQty > 5 ? '+' : '') . '</a></span>');
            }
        }
    }
    $arContact['ASSIGNED_BY_ID'] = $arContact['~ASSIGNED_BY_ID'] = intval($arContact['ASSIGNED_BY']);
    $arContact['ASSIGNED_BY'] = CUser::FormatName($arParams['NAME_TEMPLATE'], array('LOGIN' => $arContact['ASSIGNED_BY_LOGIN'], 'NAME' => $arContact['ASSIGNED_BY_NAME'], 'LAST_NAME' => $arContact['ASSIGNED_BY_LAST_NAME'], 'SECOND_NAME' => $arContact['ASSIGNED_BY_SECOND_NAME']), true, false);
    if (isset($arSelectMap['FULL_ADDRESS'])) {
        $arContact['FULL_ADDRESS'] = ContactAddressFormatter::format($arContact, array('SEPARATOR' => AddressSeparator::HtmlLineBreak, 'NL2BR' => true));
    }
    $arResult['CONTACT'][$arContact['ID']] = $arContact;
    $arResult['CONTACT_UF'][$arContact['ID']] = array();
    $arResult['CONTACT_ID'][$arContact['ID']] = $arContact['ID'];
}
unset($arContact);
$CCrmUserType->ListAddEnumFieldsValue($arResult, $arResult['CONTACT'], $arResult['CONTACT_UF'], $isInExportMode ? ', ' : '<br />', $isInExportMode, array('FILE_URL_TEMPLATE' => '/bitrix/components/bitrix/crm.contact.show/show_file.php?ownerId=#owner_id#&fieldName=#field_name#&fileId=#file_id#'));
$arResult['ENABLE_TOOLBAR'] = isset($arParams['ENABLE_TOOLBAR']) ? $arParams['ENABLE_TOOLBAR'] : false;
if ($arResult['ENABLE_TOOLBAR']) {
    $arResult['PATH_TO_CONTACT_ADD'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_EDIT'], array('contact_id' => 0));
    $addParams = array();
    if ($bInternal && isset($arParams['INTERNAL_CONTEXT']) && is_array($arParams['INTERNAL_CONTEXT'])) {
        $internalContext = $arParams['INTERNAL_CONTEXT'];
        if (isset($internalContext['COMPANY_ID'])) {
            $addParams['company_id'] = $internalContext['COMPANY_ID'];
Пример #3
0
// IM -->
$arResult['FIELDS']['tab_1'][] = array('id' => 'IM', 'name' => GetMessage('CRM_FIELD_MESSENGER'), 'type' => 'custom', 'colspan' => true, 'value' => CCrmViewHelper::PrepareFormMultiField($arResult['ELEMENT'], 'IM', $prefix, $arMutliFieldTypeInfos), 'isTactile' => true);
// <-- IM
// COMPANY -->
if (!$CCrmContact->cPerms->HavePerm('COMPANY', BX_CRM_PERM_NONE, 'READ')) {
    $arResult['FIELDS']['tab_1'][] = $arResult['COMPANY_FIELD'] = array('id' => 'COMPANY_ID', 'name' => GetMessage('CRM_FIELD_COMPANY_TITLE'), 'params' => array('size' => 50), 'type' => 'custom', 'value' => isset($arResult['ELEMENT']['COMPANY_TITLE']) ? '<a href="' . $arResult['PATH_TO_COMPANY_SHOW'] . '" id="balloon_' . $arResult['GRID_ID'] . '_' . $arResult['ELEMENT']['ID'] . '">' . $arResult['ELEMENT']['COMPANY_TITLE'] . '</a>' . '<script type="text/javascript">BX.tooltip("COMPANY_' . $arResult['ELEMENT']['~COMPANY_ID'] . '", "balloon_' . $arResult['GRID_ID'] . '_' . $arResult['ELEMENT']['ID'] . '", "/bitrix/components/bitrix/crm.company.show/card.ajax.php", "crm_balloon_company", true);</script>' : '', 'isTactile' => true);
}
// <-- COMPANY
// POST -->
if ($enableInstantEdit) {
    $arResult['EDITABLE_FIELDS'][] = 'POST';
}
$arResult['FIELDS']['tab_1'][] = array('id' => 'POST', 'name' => GetMessage('CRM_FIELD_POST'), 'type' => 'label', 'params' => array('size' => 50), 'value' => isset($arResult['ELEMENT']['~POST']) ? $arResult['ELEMENT']['~POST'] : '', 'isTactile' => true);
//<-- POST
// ADDRESS -->
$arResult['FIELDS']['tab_1'][] = array('id' => 'ADDRESS', 'name' => GetMessage('CRM_FIELD_ADDRESS'), 'type' => 'custom', 'value' => ContactAddressFormatter::format($arResult['ELEMENT'], array('SEPARATOR' => AddressSeparator::HtmlLineBreak, 'NL2BR' => true)), 'isTactile' => true);
//<-- ADDRESS
// COMMENTS -->
if ($enableInstantEdit) {
    $arResult['EDITABLE_FIELDS'][] = 'COMMENTS';
}
$arResult['FIELDS']['tab_1'][] = array('id' => 'COMMENTS', 'name' => GetMessage('CRM_FIELD_COMMENTS'), 'type' => 'custom', 'value' => isset($arResult['ELEMENT']['~COMMENTS']) ? $arResult['ELEMENT']['~COMMENTS'] : '', 'isTactile' => true);
// <-- COMMENTS
// OPENED is displayed in sidebar. The field is added for COMPATIBILITY ONLY
if ($enableInstantEdit) {
    $arResult['EDITABLE_FIELDS'][] = 'OPENED';
}
$arResult['FIELDS']['tab_1'][] = array('id' => 'OPENED', 'name' => GetMessage('CRM_FIELD_OPENED'), 'type' => 'label', 'params' => array(), 'value' => $arResult['ELEMENT']['OPENED'] == 'Y' ? GetMessage('MAIN_YES') : GetMessage('MAIN_NO'), 'isTactile' => true);
// <-- OPENED
// EXPORT -->
// EXPORT is displayed in sidebar. The field is added for COMPATIBILITY ONLY
Пример #4
0
 private function MapField(&$entityInfo, $fieldName)
 {
     $result = '';
     $typeID = isset($entityInfo['TYPE_ID']) ? intval($entityInfo['TYPE_ID']) : CCrmOwnerType::Undefined;
     $fields = isset($entityInfo['FIELDS']) ? $entityInfo['FIELDS'] : array();
     $isHtml = $this->contentType === CCrmContentType::Html;
     $isBBCode = $this->contentType === CCrmContentType::BBCode;
     $isPlainText = $this->contentType === CCrmContentType::PlainText;
     if ($typeID === CCrmOwnerType::Lead) {
         switch ($fieldName) {
             case 'ID':
                 $result = isset($fields[$fieldName]) ? intval($fields[$fieldName]) : 0;
                 break;
             case 'NAME':
             case 'SECOND_NAME':
             case 'LAST_NAME':
             case 'TITLE':
             case 'COMPANY_TITLE':
             case 'SOURCE_DESCRIPTION':
             case 'STATUS_DESCRIPTION':
             case 'POST':
             case 'ASSIGNED_BY_WORK_POSITION':
                 $result = self::MapFieldValue($fields, $fieldName, $isHtml);
                 break;
             case 'ADDRESS':
                 $addressOptions = array();
                 if ($isHtml) {
                     $addressOptions['SEPARATOR'] = AddressSeparator::HtmlLineBreak;
                     $addressOptions['NL2BR'] = true;
                 } else {
                     $addressOptions['SEPARATOR'] = AddressSeparator::NewLine;
                 }
                 $result = LeadAddressFormatter::format($fields, $addressOptions);
                 break;
             case 'COMMENTS':
                 if ($isBBCode) {
                     $result = self::MapHtmlFieldAsBbCode($fields, 'COMMENTS');
                 } elseif ($isPlainText) {
                     $result = self::MapHtmlFieldAsPlainText($fields, 'COMMENTS');
                 } else {
                     $result = self::MapFieldValue($fields, $fieldName, false);
                 }
                 break;
             case 'SOURCE':
                 $result = self::MapReferenceValue(self::PrepareSources(), $fields, 'SOURCE_ID', $isHtml);
                 break;
             case 'STATUS':
                 $result = self::MapReferenceValue(self::PrepareLeadStatuses(), $fields, 'STATUS_ID', $isHtml);
                 break;
             case 'FORMATTED_NAME':
                 $result = CCrmLead::PrepareFormattedName(array('HONORIFIC' => isset($fields['HONORIFIC']) ? $fields['HONORIFIC'] : '', 'NAME' => isset($fields['NAME']) ? $fields['NAME'] : '', 'SECOND_NAME' => isset($fields['SECOND_NAME']) ? $fields['SECOND_NAME'] : '', 'LAST_NAME' => isset($fields['LAST_NAME']) ? $fields['LAST_NAME'] : ''));
                 if ($isHtml) {
                     $result = htmlspecialcharsbx($result);
                 }
                 break;
             case 'ASSIGNED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['ASSIGNED_BY_ID']) ? $fields['ASSIGNED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'CREATED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['CREATED_BY_ID']) ? $fields['CREATED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'MODIFY_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['MODIFY_BY_ID']) ? $fields['MODIFY_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'DATE_CREATE':
                 $result = isset($fields['DATE_CREATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_CREATE'])) : '';
                 break;
             case 'DATE_MODIFY':
                 $result = isset($fields['DATE_MODIFY']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_MODIFY'])) : '';
                 break;
             case 'CURRENCY':
                 $result = isset($fields['CURRENCY_ID']) ? CCrmCurrency::GetCurrencyName($fields['CURRENCY_ID']) : '';
                 break;
             case 'OPPORTUNITY':
                 $result = isset($fields['OPPORTUNITY']) ? $fields['OPPORTUNITY'] : 0.0;
                 break;
             case 'OPPORTUNITY_FORMATTED':
                 $result = CCrmCurrency::MoneyToString(isset($fields['OPPORTUNITY']) ? $fields['OPPORTUNITY'] : 0.0, isset($fields['CURRENCY_ID']) ? $fields['CURRENCY_ID'] : '');
                 break;
         }
     } elseif ($typeID === CCrmOwnerType::Deal) {
         switch ($fieldName) {
             case 'ID':
                 $result = isset($fields[$fieldName]) ? intval($fields[$fieldName]) : 0;
                 break;
             case 'TITLE':
             case 'ASSIGNED_BY_WORK_POSITION':
                 $result = self::MapFieldValue($fields, $fieldName, $isHtml);
                 break;
             case 'COMMENTS':
                 if ($isBBCode) {
                     $result = self::MapHtmlFieldAsBbCode($fields, 'COMMENTS');
                 } elseif ($isPlainText) {
                     $result = self::MapHtmlFieldAsPlainText($fields, 'COMMENTS');
                 } else {
                     $result = self::MapFieldValue($fields, $fieldName, false);
                 }
                 break;
             case 'TYPE':
                 $result = self::MapReferenceValue(self::PrepareDealTypes(), $fields, 'TYPE_ID', $isHtml);
                 break;
             case 'STAGE':
                 $result = self::MapReferenceValue(self::PrepareDealStages(), $fields, 'STAGE_ID', $isHtml);
                 break;
             case 'PROBABILITY':
                 $result = (isset($fields[$fieldName]) ? intval($fields[$fieldName]) : 0) . ' %';
                 break;
             case 'BEGINDATE':
                 $result = isset($fields['BEGINDATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['BEGINDATE'])) : '';
                 break;
             case 'CLOSEDATE':
                 $result = isset($fields['CLOSEDATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['CLOSEDATE'])) : '';
                 break;
             case 'ASSIGNED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['ASSIGNED_BY_ID']) ? $fields['ASSIGNED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'CREATED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['CREATED_BY_ID']) ? $fields['CREATED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'MODIFY_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['MODIFY_BY_ID']) ? $fields['MODIFY_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'DATE_CREATE':
                 $result = isset($fields['DATE_CREATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_CREATE'])) : '';
                 break;
             case 'DATE_MODIFY':
                 $result = isset($fields['DATE_MODIFY']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_MODIFY'])) : '';
                 break;
             case 'CURRENCY':
                 $result = isset($fields['CURRENCY_ID']) ? CCrmCurrency::GetCurrencyName($fields['CURRENCY_ID']) : '';
                 break;
             case 'OPPORTUNITY':
                 $result = isset($fields['OPPORTUNITY']) ? $fields['OPPORTUNITY'] : 0.0;
                 break;
             case 'OPPORTUNITY_FORMATTED':
                 $result = CCrmCurrency::MoneyToString(isset($fields['OPPORTUNITY']) ? $fields['OPPORTUNITY'] : 0.0, isset($fields['CURRENCY_ID']) ? $fields['CURRENCY_ID'] : '');
                 break;
             case 'COMPANY':
                 $result = self::ResolveEntityInfo(CCrmOwnerType::Company, isset($fields['COMPANY_ID']) ? intval($fields['COMPANY_ID']) : 0);
                 break;
             case 'CONTACT':
                 $result = self::ResolveEntityInfo(CCrmOwnerType::Contact, isset($fields['CONTACT_ID']) ? intval($fields['CONTACT_ID']) : 0);
                 break;
         }
     } elseif ($typeID === CCrmOwnerType::Contact) {
         switch ($fieldName) {
             case 'ID':
                 $result = isset($fields[$fieldName]) ? intval($fields[$fieldName]) : 0;
                 break;
             case 'NAME':
             case 'SECOND_NAME':
             case 'LAST_NAME':
             case 'POST':
             case 'SOURCE_DESCRIPTION':
             case 'ASSIGNED_BY_WORK_POSITION':
                 $result = self::MapFieldValue($fields, $fieldName, $isHtml);
                 break;
             case 'ADDRESS':
                 $addressOptions = array();
                 if ($isHtml) {
                     $addressOptions['SEPARATOR'] = AddressSeparator::HtmlLineBreak;
                     $addressOptions['NL2BR'] = true;
                 } else {
                     $addressOptions['SEPARATOR'] = AddressSeparator::NewLine;
                 }
                 $result = ContactAddressFormatter::format($fields, $addressOptions);
                 break;
             case 'COMMENTS':
                 if ($isBBCode) {
                     $result = self::MapHtmlFieldAsBbCode($fields, 'COMMENTS');
                 } elseif ($isPlainText) {
                     $result = self::MapHtmlFieldAsPlainText($fields, 'COMMENTS');
                 } else {
                     $result = self::MapFieldValue($fields, $fieldName, false);
                 }
                 break;
             case 'FORMATTED_NAME':
                 $result = CCrmContact::PrepareFormattedName(array('HONORIFIC' => isset($fields['HONORIFIC']) ? $fields['HONORIFIC'] : '', 'NAME' => isset($fields['NAME']) ? $fields['NAME'] : '', 'SECOND_NAME' => isset($fields['SECOND_NAME']) ? $fields['SECOND_NAME'] : '', 'LAST_NAME' => isset($fields['LAST_NAME']) ? $fields['LAST_NAME'] : ''));
                 if ($isHtml) {
                     $result = htmlspecialcharsbx($result);
                 }
                 break;
             case 'SOURCE':
                 $result = self::MapReferenceValue(self::PrepareSources(), $fields, 'SOURCE_ID', $isHtml);
                 break;
             case 'TYPE':
                 $result = self::MapReferenceValue(self::PrepareContactTypes(), $fields, 'TYPE_ID', $isHtml);
                 break;
             case 'COMPANY':
                 $result = self::ResolveEntityInfo(CCrmOwnerType::Company, isset($fields['COMPANY_ID']) ? intval($fields['COMPANY_ID']) : 0);
                 break;
             case 'ASSIGNED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['ASSIGNED_BY_ID']) ? $fields['ASSIGNED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'CREATED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['CREATED_BY_ID']) ? $fields['CREATED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'MODIFY_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['MODIFY_BY_ID']) ? $fields['MODIFY_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'DATE_CREATE':
                 $result = isset($fields['DATE_CREATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_CREATE'])) : '';
                 break;
             case 'DATE_MODIFY':
                 $result = isset($fields['DATE_MODIFY']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_MODIFY'])) : '';
                 break;
         }
     } elseif ($typeID === CCrmOwnerType::Company) {
         switch ($fieldName) {
             case 'ID':
                 $result = isset($fields[$fieldName]) ? intval($fields[$fieldName]) : 0;
                 break;
             case 'TITLE':
             case 'COMPANY_TITLE':
             case 'SOURCE_DESCRIPTION':
             case 'ASSIGNED_BY_WORK_POSITION':
             case 'BANKING_DETAILS':
                 $result = self::MapFieldValue($fields, $fieldName, $isHtml);
                 break;
             case 'ADDRESS':
             case 'ADDRESS_LEGAL':
                 $addressOptions = array('TYPE_ID' => $fieldName === 'ADDRESS' ? EntityAddress::Primary : EntityAddress::Registered);
                 if ($isHtml) {
                     $addressOptions['SEPARATOR'] = AddressSeparator::HtmlLineBreak;
                     $addressOptions['NL2BR'] = true;
                 } else {
                     $addressOptions['SEPARATOR'] = AddressSeparator::NewLine;
                 }
                 $result = CompanyAddressFormatter::format($fields, $addressOptions);
                 break;
             case 'COMMENTS':
                 if ($isBBCode) {
                     $result = self::MapHtmlFieldAsBbCode($fields, 'COMMENTS');
                 } elseif ($isPlainText) {
                     $result = self::MapHtmlFieldAsPlainText($fields, 'COMMENTS');
                 } else {
                     $result = self::MapFieldValue($fields, $fieldName, false);
                 }
                 break;
             case 'COMPANY_TYPE':
             case 'TYPE':
                 $result = self::MapReferenceValue(self::PrepareCompanyTypes(), $fields, 'COMPANY_TYPE', $isHtml);
                 break;
             case 'INDUSTRY':
                 $result = self::MapReferenceValue(self::PrepareIndustries(), $fields, 'INDUSTRY', $isHtml);
                 break;
             case 'EMPLOYEES':
                 $result = self::MapReferenceValue(self::PrepareEmployees(), $fields, 'EMPLOYEES', $isHtml);
                 break;
             case 'CURRENCY':
                 $result = isset($fields['CURRENCY_ID']) ? CCrmCurrency::GetCurrencyName($fields['CURRENCY_ID']) : '';
                 break;
             case 'REVENUE':
                 $result = isset($fields['REVENUE']) ? $fields['REVENUE'] : 0.0;
                 break;
             case 'REVENUE_FORMATTED':
                 $result = CCrmCurrency::MoneyToString(isset($fields['REVENUE']) ? $fields['REVENUE'] : 0.0, isset($fields['CURRENCY_ID']) ? $fields['CURRENCY_ID'] : '');
                 break;
             case 'ASSIGNED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['ASSIGNED_BY_ID']) ? $fields['ASSIGNED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'CREATED_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['CREATED_BY_ID']) ? $fields['CREATED_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'MODIFY_BY_FULL_NAME':
                 $result = CCrmViewHelper::GetFormattedUserName(isset($fields['MODIFY_BY_ID']) ? $fields['MODIFY_BY_ID'] : 0, '', $isHtml);
                 break;
             case 'DATE_CREATE':
                 $result = isset($fields['DATE_CREATE']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_CREATE'])) : '';
                 break;
             case 'DATE_MODIFY':
                 $result = isset($fields['DATE_MODIFY']) ? FormatDate('SHORT', MakeTimeStamp($fields['DATE_MODIFY'])) : '';
                 break;
         }
     }
     return $result;
 }