<div class="main-content">
  <div class="container-fluid" style="margin-top: 50px;">

<h2><i class="bi bi-calendar2-week"></i> Template 4: Kalender Dialog Kinerja</h2>

<form method="post" action="<?= base_url("dialog_kinerja/save/{$pegawai_id}/4") ?>">
  <div class="card mb-4">
    <div class="card-body">
      <p><strong>OPD:</strong> <?= htmlspecialchars($pegawai->unor_induk_nama ?? '-') ?></p>
      <p><strong>Tahun:</strong> <?= date('Y') ?></p>
    </div>
  </div>

  <div class="card mb-4">
    <div class="card-header bg-info text-white">Jadwal Dialog</div>
    <div class="card-body">
      <div class="table-responsive">
        <table class="table table-bordered">
          <thead>
            <tr>
              <th>Bulan</th>
              <th>Jenis Dialog</th>
              <th>Peserta</th>
              <th>Fokus</th>
              <th>Status</th>
            </tr>
          </thead>
          <tbody>
            <?php
            $kalender = [
                ['Januari', 'Dialog Penetapan Ekspektasi', 'Semua pegawai', 'Penyusunan SKP'],
                ['Februari', 'Dialog Monitoring', 'Semua pejabat', 'Review progress'],
                ['Maret', 'Dialog Coaching', 'Pejabat dan staff', 'Pengembangan kompetensi'],
                ['April', 'Dialog Evaluasi Triwulan I', 'Semua pegawai', 'Evaluasi capaian Q1'],
                ['Mei', 'Dialog Monitoring', 'Semua pejabat', 'Review progress'],
                ['Juni', 'Dialog Evaluasi Semester I', 'Semua pegawai', 'Evaluasi semester I'],
                ['Juli', 'Dialog Coaching', 'Pejabat dan staff', 'Pengembangan lanjutan'],
                ['Agustus', 'Dialog Monitoring', 'Semua pejabat', 'Review progress'],
                ['September', 'Dialog Evaluasi Triwulan III', 'Semua pegawai', 'Evaluasi capaian Q3'],
                ['Oktober', 'Dialog Persiapan Akhir Tahun', 'Semua pegawai', 'Persiapan evaluasi'],
                ['November', 'Dialog Coaching Akhir', 'Pejabat dan staff', 'Persiapan assessment'],
                ['Desember', 'Dialog Evaluasi Tahunan', 'Semua pegawai', 'Evaluasi tahunan']
            ];
            foreach ($kalender as $i => $row):
                $idx = $i + 1;
            ?>
            <tr>
              <td><?= $row[0] ?></td>
              <td><?= $row[1] ?></td>
              <td><?= $row[2] ?></td>
              <td><?= $row[3] ?></td>
              <td>
                <select name="kalender_status_<?= $idx ?>" class="form-control">
                  <option value="Planned" <?= ($form_data["kalender_status_{$idx}"] ?? '') == 'Planned' ? 'selected' : '' ?>>Planned</option>
                  <option value="In Progress" <?= ($form_data["kalender_status_{$idx}"] ?? '') == 'In Progress' ? 'selected' : '' ?>>In Progress</option>
                  <option value="Completed" <?= ($form_data["kalender_status_{$idx}"] ?? '') == 'Completed' ? 'selected' : '' ?>>Completed</option>
                </select>
              </td>
            </tr>
            <?php endforeach; ?>
          </tbody>
        </table>
      </div>
    </div>
  </div>

  <div class="d-flex gap-2 mt-3">
    <a href="<?= base_url("dialog_kinerja/template/{$pegawai_id}/3") ?>" class="btn btn-secondary">Back</a>
    <button type="submit" class="btn btn-primary">Simpan & Lanjut</button>
  </div>
</form>