<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>
<div class="page-header"><div><h1><i class="bi bi-people me-2 text-primary"></i>Workforce Management</h1></div><a href="<?= base_url('employees/create') ?>" class="btn btn-fm-primary btn-sm"><i class="bi bi-plus-lg me-1"></i>Add Employee</a></div>
<div class="fm-card"><div class="card-header-fm"><h5><i class="bi bi-people"></i>Employees (<?= count($employees) ?>)</h5></div>
<div class="fm-card-body p-0"><div class="table-responsive">
<table class="fm-table"><thead><tr><th>Code</th><th>Name</th><th>Designation</th><th>Department</th><th>Facility</th><th>Shift</th><th>Rate/hr</th><th>Status</th><th>Actions</th></tr></thead><tbody>
<?php foreach($employees as $e): ?><tr>
<td class="fw-semibold small"><?= esc($e['emp_code']) ?></td>
<td><div class="d-flex align-items-center gap-2"><div class="user-avatar"><?= strtoupper(substr($e['name']??'?',0,2)) ?></div><div><div class="fw-semibold small"><?= esc($e['name']??'N/A') ?></div><div class="x-small text-muted"><?= esc($e['email']??'') ?></div></div></div></td>
<td class="small"><?= esc($e['designation']) ?></td>
<td class="small"><?= esc($e['department']) ?></td>
<td class="small text-muted"><?= esc($e['facility_name']??'—') ?></td>
<td class="small"><?= substr($e['shift_start'],0,5) ?> – <?= substr($e['shift_end'],0,5) ?></td>
<td class="small"><?= $currency ?> <?= number_format($e['hourly_rate'],2) ?></td>
<td><span class="fm-badge badge-status-<?= esc($e['status']) ?>"><?= ucfirst(str_replace('_',' ',$e['status'])) ?></span></td>
<td><div class="d-flex gap-1">
<a href="<?= base_url('employees/view/'.$e['id']) ?>" class="btn-action bg-primary bg-opacity-10 text-primary"><i class="bi bi-eye"></i></a>
<a href="<?= base_url('employees/edit/'.$e['id']) ?>" class="btn-action bg-warning bg-opacity-10 text-warning"><i class="bi bi-pencil"></i></a>
<a href="<?= base_url('employees/delete/'.$e['id']) ?>" class="btn-action bg-danger bg-opacity-10 text-danger" data-confirm="Deactivate this employee?"><i class="bi bi-person-x"></i></a>
</div></td></tr><?php endforeach; ?>
<?php if(empty($employees)): ?><tr><td colspan="9" class="text-center py-4 text-muted">No employees found</td></tr><?php endif; ?>
</tbody></table></div></div></div>
<?= $this->endSection() ?>
