  <?php
 require_once"labClass.php";
  $con=new labClass();

  $row=$con->getRowCount();                                                                //FUNCTION FOR VISITORS OF HOTEL HERE
  $nr=$row->rowCount()+1;
///
?>
 
 <div class="container mt-3">
 
  <h6>EMPLOYEE REGISTRATION FORM:</h6> 
 

  <!--<form action="https://www.w3schools.com/action_page.php" id="pr" name="pr" class="was-validated">--
    <div class="row">
    <div class="col">
     <div class="form-floating mb-3 mt-3">
        <h6><small></small></h6>
          <input type="text" class="form-control" id="patientID" value="<?php //echo $nr;?>"  name="patientID" disabled="true" required>
       <label for="fname">Patient ID:</label>
       <sup class="text-danger" id="pid"></sup>
       </div>
     </div>-->
  <div class="row">
   <div class="col">

    <div class="form-floating mb-3 mt-3"> 
      <input type="text" class="form-control" id="fname"   style="height:20px;" placeholder="First name" name="fname" required>
       <label for="fname">First Name:</label>
      <sup class="text-danger" id="nf"></sup>
    </div>
</div>  
 <div class="col">
       <div class="form-floating mb-3 mt-3"> 
      <input type="text" class="form-control" id="mname"   placeholder="Middle name" name="mname" required>
       <label for="mname">Middle Name:</label>
      <sup class="text-danger" id="mn"></sup>
    </div>
 </div>

    <div class="col">
    <div class="form-floating mb-3 mt-3"> 
      <input type="text" class="form-control" id="lname"   placeholder="Last name" name="lname" required>
       <label for="lname">Last Name:</label>
      <sup class="text-danger" id="ln"> </sup>
    </div>
</div>
    </div>
   <div class="row">
   <div class="col">

   <div class="form-floating mb-3 mt-3"> 
      <input type="number" class="form-control"   id="phoneno" placeholder="Phone number" name="phoneno" required>
       <label for="phoneno">Phone number:</label>
      <sup class="text-danger" id="p"> </sup>
    </div>
  </div>
 
  
  <div class="col">
       <div class="form-floating mb-3 mt-3"> 
      <input type="text" class="form-control" id="address"   placeholder="Address" name="address" required>
       <label for="address">Address:</label>
      <sup class="text-danger" id="ad"> </sup>
    </div>
 </div>  
    <div class="col">
       <div class="form-floating mb-3 mt-3"> 
      <input type="text" class="form-control" id="country"   placeholder="Citizenship" name="country" required>
       <label for="country">Citizenship:</label>
      <sup class="text-danger" id="c"> </sup>
    </div> 
  </div>
</div>
  <div class="row">
    <div class="col">
     <div class="form-floating mb-3 mt-3">   
      <input type="date" class="form-control" id="dhired" name="dhired" required>
       <label for="dhired">Date hired:</label>
      <sup class="text-danger" id="dh"> </sup>
    </div>
    </div>  
    <div class="col">
    <div class="form-floating mb-3 mt-3"> 
      <select class="form-select" id="depart" name="depart">
      
      <option value="">Department</option>
      <option value="Receiption">Receiption</option>

      <option value="Lab">Lab</option> 

      <option value="Nurse">Nurse</option>

      <option value="Pharmacy">Pharmacy</option>
     <option value="Doctor">Doctor</option>
      <option value="Manager">Manager</option>
    </select> 
     <sup class="text-danger" id="dp"> </sup>
    </div>
    </div>
 
  <div class="col">
      <div class="form-floating mb-3 mt-3"> 
      <input type="email" class="form-control" id="email"   width="30%"   name="email" required>
       <label for="email">Email:</label>
      <sup class="text-danger" id="em"> </sup>
    </div>
  </div>
  </div>
   <div class="row">
    <div class="col">
     <div class="form-floating mb-3 mt-3">   
      <input type="date" class="form-control" id="dob" placeholder="Date of birth" name="dob" required>
       <label for="dob">Date of birth:</label>
      <sup class="text-danger" id="ob"> </sup>
    </div>
    </div>  
    <div class="col">
    <div class="form-floating mb-3 mt-3"> 
      <select class="form-select" id="gender" name="gender">
        <option value=""></option>
      <option value="Male">Male</option>
      <option value="Female">Female</option> 
    </select> 
     <sup class="text-danger" id="g"> </sup>
    </div>
    </div>
 
  <div class="col">
      <div class="form-floating mb-3 mt-3"> 
      <input type="text" class="form-control" id="occupation"   width="30%" placeholder="Occupation" name="occupation" required>
       <label for="occupation">Occupation:</label>
      <sup class="text-danger" id="o"> </sup>
    </div>
  </div>
  </div>

  <div class="row">
  <div class="col">
  <div class="form-floating mb-3 mt-3"> 
      <input type="password" class="form-control" id="pwd"   placeholder="Enter password" name="pwd" required>
       <label for="pwd">Password</label>
      <sup class="text-danger" id="pw"> </sup>
    </div> 

    </div>
    
 
    <div class="col">


   <div class="form-floating mb-3 mt-3"> 
      <input type="password" class="form-control" id="cpwd"   placeholder=" password" name="cpwd" required>
       <label for="pwd">Confirm password</label>
      <sup class="text-danger" id="cpw"> </sup>
    </div>
  </div>
    <div class="col">
  <input type="submit" class="btn btn-primary" id="submit" name="submit" style="height:60PX;" onclick="saveEData();" value="Submit"/>
 
</div>
</div> 
</div>

 </div>
<script>
//$(document).ready(function(){
  
//$("#pr").on('submit',function(e){
 function saveEData(){ 
var ecc=0; 
var fname =document.getElementById('fname').value; 
$.trim(fname);
var submit =document.getElementById('submit').value; 

var mname =document.getElementById('mname').value;
$.trim(mname);

var lname =document.getElementById('lname').value;
$.trim(lname);
var email =document.getElementById('email').value;
$.trim(email);

var depart =document.getElementById('depart').value;
$.trim(depart);

var dhired =document.getElementById('dhired').value;
 

var password =document.getElementById('pwd').value;
$.trim(password);

var cpassword =document.getElementById('cpwd').value;
$.trim(cpassword);

var address =document.getElementById('address').value;
$.trim(address); 

var country =document.getElementById('country').value;
$.trim(country);
 
var phoneno =document.getElementById('phoneno').value;
$.trim(phoneno);

var occupation =document.getElementById('occupation').value;
$.trim(occupation);

var dob =document.getElementById('dob').value;

var gender =document.getElementById('gender').value;
$.trim(gender); 

var vN =/[\(A-Za-z)]/g; 

var nV =/[a-z\s]/i;
  var j=0,k=0, g=0,i=0;

                                                         //FIRST NAME VALIDATION
if(fname=="")
{
//e.preventDefault();
ecc++;
document.getElementById('nf').innerHTML="First name is required!..";
 } 
 else
 {

      for(i=0;i<fname.length;i++)
       {
         if(!fname[i].match(vN))
          {
             j++;

           }
        }
      
       if(j>0){
        //e.preventDefault();
        ecc++;
       
        document.getElementById('nf').innerHTML="Invalid name"; 


              }
         else{

        document.getElementById('nf').innerHTML="";

              }
   }
 
    j=0, i=0;
                                                                               ///MIDDLE NAME VALIDATION
 

if(mname==""){
//e.preventDefault();
ecc++;
document.getElementById('mn').innerHTML="Middle name is required!..";
 }
 else{

     for(i=0;i<mname.length;i++)
       {
         if(!mname[i].match(vN))
          {
             j++;

          }
        }
      
       if(j>0){
       //e.preventDefault();
      ecc++;
        document.getElementById('mn').innerHTML="Invalid name"; 
              }
         else{
       

        document.getElementById('mn').innerHTML="";

              }
   }
 
    j=0, i=0;
               
 

if(depart==""){
//e.preventDefault();
ecc++;
document.getElementById('dp').innerHTML="Department is required!..";
 }
 else{

    

        document.getElementById('dp').innerHTML="";

      
   }
 
    j=0, i=0;
var mail=/[\(A-Za-z)][\w.]\w+@\w+\.(net|com|edu)/;
if(email==""){
  ecc++;
// e.preventDefault();
document.getElementById('em').innerHTML="E-mail address is required!..";
 

             }
 else{
  
         if(!email.match(mail))
          {
          ecc++;
        //e.preventDefault();
        document.getElementById('em').innerHTML="Invalid email"; 
              }
         else{ 

        document.getElementById('em').innerHTML="";

              }
   }
 
 
    j=0, i=0;
               

 if(dhired=="")
 { 
ecc++;
document.getElementById('dh').innerHTML="Date hired is required!..";
 }
 else
 {

      
        document.getElementById('dh').innerHTML="";
 
  }
 
    j=0, i=0;

                                                                            ///LAST NAME VALIDATION



if(lname==""){
 //e.preventDefault();
 ecc++;
  document.getElementById('ln').innerHTML="Last name is required!..";
 
 
              }
 else{

     for(i=0;i<lname.length;i++)
       {
         if(!lname[i].match(vN))
          {
             j++;

           }
        }
      
       if(j>0){
        //e.preventDefault();
        ecc++;
        document.getElementById('ln').innerHTML="Invalid name"; 
              }
         else{

        document.getElementById('ln').innerHTML="";

              }
   }
 
    j=0, i=0;
               


 
                                                                            ///STREET VALIDATION
 

if(address==""){
 //e.preventDefault();
 ecc++;
document.getElementById('ad').innerHTML="Address is required!..";
 

 }
 else{

       for(i=0;i<address.length;i++)
         {
         if(!address[i].match(nV))
          {
             j++;

           }
          }
      if(j>0){
       //e.preventDefault();
       ecc++;
        document.getElementById('ad').innerHTML="Invalid address"; 
              }
         else{
 
        document.getElementById('ad').innerHTML="";

              }
   }
 
    j=0, i=0;
               
 

 

  
                                                                ///COUNTRY VALIDATION

 
if(country==""){
//e.preventDefault();
ecc++;
document.getElementById('c').innerHTML="Country is required!..";
 

               }
 else{

    for(i=0;i<country.length;i++)
       {
         if(!country[i].match(nV))
          {
             j++;

           }
        }
      
       if(j>0){
       // e.preventDefault();
        ecc++;
        document.getElementById('c').innerHTML="Invalid country name!.."; 
              }
         else{ 
        document.getElementById('c').innerHTML="";

              }
   }
 
    j=0, i=0;                                                                        


     ///PHONE NUMBER VALIDATION

 var phn =/[\(0-9)]{12}/;
   
if(phoneno==""){
//e.preventDefault();
ecc++;
document.getElementById('p').innerHTML="Phone is required valid one!..";
 
 
              }
 else{ 
       
       
  

       if(phoneno.length >12 || phoneno.length < 10)
         {
 
        //e.preventDefault();
        ecc++;
        document.getElementById('p').innerHTML="Valid phone number must contain either 10 or 12 digits.."; 
              

         }

         else
         {

        document.getElementById('p').innerHTML="";

        }
   }
 
    j=0, i=0; 
                                                               /// GENGER VALIDATION

if(  dob==""){
//e.preventDefault();
ecc++;
document.getElementById('ob').innerHTML="Date of birth is required!..";
 

               }
else{

document.getElementById('ob').innerHTML="";
    }
  
 /*if(  patientID==""){
//e.preventDefault();
ecc++;
document.getElementById('pid').innerHTML="patientID is required!..";
 

               }
else{

document.getElementById('pid').innerHTML="";
    }*/
  
if(  gender==""){
//e.preventDefault();
ecc++;
document.getElementById('g').innerHTML="gender is required!..";
 

               }
else{

document.getElementById('g').innerHTML="";
    }
  
                                                           ///OCCUPATION VALIDATION

 

if(occupation=="")
{
//e.preventDefault();
ecc++;
document.getElementById('o').innerHTML="Occupation is required!..";
 
}
 else{

     for(i=0;i<occupation.length;i++)
       {
         if(!occupation[i].match(nV))
          {
             j++;

           }
        }
      
       if(j>0){
        //e.preventDefault();
        ecc++;
        document.getElementById('o').innerHTML="You typed occupation with error"; 
              }
         else{

        document.getElementById('o').innerHTML="";

              }
   }
 
    j=0, i=0; 
                                                                   ///PASSWORD VALIDATION
var pd =/[\(A-Za-z)]/;
  var  pw =/[\(0-9)]/;

var j=0,k=0, g=0,i=0;  


if(password==""){
 //e.preventDefault();
document.getElementById('pw').innerHTML="Password is required !..";
 
 ecc++;
                 }

 else{ 
       for (var i =0; i < password.length ; i++)
        {

             if(password[i].match(pd) )
             {
             j++;
             }
        }
         
        for (var i =0; i < password.length ; i++)
        {

             if(!password[i].match(pd) && !password[i].match(pw) )
             {
             k++;
             }
        }
         
          for (var i =0; i < password.length ; i++)
        {

             if( password[i].match(pw) )
             {
             g++;
             }
        }
         

        if(j<=0)
        { 
          ecc++;
         document.getElementById('pw').innerHTML="Strong password must contain atleast letters mixed with digits"; 

              
         }
         
         else if(k>0)
         {
         ecc++;
         document.getElementById('pw').innerHTML="You typed unrequired character in a password"; 

         }
         else if(g<=0)
         {
            ecc++;
            document.getElementById('pw').innerHTML="Strong password must contain atleast one digits";

         }
         
         else
          {




                     if(password.length<8)
                        {
                      ecc++;
                     document.getElementById('pw').innerHTML="Valid password must contain 8 charracters.."; 
              

                        }

                        else
                        { 
                        document.getElementById('pw').innerHTML="";

                         }
            }
          }
        
         
     
 
    j=0, i=0;k=0;g=0; 


                                                                           ///CONFIRM PASSWORD VALIDATION


 



if(cpassword=="")
{
//e.preventDefault();
document.getElementById('cpw').innerHTML="Confirm password!..";
 
}
 else if(cpassword!=password)
{
//e.preventDefault();
document.getElementById('cpw').innerHTML="Password mismatch!..";
 

 }

 else
 {

document.getElementById('cpw').innerHTML="";
 }
  //alert("password:"+password+",email:"+email+",dhired:"+dhired+",depart:"+depart+",fname:"+fname+"mname:"+mname+",lname:"+lname+",phoneno:"+phoneno+",address:"+address+",occupation:"+occupation+",country:"+country+",gender:"+gender+",dob:"+dob);
    if(ecc==0)
    {
      //alert("Error found:"+ecc);
        $.post("empRegPro.php",
          {submit:submit,password:password,email:email,dhired:dhired,depart:depart,fname:fname,mname:mname,lname:lname,phoneno:phoneno,address:address,occupation:occupation,country:country,gender:gender,dob:dob},
          function(data){
      $('#disp').html(data).show();

    });
    }


 
//}
//);
//}
}
//);

</script>