<?php $__env->startSection('title', 'Employees'); ?>

<?php $__env->startSection('content'); ?>
<div x-data="{ add: false, dept: false, edit: null }">
    <div class="mb-5 flex flex-wrap items-center justify-between gap-3">
        <div>
            <h1 class="text-xl font-extrabold text-slate-900 lg:text-2xl">Employees</h1>
            <p class="text-sm text-slate-500">Staff records, departments and pay details.</p>
        </div>
        <div class="flex gap-2">
            <button @click="dept = true" class="rounded-xl bg-white px-4 py-2.5 text-sm font-bold text-slate-700 ring-1 ring-slate-200 hover:bg-slate-50">+ Department</button>
            <button @click="add = true" class="rounded-xl bg-indigo-600 px-4 py-2.5 text-sm font-bold text-white shadow-lg shadow-indigo-600/25 hover:bg-indigo-700">+ Add employee</button>
        </div>
    </div>

    <form method="GET" class="mb-4 flex flex-wrap items-center gap-2">
        <input name="q" value="<?php echo e(request('q')); ?>" placeholder="Search name or employee no…" class="w-full max-w-xs rounded-xl border-slate-200 text-sm">
        <select name="department" class="rounded-xl border-slate-200 text-sm" onchange="this.form.submit()">
            <option value="">All departments</option>
            <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($department->id); ?>" <?php if(request('department') == $department->id): echo 'selected'; endif; ?>><?php echo e($department->name); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
        <button class="rounded-xl bg-slate-900 px-4 py-2.5 text-sm font-bold text-white">Search</button>
        <?php if(request()->hasAny(['q', 'department'])): ?>
            <a href="<?php echo e(route('epelcon.hr.employees')); ?>" class="text-xs font-bold text-slate-500">Clear</a>
        <?php endif; ?>
    </form>

    <div class="overflow-x-auto rounded-2xl bg-white shadow-sm ring-1 ring-slate-200">
        <table class="w-full min-w-[860px] text-sm">
            <thead><tr class="border-b border-slate-100 bg-slate-50 text-left text-xs font-bold uppercase text-slate-400">
                <th class="px-4 py-3">Employee</th><th class="px-4 py-3">Department</th><th class="px-4 py-3">Designation</th><th class="px-4 py-3">Type</th><th class="px-4 py-3 text-right">Salary</th><th class="px-4 py-3">Status</th><th class="px-4 py-3"></th>
            </tr></thead>
            <tbody class="divide-y divide-slate-100">
            <?php $__empty_1 = true; $__currentLoopData = $employees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $employee): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <?php $badge = ['active' => 'emerald', 'on_leave' => 'amber', 'exited' => 'slate'][$employee->status] ?? 'slate'; ?>
                <tr class="hover:bg-slate-50">
                    <td class="px-4 py-3">
                        <p class="font-bold text-slate-800"><?php echo e($employee->name); ?></p>
                        <p class="font-mono text-[11px] text-slate-400"><?php echo e($employee->employee_no); ?><?php echo e($employee->phone ? ' · ' . $employee->phone : ''); ?></p>
                    </td>
                    <td class="px-4 py-3 text-slate-600"><?php echo e($employee->department->name ?? '—'); ?></td>
                    <td class="px-4 py-3 text-slate-600"><?php echo e($employee->designation ?? '—'); ?></td>
                    <td class="px-4 py-3 capitalize text-slate-600"><?php echo e(str_replace('_', ' ', $employee->employment_type)); ?></td>
                    <td class="px-4 py-3 text-right font-extrabold text-slate-900"><?php echo e($CUR ?? '₦') . number_format((float) ($employee->salary), 2); ?></td>
                    <td class="px-4 py-3"><span class="rounded-full bg-<?php echo e($badge); ?>-100 px-2.5 py-1 text-[10px] font-bold uppercase text-<?php echo e($badge); ?>-700"><?php echo e(str_replace('_', ' ', $employee->status)); ?></span></td>
                    <td class="px-4 py-3 text-right">
                        <button @click="edit = <?php echo e($employee->id); ?>" class="rounded-lg bg-slate-100 px-3 py-1.5 text-xs font-bold text-slate-700 hover:bg-slate-200">Edit</button>
                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr><td colspan="7" class="px-4 py-10 text-center text-slate-400">No employees found.</td></tr>
            <?php endif; ?>
            </tbody>
        </table>
    </div>

    <div class="mt-5"><?php echo e($employees->links()); ?></div>

    
    <div x-cloak x-show="add" class="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
        <div class="absolute inset-0 bg-slate-900/50 backdrop-blur-sm" @click="add = false"></div>
        <div x-show="add" x-transition class="relative max-h-[92vh] w-full max-w-lg overflow-y-auto rounded-t-3xl bg-white p-6 shadow-2xl sm:rounded-3xl">
            <h2 class="mb-4 text-lg font-extrabold">Add employee</h2>
            <form method="POST" action="<?php echo e(route('epelcon.hr.employees.store')); ?>" class="grid grid-cols-2 gap-4"><?php echo csrf_field(); ?>
                <label class="col-span-2"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Full name</span>
                    <input name="name" required class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Employee no.</span>
                    <input name="employee_no" placeholder="Auto if blank" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Department</span>
                    <select name="department_id" class="w-full rounded-xl border-slate-200 text-sm">
                        <option value="">— None —</option>
                        <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($department->id); ?>"><?php echo e($department->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Email</span>
                    <input type="email" name="email" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Phone</span>
                    <input name="phone" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Designation</span>
                    <input name="designation" placeholder="e.g. Receptionist" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Employment type</span>
                    <select name="employment_type" class="w-full rounded-xl border-slate-200 text-sm">
                        <?php $__currentLoopData = ['full_time', 'part_time', 'contract', 'intern']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($t); ?>"><?php echo e(ucfirst(str_replace('_', ' ', $t))); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Date joined</span>
                    <input type="date" name="date_joined" value="<?php echo e(today()->toDateString()); ?>" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Salary (<?php echo e($CUR); ?>/month)</span>
                    <input type="number" step="0.01" min="0" name="salary" value="0" required class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Bank name</span>
                    <input name="bank_name" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Account number</span>
                    <input name="account_number" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Status</span>
                    <select name="status" class="w-full rounded-xl border-slate-200 text-sm">
                        <?php $__currentLoopData = ['active', 'on_leave', 'exited']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($s); ?>"><?php echo e(ucfirst(str_replace('_', ' ', $s))); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select></label>
                <label class="col-span-2"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Address</span>
                    <input name="address" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <div class="col-span-2 flex justify-end gap-2">
                    <button type="button" @click="add = false" class="rounded-xl px-4 py-2.5 text-sm font-bold text-slate-500">Cancel</button>
                    <button class="rounded-xl bg-indigo-600 px-5 py-2.5 text-sm font-bold text-white">Save employee</button>
                </div>
            </form>
        </div>
    </div>

    
    <?php $__currentLoopData = $employees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $employee): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div x-cloak x-show="edit === <?php echo e($employee->id); ?>" class="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
            <div class="absolute inset-0 bg-slate-900/50 backdrop-blur-sm" @click="edit = null"></div>
            <div x-show="edit === <?php echo e($employee->id); ?>" x-transition class="relative max-h-[92vh] w-full max-w-lg overflow-y-auto rounded-t-3xl bg-white p-6 shadow-2xl sm:rounded-3xl">
                <h2 class="mb-4 text-lg font-extrabold">Edit — <?php echo e($employee->name); ?></h2>
                <form method="POST" action="<?php echo e(route('epelcon.hr.employees.update', $employee)); ?>" class="grid grid-cols-2 gap-4"><?php echo csrf_field(); ?>
                    <label class="col-span-2"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Full name</span>
                        <input name="name" value="<?php echo e($employee->name); ?>" required class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Employee no.</span>
                        <input name="employee_no" value="<?php echo e($employee->employee_no); ?>" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Department</span>
                        <select name="department_id" class="w-full rounded-xl border-slate-200 text-sm">
                            <option value="">— None —</option>
                            <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($department->id); ?>" <?php if($employee->department_id == $department->id): echo 'selected'; endif; ?>><?php echo e($department->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Email</span>
                        <input type="email" name="email" value="<?php echo e($employee->email); ?>" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Phone</span>
                        <input name="phone" value="<?php echo e($employee->phone); ?>" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Designation</span>
                        <input name="designation" value="<?php echo e($employee->designation); ?>" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Employment type</span>
                        <select name="employment_type" class="w-full rounded-xl border-slate-200 text-sm">
                            <?php $__currentLoopData = ['full_time', 'part_time', 'contract', 'intern']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($t); ?>" <?php if($employee->employment_type === $t): echo 'selected'; endif; ?>><?php echo e(ucfirst(str_replace('_', ' ', $t))); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Date joined</span>
                        <input type="date" name="date_joined" value="<?php echo e($employee->date_joined?->toDateString()); ?>" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Salary (<?php echo e($CUR); ?>/month)</span>
                        <input type="number" step="0.01" min="0" name="salary" value="<?php echo e($employee->salary); ?>" required class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Bank name</span>
                        <input name="bank_name" value="<?php echo e($employee->bank_name); ?>" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Account number</span>
                        <input name="account_number" value="<?php echo e($employee->account_number); ?>" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <label><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Status</span>
                        <select name="status" class="w-full rounded-xl border-slate-200 text-sm">
                            <?php $__currentLoopData = ['active', 'on_leave', 'exited']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($s); ?>" <?php if($employee->status === $s): echo 'selected'; endif; ?>><?php echo e(ucfirst(str_replace('_', ' ', $s))); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select></label>
                    <label class="col-span-2"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Address</span>
                        <input name="address" value="<?php echo e($employee->address); ?>" class="w-full rounded-xl border-slate-200 text-sm"></label>
                    <div class="col-span-2 flex justify-end gap-2">
                        <button type="button" @click="edit = null" class="rounded-xl px-4 py-2.5 text-sm font-bold text-slate-500">Cancel</button>
                        <button class="rounded-xl bg-indigo-600 px-5 py-2.5 text-sm font-bold text-white">Update employee</button>
                    </div>
                </form>
            </div>
        </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

    
    <div x-cloak x-show="dept" class="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
        <div class="absolute inset-0 bg-slate-900/50 backdrop-blur-sm" @click="dept = false"></div>
        <div x-show="dept" x-transition class="relative w-full max-w-md rounded-t-3xl bg-white p-6 shadow-2xl sm:rounded-3xl">
            <h2 class="mb-4 text-lg font-extrabold">New department</h2>
            <form method="POST" action="<?php echo e(route('epelcon.hr.departments.store')); ?>" class="space-y-4"><?php echo csrf_field(); ?>
                <label class="block"><span class="mb-1 block text-xs font-bold uppercase text-slate-500">Name</span>
                    <input name="name" required placeholder="e.g. Front Office" class="w-full rounded-xl border-slate-200 text-sm"></label>
                <?php if($departments->isNotEmpty()): ?>
                    <div class="flex flex-wrap gap-1.5">
                        <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <span class="rounded-full bg-slate-100 px-2.5 py-1 text-[11px] font-bold text-slate-600"><?php echo e($department->name); ?></span>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                <?php endif; ?>
                <div class="flex justify-end gap-2">
                    <button type="button" @click="dept = false" class="rounded-xl px-4 py-2.5 text-sm font-bold text-slate-500">Cancel</button>
                    <button class="rounded-xl bg-indigo-600 px-5 py-2.5 text-sm font-bold text-white">Save department</button>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.epelcon', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\wamp64\www\hms\resources\views/epelcon/hr/employees.blade.php ENDPATH**/ ?>