- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/lib/integration/main/uiselector/search.php
- Класс: BitrixSocialnetworkIntegrationMainUISelectorSearch
- Вызов: Search::searchCrmCompanies
static function searchCrmCompanies($params = array())
{
$searchResult = array();
if (Loader::includeModule('crm'))
{
$search = $params['search'];
$companyTypeList = CCrmStatus::getStatusListEx('COMPANY_TYPE');
$companyIndustryList = CCrmStatus::getStatusListEx('INDUSTRY');
$res = CCrmCompany::getListEx(
[],
['%TITLE' => $search, '@CATEGORY_ID' => 0,],
false,
['nTopCount' => 20],
['ID', 'TITLE', 'COMPANY_TYPE', 'INDUSTRY', 'LOGO']
);
while ($res && ($company = $res->fetch()))
{
$descList = array();
if (isset($companyTypeList[$company['COMPANY_TYPE']]))
{
$descList[] = $companyTypeList[$company['COMPANY_TYPE']];
}
if (isset($companyIndustryList[$company['INDUSTRY']]))
{
$descList[] = $companyIndustryList[$company['INDUSTRY']];
}
$searchResult['CRMCOMPANY'.$company['ID']] = array(
'id' => 'CRMCOMPANY'.$company['ID'],
'entityId' => $company['ID'],
'entityType' => 'companies',
'name' => htmlspecialcharsbx(str_replace(array(';', ','), ' ', $company['TITLE'])),
'desc' => htmlspecialcharsbx(implode(', ', $descList))
);
if (!empty($company['LOGO']) && intval($company['LOGO']) > 0)
{
$image = CFile::resizeImageGet($company['LOGO'], array('width' => 100, 'height' => 100), BX_RESIZE_IMAGE_EXACT);
$searchResult['CRMCOMPANY'.$company['ID']]['avatar'] = $image['src'];
}
}
}
return $searchResult;
}