<?php include('../includes/db_conx.php');

isset($_SESSION['detect_login']);
if (!isset($_SESSION['detect_login'])) {
    header("location: ../online/customer_login");
    exit();
} else {
    $id = $_SESSION['id'];
    // echo $id;
    // get all the varible from the database for personal information 
    include('../includes/cus-info.php');

    include('../includes/dash-header.php');
}
?>

<body>
    <?php
    include('../includes/side-nav.php');
    ?>
    <div class="main-content" id="panel">
        <!-- Topnav -->
        <?php
        include('../includes/top-nav.php');
        ?>

        <div class="header pb-4">
            <div class="container-fluid">
                <div class="header-body">
                </div>
            </div>
        </div>
        <br>
        <br>
        <!-- header end -->

        <div class="container-fluid mt--6">
            <div class="content-wrapper">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card bg-white">
                            <div class="card-body">
                                <div class="">
                                    <h3 class="">Transaction history</h3>
                                    <p class="mt-0 mb-5">This is your account statement page, always keep track for your account history</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card bg-white shadow">
                            <div class="card-header bg-transparent">
                                <div class="row align-items-center">
                                    <div class="col-8">
                                        <!-- Title -->
                                        <h3 class="mb-0 text-dark">Account timeline</h3>
                                    </div>
                                    <!-- <div class="col-4 text-right">
              <a href="javascript:void;" onclick="window.print();" class="btn btn-sm btn-neutral">Print</a>
            </div> -->
                                </div>
                            </div>

                            <div class="card transaction-card">
                                <div class="transaction-card-header d-flex flex-wrap justify-content-between align-items-center">
                                    <div>
                                        <div class="transaction-title">Transaction History</div>
                                        <div class="transaction-subtitle">Latest account activity</div>
                                    </div>

                                </div>


                                <div class="my-4">
                                    <?php
                                    while ($row_trans = mysqli_fetch_assoc($query_trans)) {
                                        $name_bank = $row_trans['name_bank'];
                                        $b_name = $row_trans['b_name'];
                                        $b_acc_no = $row_trans['b_acc_no'];
                                        $amount = $row_trans['amount'];
                                        $t_time = $row_trans['t_time'];
                                        $ref = $row_trans['ref'];
                                        $trans_status = $row_trans['trans_status'];
                                        $mode = $row_trans['mode'];
                                        $description = $row_trans['description'];


                                    ?>

                                        <?php
                                        if ($trans_no <= 0) {
                                            echo '   <div class="p-4 text-center"
                                style="background:#f8f9fa;border-radius:8px;border:1px solid #e3e3e3;">
                                <img src="https://cdn-icons-png.flaticon.com/512/4076/4076500.png"
                                    width="70" style="opacity:0.7;">
                                <h5 class="mt-3">No Results</h5>
                                <p class="text-muted mb-0">Try a different search or clear the filters.</p>
                            </div>';
                                        } else {




                                        ?>
                                            <!-- 1 -->
                                            <div class="timeline-block">

                                                <div class="timeline-content">
                                                    <div class="txn-meta">
                                                        <span class="txn-ref">#</span>
                                                        <span class="txn-date"><?= $t_time ?></span>
                                                    </div>
                                                    <div class="d-flex justify-content-between align-items-center mb-1">
                                                        <div>
                                                            <div class="txn-amount"><?= $currency ?> <?= number_format($amount, 2) ?> <span class="text-muted fw-normal text-sm">USD</span></div>
                                                            <div class="txn-account">Acct: <?= $b_acc_no ?></div>
                                                        </div>
                                                        <div class="txn-tags text-end">
                                                            <?php
                                                            if ($mode == 'deposit') {
                                                                echo '<span class="badge rounded-pill badge-soft-credit">
                                                                        Credit
                                                                    </span>';
                                                            } else {
                                                                echo '<span class="badge rounded-pill badge-soft-debit">
                                                                        Debit
                                                                    </span>';
                                                            }

                                                            ?>

                                                            <span class="badge rounded-pill badge-soft-status">Successful</span>
                                                        </div>
                                                    </div>
                                                    <p class="txn-desc mb-0"> Desc: <?= $description ?></p>
                                                </div>
                                            </div>

                                    <?php
                                        }
                                    }

                                    ?>


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


                <!-- footer begin -->
                <footer class="footer pt-0">

                </footer>
            </div>
        </div>
        <?php
        include('../includes/dash_footer.php') ?>

</body>


<!-- -->

</html>

<script>
</script>
<script type="text/javascript">
    $('.preloader').fadeOut(1000);
</script>
<script type="text/javascript">
    "use strict";

    function sellVals() {
        var amount1 = $("#amount1").val();
        var asset_price1 = $("#asset_price1").find(":selected").text();
        var myarr1 = asset_price1.split("-");
        var dar1 = myarr1[1].split("<");
        var rate1 = parseFloat(dar1) * parseFloat(amount1 / 1);
        $("#gain1").val(rate1);
    }
    $("#amount1").change(sellVals);
    sellVals();
    $("#asset_price1").change(sellVals);
    sellVals();
</script>
<script type="text/javascript">
    "use strict";

    function displayVals() {
        var amount = $("#amount").val();
        var asset_price = $("#asset_price").find(":selected").text();
        var myarr = asset_price.split("-");
        var dar = myarr[1].split("<");
        var rate = parseFloat(amount * 1) / parseFloat(dar);
        $("#gain").val(rate);
    }
    $("#amount").change(displayVals);
    displayVals();
    $("#asset_price").change(displayVals);
    displayVals();
</script>