<?php include("templates/global.php"); ?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">

  <title><?php echo $settings['org_name']; ?> : Create Account </title>
  <meta content="" name="description">
  <meta content="" name="keywords">
  <?php include("templates/inc.php"); ?>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
   
	<script>
        $(document).ready(function() {

            $("#mebBtn").click(function() {
            $("#mebBtn").html("Creating Accout ...");
				
            var v_code = $("#v_code").val();
         
            var designation = $("#designation").val();
            var name = $("#name").val();
            var email = $("#email").val();
            var mobile = $("#mobile").val();
            var state_id = $("#state_id").val();
            var district_id = $("#district_id").val();
            var address = $("#address").val();
            var password = $("#password").val();

            $.ajax({
                type: 'post',
                url: 'create-account-action.php',
                data: 
                {
                    'v_code': v_code,
                    'designation': designation,
                    'name': name,
                    'email': email,
                    'mobile': mobile,
                    'state_id': state_id,
                    'district_id': district_id,
                    'address': address,
                    'password': password,
                },
                
                    success: function(data)
                    {
                        $("#mebBtn").html("Create Accout");
                        alert(data);
                        location.reload();
                       
                        
                    }

                });

            });
        });
        
        
         $(function () {
  $("#state_id").change(function(){
	 
   var id=$("#state_id").val();
   
	
		$.ajax({
			 type:'post',
			 url: 'get-districts.php',
			 data: {'id':id},
			 success: function(data)
			 {	 
			    
				 $("#district_id").html(data); 
				
			  }
		 });
       });
       
  });
    </script>
    
</head>

<body>

  <main>
    <div class="container">

      <section class="section register min-vh-100 d-flex flex-column align-items-center justify-content-center py-4">
        <div class="container">
          <div class="row justify-content-center">
            <div class="col-lg-6 col-md-6 d-flex flex-column align-items-center justify-content-center">

              <div class="d-flex justify-content-center py-2">
                <a href="index.php" class="logo d-flex align-items-center w-auto">
                </a>
              </div><!-- End Logo -->

              <div class="card mb-1">

                <div class="card-body mt-3">
                 <center>
                  <br>
                 <img src="admin/assets/workforce-logo-rect.jpg" style="height:60px"> 
                  </center>
            

                  <div class="pt-2 pb-2">
                    <h5 class="card-title text-center pb-0 fs-4">Create Account</h5>
                  </div>

                  <form class="row g-3 needs-validation" novalidate>
                       <label for="yourDesignation" class="form-label">Select Type*</label>
                        <select class="form-select" id="designation">
                          <option value="" disabled selected hidden>Select Your Type</option>
                          <option value="Silver">Silver</option>
                          <option value="Platinum">Platinum</option>  
                        </select>
                                    

                    <div class="col-12">
                      <label for="yourUsername" class="form-label">Name*</label>
                      <div class="input-group has-validation">
                        <!--<span class="input-group-text" id="inputGroupPrepend">@</span>-->
                        <input type="text" name="name" id="name" class="form-control" placeholder="Enter Full Name" required>
                        <div class="invalid-feedback">Please enter your name.</div>
                      </div>
                    </div>
                    
                    
                    <div class="col-12">
                      <label for="yourUsername" class="form-label">Mobile Number*</label>
                      <div class="input-group has-validation">
                        <!--<span class="input-group-text" id="inputGroupPrepend">@</span>-->
                        <input type="number" name="mobile" id="mobile" class="form-control" placeholder="Enter 10 Digit Mobile" required>
                        <div class="invalid-feedback">Please enter your mobile number.</div>
                      </div>
                    </div>
                    
                    
                    <div class="col-12">
                      <label for="yourUsername" class="form-label">Email</label>
                      <div class="input-group has-validation">
                        <input type="email" name="email" id="email" class="form-control" placeholder="Enter Email Id" required>
                        
                      </div>
                    </div>
                    
                    
                    
                     <div class="col-md-12">
                                        <label for="validationDefault04" class="form-label">State*</label>
                                        <select class="form-select" id="state_id" name="state_id" required="">
                                            <option selected="salacted" value="0">Choose...</option>
                                                <?php
                                                include("./conn.php");
                                                $sql = "select * from state order by state_title asc";
                                                $smt = mysqli_query($conn, $sql);
                                                while ($rs = mysqli_fetch_assoc($smt)) 
                                                {
                                                    echo '<option value="'.$rs['id'].'">'.$rs['state_title'].'</option>';
                                                }
                                                ?>
                                        </select>
                                    </div>


                                     <div class="col-md-12">
                                        <label for="validationDefault04" class="form-label">District*</label>
                                        <select class="form-select" id="district_id" name="district_id" required="">
                                            
                                        </select>
                                    </div>

                    <div class="col-md-12">
                        <label for="validationCustom01" class="form-label">Address</label>
                          <textarea  type="text" class="form-control" id="address" name="address" required=""><?php if (isset($_GET['id'])) echo $row['address']; ?></textarea>
                          <div class="invalid-feedback">
                                            Please provide a address.
                            </div>
                            </div>
                            
                    <div class="col-12">
                      <label for="yourPassword" class="form-label">Create Password*</label>
                      <input type="password" name="password" id="password" class="form-control" placeholder="Enter a Password"  required>
                      <div class="invalid-feedback">Please enter a password!</div>
                    </div>
                    
                    <div class="col-12">
                    <button class="btn btn-primary w-100" type="button" name="mebBtn" tabindex="1" id="mebBtn">Create Account</button>
                    </div>
					          
                    <div class="col-12">
                      <p class="small mb-0" id="msg"></p>
                    </div>
                    <div class="col-12">
                    <a href="index.php"><button class="btn btn-default w-100" type="button" name="btnC" tabindex="1" id="btnC">Back to Login</button></a>
                    </div>
					          
                  </form>

                </div>
              </div>

              
            </div>
          </div>
        </div>

      </section>

    </div>
  </main><!-- End #main -->

  <a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>


   <?php include("templates/vendors.php"); ?>

</body>

</html>