<?php
$title = 'KYC Validation';
require_once('header-links.php');

$current_pg = 9;

$user_details = $basicFunctn->selectWhereDlt($user->user_details, 'user_unique_id', $user_logged['unique_id'])[0];
$full_name = explode('++', $user_logged['full_name']);
$first_name = $full_name[0];
$last_name = $full_name[1];
$date_joined = explode(',', $user_logged['created_at']);

// print_r($user_details);
// die();



?>

<body>
    <!-- BEGIN LOADER -->
    <div id="load_screen">
        <div class="loader">
            <div class="loader-content">
                <div class="spinner-grow align-self-center"></div>
            </div>
        </div>
    </div>
    <!--  END LOADER -->
    <!-- ajax loader -->
    <div style="display: none;" id="the_load_screen">
        <div class="loader">
            <div class="loader-content">
                <div class="spinner-grow align-self-center"></div>
            </div>
        </div>
    </div>
    <!-- ajax loader -->

    <!--  BEGIN NAVBAR  -->
    <?php require_once('header.php'); ?>
    <!--  END NAVBAR  -->

    <!--  BEGIN MAIN CONTAINER  -->
    <div class="main-container" id="container">

        <div class="overlay"></div>
        <div class="search-overlay"></div>

        <!--  BEGIN SIDEBAR  -->
        <?php require_once('sidebar.php'); ?>
        <!--  END SIDEBAR  -->

        <!--  BEGIN CONTENT AREA  -->
        <div id="content" class="main-content">
            <div class="layout-px-spacing">

                <div class="row layout-spacing">
                    <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 layout-top-spacing">
                        <div class="widget-content widget-content-area">
                            <!-- <form id="contact" class="section contact edit_user_form"> -->
                            <div class="info">
                                <div class="row">
                                    <div class="col-md-11 mx-auto">
                                        <div class="row">
                                            <div class="col-md-12 mb-3">
                                                <h5 class="">Please, upload an ID card and also 2 current Selfies to complete KYC validation. <br> You'll wait for confirmation before you can perform certain deposits!</h5>
                                            </div>
                                            <div class="col-md-12 mb-5">
                                                <select class="form-control" id="kyc_label">
                                                    <option value="">--Which are you uploading--</option>
                                                    <option value="id_card">ID Card</option>
                                                    <option value="selfie">Two Selfies</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-12 text-right mb-5">
                                                <form style="background: #060818;" action="" method="post" class="dropzone" id="kyc_docs" enctype="multipart/form-data">
                                                </form>
                                                <!-- <button id="add-work-platforms" class="btn btn-primary edit_user_btn">Save Changes</button> -->
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- </form> -->
                        </div>
                    </div>

                </div>
            </div>
            <?php require_once('footer.php'); ?>
        </div>
        <!--  END CONTENT AREA  -->
    </div>
    <?php require_once('footer-links.php'); ?>
    <script>
        $('.upload_img_btn').click(async function(e) {
            e.preventDefault();
            let user_id = $('#user_profile_id').val();
            let user_img = $('#user_profile_img').prop('files')[0];
            let img_data = [{
                    name: "user_profile_img",
                    value: user_img
                },
                {
                    name: "user_profile_id",
                    value: user_id
                }
            ]
            // console.log(img_data);return;
            let form_data = set_form_data(img_data);
            let returned = await ajaxRequest('ajax.php', form_data);
            // console.log(returned);return;
            throwSweetalert(returned, 'profile', 1);
        });
        $('.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);
            // console.log(returned);return;
            throwSweetalert(returned, 'profile', 1);
        });
        $("#kyc_docs").dropzone({
            paramName: "kyc_file",
            maxFiles: 3,
            url: "ajax.php",
            init: function() {
                this.on("sending", function(file, xhr, formData) {
                    console.log(file);
                    formData.append("kyc_label", $('#kyc_label').val());
                });
            },
            success: (file, response) => {
                var returned = JSON.parse(response);
                // console.log(returned);
                // return;
                throwSweetalert(returned, 'kyc-validation', 1);
            }
        });
    </script>