@extends('layouts.app')
@section('page_title','Attendance')
@section('page_subtitle','Record and review daily staff attendance.')
@section('content')
<div class="card"><form method="GET" class="form-row"><div class="field"><label>Employee</label><select name="user_id"><option value="">All</option>@foreach($employees as $employee)<option value="{{ $employee->id }}" @selected(request('user_id')==$employee->id)>{{ $employee->name }}</option>@endforeach</select></div><div class="field"><label>Date</label><input class="input" type="date" name="work_date" value="{{ request('work_date') }}"></div><div class="field"><button class="btn">Filter</button></div></form></div>
<div class="card"><h3>Add / Correct Attendance</h3><form method="POST" action="{{ route('admin.attendance.store') }}">@csrf<div class="form-row"><div class="field"><label>Employee</label><select name="user_id" required>@foreach($employees as $employee)<option value="{{ $employee->id }}">{{ $employee->name }}</option>@endforeach</select></div><div class="field"><label>Work Date</label><input class="input" type="date" name="work_date" value="{{ now()->format('Y-m-d') }}" required></div><div class="field"><label>Clock In</label><input class="input" type="datetime-local" name="clock_in_at"></div><div class="field"><label>Clock Out</label><input class="input" type="datetime-local" name="clock_out_at"></div><div class="field"><label>Status</label><select name="status"><option>present</option><option>absent</option><option>late</option><option>half_day</option><option>remote</option></select></div></div><div class="field"><label>Notes</label><textarea name="notes"></textarea></div><button class="btn">Save Attendance</button></form></div>
<div class="card"><h3>Attendance Records</h3><table class="table"><tr><th>Date</th><th>Employee</th><th>Clock In</th><th>Clock Out</th><th>Status</th><th>Notes</th></tr>@forelse($records as $record)<tr><td>{{ $record->work_date?->format('d M Y') }}</td><td>{{ $record->user?->name }}</td><td>{{ $record->clock_in_at?->format('h:i A') ?? '-' }}</td><td>{{ $record->clock_out_at?->format('h:i A') ?? '-' }}</td><td><span class="badge green">{{ ucfirst($record->status) }}</span></td><td>{{ $record->notes }}</td></tr>@empty<tr><td colspan="6"><div class="empty">No attendance records.</div></td></tr>@endforelse</table><div class="pagination">{{ $records->links() }}</div></div>
@endsection
