@extends('layouts.app')
@section('page_title','Training')
@section('page_subtitle','Create training programmes and enrol employees.')
@section('content')
<div class="card"><h3>Create Training</h3><form method="POST" action="{{ route('admin.trainings.store') }}">@csrf<div class="form-row"><div class="field"><label>Title</label><input class="input" name="title" required></div><div class="field"><label>Location</label><input class="input" name="location"></div><div class="field"><label>Start Date</label><input class="input" type="date" name="start_date"></div><div class="field"><label>End Date</label><input class="input" type="date" name="end_date"></div><div class="field"><label>Status</label><select name="status"><option>active</option><option>completed</option><option>cancelled</option></select></div></div><div class="field"><label>Description</label><textarea name="description"></textarea></div><button class="btn">Save Training</button></form></div>
<div class="card"><h3>Training Programmes</h3><table class="table"><tr><th>Title</th><th>Dates</th><th>Status</th><th>Enrolled</th><th>Enrol Employee</th></tr>@forelse($trainings as $training)<tr><td><strong>{{ $training->title }}</strong><br><span class="muted small">{{ $training->location }}</span></td><td>{{ $training->start_date?->format('d M Y') }} - {{ $training->end_date?->format('d M Y') }}</td><td><span class="badge green">{{ ucfirst($training->status) }}</span></td><td>{{ $training->enrollments_count }}</td><td><form method="POST" action="{{ route('admin.trainings.enroll',$training) }}">@csrf<select name="user_id">@foreach($employees as $employee)<option value="{{ $employee->id }}">{{ $employee->name }}</option>@endforeach</select><select name="status"><option>registered</option><option>completed</option><option>cancelled</option></select><input type="hidden" name="notes" value=""><button class="btn secondary">Enrol</button></form></td></tr>@empty<tr><td colspan="5"><div class="empty">No trainings yet.</div></td></tr>@endforelse</table><div class="pagination">{{ $trainings->links() }}</div></div>
@endsection
