CCrmActivity::DoSaveNearestUserActivity

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmActivity
  4. DoSaveNearestUserActivity
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/mysql/crm_activity.php
  • Класс: \CCrmActivity
  • Вызов: CCrmActivity::DoSaveNearestUserActivity
static function DoSaveNearestUserActivity($arFields)
{
	$connection = \Bitrix\Main\Application::getConnection();
	$helper = $connection->getSqlHelper();

	$userID = isset($arFields['USER_ID']) ? intval($arFields['USER_ID']) : 0;
	$ownerID = isset($arFields['OWNER_ID']) ? intval($arFields['OWNER_ID']) : 0;
	$ownerTypeID = isset($arFields['OWNER_TYPE_ID']) ? intval($arFields['OWNER_TYPE_ID']) : 0;
	$activityID = isset($arFields['ACTIVITY_ID']) ? intval($arFields['ACTIVITY_ID']) : 0;
	$activityTime = isset($arFields['ACTIVITY_TIME']) ? $arFields['ACTIVITY_TIME'] : false;
	if($activityTime !== false)
	{
		$activityTime = \Bitrix\Main\Type\DateTime::createFromUserTime($arFields['ACTIVITY_TIME']);
	}
	$sort = isset($arFields['SORT']) ? $arFields['SORT'] : '';

	$insert = [
		'USER_ID' => $userID,
		'OWNER_ID' => $ownerID,
		'OWNER_TYPE_ID' => $ownerTypeID,
		'ACTIVITY_TIME' => $activityTime,
		'ACTIVITY_ID' => $activityID,
		'SORT' => $sort,
		'DEPARTMENT_ID' => 0,
	];
	$merge = $helper->prepareMerge('b_crm_usr_act', ['USER_ID', 'OWNER_ID', 'OWNER_TYPE_ID'], $insert, $insert);
	$connection->query($merge[0]);
}

Добавить комментарий