• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/history/entity/leadstatushistory.php
  • Класс: Bitrix\Crm\History\Entity\LeadStatusHistoryTable
  • Вызов: LeadStatusHistoryTable::deleteByFilter
static function deleteByFilter(array $filter,  $borderID = 0)
{
	$ownerID = isset($filter['OWNER_ID']) ? (int)$filter['OWNER_ID'] : 0;
	if($ownerID <= 0)
	{
		throw new Main\ArgumentException("Filter parameter 'OWNER_ID' must be greater than zero.", 'filter');
	}

	$typeID = isset($filter['TYPE_ID']) ? $filter['TYPE_ID'] : '';
	if(!HistoryEntryType::isDefined($typeID))
	{
		throw new Main\ArgumentException("Filter parameter 'TYPE_ID' value is not supported in current context.", 'filter');
	}

	if(!is_int($borderID))
	{
		$borderID = (int)$borderID;
	}

	$sql = "DELETE from b_crm_lead_status_history WHERE OWNER_ID = {$ownerID} AND TYPE_ID = {$typeID}";
	if($borderID > 0)
	{
		$sql .= " AND ID < {$borderID}";
	}

	Main\Application::getConnection()->queryExecute($sql);
}