Relation::updateLag

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Relation
  4. updateLag
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/processor/task/scheduler/relationmanager/project/relation.php
  • Класс: BitrixTasksProcessorTaskSchedulerRelationManagerProjectRelation
  • Вызов: Relation::updateLag
public function updateLag()
{
	if (!$this->getTask() || !$this->getParentTask())
	{
		return;
	}

	$parentTask = $this->getParentTask();
	$parentPristineData = $parentTask->getDataPristine();
	$task = $this->getTask();
	$calendar = Calendar::getInstance();

	// head task was already changed outside this worker, but we need to get original lag, so use pristine dates
	if (!empty($parentPristineData) && $parentTask->isHead())
	{
		$fromTaskDateStart = $parentPristineData['START_DATE_PLAN_GMT'];
		$fromTaskDateEnd = $parentPristineData['END_DATE_PLAN_GMT'];
	}
	else
	{
		$fromTaskDateStart = $parentTask->getStartDatePlanGmt(true);
		$fromTaskDateEnd = $parentTask->getEndDatePlanGmt();
	}
	$toTaskDateStart = $task->getStartDatePlanGmt(true);
	$toTaskDateEnd = $task->getEndDatePlanGmt();
	$matchWorkTime = $task->getMatchWorkTime();

	if ($this->getType() == ProjectDependenceTable::LINK_TYPE_START_START)
	{
		if (!isset($fromTaskDateStart, $toTaskDateStart))
		{
			return;
		}
		if ($matchWorkTime)
		{
			$lag = $calendar->calculateDuration($fromTaskDateStart, $toTaskDateStart);
		}
		else
		{
			$lag = $toTaskDateStart->getTimestamp() - $fromTaskDateStart->getTimestamp();
		}
	}
	else if ($this->getType() == ProjectDependenceTable::LINK_TYPE_START_FINISH)
	{
		if (!isset($fromTaskDateStart, $toTaskDateEnd))
		{
			return;
		}
		if ($matchWorkTime)
		{
			$lag = $calendar->calculateDuration($fromTaskDateStart, $toTaskDateEnd);
		}
		else
		{
			$lag = $toTaskDateEnd->getTimestamp() - $fromTaskDateStart->getTimestamp();
		}
	}
	else if ($this->getType() == ProjectDependenceTable::LINK_TYPE_FINISH_FINISH)
	{
		if (!isset($fromTaskDateEnd, $toTaskDateEnd))
		{
			return;
		}
		if ($matchWorkTime)
		{
			$lag = $calendar->calculateDuration($fromTaskDateEnd, $toTaskDateEnd);
		}
		else
		{
			$lag = $toTaskDateEnd->getTimestamp() - $fromTaskDateEnd->getTimestamp();
		}
	}
	else
	{
		if (!isset($fromTaskDateEnd, $toTaskDateStart))
		{
			return;
		}
		if ($matchWorkTime)
		{
			$lag = $calendar->calculateDuration($fromTaskDateEnd, $toTaskDateStart);
		}
		else
		{
			$lag = $toTaskDateStart->getTimestamp() - $fromTaskDateEnd->getTimestamp();
		}
	}

	$this->lag = $lag;
}

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