<?php 
include($_SERVER['DOCUMENT_ROOT'] . "/COMPONENTS/root/path.php");
?>
<div class="p-3">
    <div class="text-center">
        <a href="https://erp.aurarichconsult.com"> <img src="https://erp.aurarichconsult.com/assets/images/staff.webp" width="350px" alt="wrapkit"></a>
    </div>
    <h2 class="mt-3 text-center">Ablɔɖe ERP</h2>
    <p class="text-center">Enter your Institution / Business ID address for you to be identified.</p>
    <form method="POST" action="" id="form_signin" autocomplete="off" validate="">
        <div class="row">
            <div class="col-lg-12">
                <div class="form-group">
                    <!-- <label class="text-dark" for="password">Unique  ID</label> -->
                    <input class="form-control" name="UniqueId" id="UniqueId" type="password" placeholder="Enter Institution / Business unique ID" required="">
                </div>
            </div>
            <div class="col-lg-12 text-center" style="margin-bottom:30px;">
                <button type="submit" class="btn btn-block btn-dark" id="signin"><span class="submitLoader">Proceed</span></button>
            </div>
            <!-- <div class="col-lg-12 text-center mt-5">
                Don't have an account? <a href="#" class="text-danger get-inn" data-url="siggnup/register-foerm-surper-admsin.php">Sign Up</a>
            </div> -->
        </div>
    </form>
</div>


<script>
    $("#signin").on("click", function() {
        $("#form_signin").submit(function(e) {
            $.ajax({
                url: domain_api + "/index/index.php",
                // url: domain_api + "/auth/signin",
                type: "POST",
                data: $(this).serialize(),
                beforeSend: function() {
                    $("#signin").attr("disabled", "disabled");
                    $(".submitLoader").html("<i class='fa fa-spinner fa-spin'></i>");
                },
                success: function(data) {
                    if (data.code == 200) {
                        $(".preloader").show();
                        $(".body").load(domain + "/COMPONENTS/signin/index.php", function() {
                            $(".signin-signup-form").load(domain + "/COMPONENTS/signin/form.php", function() {
                                $(".preloader").fadeOut();
                                var path = "/COMPONENTS/signin/index.php";
                                var path1 = "/COMPONENTS/signin/form.php";
                                sessionStorage.setItem("SigninPage", 3);
                                sessionStorage.setItem('UserType', domain + path);
                                sessionStorage.setItem('ActivePage', domain + path1);
                            })
                        });

                    } else if (data.code == 1062) {
                        $(".submitLoader").html("Sign In");
                        swal("Oops!", data.message, "error");
                    } else if (data.code == 1063) {
                        $(".submitLoader").html("Sign In");
                        swal("Oops!", data.message, "error");
                    }


                    $("#signin").attr("disabled", false);
                },
                error: function(request, error) {
                    swal("Oops!", error, "error");
                    $("#signin").attr("disabled", false);
                },
            });
            e.preventDefault();
        });
        $(this).off();
    });


    $(".get-inn").off().on("click", function() {
        var url = $(this).attr("data-url");
        // alert(url);
        $(".signin-signup-form").load(domain + "/COMPONENTS/" + url, function() {})
    });


    // $(".preloader").show();
    // $(".body").load(domain + "/COMPONENTS/business-create/index.php", function() {
    //     $(".business-create").load(domain + "/COMPONENTS/business-create/form.php", function() {
    //         $(".preloader").fadeOut();
    //         var path = "/COMPONENTS/business-create/index.php";
    //         var path1 = "/COMPONENTS/business-create/form.php";
    //         sessionStorage.setItem("SigninPage", 2);
    //         sessionStorage.setItem('UserType', domain + path);
    //         sessionStorage.setItem('ActivePage', domain + path1);
    //     })
    // });
</script>