- Модуль: timeman
- Путь к файлу: ~/bitrix/modules/timeman/lib/update/timemanversion19converter.php
- Класс: BitrixTimemanUpdateTimemanVersion19Converter
- Вызов: TimemanVersion19Converter::assignEntityToSchedule
private function assignEntityToSchedule($entityCode, $selfSettings, array $parentDepartmentIds)
{
$myScheduleForm = $this->getScheduleForm($selfSettings);
$oppositeScheduleForm = null;
if (count($this->scheduleForms) > 1)
{
$oppositeScheduleForm = $this->getScheduleForm([], $this->createScheduleSettingsKey($selfSettings) === 'COMMON' ? 'FREE' : 'COMMON');
}
$includedInMySchedule = false;
foreach (array_reverse($parentDepartmentIds) as $parentDepartmentId)
{
if ($this->isDepartmentInsideSchedule($parentDepartmentId, $myScheduleForm))
{
$includedInMySchedule = true;
break;
}
elseif ($this->isDepartmentExcludedFromSchedule($parentDepartmentId, $myScheduleForm))
{
$myScheduleForm->assignments[$entityCode] = $entityCode;
unset($myScheduleForm->assignmentsExcluded[$entityCode]);
$includedInMySchedule = true;
break;
}
}
if (!$includedInMySchedule)
{
$myScheduleForm->assignments[$entityCode] = $entityCode;
unset($myScheduleForm->assignmentsExcluded[$entityCode]);
}
if ($oppositeScheduleForm)
{
foreach (array_reverse($parentDepartmentIds) as $parentDepartmentId)
{
if ($this->isDepartmentExcludedFromSchedule($parentDepartmentId, $oppositeScheduleForm))
{
break;
}
elseif ($this->isDepartmentInsideSchedule($parentDepartmentId, $oppositeScheduleForm))
{
$this->excludeEntityFromScheduleForms($entityCode, [$oppositeScheduleForm]);
break;
}
}
}
}