@extends('layout')
@section('title', 'Manual Entry')
@section('content')
<div class="page-header"><h1>Manual Entry</h1></div>

<div class="card" style="max-width:480px;">
    <form method="POST" action="{{ route('attendance.manual-entry.store') }}">
        @csrf
        <label for="emp_id">Employee</label>
        <select name="emp_id" id="emp_id" required>
            <option value="">Select employee</option>
            @foreach($employees as $employee)
                <option value="{{ $employee->emp_id }}" @selected(old('emp_id') === $employee->emp_id)>{{ $employee->emp_id }} — {{ $employee->name }}</option>
            @endforeach
        </select>

        <label for="site_id">Site</label>
        <select name="site_id" id="site_id" required>
            @foreach($sites as $site)
                <option value="{{ $site->id }}" @selected((string) old('site_id') === (string) $site->id)>{{ $site->name }}</option>
            @endforeach
        </select>

        <label for="direction">Direction</label>
        <select name="direction" id="direction" required>
            <option value="IN" @selected(old('direction') === 'IN')>IN</option>
            <option value="OUT" @selected(old('direction') === 'OUT')>OUT</option>
        </select>

        <label for="ts">Date &amp; time</label>
        <input type="datetime-local" id="ts" name="ts" value="{{ old('ts', now()->format('Y-m-d\TH:i')) }}" required>

        <button type="submit" class="btn btn-primary btn-block">Record punch</button>
    </form>
</div>
@endsection
