<?php
session_start();

require('../includes/database.php');

if (isset($_SESSION['username']) && $_SESSION['password'] != "") {
} else {
    header("Location:index.php");
}
$username = $_SESSION['username'];


$username = $_SESSION['username'];
$password = $_SESSION['password'];

$query = "SELECT *
			FROM admin	
			WHERE username = '$username'
			&&   password = '$password'";

$result = mysqli_query($con, $query) or die(mysqli_connect_error());
$rows = mysqli_num_rows($result);
if ($rows == 1) {
    while ($data = mysqli_fetch_assoc($result)) {

        extract($data);
        include('head.php');

        if (isset($_SESSION["create_response"]) != "") {
            $create_response = $_SESSION["create_response"];
        } else {
            $create_response = "";
        }

?>

        <body class="theme-blush">

            <!-- Page Loader -->
            <?php
            include('loader.php');
            ?>

            <!-- Overlay For Sidebars -->
            <div class="overlay"></div>

            <!-- Main Search -->
            <div id="search">
                <button id="close" type="button" class="close btn btn-primary btn-icon btn-icon-mini btn-round">x</button>
                <form>
                    <input type="search" value="" placeholder="Search..." />
                    <button type="submit" class="btn btn-primary">Search</button>
                </form>
            </div>

            <?php
            include('right-sidebar.php');
            include('left-side.php');
            ?>


            <!-- Right Sidebar -->
            <?php
            include('settings&pops.php');
            ?>
            <section class="content">
                <div class="body_scroll">
                    <div class="block-header">
                        <div class="row">
                            <div class="col-lg-7 col-md-6 col-sm-12">
                                <h2>Create Online Bank Account</h2>
                                <ul class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="dashboard.php"><i class="zmdi zmdi-home"></i> Online Bank</a></li>
                                    <li class="breadcrumb-item">Pages</li>
                                    <li class="breadcrumb-item">Account</li>
                                    <li class="breadcrumb-item active">Create</li>
                                </ul>
                                <button class="btn btn-primary btn-icon mobile_menu" type="button"><i class="zmdi zmdi-sort-amount-desc"></i></button>
                            </div>
                            <div class="col-lg-5 col-md-6 col-sm-12">
                                <button class="btn btn-primary btn-icon float-right right_icon_toggle_btn" type="button"><i class="zmdi zmdi-arrow-right"></i></button>
                                <a href="profile.php" class="btn btn-info btn-icon float-right"><i class="zmdi zmdi-check"></i></a>
                            </div>
                        </div>
                    </div>

                    <div class="container-fluid">
                        <div class="row clearfix">
                            <div style="margin:auto;" class="col-sm-12 col-md-12 col-lg-10">
                                <div class="card">
                                    <div class="header">
                                        <h2><strong>Create</strong> Account</h2>
                                    </div>
                                    <div class="body">
                                        <form onSubmit="return valid();" action="../bank-manager.php?action=op-en" enctype="multipart/form-data" method="POST">
                                            <?php
                                            if ($create_response != '') {
                                            ?>
                                                <div class="alert alert-danger alert-icon alert-dismissible">
                                                    <em style="color:wheat" class="icon ni ni-cross-circle"></em> <strong></strong><?php echo $create_response ?> <button style="color:white" class="close" data-dismiss="alert"></button>
                                                </div>
                                            <?php } ?>
                                            <div class="row clearfix">
                                                <div class="col-lg-8 col-md-12 col-sm-12">
                                                    <div class="form-group">
                                                        <label for="">Account Number</label><small><b>Choose a 10-digit acc. number</b></small>
                                                        <input required type="text" onBlur="userAvailability()" inputmode="numeric" maxlength="10" id="account_number" name="account_number" class="form-control">
                                                        <span id="user-availability-status1" style="font-size:14px;"></span>
                                                    </div>
                                                </div>
                                                <div class="col-lg-4 col-md-12 col-sm-12">
                                                    <div class="form-group">
                                                        <label for="">Username</label>
                                                        <input required type="text" name="username" class="form-control">
                                                    </div>
                                                </div>
                                                <div class="col-lg-4 col-md-12 col-sm-12">
                                                    <div class="form-group">
                                                        <label for="">First Name</label>
                                                        <input required type="text" name="fname" class="form-control">
                                                    </div>
                                                </div>
                                                <div class="col-lg-4 col-md-12 col-sm-12">
                                                    <div class="form-group">
                                                        <label for="">Middle Name</label>
                                                        <input type="text" class="form-control" name="mname">
                                                    </div>
                                                </div>
                                                <div class="col-lg-4 col-md-12 col-sm-12">
                                                    <div class="form-group">
                                                        <label for="">Last Name</label>
                                                        <input required type="text" class="form-control" name="lname">
                                                    </div>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-12">
                                                    <label>Date of Birth</label>
                                                    <div class="input-group masked-input">
                                                        <div class="input-group-prepend">
                                                            <span class="input-group-text"><i class="zmdi zmdi-calendar"></i></span>
                                                        </div>
                                                        <input required type="date" name="dob" class="form-control date" placeholder="Ex: 30/07/2016">
                                                    </div>
                                                </div>
                                                <div class="col-lg-6 col-md-12 col-sm-12">
                                                    <div class="form-group">
                                                        <label>Email Address</label>
                                                        <input required name="email" type="email" class="form-control" placeholder="E-mail">
                                                    </div>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-12">
                                                    <label>Password</label>
                                                    <div class="input-group masked-input">
                                                        <div class="input-group-prepend">
                                                            <span class="input-group-text"><i class="zmdi zmdi-lock"></i></span>
                                                        </div>
                                                        <input required type="text" name="password" class="form-control" placeholder="Choose a Secured Password">
                                                    </div>

                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-12">
                                                    <label>Phone Number</label>
                                                    <div class="input-group masked-input">
                                                        <div class="input-group-prepend">
                                                            <span class="input-group-text"><i class="zmdi zmdi-phone"></i></span>
                                                        </div>
                                                        <input required type="phone" name="phone" class="form-control" placeholder="Ex. +1 (802) 234-7777">
                                                    </div>
                                                    <br>
                                                    <br>
                                                </div>
                                                <div class="col-12">
                                                    <label>Residential Address</label>
                                                    <div class="input-group masked-input">
                                                        <div class="input-group-prepend">
                                                            <span class="input-group-text"><i class="zmdi zmdi-map"></i></span>
                                                        </div>
                                                        <input required type="address" name="address" class="form-control" placeholder="12, Christian Boulevard, ">
                                                    </div>
                                                    <br>
                                                </div>
                                                <div class="col-lg-4 col-sm-12">
                                                    <div class="form-group">
                                                        <label for="currency" class="">Currency<span class="text-danger">* </span><i class="fa fa-credit-card"></i></label>
                                                        <select required class="form-control show-tick ms select2" 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 class="col-lg-4 col-sm-12">
                                                    <div class="form-group">
                                                        <label for="acc_ype" class="">Account Type<span class="text-danger">* </span><i class="fa fa-credit-card"></i></label>
                                                        <select required class="form-control show-tick ms select2" name="acc_type">
                                                            <option value="Savings">Savings</option>
                                                            <option value="Checking">Checking </option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="col-lg-4 col-sm-6 col-md-12">
                                                    <div class="form-group">
                                                        <label>City, State</label>
                                                        <input required name="state" type="text" class="form-control" placeholder="Austin, Texas">
                                                    </div>
                                                </div>

                                                <div class="col-lg-4 col-sm-6">
                                                    <label for="">Country</label>
                                                    <select required name="country" class="form-control show-tick ms select2" data-placeholder="Select">
                                                        <?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 class="col-12">
                                                    <div class="form-group">
                                                        <label>Upload A Square Passport</label>
                                                        <input required accept="image/*" name="image" type="file" class="form-control" placeholder="Austin, Texas">
                                                    </div>
                                                    <br><br>
                                                </div>
                                                <div style="margin:auto;" class="col-md-12">
                                                    <button class="btn btn-primary">Create Account</button>
                                                </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                </div>
                </div>
            </section>
    <?php include('footer.php');
    }
} ?>
    <script>
        jQuery(document).ready(function() {
            Main.init();
            Login.init();
        });
    </script>
    <script>
        function userAvailability() {
            $("#loaderIcon").show();
            jQuery.ajax({
                url: "check-availability.php",
                data: 'account_number=' + $("#account_number").val(),
                type: "POST",
                success: function(data) {
                    $("#user-availability-status1").html(data);
                    $("#loaderIcon").hide();
                },
                error: function() {}
            });
        }
    </script>