- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/sip_helper.php
- Класс: \CCrmSipHelper
- Вызов: CCrmSipHelper::getDeals
static function getDeals($entityTypeID, $entityID, $userID): array { $dealIds = static::getDealIds($entityTypeID, $entityID); if ($dealIds === []) { return []; } $dealFactory = Container::getInstance()->getFactory(\CCrmOwnerType::Deal); if (!$dealFactory) { return []; } $parameters = [ 'select' => [ Item::FIELD_NAME_ID, Item::FIELD_NAME_TITLE, Item::FIELD_NAME_STAGE_ID, Item::FIELD_NAME_OPPORTUNITY, Item::FIELD_NAME_CURRENCY_ID, Item::FIELD_NAME_CATEGORY_ID, Item::FIELD_NAME_IS_RETURN_CUSTOMER, Item\Deal::FIELD_NAME_IS_REPEATED_APPROACH, Item::FIELD_NAME_CREATED_TIME, ], 'filter' => [ '@ID' => $dealIds, 'CLOSED' => 'N', ], 'order' => [ Item::FIELD_NAME_BEGIN_DATE => 'ASC', ], 'limit' => 2, ]; $dealItems = $dealFactory->getItemsFilteredByPermissions($parameters, $userID); $deals = []; foreach ($dealItems as $item) { $id = $item->getId(); $opportunity = $item->getOpportunity(); $currencyId = $item->getCurrencyId(); $stageName = null; $stageColor = null; $stage = $dealFactory->getStage($item->getStageId()); if ($stage) { $stageName = $stage->getName(); $stageColor = $stage->getColor(); } $deals[] = [ 'ID' => $id, 'TITLE' => $item->getTitle(), 'STAGE_ID' => $item->getStageId(), 'CATEGORY_ID' => $item->getCategoryId(), 'STAGE_NAME' => $stageName, 'STAGE_COLOR' => $stageColor, 'OPPORTUNITY' => $opportunity, 'CURRENCY_ID' => $currencyId, 'SHOW_URL' => CCrmOwnerType::GetEntityShowPath(CCrmOwnerType::Deal, $id), 'FORMATTED_OPPORTUNITY' => CCrmCurrency::MoneyToString($opportunity, $currencyId), 'REPEATED_TEXT' => self::getEntityRepeatedText($item), 'CREATED_TIME' => $item->getCreatedTime()->getTimestamp(), 'IS_RETURN_CUSTOMER' => $item->getIsReturnCustomer(), 'IS_REPEATED_APPROACH' => $item->get(Item\Deal::FIELD_NAME_IS_REPEATED_APPROACH), ]; } return $deals; }