<?php 
include('../components/pages.head.php'); 

session_start();

$errors = [""];

if (isset($_SESSION["reg_error"]) != "") {
    $reg_error = $_SESSION["reg_error"];
} else {
    $reg_error = "";
}
?>
<body>
    <?php include('../components/pages.header.php'); ?>
    
    <main>
        <!-- Breadcrumbs S t a r t -->
        <section class="breadcrumbs-area breadcrumb-bg">
            <div class="container">
                <h1 class="title wow fadeInUp" data-wow-delay="0.0s"> 😊 We are glad that you are here </h1>
            </div>

        </section>
        <!--/ End-of Breadcrumbs-->

        <!-- Login area S t a r t  -->
        <div class="login-area section-padding">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-xl-9 col-lg-10 col-12">
                        <div class="login-card">
                            <!-- Logo -->
                            <div class="logo mb-40">
                                <a href="/" class="mb-30 d-block">
                                    <img style="width: 180px;" src="assets/images/logo/logo.png" alt="logo" class="changeLogo">
                                </a>
                            </div>
                            <!-- Form -->
                            <form onSubmit="return valid();" name="enq" action="../bank-manager.php?action=create-account" method="post">
                                <?php
                                    if ($reg_error != '') {
                                    ?>
                                        <div class="alert alert-danger alert-icon alert-dismissible">
                                            <em class="icon ni ni-cross-circle"></em> <strong></strong><?php echo $reg_error ?> <button class="close" data-dismiss="alert"></button>
                                        </div>
                                <?php } ?>
                                <div class="row">
                                    <div class="col-lg-4">
                                        <div class="contact-form mb-24">
                                            <label class="contact-label">First Name </label>
                                            <input class="form-control contact-input" type="text" name="fname" required placeholder="Enter Your First Name">
                                        </div>
                                    </div>
                                    <div class="col-lg-4">
                                        <div class="contact-form mb-24">
                                            <label class="contact-label">Last Name </label>
                                            <input class="form-control contact-input" type="text" name="lname" required placeholder="Enter Your Last Name">
                                        </div>
                                    </div>
                                    <div class="col-lg-4">
                                        <div class="contact-form mb-24">
                                            <label class="contact-label">Other Names </label>
                                            <input class="form-control contact-input" type="text" name="mname" placeholder="Enter Your Other Names">
                                        </div>
                                    </div>
                                    <div class="col-lg-8">
                                        <div class="contact-form mb-24">
                                            <label class="contact-label">Email Address </label>
                                            <input required class="form-control contact-input" name="email" type="email" placeholder="johndoe@eample.com">
                                        </div>
                                    </div>
                                    <div class="col-lg-4">
                                        <div class="contact-form mb-24">
                                            <label class="contact-label">Phone Number </label>
                                            <input required class="form-control contact-input" type="phone" placeholder="+12345678900">
                                        </div>
                                    </div>
                                    <div class="col-lg-4">
                                        <div class="contact-form mb-24">
                                            <label class="contact-label">Gender </label>
                                            <select required name="gender" id="" class="form-control py-2">
                                                <option value="Male">Male</option>
                                                <option value="Female">Female</option>
                                                <option value="Non-Binary">Non-Binary</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-lg-4">
                                        <div class="contact-form mb-24">
                                            <label class="contact-label">Date of Birth* </label>
                                            <input required class="form-control contact-input" name="dob" type="date" placeholder="">
                                        </div>
                                    </div>
                                    <div class="col-lg-4">
                                        <div class="contact-form mb-24">
                                            <label class="contact-label">Account Type </label>
                                            <select required name="acc_type" id="acctype" class="select form-first-name form-control" id="form-first-name">
                                                <option value="Checking Account">Checking Account</option>
                                                <option value="Savings Account">Saving Account</option>
                                                <option value="Fixed Deposit Account">Fixed Deposit Account</option>
                                                <option value="Current Account">Current Account</option>
                                                <option value="Business Account">Business Account</option>
                                                <option value="Non Resident Account">Non Resident Account</option>
                                                <option value="Cooperate Business Account">Cooperate Business Account</option>
                                                <option value="Investment Account">Investment Account</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                 <hr style="border: 1px dashed">

                                 <div class="row">
                                    <div class="col-lg-12">
                                        <div class="contact-form mb-24">
                                            <label for="email"><small><i class="fa fa-map-marker"></i> Residential Address</small><span class="text-danger">* </span></label>
                                            <input id="email" name="address" type="address" required class="form-control contact-input">
                                        </div>
                                    </div>
                                    <div class="col-lg-3 col-sm-12">
                                        <div class="contact-form mb-24">
                                            <label for="email"><small>Postal Code</small><span class="text-danger">* </span></label>
                                            <input id="email" name="postalcode" type="text" required class="form-control contact-input">
                                        </div>
                                    </div>
                                    <div class="col-lg-3 col-sm-12">
                                        <div class="contact-form mb-24">
                                            <label for="email"><small>State/County</small><span class="text-danger">* </span></label>
                                            <input id="email" name="state" type="address" required class="form-control contact-input">
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="contact-form mb-24">
                                            <label class="contact-label">Country </label>
                                            <select required name="country" id="" class="select form-select form-control py-2">
                                                <?php
                                                    include('../includes/database.php');
                                                    $country_list = mysqli_query($con, "SELECT * FROM apps_countries") or die(mysql_error());
                                                    while ($row = mysqli_fetch_assoc($country_list)) {
                                                    ?>
                                                        <option value="<?php echo $row['country_name']; ?>"><?php echo $row['country_name']; ?></option>

                                                <?php } ?>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-lg-3">
                                        <div class="contact-form mb-24">
                                            <label class="contact-label">Currency </label>
                                            <select required class="select form-control" name="currency">
                                                <option value="&dollar;">($) Dollar</option>
                                                <option value="&euro;">(€) Euros </option>
                                                <option value="&pound;">(£) Pounds</option>
                                                <option value="&#20803;"> (元)Yuan </option>
                                                <option value="&yen;">(¥) Yen</option>
                                                <option value="&#8361;">(₩) Won</option>
                                                <option value="&#8358;">(₦) Naira</option>
                                                <option value="&#8377;">(₹) Indian Rupee</option>
                                                <option value="&#8369;">(₱) Pesos</option>
                                            </select>
                                        </div>
                                    </div>
                                 </div>
                                <hr style="border: 2px dashed">
                                <div class="mb-4 login-header">
                                    <h4>Account Security Information</h4>
                                </div>
                                <div class="row">
                                    <div class="col-lg-4">
                                        <div class="contact-form mb-24">
                                            <label class="contact-label">Username </label>
                                            <input minlength="8" required name="username" class="form-control contact-input" type="text" placeholder="Choose A Username" oninput="emaila(this)" onBlur="userAvailability()">
                                            <span id="user-availability-status1" style="font-weight:bold; font-size:10px;"></span>
                                        </div>
                                    </div>
                                    <div class="col-lg-4">
                                        <div class="position-relative contact-form mb-24">
                                            <label class="contact-label">Enter Password</label>
                                            <input required type="password" name="password" class="form-control contact-input password-input"
                                                id="txtPasswordLogin" placeholder="Enter Password">
                                            <i class="toggle-password ri-eye-line"></i>
                                        </div>
                                        <!-- Password -->
                                    </div>
                                    <div class="col-lg-4">
                                         <div class="position-relative contact-form mb-24">
                                            <label class="contact-label">Confirm Password</label>
                                            <input required type="password" name="xpassword" class="form-control contact-input password-input"
                                                id="txtPasswordLogin2" placeholder="Confirm Password">
                                            <i class="toggle-password ri-eye-line"></i>
                                        </div>
                                    </div>
                                </div>
                                
                               

                                <button type="submit" class="mt-5 btn-primary-fill justify-content-center w-100">
                                    <span class="d-flex justify-content-center gap-6">
                                        <span >Register</span>
                                    </span>
                                </button>
                            </form>

                            <div class="login-footer mb-20">
                                <div class="create-account">
                                    <p>
                                        Already have an account?
                                        <a href="../login">
                                            <span class="text-primary">Login</span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--/ End-of Login -->
    </main>


     <script>
        function userAvailability() {
            $("#loaderIcon").show();
            jQuery.ajax({
                url: "check-availability.php",
                data: 'username=' + $("#username").val(),
                type: "POST",
                success: function(data) {
                    $("#user-availability-status1").html(data);
                    $("#loaderIcon").hide();
                },
                error: function() {}
            });
        }
    </script>

   <?php
   unset($_SESSION["reg_error"]);
   include('../components/pages.footer.php'); ?>