• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/lib/service/agent/initialsettingsagent.php
  • Класс: BitrixTimemanServiceAgentInitialSettingsAgent
  • Вызов: InitialSettingsAgent::createScheduleForm
private function createScheduleForm()
{
	$parentCalendarId = '';
	if ($this->getCurrentPortalZone())
	{
		$systemCalendar = CalendarTable::query()
			->addSelect('ID')
			->where('SYSTEM_CODE', $this->getCurrentPortalZone())
			->exec()
			->fetch();
		if ($systemCalendar)
		{
			$parentCalendarId = $systemCalendar['ID'];
		}
	}

	$scheduleForm = new BitrixTimemanFormScheduleScheduleForm();

	$scheduleForm->load([
		$scheduleForm->getFormName() => [
			'type' => ScheduleTable::SCHEDULE_TYPE_FIXED,
			'name' => Loc::getMessage('TIMEMAN_DEFAULT_SCHEDULE_FOR_ALL_USERS_NAME'),
			'reportPeriod' => ScheduleTable::REPORT_PERIOD_MONTH,
			'reportPeriodStartWeekDay' => ScheduleTable::REPORT_PERIOD_OPTIONS_START_WEEK_DAY_MONDAY,
			'worktimeRestrictions' => [],
			'assignments' => [ScheduleForm::ALL_USERS],
			'ShiftForm' => [
				[
					'shiftId' => '',
					'workDays' => '12345',
					'name' => '',
					'startTimeFormatted' => TimeHelper::getInstance()->convertSecondsToHoursMinutes(32400),
					'endTimeFormatted' => TimeHelper::getInstance()->convertSecondsToHoursMinutes(64800),
					'breakDurationFormatted' => '00:00',
				],
			],
			'CalendarForm' => [
				'calendarId' => '',
				'parentId' => $parentCalendarId,
				'datesJson' => '{}',
			],

			'ViolationForm' => [
				'scheduleId' => '',
				'maxExactStartFormatted' => TimeHelper::getInstance()->convertSecondsToHoursMinutes(9 * 3600 + 15 * 60),
				'minExactEndFormatted' => TimeHelper::getInstance()->convertSecondsToHoursMinutes(18 * 3600 - 15 * 60),
				'relativeStartFromFormatted' => '--:--',
				'relativeStartToFormatted' => '--:--',
				'relativeEndFromFormatted' => '--:--',
				'relativeEndToFormatted' => '--:--',
				'minDayDurationFormatted' => TimeHelper::getInstance()->convertSecondsToHoursMinutes(8 * 3600),
				'maxAllowedToEditWorkTimeFormatted' => TimeHelper::getInstance()->convertSecondsToHoursMinutes(900),
				'maxShiftStartDelayFormatted' => '--:--',
				'maxWorkTimeLackForPeriod' => '',
				'startEndNotifyUsers' => [],
				'editWorktimeNotifyUsers' => [ViolationRulesTable::USERS_TO_NOTIFY_USER_MANAGER,],
			],
			'controlledActions' => ScheduleTable::CONTROLLED_ACTION_START_AND_END,
			'allowedDevices' => [
				'browser' => 'on',
				'b24time' => 'on',
				'mobile' => 'on',
				'mobileRecordLocation' => '',
			],
		],
	]);
	$scheduleForm->validate();
	$scheduleForm->violationForm->saveAllViolationFormFields = true;
	return $scheduleForm;
}