• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/report/handler/deal.php
  • Класс: Bitrix\Crm\Integration\Report\Handler\Deal
  • Вызов: Deal::getDivisionOfDate
private function getDivisionOfDate()
{
	$filterParameters = $this->getFilterParameters();
	$view = $this->getView();
	if ($filterParameters['TIME_PERIOD'])
	{
		$timePeriodFilterParams = $filterParameters['TIME_PERIOD'];

		switch ($timePeriodFilterParams['datesel'])
		{
			case DateType::CURRENT_WEEK:
			case DateType::LAST_WEEK:
			case DateType::NEXT_WEEK:
				return self::WEEK_DAY_DIVISION;
				break;
			case DateType::CURRENT_MONTH:
			case DateType::NEXT_MONTH:
			case DateType::LAST_MONTH:
			case DateType::MONTH:
				return self::DAY_DIVISION;
				break;
			case DateType::LAST_7_DAYS:
			case DateType::LAST_30_DAYS:
			case DateType::LAST_60_DAYS:
			case DateType::LAST_90_DAYS:
			case DateType::PREV_DAYS:
			case DateType::NEXT_DAYS:
			case DateType::RANGE:
				if ($view instanceof ComparePeriodsGrid || $view instanceof ComparePeriods)
				{
					return self::DAY_MONTH_DIVISION;
				}
				else
				{
					return self::DAY_DIVISION;
				}
				break;
			case DateType::QUARTER:
			case DateType::CURRENT_QUARTER:
				if ($view instanceof ComparePeriodsGrid || $view instanceof ComparePeriods)
				{
					return self::SHIFTED_MONTH_DIVISION;
				}
				else
				{
					return self::MONTH_DIVISION;
				}
				break;
			case DateType::YEAR:
				return self::MONTH_DIVISION;
				break;
		}
	}

	$timePeriodDiff = $this->getTimePeriodDiff();
	$monthCount = $timePeriodDiff / (60 * 60 * 24 * 31);
	if ($monthCount >= 12)
	{
		return self::MONTH_DIVISION;
	}
	elseif ($monthCount > 1)
	{
		if ($view instanceof ComparePeriodsGrid || $view instanceof ComparePeriods)
		{
			return self::SHIFTED_MONTH_DIVISION;
		}
		else
		{
			return self::MONTH_DIVISION;
		}
	}
	else

	{
		return self::DAY_DIVISION;
	}
}