<?php
ob_start();
include('../include/db_conx.php');
isset($_SESSION['admin_login']);
if (!isset($_SESSION['admin_login'])) {
    header("location: auth-login.php");
    exit();
} else {
    include('../include/admin_head.php');


    // this is to check if the url is empty 

?>

    <!-- now we have to get the client full Information -->
    <?php

    include('../include/admin_action/info.php');


    // success of kyc update

    // checking if the kyc have be successfully updated

    $kyc_success = $_GET['kycStatus'];
    if ($kyc_success == 'true') {
        $msg = 'KYC Successfully Verified';
        $link = 'client_dashboard.php?userID=' . $user_id;
        swal_success($msg, $link);
    }



    // checking if kyc was successfully deleted 
    $kyc_delete = $_GET['DeleteKycStatus'];
    if ($kyc_delete == 'true') {
        $msg = 'KYC Successfully Deleted';
        $link = 'client_dashboard.php?userID=' . $user_id;
        swal_success($msg, $link);
    }
    // checking if dp was successfully deleted 
    $DeleteDpStatus = $_GET['DeleteDpStatus'];
    if ($DeleteDpStatus == 'true') {
        $msg = 'Dp Removed Successfully';
        $link = 'client_dashboard.php?userID=' . $user_id;
        swal_success($msg, $link);
    }


    $block_check = $_GET['block_check'];
    if ($block_check == 'true') {
        $msg = 'Account Blocked ';
        $link = 'client_dashboard.php?userID=' . $user_id;
        swal_success($msg, $link);
    }

    $unblock = $_GET['unblock'];
    if ($unblock == 'true') {
        $msg = 'Account Unblocked ';
        $link = 'client_dashboard.php?userID=' . $user_id;
        swal_success($msg, $link);
    }

    $PackageStatus = $_GET['PackageStatus'];
    if ($PackageStatus == 'true') {
        $msg = 'Package Selected/Upgraded ';
        $link = 'client_dashboard.php?userID=' . $user_id;
        swal_success($msg, $link);
    }
    $ReduceStatus = $_GET['ReduceStatus'];
    if ($ReduceStatus == 'true') {
        $msg = 'Amount Reduced ';
        $link = 'client_dashboard.php?userID=' . $user_id;
        swal_success($msg, $link);
    }



    ?>



    <body>

        <!-- <body data-layout="horizontal"> -->

        <!-- Begin page -->
        <div id="layout-wrapper">

            <?php include('../include/admin_header.php'); ?>

            <!-- ========== Left Sidebar Start ========== -->

            <!-- Left Sidebar End -->
            <?php include('../include/admin_sidebar.php'); ?>



            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->
            <div class="main-content">

                <div class="page-content">
                    <div class="container-fluid">

                        <!-- start page title -->
                        <div class="row">
                            <div class="col-12">
                                <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                                    <h4 class="mb-sm-0 font-size-18">Profile </h4>

                                    <div class="page-title-right">
                                        <ol class="breadcrumb m-0">
                                            <li class="breadcrumb-item"><a href="javascript: void(0);">Profile</a></li>
                                            <li class="breadcrumb-item active">Clients Info</li>
                                        </ol>
                                    </div>

                                </div>
                            </div>
                        </div>
                        <!-- end page title -->

                        <div class="row">
                            <div class="col-xl-9 col-lg-8">
                                <div class="card">
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col-sm order-2 order-sm-1">
                                                <div class="d-flex align-items-start mt-3 mt-sm-0">
                                                    <div class="flex-shrink-0">
                                                        <div class="avatar-xl me-3">
                                                            <?php

                                                            if (empty($passport)) {

                                                            ?>
                                                                <img src="https://media.istockphoto.com/id/1300845620/vector/user-icon-flat-isolated-on-white-background-user-symbol-vector-illustration.jpg?s=612x612&w=0&k=20&c=yBeyba0hUkh14_jgv1OKqIH0CCSWU_4ckRkAoy2p73o=" alt="" class="img-fluid rounded-circle d-block">
                                                            <?php  } else {
                                                            ?>

                                                                <img src="<?php echo '../../user/profile_img/' . $passport ?>" alt="" class="img-fluid rounded-circle d-block">

                                                            <?php

                                                            } ?>

                                                        </div>
                                                    </div>
                                                    <div class="flex-grow-1">
                                                        <div>
                                                            <h5 class="font-size-16 mb-1"><?php echo $first_name . ' ' . $last_name ?> </h5>
                                                            <p class="text-muted font-size-13">Billing Name</p>


                                                            <div class="d-flex flex-wrap align-items-start gap-2 gap-lg-3 text-muted font-size-13">
                                                                <div> <i class="fas fa-envelope "></i> <?php echo $email ?></div>
                                                                <div><i class=" fas fa-key "></i> Password: <?php echo $password ?></div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-sm-auto order-1 order-sm-2">
                                                <div class="d-flex align-items-start justify-content-end gap-2">
                                                    <a href='DeleteUser.php?userID=<?php echo $user_id ?>'>
                                                        <button type="button" class="btn btn-danger"><i class="me-1"></i> <i class="fas fa-trash-alt"></i> Delete</button>
                                                    </a>

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

                                        <ul class="nav nav-tabs-custom card-header-tabs border-top mt-4" id="pills-tab" role="tablist">

                                            <li class="nav-item">
                                                <a class="nav-link px-3 active" data-bs-toggle="tab" href="#about" role="tab">About</a>
                                            </li>
                                            <li class="nav-item">
                                                <a class="nav-link px-3" data-bs-toggle="tab" href="#post" role="tab">Financial</a>
                                            </li>
                                            <li class="nav-item">
                                                <a class="nav-link px-3" href="client_transfer.php?userID=<?php echo $user_id ?>" role=" tab">Transfer Code Details</a>
                                            </li>
                                            <li class="nav-item">
                                                <a class="nav-link px-3" href="loan_transfer_code.php?userID=<?php echo $user_id ?>" role=" tab">Loan Code Details</a>
                                            </li>
                                        </ul>
                                    </div>
                                    <!-- end card body -->
                                </div>
                                <!-- end card -->

                                <div class="tab-content">

                                    <div class="tab-pane active" id="about" role="tabpanel">
                                        <div class="card">
                                            <div class="card-header">
                                                <h5 class="card-title mb-0">About</h5>
                                            </div>
                                            <div class="card-body">
                                                <div>
                                                    <div class="pb-3">
                                                        <h5 class="font-size-15">Registered on the :</h5>
                                                        <div class="text-muted">
                                                            <p class="mb-2"><?php echo $date_created ?></p>

                                                        </div>
                                                    </div>

                                                    <div class="pt-3">
                                                        <h5 class="font-size-15">Address/Country :</h5>
                                                        <div class="text-muted">

                                                            <ul class="list-unstyled mb-0">
                                                                <li class="py-1"><i class="mdi mdi-circle-medium me-1 text-success align-middle"></i> Address <i class=" fas fa-map-marked"></i> : <?php if (empty($address)) {
                                                                                                                                                                                                        echo 'Not updated';
                                                                                                                                                                                                    } else {
                                                                                                                                                                                                        echo $address;
                                                                                                                                                                                                    } ?></li>
                                                                <li class="py-1"><i class="mdi mdi-circle-medium me-1 text-success align-middle"></i> city <i class=" fas fa-map-marker-alt "></i> : <?php echo $city ?></li>
                                                                <li class="py-1"><i class="mdi mdi-circle-medium me-1 text-success align-middle"></i> state <i class=" fas fa-map-marker-alt "></i> : <?php echo $state ?></li>
                                                                <li class="py-1"><i class="mdi mdi-circle-medium me-1 text-success align-middle"></i> Country <i class=" fas fa-map-marker-alt "></i> : <?php echo $nation ?></li>

                                                                <li class="py-1"><i class="mdi mdi-circle-medium me-1 text-success align-middle"></i> Phone <i class="  fas fa-phone-volume "></i> : <?php echo $phone_number ?></li>

                                                                <li class="py-1"><i class="mdi mdi-circle-medium me-1 text-success align-middle"></i> Registered Ip Address <i class=" fas fa-signal "></i> : <?php echo $ip_address ?></li>

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

                                                    <div class="pt-3">
                                                        <h5 class="font-size-15">Details:</h5>
                                                        <div class="text-muted">

                                                            <ul class="list-unstyled mb-0">

                                                                <li class="py-1"><i class="mdi mdi-circle-medium me-1 text-success align-middle"></i>Account Number: <?php echo $account_no ?></li>
                                                                <li class="py-1"><i class="mdi mdi-circle-medium me-1 text-success align-middle"></i>Username : <?php echo $username ?></li>
                                                                <li class="py-1"><i class="mdi mdi-circle-medium me-1 text-success align-middle"></i>Password : <?php echo $password ?></li>
                                                                <li class="py-1"><i class="mdi mdi-circle-medium me-1 text-success align-middle"></i> Transfer Pin : <?php echo $otp_code ?></li>


                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <!-- end card body -->
                                        </div>
                                        <!-- end card -->
                                    </div>
                                    <!-- end tab pane -->

                                    <div class="tab-pane" id="post" role="tabpanel">
                                        <div class="card">
                                            <div class="card-header">
                                                <h5 class="card-title mb-0">Financial</h5>
                                            </div>
                                            <div class="card-body">
                                                <div class="row">
                                                    <div class="col-xl-4">
                                                        <div class="card p-1 mb-xl-0">
                                                            <div class="p-3">
                                                                <div class="d-flex align-items-start">
                                                                    <div class="flex-grow-1 overflow-hidden">
                                                                        <h5 class="font-size-15 text-truncate"><a href="#" class="text-dark"><?php echo $currency . number_format($avaliable_balance, 2) ?></a></h5>
                                                                        <p class="font-size-13 text-muted mb-0">Available Balance</p>
                                                                    </div>
                                                                    <div class="flex-shrink-0 ms-2">
                                                                        <a class="btn btn-link text-muted font-size-16 p-1 py-0 " href="client_deposit.php?userID=<?php echo $user_id ?>">
                                                                            <i class=" fas fa-money-bill"></i>
                                                                            <br />
                                                                            Fund
                                                                        </a>

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



                                                            <div class="p-3">

                                                                <div>
                                                                    <a href="client_deposit.php?userID=<?php echo $user_id ?>" class="text-primary">Fund Deposit <i class="mdi mdi-arrow-right"></i></a>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <!-- end col -->

                                                    <div class="col-xl-4" style='display:none'>
                                                        <div class="card p-1 mb-xl-0">
                                                            <div class="p-3">
                                                                <div class="d-flex align-items-start">
                                                                    <div class="flex-grow-1 overflow-hidden">
                                                                        <h5 class="font-size-15 text-truncate"><a href="#" class="text-dark"><?php echo $currency . number_format($leger_balance, 2) ?></a></h5>
                                                                        <p class="font-size-13 text-muted mb-0">Current Balance</p>
                                                                    </div>
                                                                    <div class="flex-shrink-0 ms-2">
                                                                        <a class="btn btn-link text-muted font-size-16 p-1 py-0 " href="client_profit.php?userID=<?php echo $user_id ?>">
                                                                            <i class=" fas fa-money-bill"></i>
                                                                            <br />
                                                                            Fund
                                                                        </a>

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



                                                            <div class="p-3">


                                                                <div>
                                                                    <a href="client_profit.php?userID=<?php echo $user_id ?>" class="text-primary">Fund Deposit <i class="mdi mdi-arrow-right"></i></a>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <!-- end card -->
                                                    </div>
                                                    <!-- end col -->
                                                    <div class="col-xl-4">
                                                        <div class="card p-1 mb-xl-0">
                                                            <div class="p-3">
                                                                <div class="d-flex align-items-start">
                                                                    <div class="flex-grow-1 overflow-hidden">
                                                                        <h5 class="font-size-15 text-truncate"><a href="#" class="text-dark"><?php echo $currency . number_format($withheld_fund, 2) ?></a></h5>
                                                                        <p class="font-size-13 text-muted mb-0">Card Balance</p>
                                                                    </div>
                                                                    <div class="flex-shrink-0 ms-2">
                                                                        <a class="btn btn-link text-muted font-size-16 p-1 py-0 " href="client_profit.php?userID=<?php echo $user_id ?>">
                                                                            <i class=" fas fa-money-bill"></i>
                                                                            <br />
                                                                            Virtual Card
                                                                        </a>

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




                                                            <div class="p-3">


                                                                <div>
                                                                    <a href="#" class="text-primary">Virtual Card </a>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <!-- end card -->
                                                    </div>
                                                    <!-- end col -->



                                                    <!-- end col -->
                                                </div>

                                            </div>
                                            <!-- end card body -->



                                            <!-- MY REDUCE BUTTON WILL GO HERE -->
                                            <a href='reduce_funds.php?userID=<?php echo $user_id ?>'>
                                                <button type="button" class="btn btn-success waves-effect waves-light btn-sm">
                                                    <i class="bx bx-check-double font-size-16 align-middle me-2"></i> Click to Reduce Funds
                                                </button>

                                            </a>
                                            <br />
                                            <!-- MY REDUCE BUTTON WILL GO HERE -->
                                            <a href='client_debit.php?userID=<?php echo $user_id ?>' class = 'mt-3'>
                                                <button type="button" class="btn btn-primary waves-effect waves-light btn-sm">
                                                    <i class="bx bx-check-double font-size-16 align-middle me-2"></i> Click to Create DEBIT
                                                </button>

                                            </a>




                                        </div>
                                        <!-- end card -->
                                    </div>
                                    <!-- end tab pane -->
                                </div>
                                <!-- end tab content -->
                            </div>
                            <!-- end col -->

                            <div class="col-xl-3 col-lg-4">

                                <!-- end card -->

                                <div class="card">
                                    <div class="card-body">
                                        <h5 class="card-title mb-3">Other Section</h5>

                                        <div>
                                            <?php
                                            if ($c_status == 2) {
                                                echo '<div class="alert alert-success" role="alert">
                                                        A Card Request has been made by this client
                                                        </div>';
                                            }

                                            ?>
                                            <ul class="list-unstyled mb-0">

                                                <li>
                                                    <a href="card.php?userID=<?php echo $user_id ?>" class="py-2 d-block text-muted"><i class="  fas fa-archway "></i> Go To card </a>
                                                </li>

                                                <li>
                                                    <a href="edit_info.php?userID=<?php echo $user_id ?>" class="py-2 d-block text-muted"><i class="  fab fa-buffer "></i> Edit Client Information </a>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                    <!-- end card body -->
                                </div>
                                <!-- end card -->
                                <div class="card">
                                    <div class="card-body">
                                        <h5 class="card-title mb-3">Transaction Histories</h5>

                                        <div>
                                            <ul class="list-unstyled mb-0">
                                                <li>
                                                    <a href="history_deposit.php?userID=<?php echo $user_id ?>" class="py-2 d-block text-muted"><i class=" fas fa-download"></i> Deposit</a>
                                                </li>
                                                <li>
                                                    <a href="history_withdraw.php?userID=<?php echo $user_id ?>" class="py-2 d-block text-muted"><i class=" fas fa-globe-europe "></i> Withdrawals</a>
                                                </li>
                                                <li>
                                                    <a href="history_transfer.php?userID=<?php echo $user_id ?>" class="py-2 d-block text-muted"><i class=" fas fa-fax "></i> Transfer</a>
                                                </li>

                                            </ul>
                                        </div>
                                    </div>
                                    <!-- end card body -->
                                </div>
                                <!-- end card -->

                                <div class="card">
                                    <div class="card-body">
                                        <h5 class="card-title mb-3">Other Status</h5>

                                        <div class="list-group list-group-flush">
                                            <div class="d-flex align-items-center">
                                                <div class="avatar-sm flex-shrink-0 me-3">
                                                    <i class="fa fa-user"></i>
                                                </div>
                                                <div class="flex-grow-1">
                                                    <div>
                                                        <h5 class="font-size-14 mb-1">

                                                            <?php





                                                            if ($block != 1) {
                                                                echo '<span class = "text-success">  <i class="fas fa-door-open "></i>  Account Unblocked </span>';
                                                            } else {
                                                                echo '<span class = "text-danger">  <i class="fas fa-door-closed "></i>  Account Blocked </span>';
                                                            }
                                                            ?>

                                                        </h5>
                                                        <p class="font-size-13 text-muted mb-3">Account Status <i class="fas fa-magic"></i></p>


                                                        <?php


                                                        if ($block != 1) {



                                                        ?>
                                                            <a href='../include/admin_action/restrict.php?userID=<?php echo $user_id ?>'>
                                                                <button type="button" class="btn btn-danger waves-effect waves-light btn-sm">
                                                                    <i class="bx bx-block font-size-16 align-middle me-2"></i> Click to Block
                                                                </button>
                                                            </a>
                                                        <?php
                                                        } else {

                                                        ?>

                                                            <a href='../include/admin_action/unblock.php?userID=<?php echo $user_id ?>'>
                                                                <button type="button" class="btn btn-success waves-effect waves-light btn-sm">
                                                                    <i class="bx bx-check-double font-size-16 align-middle me-2"></i> Click to Unblock
                                                                </button>

                                                            </a>
                                                        <?php } ?>


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





                                        </div>
                                    </div>
                                    <!-- end card body -->
                                </div>
                                <!-- end card  for withdrawal active-->

                                <!-- end card -->
                            </div>
                            <!-- end col -->
                        </div>



                    </div> <!-- container-fluid -->
                </div>
                <!-- End Page-content -->


                <?php include('../include/admin_footer.php'); ?>
            </div>
            <!-- end main content-->

        </div>
        <!-- END layout-wrapper -->

        <!-- this modal is the one for upgrading and selecting package for client  -->

        <div class="modal fade bs-example-modal-center" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Select/Upgrade Package </h5>

                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <form Method='POST'>
                            <div class="form-group">
                                <label for="exampleFormControlSelect1">Select New Package</label>
                                <select class="form-control" id="exampleFormControlSelect1" name='new_package'>
                                    <option value="Checking Account">Checking Account</option>
                                    <option value="Savings Account">Saving Account</option>
                                    <option value="Fixed Deposit Account">Fixed Deposit Account</option>
                                    <option value="Current Account">Current Account</option>
                                    <option value="Business Account">Business Account</option>
                                    <option value="Non Resident Account">Non Resident Account</option>
                                    <option value="Cooperate Business Account">Cooperate Business Account</option>
                                    <option value="Investment Account">Investment Account</option>
                                </select>
                            </div>

                            <div class="form-group mt-2">
                                <button type="submit" name='plan_submit' class="btn btn-dark waves-effect waves-light">
                                    <i class="bx bx-loader bx-spin font-size-16 align-middle me-2"></i> Update
                                </button>
                            </div>


                        </form>

                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->

        <!-- this modal is a delete modal  -->

        <div class="modal2 fade bs-example-modal-center" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Are You sure you want to delete this account ? </h5>

                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <form Method='POST'>
                            <div class="form-group">
                                <input type="text" class="form-control" value='<?php echo $user_id ?>'>

                            </div>

                            <div class="form-group mt-2">
                                <button type="submit" name='plan_submit' class="btn btn-danger waves-effect waves-light">
                                    <i class="bx bx-loader bx-spin font-size-16 align-middle me-2"></i> click here to delete
                                </button>
                            </div>


                        </form>

                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->

        <?php
        if (isset($_POST['plan_submit'])) {
            $new_package = $db_conx->real_escape_string($_POST['new_package']);
            $sql_p = "UPDATE personal_information SET account_type = '$new_package' WHERE id = '$user_id'";
            $result_p = $db_conx->query($sql_p);
            if ($result_p) {
                header('location:client_dashboard.php?PackageStatus=true&userID=' . $user_id);
            } else {
                echo 'An error has occurred please contact admin';
            }
        }
        ?>




        <!-- Right bar overlay-->
        <div class="rightbar-overlay"></div>

        <script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
        <script src="assets/libs/metismenu/metisMenu.min.js"></script>
        <script src="assets/libs/simplebar/simplebar.min.js"></script>
        <script src="assets/libs/node-waves/waves.min.js"></script>
        <script src="assets/libs/feather-icons/feather.min.js"></script>
        <!-- pace js -->
        <script src="assets/libs/pace-js/pace.min.js"></script>

        <!-- flatpickr js -->
        <script src="assets/libs/flatpickr/flatpickr.min.js"></script>

        <!-- Required datatable js -->
        <script src="assets/libs/datatables.net/js/jquery.dataTables.min.js"></script>
        <script src="assets/libs/datatables.net-bs4/js/dataTables.bootstrap4.min.js"></script>

        <!-- Responsive examples -->
        <script src="assets/libs/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
        <script src="assets/libs/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js"></script>

        <!-- init js -->
        <script src="assets/js/pages/invoices-list.init.js"></script>

        <script src="assets/js/app.js"></script>
    </body>

    </html>

<?php  }
ob_end_flush(); ?>