- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/statistics/companygrowthstatisticentry.php
- Класс: Bitrix\Crm\Statistics\CompanyGrowthStatisticEntry
- Вызов: CompanyGrowthStatisticEntry::register
static function register($ownerID, array $entityFields = null, array $options = null)
{
if(!is_int($ownerID))
$ownerID = (int)$ownerID;
if($ownerID <= 0)
throw new Main\ArgumentException('Owner ID must be greater than zero.', 'ownerID');
if(!is_array($entityFields))
{
$dbResult = \CCrmCompany::GetListEx(
array(),
array('=ID' => $ownerID, 'CHECK_PERMISSIONS' => 'N'),
false,
false,
array('DATE_CREATE', 'ASSIGNED_BY_ID')
);
$entityFields = is_object($dbResult) ? $dbResult->Fetch() : null;
if(!is_array($entityFields))
{
return false;
}
}
$responsibleID = isset($entityFields['ASSIGNED_BY_ID']) ? (int)$entityFields['ASSIGNED_BY_ID'] : 0;
$date = new DateTime($entityFields['DATE_CREATE'] ?? null);
$date->setTime(0, 0, 0);
$present = self::get($ownerID, $date);
if(is_array($present))
{
if($responsibleID === (int)$present['RESPONSIBLE_ID'])
return true;
if($responsibleID !== (int)$present['RESPONSIBLE_ID'])
{
CompanyGrowthStatisticsTable::synchronize(
$ownerID,
array('RESPONSIBLE_ID' => $responsibleID)
);
}
}
$data = array(
'OWNER_ID' => $ownerID,
'CREATED_DATE' => $date,
'RESPONSIBLE_ID' => $responsibleID
);
CompanyGrowthStatisticsTable::upsert($data);
return true;
}