<?php include 'template/header.php' ?>

<?php if ($mobile): ?>
    <div style="margin-top: 50px;">
        <?php
        $p_query = $_GET['p'];
        if (!isset($p_query)) {
            ?>
            <div style="padding: 20px 0; background-color:var(--secondary-color);">
                <div
                    style="width: 90%; margin: 0 auto 10px auto; color: var(--primary-color); font-family: Teko-SemiBold; text-align: center; font-size: 24px;">
                    PROMO
                </div>

                <table width="100%" style="margin: 20px auto;">
                    <tbody>
                        <?php
                        $promo = mysqli_query($koneksi, "SELECT * FROM promosi");

                        while ($d = mysqli_fetch_assoc($promo)): ?>
                            <tr style="height: 150px; background-color: var(--secondary-color); display: flex; margin-bottom: 6px; padding: 2% 5%; cursor: pointer;"
                                onclick="window.location='promo?p=<?= $d['id_promosi'] ?>'">
                                <td style="width: 50%; padding-right: 10px;">
                                    <div style="font-weight: 500; font-size: 13px; padding-top: 10px;">
                                        <?= $d['judul_promosi']; ?>
                                    </div>

                                    <div style="font-size: 11px; padding-top: 20px;">
                                        <a href="promo?p=<?= $d['id_promosi'] ?>"
                                            style="background-color: var(--primary-color); color: #001739; padding: 5px 16px; border-radius: 12px;">
                                            INFO DETAIL
                                        </a>
                                    </div>
                                </td>
                                <td style="width: 50%; margin: auto 0 auto auto;">
                                    <img src="asset/img/<?= $d['gambar_promosi'] ?>" style="width: 100%; border-radius: 4px;">
                                </td>
                            </tr>
                        <?php endwhile; ?>
                    </tbody>
                </table>
            </div>

            <?php
        } else {
            $p_get = mysqli_query($koneksi, "SELECT * FROM promosi WHERE id_promosi = '$p_query'");
            $item = mysqli_fetch_assoc($p_get);

            ?>
            <div style="padding-bottom: 40px; background-color: var(--secondary-color);">
                <div style="background-color:var(--secondary-color);">
                    <div>
                        <img src="asset/img/<?= $item['gambar_promosi'] ?>" style="width: 100%;">
                    </div>

                    <div
                        style="font-weight: 500; font-size: 16px; padding: 10px 20px 6px 20px; text-align: center; margin-bottom: 30px;">
                        <?= $item['judul_promosi']; ?>
                    </div>

                    <div style="font-size: 13px; width: 90%; margin: 0 auto; padding-bottom: 20px;">
                        <?= $item['deskripsi_promosi']; ?>
                    </div>
                </div>
            </div>
        <?php }
        ?>
    </div>
<?php else: ?>
    <div style="margin-top: 170px;">
        <div class="background-top" style="padding: 30px 0 50px 0;">
            <div style="width: 95%; margin: 0 auto; max-width: 1280px;">
                <div
                    style="margin-bottom: 20px; color: var(--primary-color); font-family: Teko-SemiBold; font-size: 24px; text-align: center;">
                    PROMO
                </div>
                <div
                    style="background-color: var(--tertiary-color); color: #fff; box-shadow: 1px .125rem .5rem rgba(0, 0, 0, .3); padding-top: 20px;">
                    <ul style="list-style-type: none; padding: 0; margin-bottom: 0;">
                        <?php
                        $promo = mysqli_query($koneksi, "SELECT * FROM promosi");

                        while ($d = mysqli_fetch_assoc($promo)): ?>
                            <li
                                style="display: inline-block; background-color: var(--secondary-color); margin: 0 1% 2% 1%; text-align: center; padding: 0; border-radius: 8px; width: 47.8%;">
                                <img src="asset/img/<?= $d['gambar_promosi'] ?>"
                                    style="width: 100%; border-top-left-radius: 8px; border-top-right-radius: 8px;">
                                <div style="padding: 15px 20px; display: flex;">
                                    <div style="text-align: left; font-size: 18px; margin-right: 15px;">
                                        <?= $d['judul_promosi']; ?>
                                    </div>
                                    <a href="promo?p=<?= $d['id_promosi'] ?>" class="register-btn"
                                        style="background-color: var(--primary-color); color: #FFFFFF; margin: auto 0 auto auto; border-radius: 20px; transition: all .3s ease; text-align: center; padding: 6px 20px; font-size: 15px;">
                                        Klik Untuk Info Lebih Lanjut
                                    </a>
                                </div>
                            </li>
                        <?php endwhile; ?>
                    </ul>
                </div>
            </div>
        </div>
    </div>
<?php endif; ?>
<?php include 'template/footer.php'; ?>