<?php
$title = 'User Accounts';
require_once('header-links.php');
// require_once('../lib/basic-function.php');
// require_once('../lib/user-functions.php');
// require_once('../lib/investment-plan-functions.php');
// require_once('../lib/package-functions.php');
// require_once('../lib/currency-functions.php');
$the_user = $basicFunctn->getDataDlt($_GET['user'],$basicFunctn->user_tb);
$user_detail = $basicFunctn->selectWhereDlt($user->user_details, 'user_unique_id', $the_user['unique_id'])[0];
$full_name = explode('++', $the_user['full_name']);
$first_name = $full_name[0];
$last_name = $full_name[1];
$date_joined = explode(',', $the_user['created_at']);
?>

<body>
    <div class="app">
        <div class="layout">
            <?php require_once('sidebar.php'); ?>

            <!-- Page Container START -->
            <div class="page-container">
                <?php require_once('header.php'); ?>



                <!-- Content Wrapper START -->
                <div class="main-content">
                    <div class="container-fluid">
                        <div class="page-title">
                            <h4><?php print $title; ?></h4>
                        </div>
                        <div class="row">
                            <!-- <div class="col-lg-12"> -->
                                <div class="col-lg-4" style="float:left;">
                                    <div class="widget-profile-1 card">
                                        <div class="profile border bottom">
                                        
                                            <img width="178px" height="191px" class="mrg-top-30" src="../../user/assets/uploads/profile/<?php  print $user_detail['passport']; ?>" alt="">
                                            <h4 class="mrg-top-20 no-mrg-btm text-semibold text-capitalize"><?php print $first_name . ' ' . $last_name; ?></h4>
                                        </div>
                                        <div class="pdd-horizon-30 pdd-vertical-20">
                                            <div class="mrg-top-30 text-left">
                                                <ul class="list-unstyled list-inline">
                                                    <li class=" no-pdd-horizon">
                                                        <p><span style="color:black;"><strong>Username:</strong></span> <?php print $the_user['username']; ?></p>
                                                    </li>
                                                    <li class=" no-pdd-horizon">
                                                        <p><span style="color:black;"><strong>Email:</strong></span> <?php print $the_user['email']; ?></p>
                                                    </li>
                                                    <li class=" no-pdd-horizon">
                                                        <p><span style="color:black;"><strong>Address:</strong></span> <?php print $user_detail['address']; ?></p>
                                                    </li>
                                                    <li class=" no-pdd-horizon">
                                                        <p><span style="color:black;"><strong>Country:</strong></span> <?php print $user_detail['country']; ?></p>
                                                    </li>
                                                    <li class=" no-pdd-horizon">
                                                        <p><span style="color:black;"><strong>Phone:</strong></span> <?php print $user_detail['phone']; ?></p>
                                                    </li>
                                                    <li class=" no-pdd-horizon">
                                                        <p><span style="color:black;"><strong>Date Joined:</strong></span> <?php print $date_joined[0] . ', ' . $date_joined[1]; ?></p>
                                                    </li>
                                                    <!-- <li class=" no-pdd-horizon">
                                                        <p><span style="color:black;"><strong>Referral Link:</strong></span><a href="<?php // print $basicFunctn->the_site_root; ?>/en/register?ref=<?php // print $the_user['username'] ?>">
                                                        <?php // print $basicFunctn->the_site_root; ?>/en/register?ref=<?php // print $the_user['username'] ?></a> </p>
                                                    </li> -->
                                                </ul>
                                            </div>
                                        </div>
                                    </div>

                                </div>
                                <div class="col-lg-8" style="float:left;width:70% !important;">
                                    <div class="card">
                                        <div class="card-heading border bottom">
                                            <h4 class=""><strong>EDIT PROFILE</strong></h4>
                                        </div>
                                        <div class="card-block">
                                            <div class="row">
                                                <div class="col-md-12 col-sm-12">
                                                    <form class="edit_user_form">
                                                    <input type="hidden" name="user_id" value="<?php print $_GET['user']; ?>">
                                                        <div class="col-md-12 mrg-top-10">
                                                            <p class=" "> Full Name:</p>
                                                            <input type="text" name="edit_user_name" class="form-control" value="<?php print $first_name . ' ' . $last_name; ?>" placeholder="Enter first name then lastname">
                                                        </div><br>
                                                        <div class="col-md-12 mrg-top-10">
                                                            <p class=" "> Email:</p>
                                                            <input type="text" name="email" class="form-control" value="<?php print $the_user['email']; ?>" placeholder="Enter Email Address">
                                                        </div><br>
                                                        <div class="col-md-12 mrg-top-10">
                                                            <p class=" "> Country:</p>
                                                            <input type="text" name="country" class="form-control" value="<?php print $user_detail['country']; ?>">
                                                        </div><br>
                                                        <div class="col-md-12 mrg-top-10">
                                                            <p class=" "> Address:</p>
                                                            <input type="text" name="address" class="form-control" value="<?php print $user_detail['address']; ?>">
                                                        </div><br>
                                                        <div class="col-md-12 mrg-top-10">
                                                            <p class=" "> Phone:</p>
                                                            <input type="text" name="phone" class="form-control" value="<?php print $user_detail['phone']; ?>">
                                                        </div><br>
                                                        <div class="mrg-top-10 text-center col-md-6">
                                                            <button class="btn btn-primary edit_user_btn">Update Account Details</button>
                                                        </div>
                                                    </form>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            <!-- </div> -->
                        </div>
                    </div>
                    <!-- Modal START-->
                    <div class="modal fade zoomInUp" id="block_user_modal">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4>Block Account?</h4>
                                </div>
                                <form class="block_user_form">
                                    <div class="modal-body">
                                        <p class="">By confirming this, you acknowledge to the blocking of this account. <br> User won't have access to this account.</p>
                                    </div>
                                </form>
                                <div class="modal-footer no-border">
                                    <div class="text-right">
                                        <button class="btn btn-default btn-sm" data-dismiss="modal">Cancel</button>
                                        <button class="btn btn-primary btn-sm block_user_btn" data-dismiss="modal">Continue</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Modal START-->
                    <div class="modal fade zoomInUp" id="unblock_user_modal">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4>Unblock Account?</h4>
                                </div>
                                <form class="unblock_user_form">
                                    <div class="modal-body">
                                        <p class="">By clicking continue, this account will no longer be blocked. <br> User will now have access to this account.</p>
                                    </div>
                                </form>
                                <div class="modal-footer no-border">
                                    <div class="text-right">
                                        <button class="btn btn-default btn-sm" data-dismiss="modal">Cancel</button>
                                        <button class="btn btn-primary btn-sm unblock_user_btn" data-dismiss="modal">Continue</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Modal START-->
                    <div class="modal fade zoomInUp" id="delete_user_modal">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4>Delete Withdrawal?</h4>
                                </div>
                                <form class="delete_user_form">
                                    <div class="modal-body">
                                        <p class="text-danger">By clicking continue, this account will be deleted permanently. <br> It can't be recovered after this.</p>
                                    </div>
                                </form>
                                <div class="modal-footer no-border">
                                    <div class="text-right">
                                        <button class="btn btn-default btn-sm" data-dismiss="modal">Cancel</button>
                                        <button class="btn btn-primary btn-sm delete_user_btn" data-dismiss="modal">Continue</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Content Wrapper END -->
                    <?php require_once('footer.php'); ?>
                    <!-- Footer END -->

                </div>
                <!-- Page Container END -->

            </div>
        </div>

        <?php require_once('footer-links.php'); ?>
        <script>


            $('.edit_user_btn').click(async function(e) {
                e.preventDefault();
                let edit_user_form = $('.edit_user_form').serializeArray();
                let form_data = set_form_data(edit_user_form);
                // console.log(edit_user_form);return;
                let returned = await ajaxRequest('ajax.php', form_data);
                throwSweetalert(returned, 'user-profile?user='+edit_user_form[0].value, 1);
            });
        </script>