...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_owner_type.php
- Класс: \CCrmOwnerType
- Вызов: CCrmOwnerType::loadResponsibleId
static function loadResponsibleId(int $entityTypeId, int $entityId, bool $checkRights = true): int { $result = 0; switch($entityTypeId) { case self::Lead: { $dbRes = CCrmLead::GetListEx(array(), array('=ID' => $entityId, 'CHECK_PERMISSIONS' => ($checkRights ? 'Y' : 'N')), false, false, array('ASSIGNED_BY_ID')); $arRes = $dbRes ? $dbRes->Fetch() : null; $result = $arRes ? intval($arRes['ASSIGNED_BY_ID']) : 0; break; } case self::Contact: { $dbRes = CCrmContact::GetListEx(array(), array('=ID' => $entityId, 'CHECK_PERMISSIONS' => ($checkRights ? 'Y' : 'N')), false, false, array('ASSIGNED_BY_ID')); $arRes = $dbRes ? $dbRes->Fetch() : null; $result = $arRes ? intval($arRes['ASSIGNED_BY_ID']) : 0; break; } case self::Company: { $dbRes = CCrmCompany::GetListEx(array(), array('=ID' => $entityId, 'CHECK_PERMISSIONS' => ($checkRights ? 'Y' : 'N')), false, false, array('ASSIGNED_BY_ID')); $arRes = $dbRes ? $dbRes->Fetch() : null; $result = $arRes ? intval($arRes['ASSIGNED_BY_ID']) : 0; break; } case self::Deal: { $dbRes = CCrmDeal::GetListEx(array(), array('=ID' => $entityId, 'CHECK_PERMISSIONS' => ($checkRights ? 'Y' : 'N')), false, false, array('ASSIGNED_BY_ID')); $arRes = $dbRes ? $dbRes->Fetch() : null; $result = $arRes ? intval($arRes['ASSIGNED_BY_ID']) : 0; break; } case self::Invoice: { $dbRes = CCrmInvoice::GetList(array(), array('ID' => $entityId), false, false, array('RESPONSIBLE_ID')); $arRes = $dbRes ? $dbRes->Fetch() : null; $result = $arRes ? intval($arRes['RESPONSIBLE_ID']) : 0; break; } case self::Activity: { $dbRes = CCrmActivity::GetList(array(), array('=ID' => $entityId, 'CHECK_PERMISSIONS' => ($checkRights ? 'Y' : 'N')), false, false, array('RESPONSIBLE_ID')); $arRes = $dbRes ? $dbRes->Fetch() : null; $result = $arRes ? intval($arRes['RESPONSIBLE_ID']) : 0; break; } case self::Quote: { $dbRes = CCrmQuote::GetList(array(), array('=ID' => $entityId, 'CHECK_PERMISSIONS' => ($checkRights ? 'Y' : 'N')), false, false, array('ASSIGNED_BY_ID')); $arRes = $dbRes ? $dbRes->Fetch() : null; $result = $arRes ? intval($arRes['ASSIGNED_BY_ID']) : 0; break; } case self::Order: { if($checkRights && !\Bitrix\Crm\Order\Permissions\Order::checkReadPermission($entityId)) { break; } $dbRes = Bitrix\Crm\Order\Order::getList(array('filter' => array('=ID' => $entityId), 'select' => array('RESPONSIBLE_ID'))); $arRes = $dbRes ? $dbRes->fetch() : null; $result = $arRes ? intval($arRes['RESPONSIBLE_ID']) : 0; break; } } if ($result === 0 && static::isUseDynamicTypeBasedApproach($entityTypeId)) { $factory = Container::getInstance()->getFactory($entityTypeId); if ($factory) { $parameters = [ 'select' => [ \Bitrix\Crm\Item::FIELD_NAME_ASSIGNED, ], 'filter' => [ '=ID' => $entityId, ], 'limit' => 1, ]; if ($checkRights) { $items = $factory->getItemsFilteredByPermissions($parameters); } else { $items = $factory->getItems($parameters); } if (count($items) > 0 && $items[0] && $items[0] instanceof \Bitrix\Crm\Item) { $result = (int)$items[0]->getAssignedById(); } } } return $result; }