<?php
if ($c['level'] == "superadmin") {
?>

<div class="page-breadcrumb">
    <div class="row">
        <div class="col-5 align-self-center">
            <h4 class="page-title">Jackpot</h4>
        </div>
        <div class="col-7 align-self-center">
            <div class="d-flex align-items-center justify-content-end">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">Jackpot</a></li>
                        <li class="breadcrumb-item active">Management</li>
                    </ol>
                </nav>
            </div>
        </div>
    </div>
</div>

<div class="container-fluid">
    <div class="row">

        <!-- FORM INPUT -->
        <div class="col-lg-4">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">Input Jackpot</h4>

                    <form method="POST" action="?page=tambah_jackpot" enctype="multipart/form-data" class="form p-t-20">

                        <!-- GAME NAME -->
                        <div class="form-group">
                            <label>Game Name</label>
                            <div class="input-group mb-3">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="ti-game"></i></span>
                                </div>
                                <input type="text" name="game_name" class="form-control" required>
                            </div>
                        </div>

                        <!-- PROVIDER -->
                        <div class="form-group">
                            <label>Provider</label>
                            <div class="input-group mb-3">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="ti-briefcase"></i></span>
                                </div>
                                <input type="text" name="provider" class="form-control" required>
                            </div>
                        </div>

                        <!-- IMAGE -->
                        <div class="form-group">
                            <label>Image</label>
                            <div class="input-group mb-3">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="ti-image"></i></span>
                                </div>
                                <input type="file" name="image" class="form-control" required>
                            </div>
                        </div>

                        <!-- JACKPOT -->
                        <div class="form-group">
                            <label>Jackpot Amount</label>
                            <div class="input-group mb-3">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="ti-money"></i></span>
                                </div>
                                <input type="number" name="jackpot_amount" class="form-control" required>
                            </div>
                        </div>

                        <!-- PLAYER MASK -->
                        <div class="form-group">
                            <label>Player Mask</label>
                            <div class="input-group mb-3">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="ti-user"></i></span>
                                </div>
                                <input type="text" name="player_mask" class="form-control" placeholder="****123">
                            </div>
                        </div>

                        <button type="submit" name="upload" class="btn btn-success m-r-10">
                            <i class="ti-save"></i> Submit
                        </button>
                        <button type="reset" class="btn btn-dark">
                            Cancel
                        </button>
                    </form>

                </div>
            </div>
        </div>

<!-- TABLE -->
<div class="col-lg-8">
    <div class="card">
        <div class="card-body">
            <h4 class="card-title">Daftar Jackpot</h4>
        </div>
        <div class="table-responsive">
            <table id="zero_config" class="table table-striped table-bordered">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Game</th>
                        <th>Provider</th>
                        <th>Jackpot</th>
                        <th>Player</th>
                        <th>Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    $no = 1;
                    $q = mysqli_query($koneksi, "SELECT * FROM tb_jackpot ORDER BY id DESC");
                    while ($d = mysqli_fetch_array($q)) {
                    ?>
                    <tr>
                        <td><?= $no++; ?></td>
                        <td><?= htmlspecialchars($d['game_name']); ?></td>
                        <td><?= htmlspecialchars($d['provider']); ?></td>
                        <td>Rp <?= number_format($d['jackpot_amount'], 0, ',', '.'); ?></td>
                        <td><?= htmlspecialchars($d['player_mask']); ?></td>
                        <td>
                            <a href="?page=edit_jackpot&id=<?= $d['id']; ?>" class="btn btn-warning btn-sm">
                                Edit
                            </a>
                            <a href="?page=hapus_jackpot&id=<?= $d['id']; ?>" 
                               class="btn btn-danger btn-sm"
                               onclick="return confirm('Yakin hapus data jackpot?')">
                                Hapus
                            </a>
                        </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>

                </div>
            </div>
        </div>

    </div>
</div>

<?php
}else{
    echo "<script>window.location='?page=dashboard'</script>";
}
?>


