<?php
session_start();
require '../config.php';
require '../layouts/header.php';
?>
<div class="row justify-content-center">
    <div class="col-md-9 col-12 mb-5">
        <div class="card bg-dark shadow">
            <div class="card-header">
                <h4 class="card-title">Jadwal Gift Skin</h4>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table" id="tbb">
                        <thead>
                        <tr>
                            <th>Order Date</th>
                            <th>User ID</th>
                            <th>Nickname</th>
                            <th>Name Skin</th>
                            <th>Gift Date</th>
                            <th>Status</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 
                        $no = 1;
                        $query = mysqli_query($db, "SELECT * FROM gift_skin");
                        while($fetch = mysqli_fetch_assoc($query)): 
                        ?>
                        <tr>
                            <td><?= $fetch['date_create'];?></td>
                            <td><?= substr($fetch['userid'],0,-4); ?>xxxx</td>
                            <td><?= $fetch['nickname'];?></td>
                            <td><?= $fetch['name_skin'];?></td>
                            <td><?= $fetch['date_gift'];?></td>
                            <?php if($fetch['status'] == "Pending"){
                                $bg = "warning";
                                $stts = "PENDING";
                            }else if($fetch['status'] == "Waiting"){
                                $bg = "secondary";
                                $stts = "WAITING";
                            }else if($fetch['status'] == "Processing"){
                                $bg = "info";
                                $stts = "PROCESSING";
                            }else if($fetch['status'] == "Success"){
                                $bg = "success";
                                $stts = "SUCCESS";
                            }else if($fetch['status'] == "Canceled"){
                                $bg = "danger";
                                $stts = "CANCELED";
                            }
                            ?>
                            <td><span class="badge p-2 bg-<?=$bg;?> badge-pill"><?= $stts;?></span></td>
                        </tr>
                        <?php endwhile; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<?php include '../layouts/footer.php';?>
<script>
    $(document).ready(function(){
        $("#tbb").dataTable();
    })
</script>