BỔ SUNG CHECK THÊM điều kiện user ticket nguyên ngày #97

Merged
joseph merged 2 commits from Truong-CreateAutoTicketKPhep into master 2024-10-16 13:47:37 +11:00
1 changed files with 8 additions and 1 deletions
Showing only changes of commit 4334f3e73d - Show all commits

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'),