<?php

		$EmpID = '';
        $FirstName = '';
        $LastName = '';
        $FatherName ='';
		$Gender ='';
		$DateofBirth = '';
		$ContactNumber	='';
		$EmailId = '';
		$BloodGroup ='';
		$MartialStatus= '';
		$DateofJoining = '';
		$PreviousYearsOfExp = '';
		$Designation = '';
		$Departmentcode = '';
		$PresentAddress ='';
		$PermanentAddress = '';
		$EmergencyContactName = '';
		$EmergencyContactNumber = '';
		$Edu_Qualification = '';
		$Additional_Qualification = '';
		$AadharNo = '';
		$PANNo = '';
		$BankAccountNo = '';
		$IFSCCode ='';
		$BankBranchName = '';
		$BankAddress = '';
		$PassportNo = '';
		$Passport_Valid_till = '';
		$IsActive = '';
		$ProfilePic = '';
		$Reference_Name = '';
		$Reference_ContactNumber = '';
		$Remarks = '';
		$DepartmentName = '';
		$DOPassport = '';
		$Age = '';
		$DOB = '';
		$DOJ = '';
if(!empty($EmpDetails))
{
    foreach ($EmpDetails as $Emp)
    {
		$EmpID = $Emp->EmpID;
        $FirstName = $Emp->FirstName;
        $LastName = $Emp->LastName;
        $FatherName = $Emp->FatherName;
		$Gender = $Emp->Gender;
		$DateofBirth = $Emp->DateofBirth;
		$from = new DateTime($DateofBirth);
		$to   = new DateTime('today');
		$Age = $from->diff($to)->y;
		$DOB =  $from ->format('Y-m-d');
		$ContactNumber	= $Emp->ContactNumber;
		$EmailId = $Emp->EmailId;
		$BloodGroup = $Emp->BloodGroup;
		$MartialStatus =$Emp->MartialStatus;
		$DateofJoining = $Emp->DateofJoining;
		$dtDOJ = new DateTime($DateofJoining);
		$DOJ =  $dtDOJ ->format('Y-m-d');
		$PreviousYearsOfExp = $Emp->PreviousYearsOfExp;
		$Designation = $Emp->Designation;
		$Departmentcode = $Emp->Departmentcode;
		$DepartmentName = $Emp->DepartmentName;
		$PresentAddress = $Emp->PresentAddress;
		$PermanentAddress = $Emp->PermanentAddress;
		$EmergencyContactName = $Emp->EmergencyContactName;
		$EmergencyContactNumber = $Emp->EmergencyContactNumber;
		$Edu_Qualification = $Emp->Edu_Qualification;
		$Additional_Qualification = $Emp->Additional_Qualification;
		$AadharNo = $Emp->AadharNo;
		$PANNo = $Emp->PANNo;
		$BankAccountNo = $Emp->BankAccountNo;
		$IFSCCode = $Emp->IFSCCode;
		$BankBranchName = $Emp->BankBranchName;
		$BankAddress = $Emp->BankAddress;
		$PassportNo = $Emp->PassportNo;
		$Passport_Valid_till = $Emp->Passport_Valid_till;
		if($Passport_Valid_till != '')
		{
		$dtpassport = new DateTime($Passport_Valid_till);
		$DOPassport =  $dtpassport ->format('Y-m-d');
		}
		$IsActive = $Emp->IsActive;
		$ProfilePic = $Emp->ProfilePic;
		$Reference_Name = $Emp->Reference_Name;
		$Reference_ContactNumber = $Emp->Reference_ContactNumber;
		$Remarks = $Emp->Remarks;
						
    }
}


?>

<script>
     function readURL(input) {
            if (input.files && input.files[0]) {
                var reader = new FileReader();

                reader.onload = function (e) {
                    $('#profilepicture')
                        .attr('src', e.target.result)
                        .width(166)
                        .height(166);
                };

                reader.readAsDataURL(input.files[0]);
            }
        }
		
$(function(){
    $('#checksame').click(function(){
		if ($('#checksame').prop('checked'))
		 
		 {
		
			$('#permanentaddress').val($('#currentaddress').val());
	  
		 }
		 else
		 {
			 $('#permanentaddress').val('');
		 }
	  
    });
});



 function isNumberKey(evt)
       {
          var charCode = (evt.which) ? evt.which : evt.keyCode;
          if (charCode != 46 && charCode > 31 
            && (charCode < 48 || charCode > 57))
             return false;

          return true;
       }
	   
//PAN Validate 
function validatePAN() {
 var reg = /(?=.*[A-Za-z]).{5,}(?=.*[0-9]).{4,}(?=.*[A-Za-z]).{1,}$/;
          
			var PAN = $('#panno').val();
			
			if(PAN != '')
			{
				if (reg.test(PAN) == false) 
				{
					alert('Please Enter Valid PAN Number');
					return (false);
				}
				else
				{
					return true;
				}
			}
			
}
function Validate()
{
     if($("#FirstName").val().length < 1)
	 {
		 alert('Please Enter  FirstName');
		return;
	 }
	 if($("#LastName").val().length < 1)
	 {
		 alert('Please Enter  LastName');
		return;
	 }
	 if($("#FatherName").val().length < 1)
	 {
		 alert('Please Enter  FatherName');
		return;
	 }
	 if($("#DateofBirth").val().length < 1)
	 {
		 alert('Please Enter  Date of Birth');
		return;
	 }
	 if ( $('#ContactNumber').val().length < 1 )
	 {
		 alert('Please Enter  Contact Number');
		return;
	 }
	 else if(!getMobileValidation())
	 { return;}
		 
	 
	 if($("#emailid").val().length < 1)
	 {
		 alert('Please Enter  Email ID');
		return;
	 }
	 else if(!validateEmail()) 
	 {
		 return;
	 }
	 
	
	if($("option:selected", $("#gender")).val() == '-1')
	{
		alert('Please Select Gender');
		return;
	}
	
	if($("option:selected", $("#MartialStatus")).val() == "-1")
	{
		alert('Please Select Martial Status');
		return;
	}
	
	if($("option:selected", $("#bloodgroup")).val() == "-1")
	{
		alert('Please Select Blood group ');
		return;
	}
	 if($("#currentaddress").val().length < 1)
	 {
		 alert('Please Enter  Current Address');
		return;
	 }
	 if($("#permanentaddress").val().length < 1)
	 {
		 alert('Please Enter  Permanent Address');
		return;
	 }
	 if($("#emergencycontactname").val().length < 1)
	 {
		 alert('Please Enter  Emergency Contact Name');
		return;
	 }
	 if($("#emergencycontactnumber").val().length < 1)
	 {
		 alert('Please Enter  Emergency Contact Number');
		return;
	 }
	 else if(!getValidEmergencyNumber())
	 { return;}
	
	
	
		
	if($("#referrercontno").val().length > 0)
	 {	
		getValidReferNumber();
	 }	
	
	if($("#passportno").val().length > 1)
	 {
		 ValidatePassport();	
		
	 }
	
}
function getMobileValidation() {
	var contactNumber = $('#ContactNumber').val().length;
	if(contactNumber < 10)
	{
		alert('Please Enter valid Contact Number');
		return false;
	}
	else
	{
		return true;
	}
}
function getValidEmergencyNumber() {
	var contactNumber = $('#emergencycontactnumber').val().length;
	if(contactNumber < 10)
	{
		alert('Please Enter valid Emergency Contact Number');
		return false;
	}
	else
	{
		return true;
	}
}
function getValidReferNumber() {
	var contactNumber = $('#referrercontno').val().length;
	if(contactNumber > 0 &&  contactNumber < 10)
	{
		alert('Please Enter valid Refernce Contact Number');
		return false;
	}
	else
	{
		return true;
	}
}
function validateEmail() {
			var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
          
			var email = $('#emailid').val();
			
			if(email != '')
			{
            if (reg.test(email) == false) 
            {
                alert('Please Enter Valid Email Address');
                return (false);
            }
			else
			{
				return true;
			}
			}
			
}  
function getAge() {
	
	var  dateString =  $("#DateofBirth").val();
	
    var today = new Date();
    var birthDate = new Date(dateString);
	

    var age = today.getFullYear() - birthDate.getFullYear();
    var m = today.getMonth() - birthDate.getMonth();
    if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
        age--;
    }
	 $("#age").val(age);
   
}

$(function() {
	var d = new Date();

	var month = d.getMonth();
	var day = d.getDate();
	var year = d.getFullYear()  ;
	var SIAStartYear = year - 2015;
	var mindt = year-70;
	var maxdt =  year-15;
	
    $("#DateofBirth").datepicker({
	minDate : new Date(mindt,1,1),
	maxDate : new Date(maxdt,1,1),
	dateFormat: 'mm/dd/yy',changeMonth: true, changeYear: true,yearRange: '-100:+0'


});
	  $("#dateofjoining").datepicker({
	minDate : new Date(year-SIAStartYear,1,1),
	maxDate :'now',
	dateFormat: 'mm/dd/yy',changeMonth: true, changeYear: true,


});
	  $("#ValidTill").datepicker({dateFormat: 'mm/dd/yy',minDate :'now',changeMonth: true, changeYear: true,yearRange: '-0:+100'
});
	 
});

function resetphoto()
{
   
    $("#photo").src("");
}

function ValidatePassport()
{
        var regsaid = /^[A-PR-WY][1-9]\d\s?\d{4}[1-9]$/ig;
		var passport = $("#passportno").val();
		//alert(passport);
        if(regsaid.test(passport) == false)
        {
            alert('You have entered invalid Passport.');
			return;
        }
        
}

</script>
 <style>
 legend{
 color:#00c0ef ! important;
 } 
 .form-group
 {
	 padding-bottom:4%;
   }
   .pad{
	   padding-bottom:1%;
   }
    .badge
   {
	   color:red; background-color:#fff;
   }
 </style>

<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
          <CENTER>Siddharth Industries Employee Profile</CENTER>
         
      </h1>
	  
    </section>
    
    <section class="content">
	<div style="text-align:right;">
    <a href="<?php echo base_url() ?>employeeListing" class="btn btn-info" value="Back">Back</a>
	</div>
	<br/>
        <div class="row">
            <!-- left column -->
            <div class="col-md-12">
              <!-- general form elements -->
                 
 <div class="box box-primary">
		<!-- /.box-header -->
                    <!-- form start -->
					 
               	 
<form role="form" id="addemployee" action="<?php echo base_url() ?>employeedetails/UpdateEmployee" method="post"  enctype="multipart/form-data"> 
 
  <div class="row">
    <div class="col-md-10 col-md-offset-1"   style="border:3px solid #3c8dbc;">
      <form class="form-horizontal" role="form" >
        <fieldset>
		 
          <!-- Form Name -->
          <legend>Personal Information</legend>
           
		   <div class="col-md-12">
		   <div class="col-md-3">
		   <div class="box-header">                                              
                <img id="profilepicture" src="<?php echo  base_url().'uploads/images/'.$ProfilePic ; ?>"  alt="your image"  style="width: 139px;"/><br/>
                <input type='file' onchange="readURL(this);"   id="photo" name="photo"/>  
                <label for="photo">Select profile picture<br/><small>(only .jpg or .png)</small></label>
				
                <input type="hidden" name="Image" id="Image"  value="<?php echo $ProfilePic ; ?>" class="form-control" readonly>
                <input type="text" name="employeeid" id="employeeid"  value="<?php echo $EmpID ; ?>" placeholder="Employee ID" class="form-control" readonly>
                <br/><input type="checkbox" id="isactive" value="<?php echo $IsActive ; ?>" name="isactive" onclick="checkactive"> IsActive
        </div>
		   </div>
		   <div class="col-md-9">
           
            <div class="col-md-6 pad">
			<span>First Name</span><span class="badge">*</span>
              <input type="text" name="FirstName" maxlength="100" value="<?php echo $FirstName ; ?>" id="FirstName" placeholder="First Name" class="form-control" required>
            </div>
             
            <div class="col-md-6 pad"><span>Last Name</span><span class="badge">*</span>
              <input type="text" name="LastName"  maxlength="100" id="LastName" value="<?php echo $LastName ; ?>" placeholder="Last Name" class="form-control" required>
            </div>
			 <div class="col-md-6 pad"><span>Father / Husband  Name</span><span class="badge">*</span>
              <input type="text" name="FatherName" id="FatherName" maxlength="200" value="<?php echo $FatherName ; ?>" placeholder="Father / Husband  Name" class="form-control" required>
            </div>
			<div class="col-md-6 pad"><span>Date Of Birth</span><span class="badge">*</span>
              <input  id="DateofBirth" required name="DateofBirth" value="<?php echo $DOB  ; ?>"  maxlength="10" placeholder="Date Of Birth" onchange="getAge();" class="form-control">
            </div>
 			 
			<div class="col-md-6 pad"><span>Age</span><span class="badge">*</span>
              <input type="text"  name="age" placeholder="Age" id="age"  value="<?php echo $Age  ; ?>"  class="form-control" readonly>
            </div>
            <div class="col-md-6 pad"><span>Contact Number</span><span class="badge">*</span>
              <input type="text" name="ContactNumber"  value="<?php echo $ContactNumber  ; ?>"  onchange="getMobileValidation();"  onkeypress="return event.charCode >= 48 && event.charCode <= 57" id="ContactNumber" required placeholder="Contact Number" maxlength="10"  class="form-control">
            </div>
            <div class="col-md-6 pad"><span>Email ID</span><span class="badge">*</span>
              <input type="mail" name="emailid"  value="<?php echo $EmailId  ; ?>" id="emailid" placeholder="Email ID" maxlength="100" class="form-control">
            </div>
            
            <div class="col-md-6 pad"><span>Gender</span><span class="badge">*</span>
              <select id="gender" name="gender" type="text" placeholder="Gender" required class="form-control">
                <option  value="<?php echo $Gender  ; ?>"><?php echo $Gender; ?></option>
			  <?php
                                            if(!empty($GenderList))
                                            {
                                                foreach ($GenderList as $rl)
                                                {
                                                    ?>
                                                    <option value="<?php echo $rl->ConfigValue ?>"><?php echo $rl->ConfigValue ?></option>
                                                    <?php
                                                }
                                            }
                                            ?>
              </select>
            </div>
			
            <div class="col-md-6 pad"><span>Marital Status</span><span class="badge">*</span>
              <select  id="MartialStatus" name="MartialStatus" type="text" required placeholder="Marital status" class="form-control">
                <option  value="<?php echo $MartialStatus?>"><?php echo $MartialStatus; ?></option>
			   <?php
								if(!empty($MartialList))
                                            {
                                                foreach ($MartialList as $rl)
                                                {
                                                    ?>
                                                    <option value="<?php echo $rl->ConfigValue ?>"><?php echo $rl->ConfigValue ?></option>
                                                    <?php
                                                }
                                            }
                                            ?>
              </select>
            </div>
           
  
		  <div class="col-md-6 pad"><span>Blood group</span><span class="badge">*</span>
			<select id="bloodgroup" name="bloodgroup"  required class="form-control">
			  <option  value="<?php echo $BloodGroup   ; ?>"><?php echo $BloodGroup  ?></option>
      <?php
								if(!empty($BloodGroupList))
                                            {
                                                foreach ($BloodGroupList as $rl)
                                                {
                                                    ?>
                                                    <option value="<?php echo $rl->ConfigValue ?>"><?php echo $rl->ConfigValue ?></option>
                                                    <?php
                                                }
                                            }
                                            ?>
			 </select>
		  </div>
  </div>
</div>
		  
         

<!-- Address Section -->
          <!-- Form Name -->
          <legend>Address Details</legend>
          <!-- Text input-->
          <div class="form-group">
            <div class="col-md-12"><span>Current Address</span><span class="badge">*</span>
              <input type="text" id="currentaddress" required name="currentaddress" value="<?php echo $PresentAddress   ; ?>" maxlength="500"   placeholder="Current Address" class="form-control">
            </div>
          </div>
		   <div class="form-group">
                <div class="col-md-10">
                  <input type="checkbox" id="checksame" name="sameaddress" onclick="CheckClick">   Current address same as permanent address
                </div>                
          </div>
          <!-- Text input-->
          <div class="form-group">
            <div class="col-md-12"><span>Permanent Address</span><span class="badge">*</span>
              <input type="text" id="permanentaddress" required name="permanentaddress" value="<?php echo $PermanentAddress; ?>" maxlength="500"  placeholder="Permanent Address " class="form-control">
            </div>
          </div>
          <!-- Text input-->
          


<!-- Emergency Contact Section -->
          <!-- Form Name -->
          <legend>Emergency Contact Information</legend>
          <!-- Text input-->
          <div class="form-group">
            <div class="col-md-6"><span>Emergency Contact Name</span><span class="badge">*</span>
              <input type="text" id="emergencycontactname" maxlength="100" required name="emergencycontactname" value="<?php echo $EmergencyContactName ; ?>" placeholder="Emergency Contact Name" class="form-control">
            </div>
            <div class="col-md-6"><span>Emergency Contact Number</span><span class="badge">*</span>
              <input type="text" id="emergencycontactnumber" required name="emergencycontactnumber" onchange="getValidEmergencyNumber();" onkeypress="return event.charCode >= 48 && event.charCode <= 57" maxlength="10"  value="<?php echo $EmergencyContactNumber; ?>" placeholder="Emergency Contact Number" class="form-control">
            </div>
             
          </div>
          
		   
<!-- profile Section -->
          <!-- Form Name -->
          <legend>Work Profile</legend>
          <!-- Text input-->
		  
          <div class="form-group">
            <div class="col-md-3"><span>Designation</span><span class="badge">*</span>
			 <select type="text" id="desigination" name="desigination"  required class="form-control">
               <option  value="<?php echo $Designation ; ?>"><?php echo $Designation;   ?></option>
      <?php
								if(!empty($DesignationList))
                                            {
                                                foreach ($DesignationList as $rl)
                                                {
                                                    ?>
                                                    <option value="<?php echo $rl->ConfigValue ?>"><?php echo $rl->ConfigValue ?></option>
                                                    <?php
                                                }
                                            }
                                            ?>
              </select>
             
            </div>
            <div class="col-md-3"><span>Department</span><span class="badge">*</span>
               <select type="text" id="departmentname" name="departmentname" required  class="form-control">               
				<option  value="<?php echo $Departmentcode; ?>"><?php echo $Departmentcode." - ".$DepartmentName ;?></option>
      <?php
								if(!empty($DepartmentList))
                                            {
                                                foreach ($DepartmentList as $rl)
                                                {
                                                    ?>
                                                    <option value="<?php echo $rl->DEPCode ?>"><?php echo $rl->DEPCode." - " .$rl->DepartmentName ?></option>
                                                    <?php
                                                }
                                            }
                                            ?>				
              </select>
			  
            </div>
            <div class="col-md-3"><span>Date Of Joining</span><span class="badge">*</span>
              <input  id="dateofjoining" name="dateofjoining"   value="<?php echo $DOJ; ?>"  maxlength="10" required placeholder="Date Of Joining" class="form-control">
            </div>
			<div class="col-md-3"><span>Previous Years of Experience</span>
              <input type="text" id="Previousexperience"  value="<?php echo $PreviousYearsOfExp ; ?>" name="Previousexperience" maxlength="4" onkeypress="return isNumberKey(event)" placeholder="Previous Years of Experience" class="form-control">
            </div>
          </div>
		  
		  <div class="form-group">
            <div class="col-md-3"><span>Qualification</span><span class="badge">*</span>
              <select type="text"  id="eduqualifaction" name="eduqualifaction" required class="form-control">
               <option  value="<?php echo $Edu_Qualification; ?>"><?php echo $Edu_Qualification ;   ?></option>
      <?php
								if(!empty($QualificationList))
                                            {
                                                foreach ($QualificationList as $rl)
                                                {
                                                    ?>
                                                    <option value="<?php echo $rl->ConfigValue ?>"><?php echo $rl->ConfigValue ?></option>
                                                    <?php
                                                }
                                            }
                                            ?>
              </select>
			  
            </div>
            <div class="col-md-3"><span>Additional Qualification</span>
              <input type="text" id="addqualification" name="addqualification" value="<?php echo $Additional_Qualification ; ?>" maxlength="100" placeholder="Additional Qualification" class="form-control">
            </div>
            <div class="col-md-3"><span>Referred By</span>
              <input type="text" id="referredby" name="referredby" value="<?php echo $Reference_Name ; ?>" placeholder="Referred By" maxlength="100" class="form-control">
            </div>
			<div class="col-md-3"><span>Referrer Contact Number</span>
              <input type="text" id="referrercontno" name="referrercontno" value="<?php echo $Reference_ContactNumber ; ?>" onchange="getValidReferNumber();" maxlength="10" onkeypress="return event.charCode >= 48 && event.charCode <= 57" placeholder="Referrer Contact Number" class="form-control">
            </div>
          </div>
          
          <legend>Bank Details</legend>
          <!-- Text input-->
		  
          <div class="form-group">
            <div class="col-md-3"><span>Account Number</span> 
              <input type="text" id="accountno" onkeypress="return event.charCode >= 48 && event.charCode <= 57" maxlength="20"  name="accountno" placeholder="Account Number" class="form-control" value="<?php echo $BankAccountNo  ; ?>">
            </div>
            <div class="col-md-3"><span>IFSC Code</span> 
              <input type="text" id="ifsccode" name="ifsccode" placeholder="IFSC Code" maxlength="12" class="form-control" value="<?php echo $IFSCCode ; ?>">
            </div>
            <div class="col-md-3"><span>Bank Branch Name</span> 
              <input type="text" id="bankbranchname" maxlength="200" name="bankbranchname" placeholder="Bank Branch Name" class="form-control" value="<?php echo $BankBranchName  ; ?>">
            </div>
			<div class="col-md-3"><span>Bank Address</span> 
              <input type="text" id="bankaddress" maxlength="200" name="bankaddress" placeholder="Bank Address" class="form-control" value="<?php echo $BankAddress ; ?>">
            </div>
          </div>
		  
		   <legend>ID Proof</legend>
          <!-- Text input-->
		  
          <div class="form-group">
            <div class="col-md-3"><span>Aadhar Number</span> 
              <input type="text" id="aadharno" name="aadharno" maxlength="12"  placeholder="Aadhar Number" class="form-control" value="<?php echo $AadharNo  ; ?>">
            </div>
            <div class="col-md-3"><span>PAN Number</span> 
              <input type="text" id="panno"  maxlength="10"  name="panno" placeholder="PAN Number" onchange="validatePAN();" class="form-control" value="<?php echo $PANNo  ; ?>">
            </div>
            <div class="col-md-3"><span>Passport Number</span> 
               <input type="text" id="passportno"  maxlength="8" onchange="ValidatePassport();" name="passportno" placeholder="Passport Number" class="form-control" value="<?php echo $PassportNo ; ?>">
            </div>
			<div class="col-md-3"><span>Valid Till</span>
               <input  id="ValidTill" name="ValidTill"  maxlength="10"  placeholder="ValidTill" class="form-control" value="<?php echo $DOPassport ; ?>">
            </div>
          </div>
		  
		  
		  
		  
		  <!-- Command -->

          <div class="form-group">
            <div class="col-md-3 col-md-offset-9">
              <div class="pull-right">
			  <a href="<?php echo base_url() ?>employeeListing" class="btn btn-info" id="cancel"  value="Cancel">Cancel</a>
              
                <input type="submit" onclick="Validate();"  class="btn btn-primary">
              </div>
            </div>
          </div>
        </fieldset>
      </form>
    </div><!-- /.col-lg-12 -->
</div><!-- /.row -->
 				 
                    </form>
                </div>
            </div>
            <div class="col-md-4">
                <?php
                    $this->load->helper('form');
                    $error = $this->session->flashdata('error');
                    if($error)
                    {
                ?>
                <div class="alert alert-danger alert-dismissable">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <?php echo $this->session->flashdata('error'); ?>                    
                </div>
                <?php } ?>
                <?php  
                    $success = $this->session->flashdata('success');
                    if($success)
                    {
                ?>
                <div class="alert alert-success alert-dismissable">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <?php echo $this->session->flashdata('success'); ?>
                </div>
                <?php } ?>
                
                <div class="row">
                    <div class="col-md-12">
                        <?php echo validation_errors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>'); ?>
                    </div>
                </div>
            </div>
        </div>    
    </section>
    
</div>

<script src="<?php echo base_url(); ?>assets/js/addUser.js" type="text/javascript"></script>
<script>

 $("#emailid").change(function () {
   
    var id = $('#emailid').val();
		if(validateEmail())
		{	
		 $.ajax({
			data:{id:id},
			
			type:"POST",
			url:"<?php echo base_url();?>employeedetails/CheckEmail",
			success:function(data) {
				if(data)
			{
				alert( data+""+" Employee already exists in the database.Please Change the mail id");
				return false;
				//window.location = 'Employeedetails/employeeListing';	      
			}						
			
		}
		
		});	
		}
  
});
</script>