...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/widget/data/invoiceoverdue.php
- Класс: Bitrix\Crm\Widget\Data\InvoiceOverdue
- Вызов: InvoiceOverdue::prepareEntityListFilter
public function prepareEntityListFilter(array $filterParams) { $filter = self::internalizeFilter($filterParams); $query = new Query(InvoiceSumStatisticsTable::getEntity()); $query->setTableAliasPostfix('_s1'); $query->addSelect('OWNER_ID'); $query->addGroup('OWNER_ID'); $period = $filter->getPeriod(); $periodStartDate = $period['START']; $periodEndDate = $period['END']; $subQuery = new Query(InvoiceSumStatisticsTable::getEntity()); $subQuery->setTableAliasPostfix('_s2'); $subQuery->addSelect('OWNER_ID'); //region Overdue condition $subQuery->addFilter('=STATUS_SEMANTIC_ID', PhaseSemantics::PROCESS); $subQuery->addFilter('>=PAY_BEFORE_DATE', $periodStartDate); $subQuery->addFilter('<=PAY_BEFORE_DATE', $periodEndDate); //endregion $responsibleIDs = $filter->getResponsibleIDs(); if(!empty($responsibleIDs)) { $subQuery->addFilter('@RESPONSIBLE_ID', $responsibleIDs); } $subQuery->addGroup('OWNER_ID'); $subQuery->addSelect('MAX_CREATED_DATE'); $subQuery->registerRuntimeField('', new ExpressionField('MAX_CREATED_DATE', 'MAX(%s)', 'CREATED_DATE')); $query->registerRuntimeField('', new ReferenceField('M', Base::getInstanceByQuery($subQuery), array('=this.OWNER_ID' => 'ref.OWNER_ID', '=this.CREATED_DATE' => 'ref.MAX_CREATED_DATE'), array('join_type' => 'INNER') ) ); //region Overdue condition $query->addFilter('=STATUS_SEMANTIC_ID', PhaseSemantics::PROCESS); //endregion return array( '__CONDITIONS' => array( array( 'SQL' => 'crm_invoice_internals_invoice.ID IN ('.$query->getQuery().')' ) ) ); }