@extends('layouts.app')
@section('title','Employees - Movex HR')
@section('page_title','Employees')
@section('page_subtitle','Create, search and manage staff records. Role changes are intentionally database-only.')
@section('content')
<div class="card">
    <form method="GET" class="form-row">
        <div class="field"><label>Search</label><input class="input" name="search" value="{{ request('search') }}" placeholder="Name, email, staff ID"></div>
        <div class="field"><label>Status</label><select name="employment_status"><option value="">All</option>@foreach(['active','probation','suspended','terminated','resigned'] as $s)<option value="{{ $s }}" @selected(request('employment_status')===$s)>{{ ucfirst($s) }}</option>@endforeach</select></div>
        <div class="field"><button class="btn">Filter</button></div>
    </form>
</div>
<div class="card">
    <h3>Add Employee</h3>
    <form method="POST" action="{{ route('admin.employees.store') }}">@csrf
        <div class="form-row">
            <div class="field"><label>Name</label><input class="input" name="name" required></div><div class="field"><label>Email</label><input class="input" type="email" name="email" required></div>
            <div class="field"><label>Phone</label><input class="input" name="phone"></div><div class="field"><label>Password</label><input class="input" type="password" name="password" value="password123" required></div>
            <div class="field"><label>Department</label><select name="department_id"><option value="">None</option>@foreach($departments as $department)<option value="{{ $department->id }}">{{ $department->name }}</option>@endforeach</select></div>
            <div class="field"><label>Designation</label><select name="designation_id"><option value="">None</option>@foreach($designations as $designation)<option value="{{ $designation->id }}">{{ $designation->name }}</option>@endforeach</select></div>
            <div class="field"><label>Job Title</label><input class="input" name="job_title"></div><div class="field"><label>Employment Date</label><input class="input" type="date" name="employment_date"></div>
            <div class="field"><label>Status</label><select name="employment_status">@foreach(['active','probation','suspended','terminated','resigned'] as $s)<option value="{{ $s }}">{{ ucfirst($s) }}</option>@endforeach</select></div>
            <div class="field"><label>Basic Salary</label><input class="input" type="number" step="0.01" name="basic_salary" value="0"></div>
            <div class="field"><label>Gender</label><select name="gender"><option value="">Select</option><option>Male</option><option>Female</option><option>Other</option></select></div><div class="field"><label>Date of Birth</label><input class="input" type="date" name="date_of_birth"></div>
            <div class="field"><label>Bank Name</label><input class="input" name="bank_name"></div><div class="field"><label>Bank Account</label><input class="input" name="bank_account"></div>
        </div>
        <div class="field"><label>Address</label><input class="input" name="address"></div>
        <div class="field"><label>Emergency Contact</label><input class="input" name="emergency_contact"></div>
        <button class="btn">Save Employee</button>
    </form>
</div>
<div class="card">
    <div class="section-title"><h3>Employee List</h3><span class="muted">{{ $employees->total() }} records</span></div>
    <div class="table-wrap"><table class="table"><tr><th>Staff ID</th><th>Name</th><th>Dept</th><th>Designation</th><th>Role</th><th>Status</th><th></th></tr>
        @forelse($employees as $employee)<tr><td class="mono">{{ $employee->staff_id }}</td><td><strong>{{ $employee->name }}</strong><br><span class="muted small">{{ $employee->email }}</span></td><td>{{ $employee->department?->name ?? '-' }}</td><td>{{ $employee->designation?->name ?? '-' }}</td><td><span class="badge">{{ strtoupper($employee->role) }}</span></td><td><span class="badge {{ $employee->employment_status === 'active' ? 'green' : 'yellow' }}">{{ ucfirst($employee->employment_status) }}</span></td><td><a class="btn secondary" href="{{ route('admin.employees.show',$employee) }}">View</a></td></tr>@empty<tr><td colspan="7"><div class="empty">No employees found.</div></td></tr>@endforelse
    </table></div><div class="pagination">{{ $employees->links() }}</div>
</div>
@endsection
