- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/util/scheduler.php
- Класс: BitrixTasksUtilScheduler
- Вызов: Scheduler::matchWorkingTime
protected function matchWorkingTime($taskId, DateTime $startDate = null, Datetime $endDate = null, $duration = null)
{
$task = $this->taskPool[$taskId];
if ($this->taskPool[$taskId]['MATCH_WORK_TIME'] != 'Y')
{
/*
print_r('Actual moving '.$taskId.' to:'.PHP_EOL);
print_r($task['START_DATE_PLAN']->getInfoGmt().PHP_EOL);
print_r($task['END_DATE_PLAN']->getInfoGmt().PHP_EOL);
*/
return; // do nothing, dates are okay already
}
else
{
if ($startDate && $endDate)
{
$this->correctWorkTime($taskId, $startDate, $endDate, $duration);
}
elseif($startDate)
{
$task->setStartDatePlanUserTimeGmt($this->calendar->getClosestWorkTime($startDate, true)->toStringGmt());
$start = $task->getStartDatePlanGmt(true);
$end = $task->getEndDatePlanGmt();
if ($start->checkGT($end))
{
$task->setEndDatePlanUserTimeGmt($this->calendar->calculateEndDate($startDate, $end->getTimestamp() - $startDate->getTimestamp())->toStringGmt());
}
}
else if ($endDate)
{
$task->setEndDatePlanUserTimeGmt($this->calendar->getClosestWorkTime($endDate, false)->toStringGmt());
$start = $task->getStartDatePlanGmt(true);
$end = $task->getEndDatePlanGmt();
if ($start->checkGT($end))
{
$task->setStartDatePlanUserTimeGmt($this->calendar->calculateStartDate($end, $endDate->getTimestamp() - $start->getTimestamp())->toStringGmt());
}
}
}
}