• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/lib/absence.php
  • Класс: BitrixTimemanAbsence
  • Вызов: Absence::addReport
static function addReport($absenceId, $text, $type = self::REPORT_TYPE_WORK, $addToCalendar = true, $userId = null)
{
	if (is_null($userId) && $GLOBALS['USER'])
	{
		$userId = $GLOBALS['USER']->GetId();
	}

	$userId = intval($userId);
	if ($userId <= 0)
	{
		return false;
	}

	$text = trim($text);
	if ($text == '')
	{
		return false;
	}

	$result = BitrixTimemanModelAbsenceTable::getById($absenceId)->fetch();
	if ($result['USER_ID'] != $userId)
	{
		return false;
	}

	$calendarId = 0;
	if ($addToCalendar)
	{
		$calendarId = self::addCalendarEntry($userId, $text, $result['DATE_START'], $result['DATE_FINISH'], $type == self::REPORT_TYPE_PRIVATE);
	}

	BitrixTimemanModelAbsenceTable::update($absenceId, Array(
		'REPORT_TYPE' => $type,
		'REPORT_TEXT' => $text,
		'REPORT_CALENDAR_ID' => $calendarId,
	));

	return true;
}