@extends('layouts.app')
@section('content')
<div class="d-flex justify-content-between align-items-start mb-4"><div><div class="text-danger small fw-bold">MONITORING KEHADIRAN</div><h1 class="page-title">Absensi</h1><p class="text-muted">Riwayat absensi dengan foto, lokasi, dan waktu.</p></div><a href="{{ route('attendance.create') }}" class="btn btn-danger"><i class="bi bi-camera me-1"></i> Ambil absensi</a></div>
<div class="card p-4"><div class="table-responsive"><table class="table align-middle"><thead><tr><th>Pegawai</th><th>Tanggal</th><th>Masuk</th><th>Pulang</th><th>Lokasi</th><th>Foto</th><th>Status</th><th>Aksi</th></tr></thead><tbody>@forelse($attendances as $attendance)<tr><td>{{ $attendance->employee->full_name }}<small class="d-block text-muted">{{ $attendance->employee->employee_code }}</small></td><td>{{ $attendance->attendance_date->format('d M Y') }}</td><td>{{ optional($attendance->check_in)->format('H:i') }}</td><td>{{ optional($attendance->check_out)->format('H:i') ?: '-' }}</td><td>{{ $attendance->location_name }}<small class="d-block text-muted">{{ $attendance->latitude }}, {{ $attendance->longitude }}</small></td><td>@if($attendance->photo_path)<img src="{{ asset('storage/'.$attendance->photo_path) }}" width="44" height="44" class="rounded object-fit-cover">@else - @endif</td><td><span class="badge {{ $attendance->status === 'late' ? 'bg-warning text-dark' : 'bg-success' }}">{{ $attendance->status }}</span></td><td>@if(!$attendance->check_out)<form method="POST" action="{{ route('attendance.update',$attendance) }}" class="d-inline">@csrf @method('PUT')<input type="hidden" name="check_out" value="{{ now()->format('Y-m-d H:i:s') }}"><input type="hidden" name="status" value="{{ $attendance->status }}"><button class="btn btn-sm btn-outline-secondary">Catat pulang</button></form>@endif <form method="POST" action="{{ route('attendance.destroy',$attendance) }}" class="d-inline">@csrf @method('DELETE')<button class="btn btn-sm btn-outline-danger" onclick="return confirm('Hapus data absensi?')">Hapus</button></form></td></tr>@empty<tr><td colspan="8" class="text-center text-muted">Belum ada absensi.</td></tr>@endforelse</tbody></table></div>{{ $attendances->links() }}</div>
@endsection
