<?php
require __DIR__ . '/../layout/header.php';
require __DIR__ . '/../layout/sidebar.php';
?>

<div class="main">

    <div class="header">Kelola Lowongan Pekerjaan</div>

    <!-- FORM TAMBAH -->
    <div class="card">
        <h3>Tambah Lowongan</h3>

        <form action="/membership/lowongan-store" method="POST">

            <div class="form-group">
                <input type="text" name="judul" placeholder="Judul Pekerjaan" required>
            </div>

            <div class="form-group">
                <input type="text" name="perusahaan" placeholder="Perusahaan" required>
            </div>

            <div class="form-group">
                <input type="text" name="lokasi" placeholder="Lokasi" required>
            </div>

            <div class="form-group">
                <textarea name="deskripsi" placeholder="Deskripsi"></textarea>
            </div>

            <div class="form-group">
                <input type="date" name="deadline" required>
            </div>

            <button class="btn btn-primary">Simpan</button>

        </form>
    </div>

    <!-- LIST DATA -->
    <div class="card" style="margin-top:20px;">
        <h3>Daftar Lowongan</h3>

        <table class="table">
            <thead>
                <tr>
                    <th>Judul</th>
                    <th>Perusahaan</th>
                    <th>Lokasi</th>
                    <th>Deadline</th>
                    <th>Aksi</th>
                </tr>
            </thead>

            <tbody>
                <?php foreach ($data as $d): ?>
                <tr>
                    <td><?= $d['judul'] ?></td>
                    <td><?= $d['perusahaan'] ?></td>
                    <td><?= $d['lokasi'] ?></td>
                    <td><?= $d['deadline'] ?></td>
                    <td>
                        <a href="/membership/lowongan-delete?id=<?= $d['id'] ?>" 
                           class="btn btn-danger"
                           onclick="return confirm('Hapus data?')">
                           Hapus
                        </a>
                    </td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>

    </div>

</div>

<?php require __DIR__ . '/../layout/footer.php'; ?>