<?php
ob_start();
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');
}
?>
<!--  -->
<!-- header begin-->

<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>
        <!-- header end -->

       

        <div class="header pb-6 d-flex align-items-center" style="min-height: 300px; background-image: url(../asset/images/shutterstock_1145329577-scaled.jpg); background-size: cover; background-position: center top;">
            <!-- Mask -->
            <span class="mask bg-gradient-default opacity-4"></span>
        </div>

        <div class="container-fluid mt--6">
            <div class="content-wrapper">
                <div class="container py-5">
                    <div class="row g-3">


                        <div class="container pt-5">

                            <!-- Welcome Section -->
                            <div class="welcome-card mb-4">
                                <div class="welcome-title">Welcome, <?= $first_name . ' ' . $last_name ?></div>
                                <div class="welcome-meta">Account Number: <?= $account_no ?></div>
                            </div>


                        </div>



                        <!-- Available Balance Card -->
                        <div class="col-12 col-md-6 mb-3">
                            <div class="balance-card available">
                                <div>
                                    <div class="balance-label">Available Balance</div>
                                    <p class="balance-amount">
                                        <span class="currency"><?= $currency ?></span><?= number_format($avaliable_balance, 2) ?>
                                    </p>
                                    <div class="balance-meta">Funds you can use right now</div>
                                </div>
                                <div class="balance-icon">
                                    <!-- You can swap this icon for any emoji or SVG -->
                                    💸
                                </div>
                            </div>
                        </div>

                        <!-- Current Balance Card -->
                        <div class="col-12 col-md-6 mb-3">
                            <div class="balance-card current ">
                                <div>
                                    <div class="balance-label">Current Balance</div>
                                    <p class="balance-amount">
                                        <span class="currency">$</span><?= number_format($leger_balance, 2) ?>
                                    </p>
                                    <div class="balance-meta">Total including pending transactions</div>
                                </div>
                                <div class="balance-icon">
                                    💼
                                </div>
                            </div>
                        </div>





                        <div class="container">
                            <div class="transfer-section">
                               <?php 
                                    include ('transfer-section.php')
                                ?>
                                <div class="row g-3">
                                    <div class='col-md-6 my-4'>
                                        <div class="card bg-white shadow">
                                            <!-- Card header -->
                                            <div class="card-body">


                                                <?php

                                                if ($c_status == 0) {

                                                ?>

                                                    <div class="row align-items-center">
                                                        <div class="col-8">
                                                            <!-- Title -->
                                                            <h5 class="h4 mb-0 text-success">Need a Card?<span class="badge badge-pill badge-info"></span></h5>
                                                        </div>
                                                    </div>
                                                    <br>


                                                    <div class="cardcc">
                                                        <div class="cardcc__front cardcc__part">
                                                            <img class="cardcc__front-logo cardcc__logo" src="../asset/images/visa.png">
                                                            <p class="cardcc_numer"> XXXX XXXX XXXX XXXX </p>
                                                            <div class="cardcc__space-75">
                                                                <span class="cardcc__label">card holder</span>
                                                                <p class="cardcc__info">***** *****</p>
                                                            </div>
                                                            <div class="cardcc__space-25">
                                                                <span class="cardcc__label">Expires</span>
                                                                <p class="cardcc__info">**/**</p>
                                                            </div>
                                                        </div>

                                                        <div class="cardcc__back cardcc__part">
                                                            <div class="cardcc__black-line"></div>
                                                            <div class="cardcc__back-content">
                                                                <div class="cardcc__secret">
                                                                    <p class="cardcc__secret--last">***</p>
                                                                </div>
                                                                <img class="cardcc__back-square cardcc__square" src="../asset/images/chip.png">
                                                                <img class="cardcc__back-logo cardcc__logo" src="../asset/images/visa.png">

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

                                                    <a href="card_request"><i class="fa fa-arrow-right"></i> Request</a>

                                                <?php
                                                } else {


                                                ?>


                                                    <h3 class='text-center'> Online Virtual Card</h3>
                                                    <div class="cardcc d-block m-auto">
                                                        <div class="cardcc__front cardcc__part">
                                                            <img class="cardcc__front-logo cardcc__logo" src="../asset/images/visa.png">
                                                            <?php $new_c_no = substr($c_number, 0, -15); ?>
                                                            <p class="cardcc_numer"> <?= $new_c_no ?> XXXX XXXX XXXX </p>
                                                            <div class="cardcc__space-75">
                                                                <span class="cardcc__label">card holder</span>
                                                                <p class="cardcc__info"><?= $first_name . ' ' . $last_name ?></p>
                                                            </div>
                                                            <div class="cardcc__space-25">
                                                                <span class="cardcc__label">Expires</span>
                                                                <p class="cardcc__info"><?= $c_exp_date ?></p>
                                                            </div>
                                                        </div>

                                                        <div class="cardcc__back cardcc__part">
                                                            <div class="cardcc__black-line"></div>
                                                            <div class="cardcc__back-content">
                                                                <div class="cardcc__secret">
                                                                    <p class="cardcc__secret--last"><?= $c_cvc ?></p>
                                                                </div>
                                                                <img class="cardcc__back-square cardcc__square" src="../asset/images/chip.png">
                                                                <img class="cardcc__back-logo cardcc__logo" src="../asset/images/visa.png">

                                                            </div>

                                                        </div>
                                                    </div>
                                                    <br />
                                                    <br />
                                                    <a href="#" data-toggle="modal" data-target="#exampleModal"><i class="fa fa-arrow-right"></i> View Card Details</a>
                                                    <!-- Button trigger modal -->


                                                    <!-- Modal -->
                                                    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                                        <div class="modal-dialog" role="document">
                                                            <div class="modal-content">
                                                                <div class="modal-header">
                                                                    <h5 class="modal-title" id="exampleModalLabel"><?= $sitename ?> Virtual Card </h5>
                                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                                        <span aria-hidden="true">&times;</span>
                                                                    </button>
                                                                </div>
                                                                <div class="modal-body">
                                                                    <small> Card Number </small>
                                                                    <p><?= $c_name ?></p>
                                                                    <!-- ================================ -->
                                                                    <small> Expiration </small>
                                                                    <p><?= $c_exp_date ?></p>
                                                                    <!-- ================================ -->
                                                                    <small> CVV </small>
                                                                    <p><?= $c_cvc ?></p>

                                                                    <!-- ================================ -->
                                                                    <small> Billing Address </small>
                                                                    <p><?= $address ?></p>

                                                                    <h4 class='text-center'>
                                                                        CURRENT BALANCE
                                                                    </h4>
                                                                    <h1 class='text-center'>
                                                                        <small> <?= $currency ?></small> <?= number_format($withheld_fund, 2) ?>
                                                                    </h1>
                                                                    <p class='text-center'> Fund your Card below using funds from your <br /> <?= $sitename ?> Available Balance</p>
                                                                    <style>
                                                                        .card_btn {
                                                                            width: 90%;
                                                                            display: block;
                                                                            margin: 10px auto;
                                                                        }
                                                                    </style>
                                                                    <div class='row'>
                                                                        <div class='col-6'>
                                                                            <a href='fund_card.php'>
                                                                                <button type="button" class="btn btn-success card_btn">Fund</button>
                                                                            </a>
                                                                        </div>
                                                                        <!-- <div class='col-6'> <button type="button" class="btn btn-primary card_btn">Withdraw</button></div> -->
                                                                    </div>


                                                                </div>





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

                                                <?php   }    ?>
                                                <br>



                                            </div>
                                        </div>


                                    </div>

                                    <div class='col-md-6 my-4'>
                                        <div class="card bg-white shadow">
                                            <!-- Card header -->
                                            <div class="card-body">

                                                <h3 class='text-center'> 2fa security </h3>
                                                <span class="badge badge-pill badge-primary">
                                                    Disabled
                                                </span>
                                                <br />
                                                <a href='security'>
                                                    Click here to verify your security settings
                                                </a>


                                            </div>
                                        
                                            <div class="card-body">

                                                <h3 class='text-center'> Py scheme <span class="badge badge-pill badge-info">plan based</span> </h3>
                                                <p class="card-text mb-4 text-dark">A yearly investment feature that gives you the opportunity to earn more. Let your money work for you by learning to take advantage of py scheme plan. Invest today and save tomorrow.Join our program and learn to save wisely
                                                </p>



                                            </div>
                                        </div>


                                    </div>

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



                    </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>
    </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>
<?php
ob_end_flush();
?>