Task::getProjectDatePlan

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Task
  4. getProjectDatePlan
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/copy/implement/task.php
  • Класс: BitrixTasksCopyImplementTask
  • Вызов: Task::getProjectDatePlan
private function getProjectDatePlan($currentDatePlan, $taskCreatedDate)
{
	try
	{
		$datePlan = $this->getRecountedProjectDeadline($currentDatePlan, $taskCreatedDate);

		$startPoint = $this->projectTerm["start_point"];
		$endPoint = $this->projectTerm["end_point"];

		$projectStartDate = TasksDateTime::createFrom($startPoint);
		$projectFinishDate = TasksDateTime::createFrom($endPoint);

		$datePlanTime = TasksDateTime::createFrom($datePlan);
		if (!$datePlanTime)
		{
			return '';
		}
		$startPointTime = TasksDateTime::createFrom($startPoint);
		if (!$startPointTime)
		{
			$startPointTime = new TasksDateTime();
		}
		if ($datePlanTime->getTimestamp() < $startPointTime->getTimestamp())
		{
			$phpDateTimeFormat = DateTime::convertFormatToPhp(FORMAT_DATETIME);
			$datePlan = $startPointTime->format($phpDateTimeFormat);
		}

		if ($projectFinishDate)
		{
			$projectFinishDate->addSecond(86399);

			$datePlanTime = TasksDateTime::createFrom($datePlan);
			$endPointTime = TasksDateTime::createFrom($endPoint);
			$endPointTime->add("PT86399S");
			if ($datePlanTime->getTimestamp() > $endPointTime->getTimestamp())
			{
				$phpDateFormat = DateTime::convertFormatToPhp(FORMAT_DATE);
				$datePlan = $endPointTime->format($phpDateFormat);
			}
		}

		$datePlanTime = TasksDateTime::createFrom($datePlan);
		if ($datePlanTime && !$datePlanTime->checkInRange($projectStartDate, $projectFinishDate))
		{
			return "";
		}
		else
		{
			return $datePlan;
		}
	}
	catch (Exception $exception)
	{
		$this->result->addError(new Error($exception->getMessage(), self::TASK_COPY_ERROR));
		return "";
	}
}

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