<?= $this->extend('layouts/admin') ?>
<?= $this->section('content') ?>

<h1 class="section-title mb-4">Laporan & Ekspor</h1>

<div class="card-stt p-4" style="max-width:640px;">
  <h6 class="fw-semibold mb-3 border-bottom pb-2">
    <i class="bi bi-file-earmark-spreadsheet me-2 text-gold"></i>Ekspor Dokumen Terbit (CSV)
  </h6>
  <p class="text-muted small mb-3">
    Ekspor semua dokumen yang telah diterbitkan. Cocok untuk laporan akreditasi BAN-PT.
  </p>

  <form method="get" action="<?= base_url('admin/reports/export') ?>">
    <div class="row g-3">
      <div class="col-md-6">
        <label class="form-label small fw-semibold">Program Studi</label>
        <select name="program" class="form-select form-select-sm">
          <option value="">Semua Prodi</option>
          <?php foreach ($programs as $p): ?>
            <option value="<?= $p['id'] ?>"><?= esc($p['name']) ?></option>
          <?php endforeach; ?>
        </select>
      </div>
      <div class="col-md-6">
        <label class="form-label small fw-semibold">Jenis Dokumen</label>
        <select name="type" class="form-select form-select-sm">
          <option value="">Semua Jenis</option>
          <?php foreach ($types as $t): ?>
            <option value="<?= $t['id'] ?>"><?= esc($t['name']) ?></option>
          <?php endforeach; ?>
        </select>
      </div>
      <div class="col-md-3">
        <label class="form-label small fw-semibold">Tahun Dari</label>
        <input type="number" name="year_from" class="form-control form-control-sm"
               min="1990" max="<?= date('Y') ?>" placeholder="<?= date('Y') - 5 ?>">
      </div>
      <div class="col-md-3">
        <label class="form-label small fw-semibold">Tahun Sampai</label>
        <input type="number" name="year_to" class="form-control form-control-sm"
               min="1990" max="<?= date('Y') ?>" placeholder="<?= date('Y') ?>">
      </div>
      <div class="col-12">
        <button type="submit" class="btn btn-primary">
          <i class="bi bi-download me-2"></i>Unduh CSV
        </button>
      </div>
    </div>
  </form>
</div>

<?= $this->endSection() ?>
