@extends('layouts.layoutMaster') @section('title', __('View Attendance')) @section('vendor-style') @vite([ 'resources/assets/vendor/libs/leaflet/leaflet.scss', ]) @endsection @section('vendor-script') @vite([ 'resources/assets/vendor/libs/leaflet/leaflet.js', ]) @endsection @section('page-script') @vite([ 'resources/assets/js/app/hrcore-attendance-view.js', ]) @endsection @section('content')
{{-- Breadcrumb --}}
{{-- Employee Information Card --}}
@if($attendance->user->profile_picture) User avatar @else
{{ $attendance->user->getInitials() }}
@endif
{{ __('Details') }}
  • {{ __('Employee ID') }}: {{ $attendance->user->code }}
  • {{ __('Email') }}: {{ $attendance->user->email }}
  • {{ __('Designation') }}: {{ $attendance->user->designation->name ?? __('N/A') }}
  • {{ __('Department') }}: {{ $attendance->user->designation->department->name ?? __('N/A') }}
  • {{ __('Shift') }}: {{ $attendance->shift->name ?? __('Default Shift') }}
{{-- Attendance Details Card --}}
{{ __('Attendance Details') }}

{{ $attendance->created_at->translatedFormat('l, F j, Y') }}

@php $statusClass = match($attendance->status) { 'present' => 'success', 'late' => 'warning', 'absent' => 'danger', default => 'secondary' }; @endphp {{ __($attendance->status ?? 'present') }}

@if($checkInLog = $attendance->attendanceLogs->where('type', 'check_in')->first()) {{ $checkInLog->created_at->format('h:i A') }} @else {{ __('Not checked in') }} @endif

@if($checkOutLog = $attendance->attendanceLogs->where('type', 'check_out')->last()) {{ $checkOutLog->created_at->format('h:i A') }} @else {{ __('Not checked out') }} @endif

@if($checkInLog && $checkOutLog) @php $totalHours = $checkInLog->created_at->diffInHours($checkOutLog->created_at); $totalMinutes = $checkInLog->created_at->diffInMinutes($checkOutLog->created_at) % 60; @endphp {{ $totalHours }}h {{ $totalMinutes }}m @else {{ __('N/A') }} @endif

{{ $attendance->late_reason ?? __('N/A') }}

@if($attendance->early_checkout_reason)

{{ $attendance->early_checkout_reason }}

@endif {{-- Attendance Metrics --}}
{{ __('Attendance Metrics') }}

@if($attendance->late_hours > 0) {{ formatHours($attendance->late_hours) }} @else {{ __('On Time') }} @endif

@if($attendance->early_hours > 0) {{ formatHours($attendance->early_hours) }} @else {{ __('N/A') }} @endif

@if($attendance->overtime_hours > 0) {{ formatHours($attendance->overtime_hours) }} @else {{ __('None') }} @endif

@if($attendance->shift)

{{ \Carbon\Carbon::parse($attendance->shift->start_time)->format('h:i A') }}

{{ \Carbon\Carbon::parse($attendance->shift->end_time)->format('h:i A') }}

@endif
{{-- Attendance Logs Timeline --}}
{{ __('Attendance Timeline') }}
    @forelse($attendance->attendanceLogs->sortByDesc('created_at') as $log)
  • {{ $log->type === 'check_in' ? __('Checked In') : __('Checked Out') }}
    {{ $log->created_at->format('h:i A') }}
    @if($log->address)

    {{ $log->address }}

    @endif @if($log->notes)

    {{ $log->notes }}

    @endif
  • @empty
  • {{ __('No attendance logs found') }}
  • @endforelse
{{-- Location Map (if coordinates available) --}} @if($attendance->attendanceLogs->where('latitude', '!=', null)->count() > 0)
{{ __('Check-in/out Locations') }}
@endif
{{-- Page Data for JavaScript --}} @php $attendanceLogs = $attendance->attendanceLogs->map(function($log) { return [ 'type' => $log->type, 'latitude' => $log->latitude, 'longitude' => $log->longitude, 'address' => $log->address, 'time' => $log->created_at->format('h:i A') ]; })->filter(function($log) { return $log['latitude'] && $log['longitude']; })->values(); @endphp @endsection