<?php include_once('../function/__data_app_db.php');
$signup_tkn = substr(str_shuffle(str_repeat("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-@", 128)), 0, 128);
$_SESSION['signup_token'] = $signup_tkn;
?>
<!DOCTYPE html>
<html class="loading" lang="en" data-textdirection="ltr">
  <!-- BEGIN: Head-->
  <head>
    <?php include_once('head.php');?>
    <!-- BEGIN: Page CSS-->
    <link rel="stylesheet" type="text/css" href="../../app-assets/css/pages/authentication.css">
    <!-- END: Page CSS-->
    <!-- BEGIN: Custom CSS-->
    <link rel="stylesheet" type="text/css" href="../../assets/css/style.css?<?php echo $currentTime;?>">
    <!-- END: Custom CSS-->
  </head>
  <!-- END: Head-->

  <!-- BEGIN: Body-->
  <body class="vertical-layout vertical-menu-modern 1-column  navbar-sticky footer-static bg-full-screen-image dark-layout blank-page blank-page" data-open="click" data-menu="vertical-menu-modern" data-col="1-column">
    <!-- BEGIN: Content-->
    <div class="app-content content">
      <div class="content-overlay"></div>
      <div class="content-wrapper">
        <div class="content-header row">
        </div>
        <div class="content-body"><!-- register section starts -->
<section class="row flexbox-container">
    <div class="col-xl-8 col-10">
        <div class="card bg-authentication mb-0">
            <div class="row m-0">
                <!-- register section left -->
                <div class="col-md-8 col-12 px-0">
                    <div class="card disable-rounded-right mb-0 p-2 h-100 d-flex justify-content-center">
                        <div class="card-header pb-1">
                            <div class="card-title">
                                <h4 class="text-center mb-2">Sign Up</h4>
                            </div>
                        </div>
                        <div class="text-center">
                            <p> <small> Please enter your details to sign up and be part of our great community</small>
                            </p>
                        </div>
                        <div class="card-content">
                            <div class="card-body">
                                <form  id="data-form" action="function/insert/signup">
                                    <div class="form-group mb-50">
                                        <label class="text-bold-600" for="name">Name</label>
                                        <input type="text" class="form-control" name="name" id="name"
                                            minlength="3" maxlength="110" required></div>
                                    <div class="form-row">
                                        <div class="form-group col-md-5 mb-50">
                                            <label for="phone">phone</label>
                                            <input type="number"  minlength="10" maxlength="10" class="form-control" id="phone" name="phone" required>
                                        </div>
                                        <div class="form-group col-md-7 mb-50">
                                            <label for="email">email</label>
                                            <input type="email" class="form-control" name="email" id="email" required>
                                        </div>
                                    </div>
                                    <div class="form-group mb-50">
                                        <label class="text-bold-600" for="password">Password</label>
                                        <input type="password" class="form-control" name="password" id="password" minlength="4" maxlength="22" required></div>
                                    <div class="form-group mb-50">
                                        <label class="text-bold-600" for="confirmpassword">Confirm Password</label>
                                        <input type="password" class="form-control" name="confirmpassword" id="confirmpassword" data-parsley-equalto="#password"  minlength="4" maxlength="22" required></div>
                                    <div class="form-group mb-2">
                                        <label class="text-bold-600" for="referral_code">Any Referral Code</label>
                                        <input type="text" class="form-control" name="referral_code" id="referral_code">
                                    </div>
                                    <div class="form-group">
                                        <fieldset>
                                            <div class="checkbox">
                                                <input type="checkbox" class="checkbox-input" id="agree" required>
                                                <label for="agree">I agree with the <a href="#" class="btn-link text-bold">Terms and Conditions </a></label>
                                            </div>
                                        </fieldset>
                                    </div>
                                    <input type="hidden" name="tkn" value="<?php echo $_SESSION['signup_token'];?>">
                                    <button class="btn btn-primary position-relative w-100 ladda-button submit-btn" data-style="zoom-in" type="submit" name="action"><span class="ladda-label">SIGN UP</span> <span class="ladda-spinner"></span> <i id="icon-arrow" class="bx bx-right-arrow-alt"></i>
                                    </button>
                                </form>
                                <hr>
                                <div class="text-center"><small class="mr-25">Already have an account?</small><a href="sign_in"><small class="text-success">Login</small> </a></div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- image section right -->
                <div class="col-md-4 d-md-block d-none text-center align-self-center p-3">
                    <img class="img-fluid" src="../../app-assets/images/pages/register.png" alt="branding logo">
                </div>
            </div>
        </div>
    </div>
</section>
<!-- register section endss -->
        </div>
      </div>
    </div>
    <!-- END: Content-->


    <!-- BEGIN: Vendor JS-->
    <script src="../../app-assets/vendors/js/vendors.min.js"></script>
    <script src="../../app-assets/fonts/LivIconsEvo/js/LivIconsEvo.tools.min.js"></script>
    <script src="../../app-assets/fonts/LivIconsEvo/js/LivIconsEvo.defaults.min.js?1"></script>
    <script src="../../app-assets/fonts/LivIconsEvo/js/LivIconsEvo.min.js"></script>
    <!-- BEGIN Vendor JS-->

    <!-- BEGIN: Page Vendor JS-->
    <!-- END: Page Vendor JS-->

    <!-- BEGIN: Theme JS-->
    <script src="../../app-assets/js/scripts/parsley.min.js"></script>
    <script src="../../app-assets/plugin/ladda-button/spin.min.js"></script>
    <script src="../../app-assets/plugin/ladda-button/ladda.min.js"></script>
    <script src="../../app-assets/plugin/notify.js"></script>
    <script src="../../app-assets/plugin/sweetalert/sweetalert.min.js"></script>
    <script src="../../app-assets/js/scripts/configs/vertical-menu-light.min.js"></script>
    <script src="../../app-assets/js/core/app-menu.min.js"></script>
    <script src="../../app-assets/js/core/app.min.js"></script>
    <script src="../../app-assets/js/scripts/components.min.js"></script>
    <script src="../../app-assets/js/scripts/footer.min.js"></script>
    <!-- END: Theme JS-->
    <script type="text/javascript">
        $('form').parsley();
        $('form#data-form').submit(function (e) {
            e.preventDefault();
            var action = $(this).attr('action');
            var m_form_data = new FormData(this);
            if($(this).parsley().isValid()){
                var l = Ladda.create(document.querySelector('.submit-btn'));
                l.start();
                $.ajax({
                    type: "POST",
                    url: action,
                    data: m_form_data,
                    cache: false,
                    dataType:"json",
                    enctype: 'multipart/form-data',
                    processData: false,  // tell jQuery not to process the data
                    contentType: false,   // tell jQuery not to set contentType
                    success: function(data){
                        //alert(data);
                        l.stop();
                        var goTo ='';
                        var notify_type = data.notif_type;
                        var notify_title = data.notif_title;
                        var notify_desc = data.notif_desc;
                        $.notify({
                            // options
                            title: notify_title,
                            message: notify_desc
                        },{
                            // settings
                            type: notify_type
                        });
                        if(data.res == 'true'){
                            goTo = data.goTo;
                            window.setTimeout(function(){
                                window.location.href = goTo;
                            }, 2000);
                        }
                    },
                    error: function (jqXHR, exception) {
                        var msg = '';
                        if (jqXHR.status === 0) {
                            msg = "oops error";
                        } else if (jqXHR.status === 404) {
                            msg = "404 error";
                        } else if (jqXHR.status === 500) {
                            msg = "505 error";
                        } else if (exception === 'parsererror') {
                            msg = "error";
                        } else if (exception === 'timeout') {
                            msg = "timeout";
                        } else if (exception === 'abort') {
                            msg = "abort";
                        } else {
                            msg = "oops somthing want wrong"
                        }
                        l.stop();
                        alert(msg);
                    }
                });
            };
        });
    </script>
  </body>
  <!-- END: Body-->
</html>