本文整理汇总了PHP中CCrmContact::GetListEx方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmContact::GetListEx方法的具体用法?PHP CCrmContact::GetListEx怎么用?PHP CCrmContact::GetListEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCrmContact
的用法示例。
在下文中一共展示了CCrmContact::GetListEx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContactInfo
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: getNearestEntities
public static function getNearestEntities($entityID, $currentDate, $startDate = '', $responsibleID = 0, $intervalInDays = 7, $checkPermissions = true, $limit = 5)
{
if (!is_string($startDate) || $startDate === '') {
$startDate = $currentDate;
}
$site = new \CSite();
$dateFormat = $site->GetDateFormat('SHORT');
$curretTime = $currentDate !== '' ? MakeTimeStamp($currentDate, $dateFormat) : false;
$startTime = $startDate !== '' ? MakeTimeStamp($startDate, $dateFormat) : false;
if ($startTime === false) {
return array();
}
$dt = new \DateTime();
$dt->setTimestamp($startTime);
$dt->add(new \DateInterval("P{$intervalInDays}D"));
$endTime = $dt->getTimeStamp();
$currentSorting = self::internalPrepareSorting($curretTime);
$startSorting = self::internalPrepareSorting($startTime);
$endSorting = self::internalPrepareSorting($endTime);
$result = array();
if ($entityID === \CCrmOwnerType::Lead) {
$filter = array('>=BIRTHDAY_SORT' => $startSorting, '<=BIRTHDAY_SORT' => $endSorting, 'CHECK_PERMISSIONS' => $checkPermissions ? 'Y' : 'N');
if ($responsibleID > 0) {
$filter['=ASSIGNED_BY_ID'] = $responsibleID;
}
$dbResult = \CCrmLead::GetListEx(array(), $filter, false, array('nTopCount' => $limit), array('ID', 'BIRTHDATE', 'BIRTHDAY_SORT', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME'));
while ($fields = $dbResult->Fetch()) {
$fields['ENTITY_TYPE_ID'] = \CCrmOwnerType::Lead;
$fields['IMAGE_ID'] = 0;
$sorting = isset($fields['BIRTHDAY_SORT']) ? (int) $fields['BIRTHDAY_SORT'] : 512;
$fields['IS_BIRTHDAY'] = $sorting === $currentSorting;
$result[] = $fields;
}
} elseif ($entityID === \CCrmOwnerType::Contact) {
$filter = array('>=BIRTHDAY_SORT' => $startSorting, '<=BIRTHDAY_SORT' => $endSorting, 'CHECK_PERMISSIONS' => $checkPermissions ? 'Y' : 'N');
if ($responsibleID > 0) {
$filter['=ASSIGNED_BY_ID'] = $responsibleID;
}
$dbResult = \CCrmContact::GetListEx(array(), $filter, false, array('nTopCount' => $limit), array('ID', 'BIRTHDATE', 'BIRTHDAY_SORT', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PHOTO'));
while ($fields = $dbResult->Fetch()) {
$fields['ENTITY_TYPE_ID'] = \CCrmOwnerType::Contact;
$fields['IMAGE_ID'] = isset($fields['PHOTO']) ? (int) $fields['PHOTO'] : 0;
$sorting = isset($fields['BIRTHDAY_SORT']) ? (int) $fields['BIRTHDAY_SORT'] : 512;
$fields['IS_BIRTHDAY'] = $sorting === $currentSorting;
$result[] = $fields;
}
}
return $result;
}
示例3: unset
$filter['%FULL_NAME'] = $filter['FULL_NAME'];
unset($filter['FULL_NAME']);
}
}
}
if ($companyID > 0) {
$arResult['RUBRIC']['ENABLED'] = true;
$arResult['RUBRIC']['TITLE'] = CCrmOwnerType::GetCaption(CCrmOwnerType::Company, $companyID);
$filter['=COMPANY_ID'] = $companyID;
}
//Setup default filter name ('NONE') if it is not assigned
if (!isset($arResult['GRID_FILTER_NAME']) || $arResult['GRID_FILTER_NAME'] === '') {
$arResult['GRID_FILTER_NAME'] = GetMessage('M_CRM_CONTACT_LIST_FILTER_NONE');
}
$arResult['ITEMS'] = array();
$dbRes = CCrmContact::GetListEx($sort, $filter, false, $navParams, $select);
$dbRes->NavStart($navParams['nPageSize'], false);
$arResult['PAGE_NAVNUM'] = intval($dbRes->NavNum);
// pager index
$arResult['PAGE_NUMBER'] = intval($dbRes->NavPageNomer);
// current page index
$arResult['PAGE_NAVCOUNT'] = intval($dbRes->NavPageCount);
// page count
$arResult['PAGER_PARAM'] = "PAGEN_{$arResult['PAGE_NAVNUM']}";
$arResult['PAGE_NEXT_NUMBER'] = $arResult['PAGE_NUMBER'] + 1;
while ($item = $dbRes->GetNext()) {
CCrmMobileHelper::PrepareContactItem($item, $arParams);
$arResult['ITEMS'][] =& $item;
unset($item);
}
//NEXT_PAGE_URL, SEARCH_PAGE_URL, SERVICE_URL -->
示例4: htmlspecialcharsbx
$bCreateFromDeal = true;
}
}
if (isset($_GET['title'])) {
$arFields['~TITLE'] = $_GET['title'];
CUtil::decodeURIComponent($arFields['~TITLE']);
$arFields['TITLE'] = htmlspecialcharsbx($arFields['~TITLE']);
}
$bCreateFrom = $bCreateFromLead || $bCreateFromDeal || $bCreateFromCompany || $bCreateFromContact;
$leadId = isset($arFields['LEAD_ID']) ? intval($arFields['LEAD_ID']) : 0;
$dealId = isset($arFields['DEAL_ID']) ? intval($arFields['DEAL_ID']) : 0;
$contactId = isset($arFields['CONTACT_ID']) ? intval($arFields['CONTACT_ID']) : 0;
$companyId = isset($arFields['COMPANY_ID']) ? intval($arFields['COMPANY_ID']) : 0;
// create from contact
if ($contactId > 0) {
$dbContact = CCrmContact::GetListEx(array('ID' => 'DESC'), array('ID' => $contactId), false, array('nTopCount' => 1), array('ID', 'LEAD_ID'));
if ($arContact = $dbContact->Fetch()) {
if (isset($arContact['LEAD_ID']) && intval($arContact['LEAD_ID']) > 0) {
$arFields['~LEAD_ID'] = $arFields['LEAD_ID'] = intval($arContact['LEAD_ID']);
}
}
unset($dbContact, $arContact);
}
// create from company
if ($companyId > 0) {
$dbCompany = CCrmCompany::GetListEx(array('ID' => 'DESC'), array('ID' => $companyId), false, array('nTopCount' => 1), array('ID', 'LEAD_ID'));
if ($arCompany = $dbCompany->Fetch()) {
if (isset($arCompany['LEAD_ID']) && intval($arCompany['LEAD_ID']) > 0) {
$arFields['~LEAD_ID'] = $arFields['LEAD_ID'] = intval($arCompany['LEAD_ID']);
}
}
示例5: PreparePopupItems
public static function PreparePopupItems($entityTypeNames, $addPrefix = true, $nameFormat = '', $count = 50)
{
if (!is_array($entityTypeNames)) {
$entityTypeNames = array(strval($entityTypeNames));
}
$addPrefix = (bool) $addPrefix;
$count = intval($count);
if ($count <= 0) {
$count = 50;
}
$arItems = array();
$i = 0;
foreach ($entityTypeNames as $typeName) {
$typeName = strtoupper(strval($typeName));
if ($typeName === 'CONTACT') {
$contactTypes = CCrmStatus::GetStatusList('CONTACT_TYPE');
$contactIndex = array();
$obRes = CCrmContact::GetListEx(array('ID' => 'DESC'), array(), false, array('nTopCount' => $count), array('ID', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'COMPANY_TITLE', 'PHOTO', 'TYPE_ID'));
while ($arRes = $obRes->Fetch()) {
$arImg = array();
if (!empty($arRes['PHOTO']) && !isset($arFiles[$arRes['PHOTO']])) {
if (intval($arRes['PHOTO']) > 0) {
$arImg = CFile::ResizeImageGet($arRes['PHOTO'], array('width' => 25, 'height' => 25), BX_RESIZE_IMAGE_EXACT);
}
}
$arRes['SID'] = $addPrefix ? 'C_' . $arRes['ID'] : $arRes['ID'];
// advanced info
$advancedInfo = array();
if (isset($arRes['TYPE_ID']) && $arRes['TYPE_ID'] != '' && isset($contactTypes[$arRes['TYPE_ID']])) {
$advancedInfo['contactType'] = array('id' => $arRes['TYPE_ID'], 'name' => $contactTypes[$arRes['TYPE_ID']]);
}
$arItems[$i] = array('title' => CCrmContact::PrepareFormattedName(array('HONORIFIC' => isset($arRes['HONORIFIC']) ? $arRes['HONORIFIC'] : '', 'NAME' => isset($arRes['NAME']) ? $arRes['NAME'] : '', 'SECOND_NAME' => isset($arRes['SECOND_NAME']) ? $arRes['SECOND_NAME'] : '', 'LAST_NAME' => isset($arRes['LAST_NAME']) ? $arRes['LAST_NAME'] : ''), $nameFormat), 'desc' => empty($arRes['COMPANY_TITLE']) ? "" : $arRes['COMPANY_TITLE'], 'id' => $arRes['SID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_contact_show'), array('contact_id' => $arRes['ID'])), 'image' => $arImg['src'], 'type' => 'contact', 'selected' => 'N');
if (!empty($advancedInfo)) {
$arItems[$i]['advancedInfo'] = $advancedInfo;
}
unset($advancedInfo);
$contactIndex[$arRes['ID']] =& $arItems[$i];
$i++;
}
// advanced info - phone number, e-mail
$obRes = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'CONTACT', 'ELEMENT_ID' => array_keys($contactIndex)));
while ($arRes = $obRes->Fetch()) {
if (isset($contactIndex[$arRes['ELEMENT_ID']]) && ($arRes['TYPE_ID'] === 'PHONE' || $arRes['TYPE_ID'] === 'EMAIL')) {
$item =& $contactIndex[$arRes['ELEMENT_ID']];
if (!is_array($item['advancedInfo'])) {
$item['advancedInfo'] = array();
}
if (!is_array($item['advancedInfo']['multiFields'])) {
$item['advancedInfo']['multiFields'] = array();
}
$item['advancedInfo']['multiFields'][] = array('ID' => $arRes['ID'], 'TYPE_ID' => $arRes['TYPE_ID'], 'VALUE_TYPE' => $arRes['VALUE_TYPE'], 'VALUE' => $arRes['VALUE']);
unset($item);
}
}
unset($contactIndex);
} elseif ($typeName === 'COMPANY') {
$companyIndex = array();
$arCompanyTypeList = CCrmStatus::GetStatusListEx('COMPANY_TYPE');
$arCompanyIndustryList = CCrmStatus::GetStatusListEx('INDUSTRY');
$obRes = CCrmCompany::GetListEx(array('ID' => 'DESC'), array(), false, array('nTopCount' => $count), array('ID', 'TITLE', 'COMPANY_TYPE', 'INDUSTRY', 'LOGO'));
$arFiles = array();
while ($arRes = $obRes->Fetch()) {
$arImg = array();
if (!empty($arRes['LOGO']) && !isset($arFiles[$arRes['LOGO']])) {
if (intval($arRes['LOGO']) > 0) {
$arImg = CFile::ResizeImageGet($arRes['LOGO'], array('width' => 25, 'height' => 25), BX_RESIZE_IMAGE_EXACT);
}
$arFiles[$arRes['LOGO']] = $arImg['src'];
}
$arRes['SID'] = $addPrefix ? 'CO_' . $arRes['ID'] : $arRes['ID'];
$arDesc = array();
if (isset($arCompanyTypeList[$arRes['COMPANY_TYPE']])) {
$arDesc[] = $arCompanyTypeList[$arRes['COMPANY_TYPE']];
}
if (isset($arCompanyIndustryList[$arRes['INDUSTRY']])) {
$arDesc[] = $arCompanyIndustryList[$arRes['INDUSTRY']];
}
$arItems[$i] = array('title' => str_replace(array(';', ','), ' ', $arRes['TITLE']), 'desc' => implode(', ', $arDesc), 'id' => $arRes['SID'], 'url' => CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_company_show'), array('company_id' => $arRes['ID'])), 'image' => $arImg['src'], 'type' => 'company', 'selected' => 'N');
$companyIndex[$arRes['ID']] =& $arItems[$i];
$i++;
}
// advanced info - phone number, e-mail
$obRes = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'COMPANY', 'ELEMENT_ID' => array_keys($companyIndex)));
while ($arRes = $obRes->Fetch()) {
if (isset($companyIndex[$arRes['ELEMENT_ID']]) && ($arRes['TYPE_ID'] === 'PHONE' || $arRes['TYPE_ID'] === 'EMAIL')) {
$item =& $companyIndex[$arRes['ELEMENT_ID']];
if (!is_array($item['advancedInfo'])) {
$item['advancedInfo'] = array();
}
if (!is_array($item['advancedInfo']['multiFields'])) {
$item['advancedInfo']['multiFields'] = array();
}
$item['advancedInfo']['multiFields'][] = array('ID' => $arRes['ID'], 'TYPE_ID' => $arRes['TYPE_ID'], 'VALUE_TYPE' => $arRes['VALUE_TYPE'], 'VALUE' => $arRes['VALUE']);
unset($item);
}
}
unset($companyIndex);
} elseif ($typeName === 'LEAD') {
$leadIndex = array();
$obRes = CCrmLead::GetListEx(array('ID' => 'DESC'), array(), false, array('nTopCount' => $count), array('ID', 'TITLE', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'STATUS_ID'));
//.........这里部分代码省略.........
示例6: ExportOrders2Xml
//.........这里部分代码省略.........
if (IntVal($arOrder["USER_ID"]) > 0)
{
$dbUser = CUser::GetByID($arOrder["USER_ID"]);
if ($arUser = $dbUser->Fetch())
$arProp["USER"] = $arUser;
}
if ($bExportFromCrm)
{
$arProp["CRM"] = array();
$companyID = isset($arOrder["UF_COMPANY_ID"]) ? intval($arOrder["UF_COMPANY_ID"]) : 0;
$contactID = isset($arOrder["UF_CONTACT_ID"]) ? intval($arOrder["UF_CONTACT_ID"]) : 0;
if ($companyID > 0)
{
$arProp["CRM"]["CLIENT_ID"] = "CRMCO".$companyID;
}
else
{
$arProp["CRM"]["CLIENT_ID"] = "CRMC".$contactID;
}
$clientInfo = array(
"LOGIN" => "",
"NAME" => "",
"LAST_NAME" => "",
"SECOND_NAME" => ""
);
if ($bCrmModuleIncluded)
{
if ($companyID > 0)
{
$arCompanyFilter = array('=ID' => $companyID);
$dbCompany = CCrmCompany::GetListEx(
array(), $arCompanyFilter, false, array("nTopCount" => 1),
array("TITLE")
);
$arCompany = $dbCompany->Fetch();
unset($dbCompany, $arCompanyFilter);
if (is_array($arCompany))
{
if (isset($arCompany["TITLE"]))
$clientInfo["NAME"] = $arCompany["TITLE"];
}
unset($arCompany);
}
else if ($contactID > 0)
{
$arContactFilter = array('=ID' => $contactID);
$dbContact = CCrmContact::GetListEx(
array(), $arContactFilter, false, array("nTopCount" => 1),
array("NAME", "LAST_NAME", "SECOND_NAME")
);
$arContact = $dbContact->Fetch();
unset($dbContact, $arContactFilter);
if (is_array($arContact))
{
if (isset($arContact["NAME"]))
$clientInfo["NAME"] = $arContact["NAME"];
if (isset($arContact["LAST_NAME"]))
$clientInfo["LAST_NAME"] = $arContact["LAST_NAME"];
if (isset($arContact["SECOND_NAME"]))
$clientInfo["SECOND_NAME"] = $arContact["SECOND_NAME"];
}
unset($arContact);
}
示例7: GetUsersFromUserGroup
public static function GetUsersFromUserGroup($group, $documentId)
{
$groupLc = strtolower($group);
if ($groupLc == 'author') {
$arDocumentID = self::GetDocumentInfo($documentId);
if (empty($arDocumentID)) {
return array();
}
$dbDocumentList = null;
$entityID = isset($arDocumentID['ID']) ? intval($arDocumentID['ID']) : 0;
if ($entityID > 0) {
switch ($arDocumentID['TYPE']) {
case 'CONTACT':
$dbDocumentList = CCrmContact::GetListEx(array(), array('ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ASSIGNED_BY_ID'));
break;
case 'COMPANY':
$dbDocumentList = CCrmCompany::GetListEx(array(), array('ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ASSIGNED_BY_ID'));
break;
case 'DEAL':
$dbDocumentList = CCrmDeal::GetListEx(array(), array('ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ASSIGNED_BY_ID'));
break;
case 'LEAD':
$dbDocumentList = CCrmLead::GetListEx(array(), array('ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ASSIGNED_BY_ID'));
break;
}
}
$arFields = is_object($dbDocumentList) ? $dbDocumentList->Fetch() : null;
return is_array($arFields) && isset($arFields['ASSIGNED_BY_ID']) ? array($arFields['ASSIGNED_BY_ID']) : array();
} elseif ($groupLc == 'ungrouped') {
return isset(self::$UNGROUPED_USERS[$documentId]) ? self::$UNGROUPED_USERS[$documentId] : array();
}
$group = (int) $group;
if ($group <= 0) {
return array();
}
$arResult = array();
$dbUsersList = CUser::GetList($b = 'ID', $o = 'ASC', array('GROUPS_ID' => $group, 'ACTIVE' => 'Y'));
while ($arUser = $dbUsersList->Fetch()) {
$arResult[] = $arUser['ID'];
}
return $arResult;
}
示例8: TryGetInfo
public static function TryGetInfo($typeID, $ID, &$info, $bCheckPermissions = false)
{
$typeID = intval($typeID);
$ID = intval($ID);
if ($ID <= 0) {
return array();
}
$result = null;
switch ($typeID) {
case self::Lead:
$dbRes = CCrmLead::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => $bCheckPermissions ? 'Y' : 'N'), false, false, array('TITLE'));
$arRes = $dbRes ? $dbRes->Fetch() : null;
if (is_array($arRes)) {
$info = array('CAPTION' => isset($arRes['TITLE']) ? $arRes['TITLE'] : '', 'IMAGE_ID' => 0);
return true;
}
break;
case self::Contact:
$dbRes = CCrmContact::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => $bCheckPermissions ? 'Y' : 'N'), false, false, array('NAME', 'SECOND_NAME', 'LAST_NAME', 'PHOTO'));
$arRes = $dbRes ? $dbRes->Fetch() : null;
if (is_array($arRes)) {
$info = array('CAPTION' => CUser::FormatName(\Bitrix\Crm\Format\PersonNameFormatter::getFormat(), array('LOGIN' => '', 'NAME' => isset($arRes['NAME']) ? $arRes['NAME'] : '', 'SECOND_NAME' => isset($arRes['SECOND_NAME']) ? $arRes['SECOND_NAME'] : '', 'LAST_NAME' => isset($arRes['LAST_NAME']) ? $arRes['LAST_NAME'] : ''), false, false), 'IMAGE_ID' => isset($arRes['PHOTO']) ? intval($arRes['PHOTO']) : 0);
return true;
}
break;
case self::Company:
$dbRes = CCrmCompany::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => $bCheckPermissions ? 'Y' : 'N'), false, false, array('TITLE', 'LOGO'));
$arRes = $dbRes ? $dbRes->Fetch() : null;
if (is_array($arRes)) {
$info = array('CAPTION' => isset($arRes['TITLE']) ? $arRes['TITLE'] : '', 'IMAGE_ID' => isset($arRes['LOGO']) ? intval($arRes['LOGO']) : 0);
return true;
}
break;
case self::Deal:
$dbRes = CCrmDeal::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => $bCheckPermissions ? 'Y' : 'N'), false, false, array('TITLE'));
$arRes = $dbRes ? $dbRes->Fetch() : null;
if (is_array($arRes)) {
$info = array('CAPTION' => isset($arRes['TITLE']) ? $arRes['TITLE'] : '', 'IMAGE_ID' => 0);
return true;
}
break;
case self::Invoice:
$dbRes = CCrmInvoice::GetList(array(), array('ID' => $ID), false, false, array('ORDER_TOPIC'));
$arRes = $dbRes ? $dbRes->Fetch() : null;
if (is_array($arRes)) {
$info = array('CAPTION' => isset($arRes['ORDER_TOPIC']) ? $arRes['ORDER_TOPIC'] : '', 'IMAGE_ID' => 0);
return true;
}
break;
case self::Quote:
$dbRes = CCrmQuote::GetList(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => $bCheckPermissions ? 'Y' : 'N'), false, false, array('TITLE'));
$arRes = $dbRes ? $dbRes->Fetch() : null;
if (is_array($arRes)) {
$info = array('CAPTION' => isset($arRes['TITLE']) ? $arRes['TITLE'] : '', 'IMAGE_ID' => 0);
return true;
}
break;
}
return false;
}
示例9: foreach
foreach ($arResult['ENTITY_DATA'] as &$entityData) {
$entityTypeName = CCrmOwnerType::ResolveName(CCrmLiveFeedEntity::ResolveEntityTypeID($entityData['ENTITY_TYPE']));
$entityID = $entityData['ENTITY_ID'];
$arResult['FEED_DESTINATION']['SELECTED']['CRM' . $entityTypeName . $entityID] = $types[$entityTypeName];
}
unset($entityData);
}
if ($entityTypeName && $entityID) {
if (isset($types[$entityTypeName])) {
if (empty($arResult['ENTITY_DATA'])) {
$arResult['FEED_DESTINATION']['SELECTED']['CRM' . $entityTypeName . $entityID] = $types[$entityTypeName];
}
if (!isset($arResult['FEED_DESTINATION'][strtoupper($types[$entityTypeName])]['CRM' . $entityTypeName . $entityID])) {
switch ($entityTypeName) {
case 'CONTACT':
$dbEntity = CCrmContact::GetListEx(array(), array('ID' => $entityID), false, array(), array('ID', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'COMPANY_TITLE', 'PHOTO'));
break;
case 'COMPANY':
$dbEntity = CCrmCompany::GetListEx(array(), array('ID' => $entityID), false, array(), array('ID', 'TITLE', 'COMPANY_TYPE', 'INDUSTRY', 'LOGO'));
break;
case 'LEAD':
$dbEntity = CCrmLead::GetListEx(array(), array('ID' => $entityID), false, array(), array('ID', 'TITLE', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'STATUS_ID'));
break;
case 'DEAL':
$dbEntity = CCrmDeal::GetListEx(array(), array('ID' => $entityID), false, array(), array('ID', 'TITLE', 'STAGE_ID'));
break;
default:
$dbEntity = null;
}
if ($dbEntity && ($arEntity = $dbEntity->fetch())) {
$arResult['FEED_DESTINATION'][strtoupper($types[$entityTypeName])]['CRM' . $entityTypeName . $arEntity['ID']] = prepareCrmEntity(strtolower($entityTypeName), $arEntity);
示例10: Header
/*
* ONLY 'POST' METHOD SUPPORTED
* SUPPORTED ACTIONS:
* 'GET_BY_ID' - get deal by ID
*/
global $DB, $APPLICATION;
CUtil::JSPostUnescape();
$GLOBALS['APPLICATION']->RestartBuffer();
Header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
$CCrmDeal = new CCrmDeal();
if ($CCrmDeal->cPerms->HavePerm('CONTACT', BX_CRM_PERM_NONE, 'READ')) {
echo CUtil::PhpToJSObject(array('ERROR' => 'Access denied!'));
die;
}
$action = isset($_POST['ACTION']) ? $_POST['ACTION'] : '';
if (strlen($action) == 0) {
echo CUtil::PhpToJSObject(array('ERROR' => 'Invalid data!'));
die;
}
if ($action == 'GET_ENTITY') {
$ID = isset($_POST['ENTITY_ID']) ? intval($_POST['ENTITY_ID']) : 0;
if ($ID <= 0) {
echo CUtil::PhpToJSObject(array('ERROR' => 'Invalid parameters!'));
die;
}
$dbFields = CCrmContact::GetListEx(array(), array('ID' => $ID));
$item = $obFields->GetNext();
$formatParams = isset($_POST['FORMAT_PARAMS']) ? $_POST['FORMAT_PARAMS'] : array();
CCrmMobileHelper::PrepareContactItem($item, $formatParams);
echo CUtil::PhpToJSObject(array('DATA' => array('ENTITY' => CCrmMobileHelper::PrepareContactData($item))));
}
示例11: getSaleProperties
/**
* @param \Bitrix\Sale\Order $order
* @param $arOrder
* @param $agentParams
* @param $bExportFromCrm
* @param $bCrmModuleIncluded
* @param $paySystems
* @param $delivery
* @param array $options
*
* @return array|void
*/
function getSaleProperties(Bitrix\Sale\Order $order, $arOrder, $agentParams, $bExportFromCrm, $bCrmModuleIncluded, $paySystems, $delivery, array $options = array())
{
$providersInstance = self::getProvidersInstanceByOrder($order);
$personTypeId = $order->getPersonTypeId();
$personTypes = BusinessValue::getPersonTypes();
if (!($personType = $personTypes[$personTypeId])) {
self::logError($order->getId(), 'Undefined DOMAIN for person type id "' . $personTypeId . '"');
return;
}
$systemCodes1C = array_flip(self::$systemCodes[$personType['DOMAIN']]);
$arProp = array();
$arProp["ORDER"] = $arOrder;
if (IntVal($arOrder["USER_ID"]) > 0) {
$dbUser = CUser::GetByID($arOrder["USER_ID"]);
if ($arUser = $dbUser->Fetch()) {
$arProp["USER"] = $arUser;
}
}
if ($bExportFromCrm) {
$arProp["CRM"] = array();
$companyID = isset($arOrder["UF_COMPANY_ID"]) ? intval($arOrder["UF_COMPANY_ID"]) : 0;
$contactID = isset($arOrder["UF_CONTACT_ID"]) ? intval($arOrder["UF_CONTACT_ID"]) : 0;
if ($companyID > 0) {
$arProp["CRM"]["CLIENT_ID"] = "CRMCO" . $companyID;
} else {
$arProp["CRM"]["CLIENT_ID"] = "CRMC" . $contactID;
}
$clientInfo = array("LOGIN" => "", "NAME" => "", "LAST_NAME" => "", "SECOND_NAME" => "");
if ($bCrmModuleIncluded) {
if ($companyID > 0) {
$arCompanyFilter = array('=ID' => $companyID);
$dbCompany = CCrmCompany::GetListEx(array(), $arCompanyFilter, false, array("nTopCount" => 1), array("TITLE"));
$arCompany = $dbCompany->Fetch();
unset($dbCompany, $arCompanyFilter);
if (is_array($arCompany)) {
if (isset($arCompany["TITLE"])) {
$clientInfo["NAME"] = $arCompany["TITLE"];
}
}
unset($arCompany);
} else {
if ($contactID > 0) {
$arContactFilter = array('=ID' => $contactID);
$dbContact = CCrmContact::GetListEx(array(), $arContactFilter, false, array("nTopCount" => 1), array("NAME", "LAST_NAME", "SECOND_NAME"));
$arContact = $dbContact->Fetch();
unset($dbContact, $arContactFilter);
if (is_array($arContact)) {
if (isset($arContact["NAME"])) {
$clientInfo["NAME"] = $arContact["NAME"];
}
if (isset($arContact["LAST_NAME"])) {
$clientInfo["LAST_NAME"] = $arContact["LAST_NAME"];
}
if (isset($arContact["SECOND_NAME"])) {
$clientInfo["SECOND_NAME"] = $arContact["SECOND_NAME"];
}
}
unset($arContact);
}
}
}
$arProp["CRM"]["CLIENT"] = $clientInfo;
unset($clientInfo);
}
if (IntVal($arOrder["PAY_SYSTEM_ID"]) > 0) {
$arProp["ORDER"]["PAY_SYSTEM_NAME"] = $paySystems[$arOrder["PAY_SYSTEM_ID"]];
}
if (strlen($arOrder["DELIVERY_ID"]) > 0) {
$arProp["ORDER"]["DELIVERY_NAME"] = $delivery[$arOrder["DELIVERY_ID"]];
}
$dbOrderPropVals = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $arOrder["ID"]), false, false, array("ID", "CODE", "VALUE", "ORDER_PROPS_ID", "PROP_TYPE"));
$locationStreetPropertyValue = '';
while ($arOrderPropVals = $dbOrderPropVals->Fetch()) {
if ($arOrderPropVals["PROP_TYPE"] == "CHECKBOX") {
if ($arOrderPropVals["VALUE"] == "Y") {
$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = "true";
} else {
$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = "false";
}
} elseif ($arOrderPropVals["PROP_TYPE"] == "TEXT" || $arOrderPropVals["PROP_TYPE"] == "TEXTAREA") {
$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $arOrderPropVals["VALUE"];
} elseif ($arOrderPropVals["PROP_TYPE"] == "SELECT" || $arOrderPropVals["PROP_TYPE"] == "RADIO") {
$arVal = CSaleOrderPropsVariant::GetByValue($arOrderPropVals["ORDER_PROPS_ID"], $arOrderPropVals["VALUE"]);
$arProp["PROPERTY"][$arOrderPropVals["ORDER_PROPS_ID"]] = $arVal["NAME"];
} elseif ($arOrderPropVals["PROP_TYPE"] == "MULTISELECT") {
$curVal = explode(",", $arOrderPropVals["VALUE"]);
foreach ($curVal as $vm) {
$arVal = CSaleOrderPropsVariant::GetByValue($arOrderPropVals["ORDER_PROPS_ID"], $vm);
//.........这里部分代码省略.........
示例12: unset
unset($gridFilter['GRID_FILTER_ID']);
}
if (is_array($gridFilter) && !empty($gridFilter)) {
$dbEntities = null;
if ($entityType === 'LEAD') {
CCrmLead::PrepareFilter($gridFilter);
$dbEntities = CCrmLead::GetListEx(array(), $gridFilter, false, false, array('ID'));
} elseif ($entityType === 'DEAL') {
CCrmDeal::PrepareFilter($gridFilter);
$dbEntities = CCrmDeal::GetListEx(array(), $gridFilter, false, false, array('ID'));
} elseif ($entityType === 'COMPANY') {
CCrmCompany::PrepareFilter($gridFilter);
$dbEntities = CCrmCompany::GetListEx(array(), $gridFilter, false, false, array('ID'));
} elseif ($entityType === 'CONTACT') {
CCrmContact::PrepareFilter($gridFilter);
$dbEntities = CCrmContact::GetListEx(array(), $gridFilter, false, false, array('ID'));
}
if ($dbEntities) {
while ($arEntity = $dbEntities->Fetch()) {
$arEntityID[] = $arEntity['ID'];
}
}
}
}
$arFilter = array('ENTITY_ID' => $entityType, 'TYPE_ID' => $communicationType, '@VALUE_TYPE' => array('WORK', 'HOME', 'OTHER'));
if (!empty($arEntityID)) {
$arFilter['@ELEMENT_ID'] = $arEntityID;
}
$dbResFields = CCrmFieldMulti::GetList(array('ID' => 'asc'), $arFilter);
$data = array();
while ($arField = $dbResFields->Fetch()) {
示例13: findByPhoneNumber
public static function findByPhoneNumber($number, $params = array())
{
if (!is_string($number)) {
throw new \Bitrix\Main\ArgumentTypeException('number', 'string');
}
if ($number === '') {
throw new \Bitrix\Main\ArgumentException('Is empty', 'number');
}
if (!is_array($params)) {
$params = array();
}
$userID = isset($params['USER_ID']) ? intval($params['USER_ID']) : 0;
if ($userID <= 0) {
$userID = CCrmPerms::GetCurrentUserID();
}
$isAdmin = CCrmPerms::IsAdmin($userID);
$userPermissions = CCrmPerms::GetUserPermissions($userID);
$enableExtendedMode = isset($params['ENABLE_EXTENDED_MODE']) ? (bool) $params['ENABLE_EXTENDED_MODE'] : true;
$contactFormID = isset($params['CONTACT_FORM_ID']) ? intval($params['CONTACT_FORM_ID']) : '';
if ($contactFormID === '') {
$contactFormID = CCrmContact::DEFAULT_FORM_ID;
}
$dups = array();
$criterion = new \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion('PHONE', $number);
$entityTypes = array(CCrmOwnerType::Contact, CCrmOwnerType::Company, CCrmOwnerType::Lead);
foreach ($entityTypes as $entityType) {
$duplicate = $criterion->find($entityType, 1);
if ($duplicate !== null) {
$dups[] = $duplicate;
}
}
$entityByType = array();
foreach ($dups as &$dup) {
/** @var \Bitrix\Crm\Integrity\Duplicate $dup */
$entities = $dup->getEntities();
if (!(is_array($entities) && !empty($entities))) {
continue;
}
//Each entity type limited by 50 items
foreach ($entities as &$entity) {
/** @var \Bitrix\Crm\Integrity\DuplicateEntity $entity */
$entityTypeID = $entity->getEntityTypeID();
$entityID = $entity->getEntityID();
$fields = null;
if ($entityTypeID === CCrmOwnerType::Contact) {
$dbEntity = CCrmContact::GetListEx(array(), array('=ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PHOTO', 'POST', 'COMPANY_ID', 'COMPANY_TITLE', 'ASSIGNED_BY_ID'));
$entityFields = is_object($dbEntity) ? $dbEntity->Fetch() : null;
if (is_array($entityFields)) {
$formattedName = CCrmContact::PrepareFormattedName(array('HONORIFIC' => isset($entityFields['HONORIFIC']) ? $entityFields['HONORIFIC'] : '', 'NAME' => isset($entityFields['NAME']) ? $entityFields['NAME'] : '', 'SECOND_NAME' => isset($entityFields['SECOND_NAME']) ? $entityFields['SECOND_NAME'] : '', 'LAST_NAME' => isset($entityFields['LAST_NAME']) ? $entityFields['LAST_NAME'] : ''));
$fields = array('ID' => intval($entityFields['ID']), 'FORMATTED_NAME' => $formattedName, 'PHOTO' => isset($entityFields['PHOTO']) ? intval($entityFields['PHOTO']) : 0, 'COMPANY_ID' => isset($entityFields['COMPANY_ID']) ? intval($entityFields['COMPANY_ID']) : 0, 'COMPANY_TITLE' => isset($entityFields['COMPANY_TITLE']) ? $entityFields['COMPANY_TITLE'] : '', 'POST' => isset($entityFields['POST']) ? $entityFields['POST'] : '', 'ASSIGNED_BY_ID' => isset($entityFields['ASSIGNED_BY_ID']) ? intval($entityFields['ASSIGNED_BY_ID']) : 0, 'CAN_READ' => CCrmContact::CheckReadPermission($entityID, $userPermissions));
if ($fields['CAN_READ'] && $enableExtendedMode) {
$deals = array();
$dbDeal = CCrmDeal::GetListEx(array('BEGINDATE' => 'ASC'), array('=CONTACT_ID' => $entityID, 'CLOSED' => 'N', 'CHECK_PERMISSIONS' => $isAdmin ? 'N' : 'Y'), false, array('nTopCount' => 2), array('ID', 'TITLE', 'STAGE_ID'), array('PERMS' => $userPermissions));
if (is_object($dbDeal)) {
while ($dealFields = $dbDeal->Fetch()) {
$dealID = intval($dealFields['ID']);
//$dealFields['CAN_READ'] = CCrmDeal::CheckReadPermission($dealID, $userPermissions);
$dealFields['SHOW_URL'] = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Deal, $dealID);
$deals[] = $dealFields;
}
}
$fields['DEALS'] =& $deals;
unset($deals);
}
}
} elseif ($entityTypeID === CCrmOwnerType::Company) {
$dbEntity = CCrmCompany::GetListEx(array(), array('=ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'TITLE', 'LOGO', 'ASSIGNED_BY_ID'));
$entityFields = is_object($dbEntity) ? $dbEntity->Fetch() : null;
if (is_array($entityFields)) {
$fields = array('ID' => intval($entityFields['ID']), 'TITLE' => isset($entityFields['TITLE']) ? $entityFields['TITLE'] : '', 'LOGO' => isset($entityFields['LOGO']) ? intval($entityFields['LOGO']) : 0, 'ASSIGNED_BY_ID' => isset($entityFields['ASSIGNED_BY_ID']) ? intval($entityFields['ASSIGNED_BY_ID']) : 0, 'CAN_READ' => CCrmCompany::CheckReadPermission($entityID, $userPermissions));
if ($fields['CAN_READ'] && $enableExtendedMode) {
$deals = array();
$dbDeal = CCrmDeal::GetListEx(array('BEGINDATE' => 'ASC'), array('=COMPANY_ID' => $entityID, 'CLOSED' => 'N', 'CHECK_PERMISSIONS' => $isAdmin ? 'N' : 'Y'), false, array('nTopCount' => 2), array('ID', 'TITLE', 'STAGE_ID'), array('PERMS' => $userPermissions));
if (is_object($dbDeal)) {
while ($dealFields = $dbDeal->Fetch()) {
$dealID = intval($dealFields['ID']);
//$dealFields['CAN_READ'] = CCrmDeal::CheckReadPermission($dealID, $userPermissions);
$dealFields['SHOW_URL'] = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Deal, $dealID);
$deals[] = $dealFields;
}
}
$fields['DEALS'] =& $deals;
unset($deals);
}
}
} elseif ($entityTypeID === CCrmOwnerType::Lead) {
$dbEntity = CCrmLead::GetListEx(array(), array('=ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'TITLE', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'POST', 'COMPANY_TITLE', 'ASSIGNED_BY_ID'));
$entityFields = is_object($dbEntity) ? $dbEntity->Fetch() : null;
if (is_array($entityFields)) {
$formattedName = '';
if (!empty($entityFields['NAME']) || !empty($entityFields['SECOND_NAME']) || !empty($entityFields['LAST_NAME'])) {
$formattedName = CCrmLead::PrepareFormattedName(array('HONORIFIC' => isset($entityFields['HONORIFIC']) ? $entityFields['HONORIFIC'] : '', 'NAME' => isset($entityFields['NAME']) ? $entityFields['NAME'] : '', 'SECOND_NAME' => isset($entityFields['SECOND_NAME']) ? $entityFields['SECOND_NAME'] : '', 'LAST_NAME' => isset($entityFields['LAST_NAME']) ? $entityFields['LAST_NAME'] : ''));
}
$fields = array('ID' => intval($entityFields['ID']), 'TITLE' => isset($entityFields['TITLE']) ? $entityFields['TITLE'] : '', 'FORMATTED_NAME' => $formattedName, 'COMPANY_TITLE' => isset($entityFields['COMPANY_TITLE']) ? $entityFields['COMPANY_TITLE'] : '', 'POST' => isset($entityFields['POST']) ? $entityFields['POST'] : '', 'ASSIGNED_BY_ID' => isset($entityFields['ASSIGNED_BY_ID']) ? intval($entityFields['ASSIGNED_BY_ID']) : 0, 'CAN_READ' => CCrmLead::CheckReadPermission($entityID, $userPermissions));
}
}
if (!is_array($fields)) {
continue;
}
if ($fields['CAN_READ'] && $enableExtendedMode) {
//.........这里部分代码省略.........
示例14: GetByID
public static function GetByID($ID, $bCheckPerms = true)
{
$arFilter = array('=ID' => intval($ID));
if (!$bCheckPerms) {
$arFilter['CHECK_PERMISSIONS'] = 'N';
}
$dbRes = CCrmContact::GetListEx(array(), $arFilter);
return $dbRes->Fetch();
}
示例15: array
$contextID = $_REQUEST['context_id'];
}
if ($contextID === '') {
$contextID = "{$uid}_{$entityID}";
}
$arResult['CONTEXT_ID'] = $arParams['CONTEXT_ID'] = $contextID;
//<-- CONTEXT_ID
$arResult['STAGE_LIST'] = CCrmStatus::GetStatusList('DEAL_STAGE');
$arResult['TYPE_LIST'] = CCrmStatus::GetStatusList('DEAL_TYPE');
$arFields = null;
if ($entityID <= 0) {
$arResult['MODE'] = 'CREATE';
$arFields = array('~CURRENCY_ID' => CCrmCurrency::GetBaseCurrencyID(), 'CURRENCY_ID' => htmlspecialcharsbx(CCrmCurrency::GetBaseCurrencyID()));
$contactID = $arResult['CONTACT_ID'] = isset($_REQUEST['contact_id']) ? intval($_REQUEST['contact_id']) : 0;
if ($contactID > 0) {
$dbContact = CCrmContact::GetListEx(array(), array('=ID' => $contactID), false, false, array('NAME', 'LAST_NAME', 'SECOND_NAME', 'COMPANY_ID', 'COMPANY_TITLE'));
$contact = $dbContact->Fetch();
if (is_array($contact)) {
$arFields['~CONTACT_ID'] = $arFields['CONTACT_ID'] = $contactID;
$arFields['~CONTACT_NAME'] = isset($contact['NAME']) ? $contact['NAME'] : '';
$arFields['CONTACT_NAME'] = htmlspecialcharsbx($arFields['~CONTACT_NAME']);
$arFields['~CONTACT_SECOND_NAME'] = isset($contact['SECOND_NAME']) ? $contact['SECOND_NAME'] : '';
$arFields['CONTACT_SECOND_NAME'] = htmlspecialcharsbx($arFields['~CONTACT_SECOND_NAME']);
$arFields['~CONTACT_LAST_NAME'] = isset($contact['LAST_NAME']) ? $contact['LAST_NAME'] : '';
$arFields['CONTACT_LAST_NAME'] = htmlspecialcharsbx($arFields['~CONTACT_LAST_NAME']);
$contactCompanyID = isset($contact['COMPANY_ID']) ? intval($contact['COMPANY_ID']) : 0;
if ($contactCompanyID > 0) {
$arFields['~COMPANY_ID'] = $arFields['COMPANY_ID'] = $contactCompanyID;
$arFields['~COMPANY_TITLE'] = isset($contact['COMPANY_TITLE']) ? $contact['COMPANY_TITLE'] : '';
$arFields['COMPANY_TITLE'] = htmlspecialcharsbx($arFields['~COMPANY_TITLE']);
}