• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/lib/service/worktime/violation/worktimeviolationbuilder.php
  • Класс: BitrixTimemanServiceWorktimeViolationWorktimeViolationBuilder
  • Вызов: WorktimeViolationBuilder::buildViolations
public function buildViolations($types = [])
{
	$record = $this->getRecord();
	if (!$record || !$this->getSchedule() || !$this->getViolationRules())
	{
		return [];
	}
	$violations = [];
	if (!$this->skipViolationsCheck())
	{
		$violations = array_merge($violations, $this->buildStartViolations());
		if ($record->getRecordedStopTimestamp() > 0)
		{
			$violationsConfig = $this->getViolationRules();
			$minExactEnd = $violationsConfig->getMinExactEnd();
			$skipEndViolations = false;
			if (ViolationRules::isViolationConfigured($minExactEnd) && $this->getShift())
			{
				$userStartDate = TimeHelper::getInstance()->createDateTimeFromFormat('U', $record->getRecordedStartTimestamp(), $record->getStartOffset());
				$userEndDate = TimeHelper::getInstance()->createDateTimeFromFormat('U', $record->getRecordedStopTimestamp(), $record->getStopOffset());
				if ($this->getShift()->getWorkTimeEnd() > $this->getShift()->getWorkTimeStart() &&
					(int)$userEndDate->format('d') > (int)$userStartDate->format('d')
				)
				{
					$skipEndViolations = true;
				}
			}
			$violations = array_merge($violations, $this->buildDurationViolations());
			if (!$skipEndViolations)
			{
				$violations = array_merge($violations, $this->buildEndViolations());
			}
		}
	}

	/** @var WorktimeViolation[] $violations */
	$violations = array_filter(array_merge(
		$violations,
		$this->buildEditViolations()
	));

	if (!empty($types))
	{
		foreach ($violations as $index => $violation)
		{
			if (!in_array($violation->type, $types, true))
			{
				unset($violations[$index]);
			}
		}
	}
	return array_filter($violations);
}