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

    $updateCode = $_GET['updateCode'];
    if ($updateCode == 'true') {
        $msg = 'Details updated Successfully';
        $link = 'transfer_progress_section.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">Transfer Progress</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">Codes sections</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">Transaction code Section</a>
                                            </li>

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

                        <div class="card">
                            <div class="card">
                                <div class="card-body">
                                    <h5 class="card-title mb-3">Client Track transfer button </h5>
                                    <h6 class="card-title mb-3 text-primary">Button Visibility Status </h6>

                                    <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 ($p_button != 1) {
                                                            echo '<span class = "text-danger ">  <i class="fas fa-door-open "></i> Visibility Blocked  </span>';
                                                        } else {
                                                            echo '<span class = "text-success">  <i class="fas fa-door-closed "></i>  Visibility Unblocked </span>';
                                                        }
                                                        ?>

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


                                                    <?php


                                                    if ($p_button != 1) {



                                                    ?>
                                                        <a href='../include/admin_action/unblock_progress.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 Unblock
                                                            </button>
                                                        </a>
                                                    <?php
                                                    } else {

                                                    ?>

                                                        <a href='../include/admin_action/restrict_progress.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 Block
                                                            </button>

                                                        </a>
                                                    <?php } ?>


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





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

                            <div class="card-body p-4">
                                <h5 class="card-title mb-3 text-center">Update Client Progress Transfer Details </h5>

                                <div class="row">
                                    <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">Progress Name </label>
                                                <input class="form-control" type="text" placeholder="Micheal Borris" name="name" value='<?php echo $p_name ?>' required>
                                            </div>
                                            <div class="mb-3">
                                                <label for="example-search-input" class="form-label">Amount</label>
                                                <input class="form-control" type="text" placeholder="$250,000.90" name="amount" value='<?php echo $p_amount ?>' required>
                                            </div>
                                            <div class="mb-3">
                                                <label for="example-search-input" class="form-label">Date Progress 1</label>
                                                <input class="form-control" type="text" placeholder="JUNE 15, 16:03" name="date" value='<?php echo $p_date ?>' required>
                                            </div>
                                            <div class="mb-3">
                                                <label for="example-search-input" class="form-label">Date Progress 2</label>
                                                <input class="form-control" type="text" placeholder="JUNE 15, 16:04" name="date2" value='<?php echo $p_date_2 ?>' required>
                                            </div>
                                            <div class="mb-3">
                                                <label for="example-search-input" class="form-label">Date Progress 3</label>
                                                <input class="form-control" type="text" placeholder="JUNE 15, 16:05" name="date3" value='<?php echo $p_date_3 ?>' required>
                                            </div>




                                            <button type="submit" class="btn btn-primary" name="submit">Click Here to Update <i class="fas fa-sign "></i></button>


                                        </div>
                                    </form>

                                    <br />


                                    <?php
                                    if (isset($_POST['submit'])) {
                                        $name = $db_conx->real_escape_string($_POST['name']);
                                        $amount = $db_conx->real_escape_string($_POST['amount']);
                                        $date = $db_conx->real_escape_string($_POST['date']);
                                        $date2 = $db_conx->real_escape_string($_POST['date2']);
                                        $date3 = $db_conx->real_escape_string($_POST['date3']);




                                        $sql_trans_update = "UPDATE personal_information  SET p_name = '$name',p_amount = '$amount',p_date = '$date',
                                        p_date_2 = '$date2',p_date_3 = '$date3' WHERE id = '$user_id' ";

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


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

                                    ?>


                                </div>
                                <!-- end row -->
                            </div>
                            <div class="card-body p-4">
                                <h5 class="card-title mb-3 text-center">Update Client Progress Status </h5>

                                <div class="row">
                                    <form method="POST" autocomplete="off">
                                        <div class="col-lg-6 d-block m-auto">


                                            <div class="form-group">
                                                <label for="exampleFormControlSelect1">Status Progress</label>
                                                <select class="form-control" id="exampleFormControlSelect1" name='current_status'>
                                                    <option value='0'>Step 1</option>
                                                    <option Value='1'>Step 2</option>
                                                    <option Value='2'>Step 3</option>

                                                </select>
                                            </div>



                                            <button type="submit" class="btn btn-primary" name="submit_p">Click Here to Update <i class="fas fa-sign "></i></button>


                                        </div>
                                    </form>

                                    <br />


                                    <?php
                                    if (isset($_POST['submit_p'])) {
                                        $current_status = $db_conx->real_escape_string($_POST['current_status']);




                                        $sql_trans_update = "UPDATE personal_information  SET step_transfer = '$current_status' WHERE id = '$user_id' ";

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


                                        if ($query_trans_update) {
                                            header('location:transfer_progress_section.php?updateCode=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();

?>