...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_deal.php
- Класс: \CAllCrmDeal
- Вызов: CAllCrmDeal::RebuildStatistics
static function RebuildStatistics(array $IDs, array $options = null) { $dbResult = self::GetListEx( array(), array('@ID' => $IDs, 'CHECK_PERMISSIONS' => 'N'), false, false, array( 'ID', 'DATE_CREATE', 'DATE_MODIFY', 'STAGE_ID', 'CATEGORY_ID', 'ASSIGNED_BY_ID', 'BEGINDATE', 'CLOSEDATE', 'IS_RECURRING', 'CURRENCY_ID', 'OPPORTUNITY', 'UF_*' ) ); if(!is_object($dbResult)) { return; } if(!is_array($options)) { $options = array(); } $forced = isset($options['FORCED']) ? $options['FORCED'] : false; $enableHistory = isset($options['ENABLE_HISTORY']) ? $options['ENABLE_HISTORY'] : true; $enableSumStatistics = isset($options['ENABLE_SUM_STATISTICS']) ? $options['ENABLE_SUM_STATISTICS'] : true; $enableInvoiceStatistics = isset($options['ENABLE_INVOICE_STATISTICS']) ? $options['ENABLE_INVOICE_STATISTICS'] : true; $enableActivityStatistics = isset($options['ENABLE_ACTIVITY_STATISTICS']) ? $options['ENABLE_ACTIVITY_STATISTICS'] : true; while($fields = $dbResult->Fetch()) { $ID = (int)$fields['ID']; //--> History if($enableHistory && ($forced || !DealStageHistoryEntry::isRegistered($ID))) { $created = isset($fields['DATE_CREATE']) ? $fields['DATE_CREATE'] : ''; $createdTime = null; try { $createdTime = new Bitrix\Main\Type\DateTime( $created, Bitrix\Main\Type\DateTime::convertFormatToPhp(FORMAT_DATETIME)); } catch(Bitrix\Main\ObjectException $e) { } $modified = isset($fields['DATE_MODIFY']) ? $fields['DATE_MODIFY'] : ''; $modifiedTime = null; if($modified !== '') { try { $modifiedTime = new Bitrix\Main\Type\DateTime( $modified, Bitrix\Main\Type\DateTime::convertFormatToPhp(FORMAT_DATETIME)); } catch(Bitrix\Main\ObjectException $e) { } } if($createdTime && $modifiedTime && $createdTime->getTimestamp() !== $modifiedTime->getTimestamp()) { DealStageHistoryEntry::register( $ID, $fields, array('IS_NEW' => false, 'TIME' => $modifiedTime, 'FORCED' => $forced) ); } elseif($createdTime) { DealStageHistoryEntry::register( $ID, $fields, array('IS_NEW' => true, 'TIME' => $createdTime, 'FORCED' => $forced) ); } } //<-- History //--> Statistics if ($fields['IS_RECURRING'] !== 'Y') { if($enableSumStatistics && ($forced || !DealSumStatisticEntry::isRegistered($ID))) { DealSumStatisticEntry::register($ID, $fields, array('FORCED' => $forced)); } if($enableInvoiceStatistics && ($forced || !DealInvoiceStatisticEntry::isRegistered($ID))) { DealInvoiceStatisticEntry::register($ID, $fields); } if($enableActivityStatistics) { $timeline = DealActivityStatisticEntry::prepareTimeline($ID); foreach($timeline as $date) { DealActivityStatisticEntry::register($ID, $fields, array('FORCED' => $forced, 'DATE' => $date)); } } } //<-- Statistics } }