<div class="container-fluid py-5">
    
    <h3 class="text-center py-2">Add Driver</h3>
    <!--<span class="text-danger">(*)Fields are Mandatory</span>-->
      <?php 
	$success=$this->session->flashdata('message_name');
	$error=$this->session->flashdata('error');
	
	if(!empty($success)) { ?>

	<div class="alert alert-success col-md-6 mx-auto py-1 rounded-0 mb-3">
	<strong>Success!</strong> <?php echo $this->session->flashdata('message_name'); ?>
	</div>

	<?php } ?>
	<?php if(!empty($error)) { ?>

	<div class="alert alert-danger col-md-6 mx-auto py-1 rounded-0 mb-3">
	<strong>Error!</strong> <?php echo $this->session->flashdata('error'); ?>
	</div>

	<?php } ?>
    <div class="box-body">
		<form action="<?=base_url()?>Admin/registration_driver" method="post"  enctype="multipart/form-data" >
						<div class="row col-md-9 mx-auto p-2 bg-white py-3 gy-3">
						<div class="form-group  col-md-6">
							<label for="input_first_name" class="col-sm-3 control-label">First Name<em class="text-danger">*</em></label>
							<div class="col-sm-offset-1">
								<input class="form-control" id="input_first_name" placeholder="First Name" name="first_name" type="text"  onkeypress="return /[a-zA-Z ]/i.test(event.key)" pattern="^[a-zA-Z ]+$" required>
								
							</div>
						</div>
						<div class="form-group  col-md-6">
							<label for="input_last_name" class="col-sm-3 control-label">Last Name<em class="text-danger">*</em></label>
							<div class="col-sm-offset-1">
								<input class="form-control" id="input_last_name" placeholder="Last Name" name="last_name" type="text" fdprocessedid="kilry">
							
							</div>
						</div>
						<div class="form-group  col-md-6">
							<label for="input_email" class="col-sm-3 control-label">Email<em class="text-danger">*</em></label>
							<div class="col-sm-offset-1">
								<input class="form-control" id="email" placeholder="Email" name="email" type="email" required>
							
							</div>
						</div>
							<div class="form-group  col-md-6">
							<label for="gender" class="col-sm-3 control-label">Gender <em class="text-danger">*</em></label>
						<select class="form-control" name="gender" required >
						    <option>Choose Gender</option>
						    <option>Male</option>
						     <option>Female</option>
						</select>
						</div>
						<div class="form-group  col-md-6">
							<label for="input_password" class="col-sm-3 control-label">Password<em class="text-danger">*</em></label>
							<div class="col-sm-offset-1">
								<input class="form-control" id="input_password" placeholder="Password" name="password" type="text" required>
								
							</div>
						</div>
					
					
						<div class="form-group  col-md-6 ">
							<label for="input_status" class=" control-label">Mobile Number <em class="text-danger">*</em></label>
							<div class="col-sm-offset-1">
								<input class="form-control" id="phone" placeholder="Mobile Number" name="mobile_number" type="text" pattern="[6789][0-9]{9}" title="Please enter valid phone number" maxlength="10"  required="required">
							
							</div>
						</div>
						<!--						<div class="form-group  col-md-6">-->
						<!--	<label for="input_company" class="control-label">Company Name<em class="text-danger">*</em></label>-->
						<!--	<div class="col-sm-offset-1">-->
						<!--		<select class="form-control" id="input_company_name" name="company_name" fdprocessedid="6ampgz"><option selected="selected" value="">Select</option><option value="1">Admin</option><option value="6">Odhiambo Atieno</option><option value="7">Test</option><option value="8">BABA</option><option value="12">BIPL</option><option value="16">zara</option><option value="17">Zarayt</option><option value="18">Picky</option><option value="22">Hamid Lusjani</option><option value="25">Siro</option><option value="31">joy</option><option value="38">Công ty TAXI</option><option value="39">weconnect</option><option value="40">S.C SMARTIOOAPP SRL</option><option value="41">Oopal</option><option value="43">NakulC</option><option value="44">conf</option><option value="46">Lakmi chand</option><option value="49">Trackup</option><option value="50">Travel Test</option><option value="52">jorge estrada</option><option value="53">Delight Travelinks</option><option value="55">Hanoon</option><option value="58">Nira</option><option value="60">Malda</option><option value="63">newCompany</option></select>-->
						<!--		<span class="text-danger"></span>-->
						<!--	</div>-->
						<!--</div>-->
						<!--						<div class="form-group  col-md-6">-->
						<!--	<label for="input_status" class="col-sm-3control-label">Status<em class="text-danger">*</em></label>-->
						<!--	<div class="col-sm-offset-1">-->
						<!--		<input class="form-control" id="input_status" readonly="" name="status" type="text" value="Car_details" fdprocessedid="ygjt3e">-->
						<!--	</div>-->
						<!--</div>-->
						<div class="form-group  col-md-6">
							<label for="input_status" class="col-sm-3 control-label">Address </label>
							<div class="col-sm-offset-1">
								<input class="form-control" id="address_line1" placeholder="Address Line 1" name="address" type="text" required>
								<span class="text-danger"></span>
							</div>
						</div>
					
						<div class="form-group  col-md-6">
							<label for="input_status" class="col-sm-3 control-label">City </label>
							<div class="col-sm-offset-1">
								<input class="form-control" id="city" placeholder="City" name="city" type="text" required>
								<span class="text-danger"></span>
							</div>
						</div>
								<div class="form-group  col-md-6">
							<label for="input_status" class="col-sm-3 control-label">Pin Code </label>
							<div class="col-sm-offset-1">
								<input class="form-control" id="postal_code" placeholder="Postal Code" name="pin_code" type="text" onkeypress="return onlyNumberKey(event)" maxlength="6" required="required">
								<span class="text-danger"></span>
							</div>
						</div>
						<div class="form-group  col-md-6">
							<label for="input_status" class="col-sm-3 control-label">State</label>
							<div class="col-sm-offset-1">
								<input class="form-control" id="state" placeholder="State" name="state" type="text" required>
								<span class="text-danger"></span>
							</div>
						</div>
				
				<div class="col-md-6 ">
							    	<label class=" control-label ng-binding">Driving Profile Photo <em class="text-danger">*</em></label>
								<input type="file" name="driver_photo" class="form-control" required>
							
							</div>
					<div class="col-md-6 ">
							    	<label class=" control-label ng-binding">Driving License <em class="text-danger">*</em></label>
								<input type="file" name="driver_file" class="form-control" required>
							
							</div>
							
									<div class="col-sm-6 ">
						<label class="col-sm-3 control-label ng-scope" ng-if="doc.expiry_required=='1'">Expire Date <em class="text-danger">*</em></label>
						<div class=" col-sm-offset-1 ng-scope" ng-if="doc.expiry_required=='1'">
								<input type="date" min="2024-04-09" name="expired_date_1" required class="form-control document_expired" placeholder="Expire date" autocomplete="off" fdprocessedid="3qp1a7">
								<span class="text-danger ng-binding"></span>
							</div>
						</div>
						<div class="col-sm-6 ">
							<label class="control-label ng-binding"> Driving License Status<em class="text-danger">*</em></label>
							<div class=" col-sm-offset-1">
								<select class="form-control" name="driving_license_status" required >
								<option  selected="selected">Select the Driving License Status</option>
									<option value="0"  selected="selected">Pending</option>
									<option value="1" >Approved</option>
									<option value="2" >Rejected</option>
								</select>
							</div>
						</div>
				
			
				
				
			<div class="py-3 text-end">
			    <button type="submit" class="btn btn-primary"  id="continue">Add Driver</button>
			</div>
					</div>
					
					
					
					</form>
											</div>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</div>


<script>
     function onlyNumberKey(evt) {
              
            // Only ASCII character in that range allowed
            var ASCIICode = (evt.which) ? evt.which : evt.keyCode
            if (ASCIICode > 31 && (ASCIICode < 48 || ASCIICode > 57))
                return false;
            return true;
        }
        
        $(document).ready(function() {
     $("#continue").click(function(){
    
  
    
     var phone = document.getElementById("phone").value;
     var email = document.getElementById("email").value;
     var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
     
    
     if (phone=="") {
               
                 alert('Please Enter Phone Number');
                $('#phone').focus();
                
                return false;
            } if (phone.length != 10) {
               
                alert('Please Enter 10 Digit Phone Number');
                $('#phone').focus();
                
                return false;
            }else{
                
                 $.ajax({   url : "<?php echo base_url(); ?>Admin/check_phone",
                            type: 'POST',   
                            data:{phone:phone},  
                            success:function(data){ 
                           
                            if(data==1){
                                
                                 alert('Phone Already Register');
                                 $('#phone').val("");
                                 $('#phone').focus();
                                return false; 
                            }else{
                                 
                            }
                     }
                       
                });    
            }
            if (email=="") {
                 alert('Please enter email ID');
                 $('#email').focus();
                return false;
            }
            
      if( !emailReg.test( email ) ) {
         alert('Please enter valid email ID');
                 $('#email').focus();
        return false;
    }else{
        
                 $.ajax({   url : "<?php echo base_url(); ?>Admin/check_deliemail",
                            type: 'POST',   
                            data:{email_id:email},  
                            success:function(data){ 
                          
                            if(data==1){
                              
                                  alert('Email id Already Register');
                                 $('#email').val("");
                                 $('#email').focus();
                                 return false; 
                            }else{
                                 
                            }
                     }
                       
                });    
            }
            
           
    
  });
  
  
});
</script>


