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

<?php $__env->startSection('content'); ?>
<div class="space-y-6">
    <header class="flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between"><div><p class="text-xs font-bold uppercase tracking-[.18em] text-emerald-600">Employees & HR</p><h1 class="mt-1 text-3xl font-bold text-slate-950">Employee directory</h1><p class="mt-1 text-sm text-slate-500">Independent HR records, employment compliance, today’s attendance and controlled ERP access.</p></div><div class="flex flex-wrap gap-2"><a href="<?php echo e(route('app.employees.expiries')); ?>" class="rounded-xl border border-amber-200 bg-amber-50 px-4 py-2.5 text-sm font-bold text-amber-700">Document expiries</a><a href="<?php echo e(route('app.attendance.index')); ?>" class="rounded-xl border border-slate-200 bg-white px-4 py-2.5 text-sm font-bold text-slate-700">Attendance</a><?php if(auth()->check() && auth()->user()->hasPermission('employees.create')): ?><a href="<?php echo e(route('app.employees.create')); ?>" class="rounded-xl bg-emerald-600 px-4 py-2.5 text-sm font-bold text-white">+ New employee</a><?php endif; ?></div></header>

    <form method="GET" class="grid gap-3 rounded-2xl border border-slate-200 bg-white p-4 shadow-sm md:grid-cols-3 xl:grid-cols-7"><input name="q" value="<?php echo e(request('q')); ?>" class="erp-input md:col-span-2" placeholder="Search employee ID, name, mobile, EID, passport"><select name="branch_id" class="erp-input"><option value="">All branches</option><?php $__currentLoopData = $branches; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $branch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($branch->id); ?>" <?php if(request('branch_id')==$branch->id): echo 'selected'; endif; ?>><?php echo e($branch->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select><select name="department_id" class="erp-input"><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_id')==$department->id): echo 'selected'; endif; ?>><?php echo e($department->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select><select name="employment_type" class="erp-input"><option value="">All employment types</option><?php $__currentLoopData = ['full_time','contract','temporary','part_time','intern','consultant']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($type); ?>" <?php if(request('employment_type')===$type): echo 'selected'; endif; ?>><?php echo e(ucfirst(str_replace('_',' ',$type))); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select><select name="status" class="erp-input"><option value="">All statuses</option><?php $__currentLoopData = ['active','inactive','on_leave','resigned','terminated']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($status); ?>" <?php if(request('status')===$status): echo 'selected'; endif; ?>><?php echo e(ucfirst(str_replace('_',' ',$status))); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select><select name="expiry_days" class="erp-input"><option value="">All document validity</option><?php $__currentLoopData = [7,15,30,60,90]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $days): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($days); ?>" <?php if(request('expiry_days')==$days): echo 'selected'; endif; ?>>Expiring in <?php echo e($days); ?> days</option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select><button class="rounded-xl bg-slate-900 px-4 py-2.5 text-xs font-bold text-white">Apply filters</button></form>

    <section class="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm"><div class="overflow-x-auto"><table class="erp-table"><thead><tr><th>Employee</th><th>Department / designation</th><th>Branch</th><th>Employment</th><th>Contact</th><th>Attendance today</th><th>Document expiries</th><th>ERP access</th><th>Status</th><th>Actions</th></tr></thead><tbody>
    <?php $__empty_1 = true; $__currentLoopData = $employees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $employee): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><tr onclick="if(!event.target.closest('a,button')) window.location='<?php echo e(route('app.employees.show',$employee)); ?>'" class="cursor-pointer"><td><div class="flex items-center gap-3"><span class="grid h-10 w-10 place-items-center rounded-xl bg-emerald-50 font-bold text-emerald-700"><?php echo e(strtoupper(substr($employee->first_name,0,1).substr($employee->last_name??'',0,1))); ?></span><div><a href="<?php echo e(route('app.employees.show',$employee)); ?>" class="font-bold text-slate-900 hover:text-emerald-700"><?php echo e($employee->display_name ?: $employee->full_name); ?></a><small><?php echo e($employee->employee_code); ?></small></div></div></td><td><?php echo e($employee->department?->name ?? 'No department'); ?><small><?php echo e($employee->designation ?: 'No designation'); ?></small></td><td><?php echo e($employee->branch?->name ?? '—'); ?></td><td><?php echo e(ucfirst(str_replace('_',' ',$employee->employment_type))); ?><small>Joined <?php echo e($employee->joining_date?->format('d M Y') ?? '—'); ?></small></td><td><?php echo e($employee->mobile ?: '—'); ?><small><?php echo e($employee->email ?: 'No work email'); ?></small></td><td><?php ($todayAttendance=$employee->attendanceRecords->first()); ?> <?php if($todayAttendance): ?><span class="rounded-full bg-emerald-50 px-2.5 py-1 text-[10px] font-bold uppercase text-emerald-700"><?php echo e(str_replace('_',' ',$todayAttendance->status)); ?></span><?php else: ?><span class="rounded-full bg-amber-50 px-2.5 py-1 text-[10px] font-bold text-amber-700">Not checked in</span><?php endif; ?></td><td><?php ($nextExpiry=$employee->documents->whereNotNull('expiry_date')->sortBy('expiry_date')->first()); ?> <?php if($nextExpiry): ?><span class="text-xs font-bold <?php echo e($nextExpiry->expiry_date->isPast() ? 'text-rose-700' : 'text-amber-700'); ?>"><?php echo e(ucfirst(str_replace('_',' ',$nextExpiry->document_type))); ?></span><small><?php echo e($nextExpiry->expiry_date->format('d M Y')); ?></small><?php else: ?><span class="text-xs text-slate-400">No tracked expiry</span><?php endif; ?></td><td><?php if($employee->user): ?><span class="rounded-full bg-emerald-50 px-2.5 py-1 text-[10px] font-bold text-emerald-700">Active</span><?php elseif(auth()->user()->hasPermission('employees.edit')): ?><a href="<?php echo e(route('app.employees.give_access',$employee)); ?>" class="text-xs font-bold text-emerald-700">Create login</a><?php else: ?><span class="text-xs text-slate-400">No login</span><?php endif; ?></td><td><span class="rounded-full bg-slate-100 px-2.5 py-1 text-[10px] font-bold uppercase"><?php echo e(str_replace('_',' ',$employee->status)); ?></span></td><td><a href="<?php echo e(route('app.employees.show',$employee)); ?>" class="text-xs font-bold text-emerald-700">Employee 360</a></td></tr>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><tr><td colspan="10" class="py-14 text-center"><strong>No employees match these filters</strong><small>Clear the filters or create the first employee record.</small><?php if(auth()->check() && auth()->user()->hasPermission('employees.create')): ?><a href="<?php echo e(route('app.employees.create')); ?>" class="mt-3 inline-block rounded-xl bg-emerald-600 px-4 py-2 text-xs font-bold text-white">Create employee</a><?php endif; ?></td></tr><?php endif; ?>
    </tbody></table></div><div class="border-t border-slate-200 p-4"><?php echo e($employees->links()); ?></div></section>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\typingcenter\resources\views\tenant\hr\employees\index.blade.php ENDPATH**/ ?>