<?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 -->

        <?php
        $sql_details = 'SELECT * FROM pay_details WHERE id =  1';
        $query_details = $db_conx->query($sql_details);
        $row_PD = mysqli_fetch_assoc($query_details);
        $details1 = $row_PD['details1'];
        $details2 = $row_PD['details2'];
        $details3 = $row_PD['details3'];
        $details4 = $row_PD['details4'];
        $details5 = $row_PD['details5'];
        $details6 = $row_PD['details6'];
        $PD_status = $row_PD['status'];
        $PD_image = $row_PD['image'];

        $sql_details2 = 'SELECT * FROM pay_details WHERE id =  2';
        $query_details2 = $db_conx->query($sql_details2);
        $row_PD2 = mysqli_fetch_assoc($query_details2);
        $details_c1 = $row_PD2['details1'];
        $details_c2 = $row_PD2['details2'];
        $details_c3 = $row_PD2['details3'];
        $details_c4 = $row_PD2['details4'];
        $details_c5 = $row_PD2['details5'];
        $details_c6 = $row_PD2['details6'];
        $PD_status_c = $row_PD2['status'];
        $PD_image_c = $row_PD2['image'];

        $sql_details3 = 'SELECT * FROM pay_details WHERE id =  3';
        $query_details3 = $db_conx->query($sql_details3);
        $row_PD3 = mysqli_fetch_assoc($query_details3);
        $details_s1 = $row_PD3['details1'];
        $details_s2 = $row_PD3['details2'];
        $details_s3 = $row_PD3['details3'];
        $details_s4 = $row_PD3['details4'];
        $details_s5 = $row_PD3['details5'];
        $details_s6 = $row_PD3['details6'];
        $PD_status_s = $row_PD3['status'];
        $PD_image_s = $row_PD3['image'];


        $sql_details4 = 'SELECT * FROM pay_details WHERE id =  4';
        $query_details4 = $db_conx->query($sql_details4);
        $row_PD4 = mysqli_fetch_assoc($query_details4);
        $details_p1 = $row_PD4['details1'];
        $details_p2 = $row_PD4['details2'];
        $details_p3 = $row_PD4['details3'];
        $details_p4 = $row_PD4['details4'];
        $details_p5 = $row_PD4['details5'];
        $details_p6 = $row_PD4['details6'];
        $PD_status_p = $row_PD4['status'];
        $PD_image_p = $row_PD4['image'];



        ?>

        <!-- Page content -->
        <div class="container-fluid mt--6">
            <div class="content-wrapper">
                <div class="row">
                    <?php
                    if ($PD_status == 1) {



                    ?>
                        <div class="col-md-4">
                            <div class="card">
                                <div class="card-body">
                                    <div class="row align-items-center">
                                        <div class="col-auto">
                                            <a href="bank_transfer" class="avatar avatar-xl">
                                                <img alt="Image placeholder" src="img/webmoney.png">
                                            </a>
                                        </div>
                                        <div class="col ml--2">
                                            <h4 class="mb-0 text-primary">
                                                <a>Fund Account</a>
                                            </h4>
                                            <!-- <p class="text-sm text-dark mb-0">Swift code: 5444</p> -->
                                            <p class="text-sm text-dark mb-0">Account number: <?= $details6 ?> </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    <?php   } ?>

                    <?php
                    if ($PD_status_c == 1) {



                    ?>

                        <div class="col-md-4">
                            <div class="card">
                                <!-- Card body -->
                                <div class="card-body">
                                    <div class="row align-items-center">
                                        <div class="col-auto">
                                            <!-- Avatar -->
                                            <a href="coinpayment" class="avatar avatar-xl">
                                                <img alt="Image placeholder" src="../asset/payment_gateways/coinpayment.png">
                                            </a>
                                        </div>
                                        <div class="col ml--2">
                                            <h4 class="mb-0 text-primary">
                                                <a href="coinpayment">CoinPayment</a>
                                            </h4>
                                            <p class="text-sm text-dark mb-0"><?= $details_c3 ?></p>
                                            <p class="text-sm text-dark mb-0"><?= $details_c4 ?></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    <?php   } ?>



                    <?php
                    if ($PD_status_s == 1) {



                    ?>


                        <div class="col-md-4">
                            <div class="card">
                                <!-- Card body -->
                                <div class="card-body">
                                    <div class="row align-items-center">
                                        <div class="col-auto">
                                            <!-- Avatar -->
                                            <a href="skrill" class="avatar avatar-xl">
                                                <img alt="Image placeholder" src="../asset/payment_gateways/skrill.png">
                                            </a>
                                        </div>
                                        <div class="col ml--2">
                                            <h4 class="mb-0 text-primary">
                                                <a href="skrill">Skrill</a>
                                            </h4>
                                            <p class="text-sm text-dark mb-0"><?= $details_s3 ?></p>
                                            <p class="text-sm text-dark mb-0"><?= $details_s4 ?></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    <?php   } ?>

                    <?php
                    if ($PD_status_p == 1) {



                    ?>


                        <div class="col-md-4">
                            <div class="card">
                                <!-- Card body -->
                                <div class="card-body">
                                    <div class="row align-items-center">
                                        <div class="col-auto">
                                            <!-- Avatar -->
                                            <a href="paypal" class="avatar avatar-xl">
                                                <img alt="Image placeholder" src="../asset/payment_gateways/paypal.png">
                                            </a>
                                        </div>
                                        <div class="col ml--2">
                                            <h4 class="mb-0 text-primary">
                                                <a href="paypal">PayPal</a>
                                            </h4>
                                            <p class="text-sm text-dark mb-0"><?= $details_p3 ?></p>
                                            <p class="text-sm text-dark mb-0"><?= $details_p4 ?></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    <?php   } ?>

                </div>
                <div class="card" id="other">
                    <div class="card-header header-elements-inline">
                        <h3 class="mb-0">Deposit logs</h3>
                    </div>
                    <div class="table-responsive py-4">
                        <table class="table table-flush" id="datatable-basic">
                            <thead class="">
                                <tr>
                                    <th>S/N</th>
                                    <th>Reference ID</th>
                                    <th>Amount</th>
                                    <th>Method</th>
                                    <th>Status</th>
                                    <th>Charge</th>
                                    <th>Created</th>
                                    <th>Last updated</th>
                                </tr>
                            </thead>


                            <tbody>
                                <?php
                                while ($row_trans = mysqli_fetch_assoc($query_trans_3)) {
                                    $bid = $row_trans['id'];
                                    $ref_id = $row_trans['ref_id'];
                                    $amount = $row_trans['amount'];
                                    $method = $row_trans['method'];
                                    $status = $row_trans['status'];
                                    $charge = $row_trans['charge'];
                                    $date_created = $row_trans['date_created'];
                                    $last_updated = $row_trans['last_updated'];
                                    $details = $row_trans['details'];


                                ?>


                                    <tr>
                                        <td><?= $bid ?>.</td>
                                        <td>#<?= $ref_id ?></td>
                                        <td><?= $currency ?><?= number_format($amount, 2) ?></td>
                                        <td><?= $method ?></td>
                                        <td>
                                            <?php
                                            if ($status == 0) {
                                                echo '<span class="badge badge-danger"> PENDING</span>';
                                            } else {
                                                echo '<span class="badge badge-success"> SUCCESS</span>';
                                            }
                                            ?>

                                        </td>
                                        <td>$<?= $charge ?></td>
                                        <td><?= $date_created ?></td>
                                        <td>2<?= $last_updated ?></td>
                                    </tr>
                                <?php   } ?>

                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="card" id="bank">
                    <div class="card-header header-elements-inline">
                        <h3 class="mb-0">Bank transfer logs</h3>
                    </div>
                    <div class="table-responsive py-4">
                        <table class="table table-flush" id="datatable-basic2">
                            <thead class="">
                                <tr>
                                    <th>S/N</th>
                                    <th>Reference ID</th>
                                    <th>Amount</th>
                                    <th>Status</th>
                                    <th>Created</th>
                                    <th>Description</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                while ($row_trans = mysqli_fetch_assoc($query_trans_2)) {
                                    $hid = $row_trans['id'];
                                    $name_bank = $row_trans['name_bank'];
                                    $swift_code = $row_trans['swift_code'];
                                    $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'];

                                    // checking for empty fields 

                                    if ($trans_no == 0) {
                                        echo "No records found";
                                    } else {
                                ?>
                                        <tr>
                                            <td><?php echo $hid ?></td>
                                            <td><?php echo $ref ?></td>
                                            <td><?= $currency ?><?php echo $amount ?></td>
                                            <td><?php echo '<span class="badge badge-success"> SUCCESS</span>'; ?></td>
                                            <td><?php echo $t_time ?></td>
                                            <td><?php echo $description ?></td>
                                        </tr>


                                <?php

                                    }
                                    // ends checking for empty fields 


                                }
                                // this ends the while loop
                                ?>
                            </tbody>
                        </table>
                    </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>