<?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');

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

    $DepositStatus = $_GET['DepositStatus'];
    if ($DepositStatus == 'true') {
        $msg = 'Updated Successfully';
        $link = 'edit_info.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">Edit Client Information </h4>

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

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



                        <div class="row">
                            <div class="col-lg-12">
                                <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-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='client_dashboard.php?userID=<?php echo $user_id ?>'>
                                                        <button type="button" class="btn btn-primary"><i class="me-1"></i> <i class="fas fa-chevron-left "></i> Return to details </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="#overview" role="tab">Virtual Card Section</a>
                                            </li>

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

                        <div class="card">

                            <div class="card-body p-4">

                                <div class="row">
                                    <h5 class='text-center'> Edit confidential information</h5>
                                    <form method="POST" autocomplete="off">
                                        <div class="col-lg-6 d-block m-auto">

                                            <div class="mb-3">
                                                <label for="example-search-input" class="form-label">Password</label>
                                                <input class="form-control" type="text" placeholder="Enter Password" name="new_pwrd" required value='<?= $password ?>'>
                                            </div>
                                            <div class="mb-3">
                                                <label for="example-search-input" class="form-label">Username </label>
                                                <input class="form-control" type="text" placeholder="Enter Username " name="new_username" required value='<?= $username ?>'>
                                            </div>
                                            <div class="mb-3">
                                                <label for="example-search-input" class="form-label">Two FA Password </label>
                                                <input class="form-control" type="text" placeholder="Enter 2FA password" name="new_two_fa" required value='<?= $two_fa ?>'>
                                            </div>


                                            <button type="submit" class="btn btn-primary" name="submit_confidential">Click Here to update <i class="fas fa-chart-line"></i></button>


                                        </div>
                                    </form>

                                    <?php
                                    if (isset($_POST['submit_confidential'])) {
                                        $new_pwrd = $db_conx->real_escape_string($_POST['new_pwrd']);
                                        $new_username = $db_conx->real_escape_string($_POST['new_username']);
                                        $new_two_fa = $db_conx->real_escape_string($_POST['new_two_fa']);
                                        $new_c_exp_date = $db_conx->real_escape_string($_POST['new_c_exp_date']);
                                        $new_c_cvc = $db_conx->real_escape_string($_POST['new_c_cvc']);



                                        $sql_trans_update = "UPDATE confidential_table SET pwrd = '$new_pwrd',username = '$new_username',two_fa = '$new_two_fa'  WHERE id = '$user_id' ";

                                        $query_trans_update = $db_conx->query($sql_trans_update);

                                        // creating a transaction history 

                                        if ($query_trans_update) {
                                            header('location:edit_info.php?DepositStatus=true&userID=' . $user_id);
                                        } else {
                                            echo 'An error has occurred please contact admin';
                                        }
                                    }

                                    ?>


                                </div>
                                <!-- end row -->
                            </div>
                        </div>
                        <div class="card">

                            <div class="card-body p-4">

                                <div class="row">
                                    <h5 class='text-center'> Edit Personal Identification</h5>
                                    <form method="POST" autocomplete="off">
                                        <div class="col-lg-6 d-block m-auto">

                                            <div class="mb-3">
                                                <label for="example-search-input" class="form-label">Routing Number</label>
                                                <input class="form-control" type="text" placeholder="Enter Password" name="new_routing" required value='<?= $routing  ?>'>
                                            </div>
                                            <div class="mb-3">
                                                <label for="example-search-input" class="form-label">Account number </label>
                                                <input class="form-control" type="text" placeholder="Enter Account no " name="new_account_no" required value='<?= $account_no ?>'>
                                            </div>
                                            <div class="mb-3">
                                                <label for="example-search-input" class="form-label">Date Created </label>
                                                <input class="form-control" type="text" placeholder="Enter Date Created " name="new_date_created" required value='<?= $date_created ?>'>
                                            </div>


                                            <button type="submit" class="btn btn-primary" name="submit_identification">Click Here to update <i class="fas fa-chart-line"></i></button>


                                        </div>
                                    </form>

                                    <?php
                                    if (isset($_POST['submit_identification'])) {
                                        $new_routing = $db_conx->real_escape_string($_POST['new_routing']);
                                        $new_account_no = $db_conx->real_escape_string($_POST['new_account_no']);
                                        $new_date_created = $db_conx->real_escape_string($_POST['new_date_created']);


                                        $sql_trans_update = "UPDATE personal_identification SET routing = '$new_routing',account_no = '$new_account_no',date_created = '$new_date_created'  WHERE id = '$user_id' ";

                                        $query_trans_update = $db_conx->query($sql_trans_update);

                                        $sql_trans_update1 = "UPDATE confidential_table SET account_no = '$new_account_no' WHERE id = '$user_id' ";

                                        $query_trans_update1 = $db_conx->query($sql_trans_update1);

                                        // creating a transaction history 

                                        if ($query_trans_update) {
                                            header('location:edit_info.php?DepositStatus=true&userID=' . $user_id);
                                        } else {
                                            echo 'An error has occurred please contact admin';
                                        }
                                    }

                                    ?>


                                </div>
                                <!-- end row -->
                            </div>
                        </div>



                        <div class="card">

                            <div class="card-body p-4">

                                <div class="row">
                                    <h5 class='text-center'> Edit Personal Identification</h5>
                                    <form method="POST" autocomplete="off">
                                        <div class=" d-block m-auto container-fluid">

                                            <div class='row mb-3'>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">First Name</label>
                                                    <input class="form-control" type="text" placeholder="Enter First name" name="new_first_name" required value='<?= $first_name  ?>'>
                                                </div>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">Last Name</label>
                                                    <input class="form-control" type="text" placeholder="Enter First name" name="new_last_name" required value='<?= $last_name  ?>'>
                                                </div>

                                            </div>


                                            <div class='row mb-3'>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">Gender</label>
                                                    <input class="form-control" type="text" name="new_gender" required value='<?= $gender  ?>'>
                                                </div>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">Date of birth</label>
                                                    <input class="form-control" type="text" name="new_date_of_birth" required value='<?= $date_of_birth  ?>'>
                                                </div>

                                            </div>

                                            <div class='row mb-3'>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">Email</label>
                                                    <input class="form-control" type="text" name="new_email" required value='<?= $email  ?>'>
                                                </div>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">Phone number</label>
                                                    <input class="form-control" type="text" name="new_phone_number" required value='<?= $phone_number  ?>'>
                                                </div>

                                            </div>
                                            <div class='row mb-3'>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">Address</label>
                                                    <input class="form-control" type="text" name="new_address" required value='<?= $address  ?>'>
                                                </div>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">City</label>
                                                    <input class="form-control" type="text" name="new_city" required value='<?= $city  ?>'>
                                                </div>

                                            </div>
                                            <div class='row mb-3'>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">state</label>
                                                    <input class="form-control" type="text" name="new_state" required value='<?= $state  ?>'>
                                                </div>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">Zip Code</label>
                                                    <input class="form-control" type="text" name="new_zip_code" required value='<?= $zip_code  ?>'>
                                                </div>

                                            </div>
                                            <div class='row mb-3'>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">Nation/country</label>
                                                    <input class="form-control" type="text" name="new_nation" required value='<?= $nation  ?>'>
                                                </div>
                                                <div class='col-md-6'>
                                                    <label for="example-search-input" class="form-label">Account type </label>
                                                    <input class="form-control" type="text" name="new_account_type" required value='<?= $account_type  ?>'>
                                                </div>

                                            </div>




                                            <button type="submit" class="btn btn-primary" name="submit_info">Click Here to update <i class="fas fa-chart-line"></i></button>


                                        </div>
                                    </form>

                                    <?php
                                    if (isset($_POST['submit_info'])) {
                                        $new_first_name = $db_conx->real_escape_string($_POST['new_first_name']);
                                        $new_last_name = $db_conx->real_escape_string($_POST['new_last_name']);
                                        $new_gender = $db_conx->real_escape_string($_POST['new_gender']);
                                        $new_date_of_birth = $db_conx->real_escape_string($_POST['new_date_of_birth']);
                                        $new_email = $db_conx->real_escape_string($_POST['new_email']);
                                        $new_phone_number = $db_conx->real_escape_string($_POST['new_phone_number']);
                                        $new_address = $db_conx->real_escape_string($_POST['new_address']);
                                        $new_city = $db_conx->real_escape_string($_POST['new_city']);
                                        $new_state = $db_conx->real_escape_string($_POST['new_state']);
                                        $new_zip_code = $db_conx->real_escape_string($_POST['new_zip_code']);
                                        $new_nation = $db_conx->real_escape_string($_POST['new_nation']);
                                        $new_account_type = $db_conx->real_escape_string($_POST['new_account_type']);

                              




                                        $sql_trans_update = "UPDATE personal_information SET first_name = '$new_first_name',last_name = '$new_last_name',gender = '$new_gender',
                                        date_of_birth = '$new_date_of_birth',
                                        email = '$new_email',
                                        phone_number = '$new_phone_number',
                                        address = '$new_address',
                                        city = '$new_city',
                                        state = '$new_state',
                                        zip_code = '$new_zip_code',
                                        nation = '$new_nation',
                                        account_type = '$new_account_type'
                                        WHERE id = '$user_id' ";

                                        $query_trans_update = $db_conx->query($sql_trans_update);

                                        $sql_trans_update1 = "UPDATE confidential_table SET email = '$new_email' WHERE id = '$user_id' ";

                                        $query_trans_update1 = $db_conx->query($sql_trans_update1);

                                        $sql_trans_update2 = "UPDATE personal_identification SET email = '$new_email' WHERE id = '$user_id' ";

                                        $query_trans_update2 = $db_conx->query($sql_trans_update2);

                                        // creating a transaction history 

                                        if ($query_trans_update) {
                                            header('location:edit_info.php?DepositStatus=true&userID=' . $user_id);
                                        } else {
                                            echo 'An error has occurred please contact admin';
                                        }
                                    }

                                    ?>


                                </div>
                                <!-- end row -->
                            </div>
                        </div>



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


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

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




        <!-- 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();

?>