@extends('layouts.template.main') @section('content')
{{-- ----------------------------- attendance grace time setup ----------------------------- --}} @if (auth()->user()->hasRole('admin') || auth()->user()->hasRole('hr'))
Thời hạn chấm công
@if (session('success')) @endif
@csrf @method('put')
@endif {{-- ----------------------------- attendance grace time setup ----------------------------- --}}
Danh sách chấm công @php $route = 'attendance_list'; if (auth()->user()->hasRole('manager')) { $route = 'attendance_list_manager'; } elseif (auth()->user()->hasRole('employee')) { $route = 'attendance_list_employee'; } @endphp
@if(auth()->user()->hasRole('admin') || auth()->user()->hasRole('hr')) @endif
@php $currentSort = request('sort', 'date'); $currentOrder = request('order', 'desc'); $nextOrder = $currentOrder == 'asc' ? 'desc' : 'asc'; @endphp @foreach ($attendances as $attendance) @if (auth()->user()->hasRole('manager') || auth()->user()->hasRole('employee')) @else @endif @endforeach
Name @if($currentSort == 'name') @else @endif Ngày @if($currentSort == 'date') @else @endif Checked in Checked out Trạng thái Giờ làm việc Hành động
{{ $attendance->employee->name ?? '' }} {{ $attendance->date ?? '' }} @php $key = "{$attendance->employee_id}_{$attendance->date}"; $dayLeaves = $leaveRequestsMap[$key] ?? []; @endphp @if(count($dayLeaves) > 0) @php $dayLeavesCol = collect($dayLeaves); $hasPending = $dayLeavesCol->contains('status', 'Pending'); $hasApproved = $dayLeavesCol->contains('status', 'Approved'); $hasRejected = $dayLeavesCol->contains('status', 'Rejected'); if ($hasPending) { $iconColor = 'text-warning'; $statusText = 'Có đơn đang chờ'; } elseif ($hasApproved) { $iconColor = 'text-primary'; $statusText = 'Đã có đơn duyệt'; } else { $iconColor = 'text-danger'; $statusText = 'Đơn bị từ chối'; } @endphp
@endif
{{ $attendance->check_in_time ? \Carbon\Carbon::parse($attendance->check_in_time)->format('h:i A') : '' }} {{ $attendance->check_out_time ? \Carbon\Carbon::parse($attendance->check_out_time)->format('h:i A') : '' }}
@if(auth()->user()->hasRole('admin') || auth()->user()->hasRole('hr') || auth()->user()->hasRole('manager')) @else @if($attendance->status == 'Late') Đi muộn @elseif($attendance->status == 'EarlyLeave') Về sớm @elseif($attendance->status == 'Present') Có mặt @elseif($attendance->status == 'MissingPunch') Quên chấm công @else {{ $attendance->status }} @endif @endif @php $key = "{$attendance->employee_id}_{$attendance->date}"; $dayLeaves = $leaveRequestsMap[$key] ?? []; @endphp @if(count($dayLeaves) > 0) @php $dayLeavesCol = collect($dayLeaves); $hasPending = $dayLeavesCol->contains('status', 'Pending'); $hasApproved = $dayLeavesCol->contains('status', 'Approved'); if ($hasPending) { $iconColor = 'text-warning'; $statusText = 'Có đơn đang chờ'; } elseif ($hasApproved) { $iconColor = 'text-success'; $statusText = 'Có đơn đã duyệt'; } else { $iconColor = 'text-danger'; $statusText = 'Đơn bị từ chối'; } @endphp
@endif
@php $hours = floor($attendance->working_hours); $minutes = round(($attendance->working_hours - $hours) * 60); $parts = []; if ($hours > 0) { $parts[] = $hours . ' ' . ($hours === 1 ? 'hr' : 'hrs'); } if ($minutes > 0) { $parts[] = $minutes . ' ' . ($minutes === 1 ? 'min' : 'mins'); } $formattedTime = count($parts) ? implode(' ', $parts) : '0 min'; @endphp {{ $formattedTime }}
{{ $attendances->links('pagination::bootstrap-5') }}
@push('scripts') @endpush @endsection