• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/widget/filter.php
  • Класс: Bitrix\Crm\Widget\Filter
  • Вызов: Filter::internalizeParams
static function internalizeParams(array $params)
{
	$result = array('periodType' => FilterPeriodType::UNDEFINED);
	$period = isset($params['PERIOD']) ? $params['PERIOD'] : '';
	if(is_array($period))
	{
		$result['periodType'] = $period['periodType'];
		if($result['periodType'] === FilterPeriodType::YEAR
				|| $result['periodType'] === FilterPeriodType::QUARTER
				|| $result['periodType'] === FilterPeriodType::MONTH)
		{
			$result['year'] = (int)$period['year'];
		}
		if($result['periodType'] === FilterPeriodType::QUARTER)
		{
			$result['quarter'] = (int)$period['quarter'];
		}
		if($result['periodType'] === FilterPeriodType::MONTH)
		{
			$result['month'] = (int)$period['month'];
		}
	}
	else
	{
		$periodParts = explode('-', $period);
		$periodPartCount = count($periodParts);
		if($periodPartCount > 0)
		{
			$result['periodType'] = $periodParts[0];
		}
		if($periodPartCount > 1
			&& ($result['periodType'] === FilterPeriodType::YEAR
				|| $result['periodType'] === FilterPeriodType::QUARTER
				|| $result['periodType'] === FilterPeriodType::MONTH))
		{
			$result['year'] = (int)$periodParts[1];
		}
		if($periodPartCount > 2 && $result['periodType'] === FilterPeriodType::QUARTER)
		{
			$result['quarter'] = (int)$periodParts[2];
		}
		if($periodPartCount > 2 && $result['periodType'] === FilterPeriodType::MONTH)
		{
			$result['month'] = (int)$periodParts[2];
		}

		if($result['periodType'] === FilterPeriodType::BEFORE && isset($params['END']))
		{
			try
			{
				$result['end'] = new Date($params['END'], 'Y-m-d');
			}
			catch(Main\ObjectException $ex)
			{
			}
		}
	}

	if(isset($params['RESPONSIBLE_ID']))
	{
		$responsibleIDs = array();
		if(is_array($params['RESPONSIBLE_ID']))
		{
			foreach($params['RESPONSIBLE_ID'] as $userID)
			{
				if($userID > 0)
				{
					$responsibleIDs[] = (int)$userID;
				}
			}
		}
		elseif($params['RESPONSIBLE_ID'] > 0)
		{
			$responsibleIDs[] = (int)$params['RESPONSIBLE_ID'];
		}

		if(!empty($responsibleIDs))
		{
			$result['responsibleIDs'] = $responsibleIDs;
		}
	}

	return $result;
}