@extends('layouts.app')
@section('page_title','Employee Documents')
@section('page_subtitle','Upload contracts, IDs, certificates and HR compliance documents.')
@section('content')
<div class="card"><h3>Add Document</h3><form method="POST" action="{{ route('admin.documents.store') }}" enctype="multipart/form-data">@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>Title</label><input class="input" name="title" required></div><div class="field"><label>Type</label><input class="input" name="document_type" placeholder="Contract, ID, Certificate"></div><div class="field"><label>File</label><input class="input" type="file" name="file"></div><div class="field"><label>Expiry Date</label><input class="input" type="date" name="expiry_date"></div><div class="field"><label>Status</label><select name="status"><option>valid</option><option>expired</option><option>pending</option></select></div></div><div class="field"><label>Notes</label><textarea name="notes"></textarea></div><button class="btn">Save Document</button></form></div>
<div class="card"><h3>Documents</h3><table class="table"><tr><th>Employee</th><th>Title</th><th>Type</th><th>Expiry</th><th>Status</th><th>File</th></tr>@forelse($documents as $document)<tr><td>{{ $document->user?->name }}</td><td>{{ $document->title }}</td><td>{{ $document->document_type }}</td><td>{{ $document->expiry_date?->format('d M Y') ?? '-' }}</td><td><span class="badge {{ $document->status==='valid'?'green':'yellow' }}">{{ ucfirst($document->status) }}</span></td><td>@if($document->file_path)<a class="btn secondary" target="_blank" href="{{ asset('storage/'.$document->file_path) }}">Open</a>@else - @endif</td></tr>@empty<tr><td colspan="6"><div class="empty">No documents yet.</div></td></tr>@endforelse</table><div class="pagination">{{ $documents->links() }}</div></div>
@endsection
