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

<div class="main">

    <div class="header">Kas Masuk (Vendor)</div>

    <!-- FORM -->
    <div class="card">

        <h3>Tambah Kas Masuk</h3>

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

            <div class="form-group">
                <input type="number" name="jumlah" placeholder="Jumlah (Rp)" required>
            </div>

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

            <div class="form-group">
                <textarea name="keterangan" placeholder="Keterangan (misal: Sponsor Event)"></textarea>
            </div>

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

        </form>

    </div>

    <!-- TABLE -->
    <div class="card" style="margin-top:20px;">

        <h3>Data Kas Masuk</h3>

        <table class="table">
            <thead>
                <tr>
                    <th>Tanggal</th>
                    <th>Jumlah</th>
                    <th>Keterangan</th>
                    <th>Aksi</th>
                </tr>
            </thead>

            <tbody>
                <?php foreach ($data as $d): ?>
                <tr>
                    <td><?= $d['tanggal'] ?></td>
                    <td>Rp <?= number_format($d['jumlah']) ?></td>
                    <td><?= $d['keterangan'] ?></td>
                    <td>
                        <a href="/membership/kas-masuk-edit?id=<?= $d['id'] ?>" 
                           class="btn btn-warning">
                           Edit
                        </a>
                    
                        <a href="/membership/kas-masuk-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'; ?>