Bổ sung check điều kiện có user check in check out (ngày hợp lệ)

This commit is contained in:
Truong Vo 2024-10-16 09:44:29 +07:00
parent 1c16b4b164
commit 4334f3e73d
1 changed files with 8 additions and 1 deletions

View File

@ -125,8 +125,15 @@ class CheckUserAttendanceJob implements ShouldQueue
$type = 'ONLEAVE';
$reason = 'KHONG PHEP';
//Check ngày hợp lệ nếu có check và check out của user khác
$dateNow = Tracking::whereBetween('time_string', [$startTime, $endTime])
->get();
$hasCheckIndateNow = $dateNow->where('status', 'check in')->isNotEmpty();
$hasCheckOutdateNow = $dateNow->where('status', 'check out')->isNotEmpty();
// Nếu không có check-in hoặc check-out, và chưa có ticket, tạo ticket mới
if (!$hasCheckIn && !$hasCheckOut && !$existingTicket) {
if (($hasCheckIndateNow && $hasCheckOutdateNow) && !$hasCheckIn && !$hasCheckOut && !$existingTicket) {
Ticket::create([
'user_id' => $userId,
'start_date' => $today->format('Y-m-d'),