<?php $employees = db()->query("SELECT id, full_name FROM employees ORDER BY full_name")->fetchAll(); ?>
<div class="row">
  <div class="col-md-6 mb-3"><label class="form-label">Empleado</label>
    <select name="employee_id" class="form-select" required>
      <option value="">Seleccione</option>
      <?php foreach ($employees as $emp): ?>
      <option value="<?= e($emp['id']) ?>" <?= (($item['employee_id'] ?? '') == $emp['id']) ? 'selected' : '' ?>><?= e($emp['full_name']) ?></option>
      <?php endforeach; ?>
    </select>
  </div>
  <div class="col-md-3 mb-3"><label class="form-label">Tipo</label>
    <select name="leave_type" class="form-select">
      <?php foreach (['Vacaciones','Reposo','Permiso personal','Maternidad','Otro'] as $t): ?>
      <option value="<?= e($t) ?>" <?= (($item['leave_type'] ?? '') == $t) ? 'selected' : '' ?>><?= e($t) ?></option>
      <?php endforeach; ?>
    </select>
  </div>
  <div class="col-md-3 mb-3"><label class="form-label">Estado</label>
    <select name="status" class="form-select">
      <?php foreach (['Pendiente','Aprobado','Rechazado'] as $s): ?>
      <option value="<?= e($s) ?>" <?= (($item['status'] ?? 'Pendiente') == $s) ? 'selected' : '' ?>><?= e($s) ?></option>
      <?php endforeach; ?>
    </select>
  </div>
  <div class="col-md-3 mb-3"><label class="form-label">Desde</label><input type="date" name="start_date" class="form-control" required value="<?= e($item['start_date'] ?? date('Y-m-d')) ?>"></div>
  <div class="col-md-3 mb-3"><label class="form-label">Hasta</label><input type="date" name="end_date" class="form-control" required value="<?= e($item['end_date'] ?? date('Y-m-d')) ?>"></div>
  <div class="col-md-2 mb-3"><label class="form-label">Con goce</label>
    <select name="paid_leave" class="form-select">
      <option value="1" <?= (($item['paid_leave'] ?? 1) == 1) ? 'selected' : '' ?>>Sí</option>
      <option value="0" <?= (($item['paid_leave'] ?? 1) == 0) ? 'selected' : '' ?>>No</option>
    </select>
  </div>
  <div class="col-md-12 mb-3"><label class="form-label">Observación</label><input name="reason" class="form-control" value="<?= e($item['reason'] ?? '') ?>"></div>
</div>
