<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>
<div class="page-header"><div><h1><i class="bi bi-pencil me-2 text-primary"></i>Edit Employee</h1></div></div>
<?= form_open(base_url('employees/update/'.$emp['id'])) ?>
<div class="row g-3"><div class="col-lg-8"><div class="fm-form-section"><h6>Employee Details</h6><div class="row g-3">
<div class="col-md-6"><label class="form-label">Facility</label><select name="facility_id" class="form-select"><option value="">— None —</option><?php foreach($facilities as $f): ?><option value="<?= $f['id'] ?>" <?= $emp['facility_id']==$f['id']?'selected':'' ?>><?= esc($f['name']) ?></option><?php endforeach; ?></select></div>
<div class="col-md-6"><label class="form-label">Status</label><select name="status" class="form-select"><?php foreach(['active','on_leave','inactive'] as $s): ?><option value="<?= $s ?>" <?= $emp['status']===$s?'selected':'' ?>><?= ucfirst(str_replace('_',' ',$s)) ?></option><?php endforeach; ?></select></div>
<div class="col-md-6"><label class="form-label">Designation *</label><input type="text" name="designation" class="form-control" value="<?= esc($emp['designation']) ?>" required></div>
<div class="col-md-6"><label class="form-label">Department *</label><input type="text" name="department" class="form-control" value="<?= esc($emp['department']) ?>" required></div>
<div class="col-md-3"><label class="form-label">Shift Start</label><input type="time" name="shift_start" class="form-control" value="<?= $emp['shift_start'] ?>"></div>
<div class="col-md-3"><label class="form-label">Shift End</label><input type="time" name="shift_end" class="form-control" value="<?= $emp['shift_end'] ?>"></div>
<div class="col-md-6"><label class="form-label">Hourly Rate (<?= $currency ?>)</label><input type="number" name="hourly_rate" step="0.01" class="form-control" value="<?= $emp['hourly_rate'] ?>"></div>
</div></div></div>
<div class="col-lg-4"><div class="fm-form-section"><h6>Actions</h6><button type="submit" class="btn btn-fm-primary w-100 mb-2">Save</button><a href="<?= base_url('employees/view/'.$emp['id']) ?>" class="btn btn-fm-outline w-100">Cancel</a></div></div></div>
<?= form_close() ?>
<?= $this->endSection() ?>
