<?php include_once __DIR__ . '/../layouts/head.php'; ?>
    <div class="container py-4" style="max-width: 1350px; width: 100%;">
      <div class="row">
        <div class="col-lg-12">
          <div class="shadow-sm bg-white rounded overflow-hidden border">
            <div class="p-0">
              <div class="row px-0 m-0">
			
				<?php include_once __DIR__ . '/../layouts/menu_body.php'; ?>
				
					<div class="col-12 col-md-9 px-0">
						<div class="tab-content" id="v-pills-tabContent">
						
							<!-- wates -->
							<div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">
								<div class="p-4">
									<div class="mb-4">
										<h5 class="mb-0 fw-bold">Tambah Mahasiswa</h5>
									</div>

<?php if (isset($_GET['success'])): ?>
  <div class="alert alert-success">Data mahasiswa berhasil ditambahkan.</div>
<?php endif; ?>

<form method="post" action="/dashboard/admin-add_mahasiswa">
  <div class="row g-3">
    <div class="col-md-6">
      <label>NIM</label>
      <input type="text" name="nim" class="form-control" required>
    </div>
    <div class="col-md-6">
      <label>Nama</label>
      <input type="text" name="nama" class="form-control" required>
    </div>
    <div class="col-md-6">
      <label>ID Prodi</label>
      <input type="text" name="id_prodi" class="form-control" required>
    </div>
    <div class="col-md-6">
      <label>Alamat</label>
      <input type="text" name="alamat" class="form-control">
    </div>
    <div class="col-md-6">
      <label>Telpon</label>
      <input type="text" name="telpon" class="form-control">
    </div>
    <div class="col-md-6">
      <label>Tempat Lahir</label>
      <input type="text" name="tempat_lahir" class="form-control">
    </div>
    <div class="col-md-6">
      <label>Tanggal Lahir</label>
      <input type="date" name="tgl_lahir" class="form-control">
    </div>
    <div class="col-md-6">
      <label>Agama</label>
      <select name="agama" class="form-control">
        <option value="Islam">Islam</option>
        <option value="Kristen">Kristen</option>
        <option value="Katolik">Katolik</option>
        <option value="Hindu">Hindu</option>
        <option value="Buddha">Buddha</option>
        <option value="Konghucu">Konghucu</option>
      </select>
    </div>
    <div class="col-md-6">
      <label>Jenis Kelamin</label>
      <select name="jenis_kelamin" class="form-control">
        <option value="Laki-laki">Laki-laki</option>
        <option value="Perempuan">Perempuan</option>
      </select>
    </div>
    <div class="col-md-6">
      <label>Tahun Masuk</label>
      <input type="text" name="tahun_masuk" class="form-control">
    </div>
    <div class="col-md-6">
      <label>Kurikulum</label>
      <select name="id_kurikulum" class="form-control">
        <?php foreach ($kurikulums as $k): ?>
          <option value="<?= $k['id_kurikulum']; ?>"><?= $k['nama_kurikulum']; ?></option>
        <?php endforeach; ?>
      </select>
    </div>
    <div class="col-12">
      <button type="submit" class="btn btn-primary">Simpan Mahasiswa</button>
    </div>
  </div>
</form>

<hr class="my-4">

<h5 class="mb-3 fw-bold">Daftar Mahasiswa (maks. 20 data)</h5>

<form method="get" action="/dashboard/admin-add_mahasiswa" class="mb-3">
  <div class="input-group" style="max-width: 400px;">
    <input type="text" name="search" class="form-control" placeholder="Cari NIM atau Nama" value="<?= isset($_GET['search']) ? htmlspecialchars($_GET['search']) : '' ?>">
    <button class="btn btn-outline-secondary" type="submit">Cari</button>
  </div>
</form>

<div class="table-responsive">
  <table class="table table-bordered table-hover">
    <thead class="table-light">
      <tr>
        <th>No</th>
        <th>NIM</th>
        <th>Nama</th>
        <th>Prodi</th>
        <th>Kurikulum</th>
      </tr>
    </thead>
    <tbody>
      <?php if (!empty($mahasiswa)): ?>
        <?php $no = 1; foreach ($mahasiswa as $m): ?>
          <tr>
            <td><?= $no++; ?></td>
            <td><?= htmlspecialchars($m['nim']) ?></td>
            <td><?= htmlspecialchars($m['nama']) ?></td>
            <td><?= htmlspecialchars($m['id_prodi']) ?></td>
            <td><?= htmlspecialchars($m['nama_kurikulum']) ?></td>
          </tr>
        <?php endforeach; ?>
      <?php else: ?>
        <tr><td colspan="5" class="text-center">Data mahasiswa tidak ditemukan</td></tr>
      <?php endif; ?>
    </tbody>
  </table>
</div>



								</div>
							</div>
						</div>
					</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
	
<?php include_once __DIR__ . '/../layouts/footer.php'; ?>