BỔ SUNG CHECK THÊM điều kiện user ticket nguyên ngày #96
|
|
@ -39,7 +39,7 @@ class CheckUserAttendanceJob implements ShouldQueue
|
|||
// Lấy tất cả người dùng
|
||||
$users = User::where('permission', 'not like', '%admin%')->get();
|
||||
foreach ($users as $key => $user) {
|
||||
// if ($user->id != 2) {
|
||||
// if ($user->id != 4) {
|
||||
// continue;
|
||||
// }
|
||||
// Kiểm tra dựa trên period (Sáng 'S' hoặc Chiều 'C')
|
||||
|
|
@ -72,11 +72,18 @@ class CheckUserAttendanceJob implements ShouldQueue
|
|||
// Kiểm tra nếu đã có ticket chờ xử lý hoặc đã được xác nhận
|
||||
$existingTicket = Ticket::where('user_id', $userId)
|
||||
->where('start_date', $today->format('Y-m-d'))
|
||||
->where('start_period', $periodCode)
|
||||
->where('end_date', $today->format('Y-m-d'))
|
||||
->where('end_period', $periodCode)
|
||||
->where(function ($query) use ($periodCode) {
|
||||
$query->where('start_period', $periodCode) // Check the current period (S or C)
|
||||
->orWhere(function ($query) {
|
||||
// Check if there's a ticket for both morning and afternoon
|
||||
$query->where('start_period', 'S')
|
||||
->where('end_period', 'C');
|
||||
});
|
||||
})
|
||||
->whereIn('status', ['WAITING', 'CONFIRMED'])
|
||||
->first();
|
||||
|
||||
$type = 'ONLEAVE';
|
||||
$reason = 'KHONG PHEP';
|
||||
// Nếu không có check-in hoặc check-out, và chưa có ticket, tạo ticket mới
|
||||
|
|
|
|||
Loading…
Reference in New Issue