• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/report/handler/deal.php
  • Класс: Bitrix\Crm\Integration\Report\Handler\Deal
  • Вызов: Deal::addTimePeriodToQuery
protected function addTimePeriodToQuery(Query $query, $timePeriodValue)
{
	if ($timePeriodValue['from'] !== "" && $timePeriodValue['to'] !== "")
	{
		$toDateValue = DateTime::createFromUserTime($timePeriodValue['to']);
		$fromDateValue = DateTime::createFromUserTime($timePeriodValue['from']);

		$isPastPeriodField = $this->getFormElement('pastPeriod');

		if ($isPastPeriodField && $isPastPeriodField->getValue())
		{
			$timePeriodDiffSecs = $this->getTimePeriodDiff();
			$diffDaysCount = $this->getDayCountFromSecs($timePeriodDiffSecs);
			$toDateValue->add("-{$diffDaysCount} days");
			$fromDateValue->add("-{$diffDaysCount} days");
		}

		$query
			->where('FULL_HISTORY.LAST_UPDATE_DATE', '<=', $toDateValue)
			->where('FULL_HISTORY.CLOSE_DATE', '>=', $fromDateValue);
	}
}