- Модуль: timeman
- Путь к файлу: ~/bitrix/modules/timeman/lib/repository/worktime/worktimerepository.php
- Класс: BitrixTimemanRepositoryWorktimeWorktimeRepository
- Вызов: WorktimeRepository::findOverlappingRecordByDates
public function findOverlappingRecordByDates(WorktimeRecord $record): bool
{
$userId = $record->getUserId();
$startTimestamp = $record->getRecordedStartTimestamp();
$stopTimestamp = $record->getRecordedStopTimestamp();
$id = $record->getId();
$scheduleId = $record->getScheduleId();
$shiftId = $record->getShiftId();
$orFilter = Query::filter()->logic('or');
$orFilter->where(
Query::filter()->logic('and')
->where('RECORDED_START_TIMESTAMP', '<=', $startTimestamp)
->where('RECORDED_STOP_TIMESTAMP', '>=', $startTimestamp)
);
if ($stopTimestamp > 0)
{
$orFilter->where(
Query::filter()->logic('and')
->where('RECORDED_START_TIMESTAMP', '<=', $stopTimestamp)
->where('RECORDED_START_TIMESTAMP', '>=', $startTimestamp)
);
}
$query = WorktimeRecordTable::query()
->addSelect('ID')
->where('USER_ID', $userId);
if ($id > 0)
{
$query->where('ID', '!=', $id);
}
if ($scheduleId > 0)
{
$query->where('SCHEDULE_ID', $scheduleId);
}
if ($shiftId > 0)
{
$query->where('SHIFT_ID', $shiftId);
}
$query->where($orFilter);
return $query->fetch() !== false;
}