• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/lib/form/schedule/scheduleform.php
  • Класс: BitrixTimemanFormScheduleScheduleForm
  • Вызов: ScheduleForm::__construct
public function __construct($schedule = null)
{
	if (!($schedule instanceof Schedule))
	{
		$this->shiftForms = [new ShiftForm()];
		$this->calendarForm = new CalendarForm();
		$this->restrictionsForm = new WorktimeRestrictionsForm();
		$this->violationForm = new ViolationForm();
		return;
	}
	$this->schedule = $schedule;
	# editing
	$this->name = $schedule->getName();
	$this->type = $schedule->getScheduleType();
	$this->reportPeriod = $schedule->getReportPeriod();
	$this->reportPeriodStartWeekDay = $schedule->getReportPeriodStartWeekDay();
	$this->allowedDevices = $schedule->getAllowedDevices();
	$this->controlledActions = $schedule->getControlledActions();
	$this->isForAllUsers = $schedule->getIsForAllUsers();
	if ($this->isForAllUsers)
	{
		$this->assignments[] = static::ALL_USERS;
	}
	foreach ($schedule->obtainUserAssignments() as $user)
	{
		$code = 'U' . $user->getUserId();
		if ($user->isExcluded())
		{
			$this->assignmentsExcluded[] = $code;
			$this->userIdsExcluded[] = $user->getUserId();
		}
		else
		{
			$this->assignments[] = $code;
			$this->userIds[] = $user->getUserId();
		}
	}

	foreach ($schedule->obtainDepartmentAssignments() as $item)
	{
		$code = 'DR' . $item->getDepartmentId();
		if ($item->isExcluded())
		{
			$this->departmentIdsExcluded[] = $item->getDepartmentId();
			$this->assignmentsExcluded[] = $code;
		}
		else
		{
			$this->departmentIds[] = $item->getDepartmentId();
			$this->assignments[] = $code;
		}
	}

	$this->shiftForms = $shiftForms = [];
	foreach ($schedule->obtainShifts() as $shift)
	{
		$shiftForms[] = new ShiftForm($shift);
	}
	if ($shiftForms)
	{
		$this->shiftForms = $shiftForms;
	}

	$this->restrictionsForm = new WorktimeRestrictionsForm($schedule);
	$this->calendarForm = new CalendarForm($schedule->getCalendar());
	$this->violationForm = new ViolationForm($schedule->obtainScheduleViolationRules());
}