...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/widget/data/invoiceinwork.php
- Класс: Bitrix\Crm\Widget\Data\InvoiceInWork
- Вызов: InvoiceInWork::prepareSumStatisticsQuery
static function prepareSumStatisticsQuery($endDate) { $query = new Query(InvoiceSumStatisticsTable::getEntity()); $query->setTableAliasPostfix('_s1'); $query->addSelect('OWNER_ID'); $query->addSelect('SUM_TOTAL'); $subQuery = new Query(InvoiceSumStatisticsTable::getEntity()); $subQuery->setTableAliasPostfix('_s2'); $subQuery->addSelect('OWNER_ID'); $subQuery->addGroup('OWNER_ID'); $subQuery->addFilter('<=CREATED_DATE', $endDate); $subQuery->registerRuntimeField('', new ExpressionField('MAX_CREATED_DATE', 'MAX(%s)', 'CREATED_DATE')); $subQuery->addSelect('MAX_CREATED_DATE'); $query->registerRuntimeField( '', new ReferenceField( 'SL', Base::getInstanceByQuery($subQuery), array( '=this.OWNER_ID' => 'ref.OWNER_ID', '=this.CREATED_DATE' => 'ref.MAX_CREATED_DATE' ), array('join_type' => 'INNER') ) ); return $query; }