<?php
require '../../config.php';
session_start();
load('middleware','user');
$query_deposit = $db->query("SELECT * FROM deposit WHERE username='{$_SESSION['user']['username']}' ORDER BY id DESC");
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">Riwayat Deposit</h4>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-striped table-dark table-bordered table-hover dataTable no-footer"  id="tbb">
                        <thead>
                        <tr>
                            <th>Tanggal</th>
                            <th>Order ID</th>
                            <th>Layanan</th>
                            <th>Get Saldo</th>
                            <th>Status</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 
                        while($fetch = mysqli_fetch_assoc($query_deposit)):
                        ?>
                        <tr>
                            <td><?= $fetch['date_create'];?></td>
                            <td><a href="<?= base_url('account/deposit/invoice?no='.$fetch['order_id']);?>">#<?= $fetch['order_id'];?></a></td>
                            <td><?= $fetch['layanan'];?></td>
                            <td>Rp. <?= number_format($fetch['get_saldo'],0,',','.');?></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;?>"><?= $stts;?></span></td>
                        </tr>
                        <?php endwhile; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<?php require '../../layouts/footer-admin.php';?>
<script>
    $(document).ready(function(){
        $("#tbb").dataTable();
    })
</script>