<?php 
 
include('../dbconnect.php');
ob_start();
session_start();

if( !isset($_SESSION['user']) ) {
 header("Location: ../index.php");
 exit;
}


//VARIABLES
$empID = $_SESSION['user'];
$scode = $_GET['salarycode'];

$sql = "SELECT * FROM `empinfo` JOIN empdetails ON empinfo.empid = empdetails.empid WHERE empinfo.empid = '$empID'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);

///empdetails SQL///////////////////////////////////
$empdsql = "SELECT * FROM empdetails JOIN payrollinfo ON empdetails.detailid = payrollinfo.empID WHERE empdetails.detailid='$empID'";
$empdresult = mysqli_query($conn, $empdsql);
$empdrow = mysqli_fetch_assoc($empdresult);
////////////////////////////////////////////////




///TABS TABS TABS //////////////////////

if(isset($_POST['viewcomp'])){
                                                        
    $cb = 'style="display: block;"';
    $cr = 'style="display: block;"';


}
if(isset($_POST['viewindi'])){
                                                        
    $tabshrd = 'style="display: none;"';
    $tls = 'style="display: block;"';
    $tabindi = 'style="display: block;"';

}
if(isset($_POST['viewshrd'])){
                                                        

    $tls = 'style="display: block;"';
    $tabindi = 'style="display: none;"';
    $tabshrd = 'style="display: block;"';

}




/////////////////////////////////////////

$gid =$row['gid'];
$surname = $row['surname'];
$firstname = $row['firstname'];
$middlename = $row['middlename'];
$permanentadd = $row['permanentadd'];
$residentialadd = $row['residentialadd'];
$bday = $row['bday'];
$age = $row['age'];
$gender = $row['gender'];
$contactno = $row['contactno'];
$email = $row['email'];
$civilstat = $row['civilstat'];
$spouse = $row['spouse'];
$spousebday = $row['spousebday'];
$mothersname = $row['mothersmaiden'];
$motheroccu = $row['mothersoccu'];
$fathersname = $row['fathersname'];
$fatheroccu = $row['fathersoccu'];
$ename = $row['ename'];
$erelatioship = $row['erel'];
$eaddress = $row['eadd'];
$econtactno = $row['econtactno'];
$hireddate = $row['hireddate'];
$thirdmonth = $row['thirdmonth'];
$fifthmonth = $row['fourthmonth'];
$tenure = $row['tenure'];
$level = $row['level'];
$department = $row['department'];
$teams= $row['team'];
$genpos = $row['generalpos'];
$jobtitle =  $row['jobtitle'];
$supervisor = $row['supervisor'];
$status = $row['status'];
$date = $row['date'];
$userpic = $row['picture'];
$inactivedate = $row['inactivedate'];


$atm1 = $empdrow['atm'];
$bank1 = $empdrow['bank'];
$type1 = $empdrow['type'];

$Psurname = $_POST['sname'];
$Pfirstname = $_POST['fname'];
$Pmiddlename = $_POST['mname'];
$Ppermanentadd = $_POST['permanentadd'];
$Presidentialadd = $_POST['residentialadd'];
$Pbday = $_POST['bday'];
$Page = $_POST['age'];
$Pgender = $_POST['gender'];
$Pcontactno = $_POST['contactno'];
$Pemail = $_POST['email'];
$Pcivilstat = $_POST['civilstat'];
$Pspouse = $_POST['spouse'];
$Pspousebday = $_POST['spousebday'];
$Pmothersname = $_POST['mothersname'];
$Pmotheroccu = $_POST['motheroccu'];
$Pfathersname = $_POST['fathersname'];
$Pfatheroccu = $_POST['fatheroccu'];
$Pename = $_POST['ename'];
$Perelatioship = $_POST['erelationship'];
$Peaddress = $_POST['eaddress'];
$Pecontactno = $_POST['econtact'];
$Phireddate = $_POST['hireddate'];
$Pthirdmonth = $_POST['thirdmonth'];
$Pfifthmonth = $_POST['fifthmonth'];
$Ptenure = $_POST['tenure'];
$Plevel = $_POST['level'];
$Pdepartment = $_POST['department'];
$Pteam = $_POST['team'];
$Pgenpos = $_POST['genpos'];
$Pjobtitle =  $_POST['jobtitle'];
$Psupervisor = $_POST['supervisor'];
$Pstatus = $_POST['status'];
$type = $_POST['paytype'];
$atm = $_POST['atm'];
$bank = $_POST['bankaccount'];
$effectdate = $_POST['effectdate'];
$Pinactivedate = $_POST['inactivedate'];
$salarycode = $_POST['salarycode']; 


$selindi = $_POST['selindi'];
$selshrd= $_POST['selshrd'];

//PERSONAL INFORMATION
//UPDATE PERSONAL INFORMATION
if(isset($_POST['saveinfo'])){

    //update profile picture
    $pi = 'style="display: block;"';
    $imgFile = $_FILES['userpic']['name'];
    $tmp_dir = $_FILES['userpic']['tmp_name'];
    $imgSize = $_FILES['userpic']['size'];
    
    if($imgFile)
                 {
                  $upload_dir = '../files/pictures/'; // upload directory 
                  $imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension
                  $valid_extensions = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions
                  $Puserpic = $empID.".".$imgExt;
                  if(in_array($imgExt, $valid_extensions))
                  {   
                   if($imgSize < 5000000)
                   {
                    if($userpic == 'profile.png'){
                        move_uploaded_file($tmp_dir,$upload_dir.$Puserpic);
                           
                       }
                       else {

                        unlink($upload_dir.$userpic);
                        move_uploaded_file($tmp_dir,$upload_dir.$Puserpic);

                       }
                   }
                   else
                   {
                    $errMSG = "Sorry, your file is too large it should be less then 5MB";
                   }
                  }
                  else
                  {
                   $errMSG = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";  
                  } 
                 }
    
                 else
                 {
                  // if no image selected the old image remain as it is.
                  $Puserpic = $userpic; // old image from database
                 } 
                
    
    
    $sql = "UPDATE `empinfo` SET `surname`='$Psurname',`firstname`='$Pfirstname',
    `middlename`='$Pmiddlename',`permanentadd`='$Ppermanentadd',`residentialadd`='$Presidentialadd',`bday`='$Pbday',
    `age`='$Page',`gender`='$Pgender',`contactno`='$Pcontactno',`email`='$Pemail',`civilstat`='$Pcivilstat',
    `mothersmaiden`='$Pmothersname',`fathersname`='$Pfathersname',`mothersoccu`='$Pmotheroccu',`fathersoccu`='$Pfatheroccu',
    `ename`='$Pename',`erel`='$Perelatioship',`eadd`='$Peaddress',`econtactno`='$Pecontactno',`picture`='$Puserpic',`spouse`='$Pspouse',`spousebday`='$Pspousebday' WHERE empid = '$empID'";
    
    //update employee details
    
    $updateemp = "UPDATE `empdetails` SET `hireddate`='$Phireddate',`thirdmonth`='$Pthirdmonth',`fourthmonth`='$Pthirdmonth',
    `tenure`='$Ptenure',`level`='$Plevel',`department`='$Pdepartment',`team`='$Pteam',`generalpos`='$Pgenpos',`jobtitle`='$Pjobtitle',`supervisor`='$Psupervisor',
    `status`='$Pstatus', `inactivedate` = '$Pinactivedate' WHERE `detailid`='$empID'";
    
    if (mysqli_query($conn, $sql) && mysqli_query($conn, $updateemp) ) {
        $alert = "<div class='alert alert-success'><strong style='font-size:12pt;'>Personal Information Successfully Saved.</strong> </div>";
        $pi = "style='display: block;'";
        header("location: updateemp.php?ID=$empID&pi=$pi&alert=$alert");
     
    } else {
        echo "Error updating record: " . mysqli_error($conn);
    }
    
    
    
}
//PRE EMPLOYMENT


if(isset($_POST['savedoc'])){



    $na = $_POST['na'];

   
    $pe = 'style="display: block;"';

    $docimgFile = $_FILES['doc']['name'];
    $doctmp_dir = $_FILES['doc']['tmp_name'];
    $docimgSize = $_FILES['doc']['size'];
    $documents = $_POST['document'];

    $upload_dir = '../files/documents/'; // upload directory
       
    $imgExt = strtolower(pathinfo($docimgFile,PATHINFO_EXTENSION));
    $valid_extensions = array('jpeg', 'jpg', 'png', 'gif');
    $doc = $empID.$documents.".".$imgExt;
    $docID = $empID.$documents;
    if(in_array($imgExt, $valid_extensions)){			
     // Check file size '5MB'
     if($docimgSize < 5000000 )				{
       move_uploaded_file($doctmp_dir,$upload_dir.$doc);
       
     }
     else{
       $error="<div class='alert alert-warning'>
       <strong style='font-size:12pt;'>Sorry, your file is too large</strong> 
     </div>";
     }
 }
 else
 {
     $error="<div class='alert alert-warning'>
     <strong style='font-size:12pt;'>Sorry, only JPG, JPEG, PNG & GIF files are allowed.</strong> 
   </div>";




}
$checkb = $_POST['nacheck'];
    
if($checkb == 'check'){
     $doc = 'none';
         $docstatus = 'N/A';
         $dateupload = '0000-00-00';
echo 'hello world';
   
    
}
else{
    $dateupload = date('Y/m/d');
    $docstatus = 'check';
}


    


//$docsql= "INSERT INTO `documents`(`docid`, `name`, `document`, `date`, `status`, `empid`) VALUES ('$docID','$documents','$doc','$dateupload','check','$empID')";
$docsql= "UPDATE documents SET document='$doc', date='$dateupload', status='$docstatus' WHERE empid='$empID' AND name='$documents'";

if (mysqli_query($conn, $docsql)) {
    $alert = "<div class='alert alert-success'><strong style='font-size:12pt;'>Documents Successfully Added.</strong> </div>";
    $pe = "style='display: block;'";
    header("location: updateemp.php?ID=$empID&pe=$pe&alert=$alert&doc=$pe");


 } else {
  echo "Error: " . $sql . "<br>" . mysqli_error($conn);
 }

}



//GOVERNMENT INFO UPDATE
$sqlgov = "SELECT * FROM `governmentinfo` JOIN empinfo ON governmentinfo.gid = empinfo.gid WHERE governmentinfo.gid  = '$gid'";
    $resultgov = mysqli_query($conn, $sqlgov);
    $rowgov = mysqli_fetch_assoc($resultgov);

    $getsss = $rowgov['sss'];
    $getpagibig = $rowgov['pagibig'];
    $gettin = $rowgov['tin'];
    $getphilhealth = $rowgov['philhealth'];

    

if(isset($_POST['savegov'])){

   
   
    $gi = 'style="display: block;"';


    $gid = $empID;
    $SSS = $_POST['sss'];
    $TIN = $_POST['tin'];
    $philhealth = $_POST['philhealth'];
    $pagibig = $_POST['pagibig'];

    $sql = "UPDATE `governmentinfo` SET
     `sss`='$SSS',`pagibig`='$pagibig',`tin`='$TIN',`philhealth`='$philhealth' WHERE gid='$empID'";
    
    $sql1 = "UPDATE empinfo SET gid='$gid' WHERE empid='$empID'";

    if (mysqli_multi_query($conn, $sql) && mysqli_multi_query($conn, $sql1)) {
        $alert = "<div class='alert alert-success'><strong style='font-size:12pt;'>Government Information Successfully Saved.</strong> </div>";
      $gi = "style='display: block;'";
      header("location: updateemp.php?ID=$empID&gi=$gi&alert=$alert");
  
    } else {
        echo "Error: " . $sql . "<br>" . mysqli_error($conn);
    }

    ///get data
 

}
//COMPENSATION & BENEFIT
if(isset($_POST['addcomp'])){
    
    $cb = 'style="display: block;"';
    $cr = 'style="display: block;"';
   
    $checkcomp = "SELECT * FROM salaryemp WHERE salarycode='$salarycode' AND empid='$empID' AND effectivitydate='$effectdate'";
    $resultcomp = mysqli_query($conn, $checkcomp);
    if (mysqli_num_rows($resultcomp) > 0) {
        $alert ="<div class='alert alert-danger'>
        <strong style='font-size:12pt;'>Salary Package Exist</strong> 
      </div>";

    }
    
    else{
     
        $comsql = "INSERT INTO `salaryemp`(`salarycode`, `effectivitydate`, `empid`) VALUES ('$salarycode','$effectdate','$empID')";
        if(mysqli_query($conn, $comsql)){
            
            $alert ="<div class='alert alert-success'>
            <strong style='font-size:12pt;'>Salary Package Successfully Added</strong> 
          </div>";
    
        }
        else {
            echo "Error: " . $comsql."<br>" . mysqli_error($conn);
        }


    }

}

////ROBINSONS PAYROLL

if(empty($atm1) ){
    $updisabled ="disabled";
 
}
elseif (!empty($atm1)) {
    $addisabled ="disabled";
}

else{
    $bdisabled ="";

}

if(isset($_POST['uppayroll'])){
    $cb = 'style="display: block;"';
    $cr = 'style="display: block;"';
    $hs = 'style="display: none;"';
    $uppaysql = "UPDATE `payrollinfo` SET `atm`='$atm',`bank`='$bank',`type`='$type'WHERE empid='$empID'";

    if (mysqli_query($conn, $uppaysql)){
        $alert = "<div class='alert alert-success'><strong style='font-size:12pt;'>Payroll Information Successfully Saved.</strong> </div>";
        $pi = "style='display: block;'";
        header("location: updateemp.php?ID=$empID&cb=$cb&alert=$alert&cr=$cr&his=$hs");
     
    }
    else {
        echo "Error: " . $uppaysql . "<br>" . mysqli_error($conn);
    }
}

if(isset($_POST['adpayroll'])){
    $cb = 'style="display: block;"';
    $cr = 'style="display: block;"';
    $hs = 'style="display: none;"';
    $paysql = "INSERT INTO `payrollinfo`( `atm`, `bank`, `type`, `empid`) VALUES ('$atm','$bank','$type','$empID')";

    if (mysqli_query($conn, $paysql)){
        $alert = "<div class='alert alert-success'><strong style='font-size:12pt;'>Payroll Successfully Added.</strong> </div>";
        $pi = "style='display: block;'";
        header("location: updateemp.php?ID=$empID&cb=$cb&alert=$alert&cr=$cr&his=$hs");
     
    }
    else {
        echo "Error: " . $paysql . "<br>" . mysqli_error($conn);
    }



}
if(isset($_POST['savecheck'])){

    $pe = 'style="display: block;"';
    $ch = 'style="display: block;"';
    $up = 'style="display: none;"';
    $hs = 'style="display: none;"';
    
    $nbidate = $_POST['nbidate'];
    $nbi = $_POST['nbi'];
    $nsodate = $_POST['nsodate'];
    $nso = $_POST['nso'];
    $meddate = $_POST['meddate'];
    $med = $_POST['med'];
    $birdate = $_POST['birdate'];
    $bir = $_POST['bir'];
    $mdfdate = $_POST['mdfdate'];
    
    $mdf = $_POST['mdf'];
    $mdrdate = $_POST['mdrdate'];
    
    $mdr = $_POST['mdr'];

    $mcdate = $_POST['mcdate'];
    $mc = $_POST['mc'];
    $cbcdate = $_POST['cbcdate'];
    $cbc = $_POST['cbc'];

    $aofdate = $_POST['aofdate'];
    $aof = $_POST['aof'];

    $vdate = $_POST['vdate'];
    $v = $_POST['v'];

    $coedate = $_POST['coedate'];
    $coe = $_POST['coe'];

    $itrdate = $_POST['itrdate'];
    $itr = $_POST['itr'];

    $tordate = $_POST['tordate'];
    $tor = $_POST['tor'];

    $upsql = "UPDATE `checklist` SET `date`='$nbidate',`status`='$nbi' WHERE empid='$empID' AND document='NBI Clearance' ";
    $upsql1 = "UPDATE `checklist` SET `date`='$nsodate',`status`='$nso' WHERE empid='$empID' AND document='NSO/PSA Birth Certificate'";
    $upsql2 = "UPDATE `checklist` SET `date`='$meddate',`status`='$med' WHERE empid='$empID' AND document='Pre Employement Medical Exam'";
    $upsql3 = "UPDATE `checklist` SET `date`='$birdate',`status`='$bir' WHERE empid='$empID' AND document='BIR 1905 and 2305'";
    $upsql4 = "UPDATE `checklist` SET `date`='$mdfdate',`status`='$mdf' WHERE empid='$empID' AND document='Updated MDR'";
    $upsql5 = "UPDATE `checklist` SET `date`='$mdrdate',`status`='$mdr' WHERE empid='$empID' AND document='Updated MDF'";
    $upsql6 = "UPDATE `checklist` SET `date`='$mcdate',`status`='$mc' WHERE empid='$empID' AND document='Marriage Certificate'";
    $upsql7 = "UPDATE `checklist` SET `date`='$cbcdate',`status`='$cbc' WHERE empid='$empID' AND document='Children Birth Certificate'";
    $upsql8 = "UPDATE `checklist` SET `date`='$aofdate',`status`='$aof' WHERE empid='$empID' AND document='Account Opening Form'";
    $upsql9 = "UPDATE `checklist` SET `date`='$vdate',`status`='$v' WHERE empid='$empID' AND document='Valid ID'";
    $upsql10 = "UPDATE `checklist` SET `date`='$coedate',`status`='$coe' WHERE empid='$empID' AND document='Certificate of Employment'";
    $upsql11 = "UPDATE `checklist` SET `date`='$itrdate',`status`='$itr' WHERE empid='$empID' AND document='ITR'";
    $upsql12 = "UPDATE `checklist` SET `date`='$tordate',`status`='$tor' WHERE empid='$empID' AND document='TOR/DIPLOMA'";
    if (mysqli_query($conn, $upsql) &&
    mysqli_query($conn, $upsql1) &&
    mysqli_query($conn, $upsql2) &&
    mysqli_query($conn, $upsql3) &&
    mysqli_query($conn, $upsql4) &&
    mysqli_query($conn, $upsql5) &&
    mysqli_query($conn, $upsql6) &&
    mysqli_query($conn, $upsql7) &&
    mysqli_query($conn, $upsql8) &&
    mysqli_query($conn, $upsql9) &&
    mysqli_query($conn, $upsql10) &&
    mysqli_query($conn, $upsql11) &&
    mysqli_query($conn, $upsql12)) {
        $alert ="<div class='alert alert-success'>
        <strong style='font-size:12pt;'>Document Checklist Successfully Updated</strong>
      </div> ";
    } else {
        echo "Error: " . $upsql . $upsql1."<br>" . mysqli_error($conn);
    }


    


}
///////////////////TOOLS TAB TOOLS TAB TOOLS TAB //////////////////////////////////////////////////
if(isset($_POST['addindi'])){

    
    $tls = 'style="display: block;"';
    $tabindi = 'style="display: block;"';

    $toolsdesc = $_POST['toolsdesc'];
    $toolusername = $_POST['toolusername'];
    $toolpassword = $_POST['toolpassword'];
    $toolid = $_POST['selindi'];

    $checkdup = "SELECT * FROM emptools WHERE idtools = '$toolid' AND empid='$empID' AND username='$toolusername' AND password='$toolpassword'";
    $checkdupres = mysqli_query($conn, $checkdup);
    
    if(mysqli_num_rows($checkdupres) > 0){

        $alert = '<div class="alert alert-danger">Individual Tools Existed</div>';
        header("location: updateemp.php?ID=$empID&alert=$alert&tls=$tls&indi=$tls");

    }else{

        $usersql = "INSERT INTO `emptools`(`description`, `username`, `password`,`empid`, `idtools`) VALUES ('$toolsdesc','$toolusername','$toolpassword','$empID','$toolid')";

        if (mysqli_query($conn, $usersql)) {
          
          
            $alert = '<div class="alert alert-success">Individual Tools Successfully Added</div>';
            header("location: updateemp.php?ID=$empID&alert=$alert&tls=$tls&indi=$tls");
           
        
          
        } 
        else {
            echo "Error: " . $usersql ."<br>" . mysqli_error($conn);
        }


    }


    

}

if(isset($_POST['addshrd'])){
    $tls = 'style="display: block;"';

    
    $shareddesc = $_POST['shareddesc'];
    $sharedusername = $_POST['sharedusername'];
    $sharedpassword = $_POST['sharedpassword'];
    $idshared = $_POST['selshrd'];

    $checkdup = "SELECT * FROM emptools WHERE idtools = '$idshared' AND empid='$empID' AND username='$sharedusername' AND password='$sharedpassword'";
    $checkdupres = mysqli_query($conn, $checkdup);
    
    if(mysqli_num_rows($checkdupres) > 0){

        $alert = '<div class="alert alert-danger">Shared Tools Existed</div>';
        header("location: updateemp.php?ID=$empID&alert=$alert&tls=$tls&indi=$tls");

    }    else{

    

    $usersql = "INSERT INTO `emptools`(`description`, `username`, `password`, `empid`, `idtools`) VALUES ('$shareddesc','$sharedusername','$sharedpassword','$empID','$idshared')";

    if (mysqli_query($conn, $usersql)) {
      
      
        $alert = '<div class="alert alert-success">Individual Tools Successfully Added</div>';
        header("location: updateemp.php?ID=$empID&alert=$alert&tls=$tls&indi=$tls");
       
    
      
    } 
    else {
        echo "Error: " . $usersql ."<br>" . mysqli_error($conn);
    }
    
    }

 
    

}

//////////////////END OF TOOLS TAB END OF TOOLS TAB///////////////////////////////////////////////

////FUNCTIONS FUNCTIONS //////////////////
function empprofile($sname,$fname,$mname,$id,$t,$s,$pic){
   
    echo'

    <div class="col-sm-6">
        <div class="card bg-light text-dark text-center p-3">
            <div class="row" style="text-align:center">
                    <div class="col-sm-3">
               
                        <img id="output_image" style="height: 100px; width: 100px; border-radius:100px;" src="../files/pictures/'.$pic.'" alt="hello"/> 
                    </div>

                    <div class="col-sm-9 text-left">
                    <h4>'.$sname.', '.$fname.' '.$mname.'</h4>
                    <h6>'.$id.' | '.$t.'</h6>
          
                    <h6>'.$s.'</h6>

                    </div>
            </div>

        </div>
    </div>

    ';

}


//////FUNCTIONS FUNCTIONS /////////////


///BENEFITS  UPDATE /////


$benefit = $_POST['benefits'];
$benefitid = $_POST['benid'];
$ptoearned = $_POST['ptoearned'];
$yearupdate = $_POST['yearupdate'];



if(isset($_POST['savebenefits'])){
  
/*     if(){

    }
    
    $Ppto  */

/*     $ptoupdate = "UPDATE pto SET maxpto='$Ppto' WHERE id='$ptoid'";
    $elupdate = "UPDATE pto SET maxpto='$Pel' WHERE id='$elid'";
    $blupdate = "UPDATE pto SET maxpto='$Pbl' WHERE id='$blid'";
    $spupdate = "UPDATE pto SET maxpto='$Psp' WHERE id='$spid'";
    $vawcupdate = "UPDATE pto SET maxpto='$Pvawc' WHERE id='$vawcid'";
    $mcupdate = "UPDATE pto SET maxpto='$Pmc' WHERE id='$mcid'";
    $mtupdate = "UPDATE pto SET maxpto='$Pmt' WHERE id='$mtid'";
    $ptupdate = "UPDATE pto SET maxpto='$Ppt' WHERE id='$ptid'";
    $slupdate = "UPDATE pto SET maxpto='$Psl' WHERE id='$slid'";

    if(mysqli_query($conn, $ptoupdate) && mysqli_query($conn, $elupdate) && mysqli_query($conn, $blupdate) && mysqli_query($conn, $spupdate) && mysqli_query($conn, $vawcupdate)
    && mysqli_query($conn, $mcupdate) && mysqli_query($conn, $mtupdate) && mysqli_query($conn, $ptupdate) && mysqli_query($conn, $slupdate)
    ) {
        echo "UPDATED";
    }
    else{
      echo   mysqli_error($conn);
    } */


$today = date('Y-m-d');

 



    for($a=0; $a < count($benefit); $a++ ){

        if($ptoearned[$a] == 0 ){
          

            $ts1 = strtotime($yearupdate[$a]);
            $ts2 = strtotime($today);
            
            $year1 = date('Y', $ts1);
            $year2 = date('Y', $ts2);
            
            $month1 = date('m', $ts1);
            $month2 = date('m', $ts2);
            
        echo $monthduration = (($year2 - $year1) * 12) + ($month2 - $month1);

        $multiplier = $benefit[$a] / 12;
        $multiplier = round($multiplier, 2);

        $earned = $multiplier * $monthduration;
        if(date('d', strtotime($yearupdate[$a])) > date('d') ){
           

            $month = $month2 - 1;

        }else{

            $month = $month2;
        } 

        if($benefit[$a] != '0'){
            $monthupdate = date('Y').'-'.$month.'-'.date('d', strtotime($yearupdate[$a]));

        }
        else{
             $monthupdate = '';
        }
        

      $benupdate = "UPDATE pto SET multiplier='$multiplier', ptoearned  = '$earned', availablepto= '$earned', maxpto='$benefit[$a]', monthupdate='$monthupdate' WHERE id='$benefitid[$a]'";

        if(mysqli_query($conn, $benupdate)){
            $alert = "<div class='alert alert-success'><strong style='font-size:12pt;'>Employee Benefits Successfully Save.</strong> </div>";
            $benetab = "style='display: block;'";
            $cbben = 'style="display: block;"';
            header("location: updateemp.php?ID=$empID&alert=$alert&cbben=$cbben;&benetab=$benetab");

        }else{
            echo 'FAILED';
            echo mysqli_error($conn);
        }
                    
                    
        
        }

        else{
            $multiplier = $benefit[$a] / 12; 
            $multiplier = round($multiplier, 2);

            $benupdate = "UPDATE pto SET multiplier='$multiplier', maxpto='$benefit[$a]' WHERE id='$benefitid[$a]'";


            if(mysqli_query($conn, $benupdate)){
                $alert = "<div class='alert alert-success'><strong style='font-size:12pt;'>Employee Benefits Successfully Save.</strong> </div>";
                $benetab = "style='display: block;'";
                $cbben = 'style="display: block;"';
                header("location: updateemp.php?ID=$empID&alert=$alert&cbben=$cbben;&benetab=$benetab");
            }else{
                echo 'FAILED';
                echo mysqli_error($conn);
            }


            
        }


        

       


            


        

/*         if(mysqli_query($conn, $benupdate){

        

        }
 */

    }


}






///////////////////////////
?>
<!DOCTYPE html>
<html lang="en">

  <head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Super Admin | Update Employee</title>

    <!-- Bootstrap core CSS-->
    <link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom fonts for this template-->
    <link href="../vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">

    <!-- Page level plugin CSS-->
    <link href="../vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <link rel="icon" href="../images/logo.jpg" type="image/gif" sizes="16x16">


    <!-- Custom styles for this template-->
        <link href="../css/sb-admin.css" rel="stylesheet">
    <link href="../css/style.css" rel="stylesheet">

    <link href = "../css/style.css" rel = "stylesheet">

    <script>
    function csdiv(){
        
        var cs = document.getElementById("civilstat").value;
        if(cs == 'Married' || cs == 'Widowed' || cs == 'Divorced'){
            document.getElementById("civilstatbox").style.display ="block";
        }
        else if(cs == 'Single'){
           
            document.getElementById("civilstatbox").style.display ="none";
    }

    }
    function preview_image(event) 
        {
        var reader = new FileReader();
        reader.onload = function()
        {
        var output = document.getElementById('output_image');
        output.src = reader.result;
        }
        reader.readAsDataURL(event.target.files[0]);
        }

    
       
    function openpi(){
        
        document.getElementById('empinfo').style.display = 'block';
        document.getElementById('pib').style.backgroundColor = '#dddddd';
        document.getElementById('gib').style.backgroundColor = '#f1f1f1';
        document.getElementById('cbb').style.backgroundColor = '#f1f1f1';
        document.getElementById('peb').style.backgroundColor = '#f1f1f1';
        document.getElementById('ts').style.backgroundColor = '#f1f1f1';
        document.getElementById('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'none';
        document.getElementById('compb').style.display = 'none';
        document.getElementById('emptools').style.display = 'none';

        document.getElementById('poshis').style.display = 'none';
        document.getElementById('ph').style.backgroundColor = '#f1f1f1';
        window.history.pushState('object', document.title, location.href.split("&")[0]);
    }
    function opengi(){
        document.getElementById('empinfo').style.display = 'none';
         document.getElementById('gib').style.backgroundColor = '#dddddd';
         document.getElementById('pib').style.backgroundColor = '#f1f1f1';
        document.getElementById('cbb').style.backgroundColor = '#f1f1f1';
        document.getElementById('peb').style.backgroundColor = '#f1f1f1';
        document.getElementById('ts').style.backgroundColor = '#f1f1f1';
        document.getElementById('govinfo').style.display = 'block';
        document.getElementById('preemp').style.display = 'none';
        document.getElementById('compb').style.display = 'none';
        document.getElementById('emptools').style.display = 'none';

        document.getElementById('poshis').style.display = 'none';
        document.getElementById('ph').style.backgroundColor = '#f1f1f1';
        window.history.pushState('object', document.title, location.href.split("&")[0]);
    }
    function opencb(){
        document.getElementById('empinfo').style.display = 'none';
        document.getElementById('cbb').style.backgroundColor = '#dddddd';
         document.getElementById('pib').style.backgroundColor = '#f1f1f1';
        document.getElementById('gib').style.backgroundColor = '#f1f1f1';
        document.getElementById('peb').style.backgroundColor = '#f1f1f1';
        document.getElementById('ts').style.backgroundColor = '#f1f1f1';
        document.getElementById('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'none';
        document.getElementById('compb').style.display = 'block';       
        document.getElementById('current').style.display = 'block';
        document.getElementById('history').style.display = 'none';
        document.getElementById('emptools').style.display = 'none';
        document.getElementById('curb').style.backgroundColor = '#dddddd';
         document.getElementById('hisb').style.backgroundColor = '#f1f1f1';

         document.getElementById('compendiv').style.display = 'block';
         document.getElementById('poshis').style.display = 'none';
         document.getElementById('ph').style.backgroundColor = '#f1f1f1';
         
        window.history.pushState('object', document.title, location.href.split("&")[0]);
    }
    function opencur(){
        document.getElementById('empinfo').style.display = 'none';
        document.getElementById('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'none';
        document.getElementById('compb').style.display = 'block';
        document.getElementById('current').style.display = 'block';
        document.getElementById('history').style.display = 'none';
        document.getElementById('emptools').style.display = 'none';
        document.getElementById('curb').style.backgroundColor = '#dddddd';
         document.getElementById('hisb').style.backgroundColor = '#f1f1f1';
    
         document.getElementById('compendiv').style.display = 'block';
         document.getElementById('poshis').style.display = 'none';
         document.getElementById('ph').style.backgroundColor = '#f1f1f1';
        window.history.pushState('object', document.title, location.href.split("&")[0]);
    }
    function openhis(){
        document.getElementById('empinfo').style.display = 'none';
        document.getElementById('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'none';
        document.getElementById('compb').style.display = 'block';
        document.getElementById('current').style.display = 'none';
        document.getElementById('history').style.display = 'block';
        document.getElementById('emptools').style.display = 'none';
        document.getElementById('curb').style.backgroundColor = '#f1f1f1';
         document.getElementById('hisb').style.backgroundColor = '#dddddd';
        
         document.getElementById('poshis').style.display = 'none';
         document.getElementById('ph').style.backgroundColor = '#f1f1f1';
        window.history.pushState('object', document.title, location.href.split("&")[0]);
    }
    function openpe(){
        document.getElementById('empinfo').style.display = 'none';
        document.getElementById('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'block';
        document.getElementById('compb').style.display = 'none';
        document.getElementById('document').style.display = 'block';
        document.getElementById('peb').style.backgroundColor = '#dddddd';
         document.getElementById('pib').style.backgroundColor = '#f1f1f1';
        document.getElementById('cbb').style.backgroundColor = '#f1f1f1';
        document.getElementById('gib').style.backgroundColor = '#f1f1f1';
        document.getElementById('upb').style.backgroundColor = '#dddddd';
        document.getElementById('chb').style.backgroundColor = '#f1f1f1';
        document.getElementById('ts').style.backgroundColor = '#f1f1f1';
        document.getElementById('emptools').style.display = 'none';
        document.getElementById('checklist').style.display = 'none';

        document.getElementById('poshis').style.display = 'none';
        document.getElementById('ph').style.backgroundColor = '#f1f1f1';
        window.history.pushState('object', document.title, location.href.split("&")[0]);
    }
    function openup(){
        document.getElementById('empinfo').style.display = 'none';
        document.getElementById('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'block';
        document.getElementById('compb').style.display = 'none';
        document.getElementById('upb').style.backgroundColor = '#dddddd';
        document.getElementById('chb').style.backgroundColor = '#f1f1f1';
        document.getElementById('document').style.display = 'block';
        document.getElementById('emptools').style.display = 'none';
        document.getElementById('checklist').style.display = 'none';
     
        document.getElementById('poshis').style.display = 'none';
        document.getElementById('ph').style.backgroundColor = '#f1f1f1';

        window.history.pushState('object', document.title, location.href.split("&")[0]);
    }
    function opencheck(){
        document.getElementById('empinfo').style.display = 'none';
        document.getElementById('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'block';
        document.getElementById('compb').style.display = 'none';
        document.getElementById('document').style.display = 'none';
        document.getElementById('checklist').style.display = 'block';
        document.getElementById('emptools').style.display = 'none';
        document.getElementById('upb').style.backgroundColor = '#f1f1f1';
        document.getElementById('chb').style.backgroundColor = '#dddddd';
    
        document.getElementById('poshis').style.display = 'none';
        document.getElementById('ph').style.backgroundColor = '#f1f1f1';
        window.history.pushState('object', document.title, location.href.split("&")[0]);
    }
    function opents(){
        document.getElementById('empinfo').style.display = 'none';
        document.getElementById('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'none';
        document.getElementById('compb').style.display = 'none';
        document.getElementById('document').style.display = 'none';
        document.getElementById('checklist').style.display = 'none';
        document.getElementById('emptools').style.display = 'block';
        document.getElementById('individual').style.display = 'block';
        document.getElementById('shared').style.display = 'none';
        document.getElementById('peb').style.backgroundColor = '#f1f1f1';
         document.getElementById('pib').style.backgroundColor = '#f1f1f1';
        document.getElementById('cbb').style.backgroundColor = '#f1f1f1';
        document.getElementById('gib').style.backgroundColor = '#f1f1f1';
        document.getElementById('upb').style.backgroundColor = '#f1f1f1';
        document.getElementById('chb').style.backgroundColor = '#f1f1f1';
        document.getElementById('ts').style.backgroundColor = '#dddddd';
        document.getElementById('indi').style.backgroundColor = '#dddddd';
        document.getElementById('poshis').style.display = 'none';
        document.getElementById('ph').style.backgroundColor = '#f1f1f1';
        
        window.history.pushState('object', document.title, location.href.split("&")[0]);

    }
    function openindi(){
        document.getElementById('empinfo').style.display = 'none';
        document.getElementById('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'none';
        document.getElementById('compb').style.display = 'none';
        document.getElementById('document').style.display = 'none';
        document.getElementById('checklist').style.display = 'none';
        document.getElementById('emptools').style.display = 'block';
        document.getElementById('individual').style.display = 'block';
        document.getElementById('shared').style.display = 'none';
        document.getElementById('ts').style.backgroundColor = '#dddddd';
        document.getElementById('indi').style.backgroundColor = '#dddddd';
        document.getElementById('shrd').style.backgroundColor = '#f1f1f1';
        document.getElementById('poshis').style.display = 'none';
        document.getElementById('ph').style.backgroundColor = '#f1f1f1';

    }
    function openshrd(){
        document.getElementById('empinfo').style.display = 'none';
        document.getElementById('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'none';
        document.getElementById('compb').style.display = 'none';
        document.getElementById('document').style.display = 'none';
        document.getElementById('checklist').style.display = 'none';
        document.getElementById('emptools').style.display = 'block';
        document.getElementById('individual').style.display = 'none';
        document.getElementById('shared').style.display = 'block';
        document.getElementById('ts').style.backgroundColor = '#dddddd';
        document.getElementById('indi').style.backgroundColor = '#f1f1f1';
        document.getElementById('ph').style.backgroundColor = '#f1f1f1';
        document.getElementById('shrd').style.backgroundColor = '#dddddd';
        document.getElementById('poshis').style.display = 'none';
    }
    function opencompen(){
        document.getElementById('compendiv').style.display = 'block';
        document.getElementById('benediv').style.display = 'none';
        document.getElementById('poshis').style.display = 'none';
        window.history.pushState('object', document.title, location.href.split("&")[0]);

    }
    function openbene(){
        document.getElementById('benediv').style.display = 'block';
        document.getElementById('compendiv').style.display = 'none';
        document.getElementById('poshis').style.display = 'none';
        document.getElementById('ph').style.backgroundColor = '#f1f1f1';
        window.history.pushState('object', document.title, location.href.split("&")[0]);

    }
    function computeage(){
            var bday = document.getElementById("bday").value;
            var getbday = new Date(bday);
            var today = new Date();
            var age = today.getFullYear() - getbday.getFullYear();
            var  m = today.getMonth() - getbday.getMonth();
            document.getElementById("age").value = age;

    }
        // Date Validation for Date Effectivity  effectdate.min = new Date().toISOString().split("T")[0];

    function inactive(){
      
    if(document.getElementById('status').value == 'Inactive'){
    
        document.getElementById('activedate').style.display ='none';
        document.getElementById('inactivedate').style.display = 'block';
       
    }
    else{
        document.getElementById('activedate').style.display ='block';
        document.getElementById('inactivedate').style.display = 'none';
    }
    }
    function openposhis(){
       

        document.getElementById('empinfo').style.display = 'none';
       
        document.getElementById('pib').style.backgroundColor = '#f1f1f1';
        document.getElementById('gib').style.backgroundColor = '#f1f1f1';
        document.getElementById('cbb').style.backgroundColor = '#f1f1f1';
        document.getElementById('peb').style.backgroundColor = '#f1f1f1';
        document.getElementById('ts').style.backgroundColor = '#f1f1f1';
        document.getElementById('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'none';
        
        document.getElementById('compb').style.display = 'none';
        document.getElementById('emptools').style.display = 'none';

       
        document.getElementById('poshis').style.display = 'block';
        document.getElementById('ph').style.backgroundColor = '#dddddd';
        window.history.pushState('object', document.title, location.href.split("&")[0]);





    }



    
    
    </script>


  </head>

  <body id="page-top" onload="computeage()">
  
 

    <?php 
    $myprofile='active';
    include('uppernav.php')?>
   

      <!-- Sidebar -->
      
      <?php 
       

        include('sidebar.php');
      ?>
      <div id="content-wrapper">

        <div class="container-fluid">

          <!-- Breadcrumbs-->
          <ol class="breadcrumb">
            <li class="breadcrumb-item active">
         User Profile
            </li>
            
          </ol>



          <!--DIV CONTAINER-->

            <div class="container-fluid">

                <?php echo $_GET['alert']; echo $alert ?>

                <div class="tab">
                    <button class="tablinks " id="pib" onclick="openpi()" >Personal Information</button>
                    <button class="tablinks" id="gib" onclick="opengi()">Government Info</button>
                    <button class="tablinks" id="cbb" onclick="opencb()">Compensation & Benefit</button>
                    <button class="tablinks" id="peb" onclick="openpe()">Pre Employement</button>
                    <button class="tablinks" id="ts" onclick="opents()">Tools</button>
                    <button class="tablinks" id="ph" onclick="openposhis()">Position History</button>
                    
                </div>
                <!--- PERSONAL INFORMATION TAB-->
                
                    <div id="empinfo" class="tabcontent" style="display: block;" >
                        <form method="post" enctype="multipart/form-data"> 
                                    <h3>Personal Information</h3>
                                    <div class="row justify-content-lg-center"  >
                                        <img id="output_image" style="height: 150px; width: 150px; border-radius:100px;" src="../files/pictures/<?php echo $userpic;?>" alt="hello"/> 
                                    </div>

                                    <div class="row justify-content-lg-center">
                                        <div class="col-sm-3">
                                            <input type="text" id="empid" name="empid" class="form-control" value="<?php echo $empID;?>" readonly/>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-4 form-group required">
                                            <label class="control-label"> Surname </label> <br>
                                            <input type="text" class="form-control" name="sname"  value="<?php echo $surname;?>" placeholder="Surname" required readonly>
                                        </div>
                                        <div class="col-sm-4 form-group required">
                                            <label class="control-label">First Name </label> <br>
                                            <input type="text" class="form-control" name="fname"  value="<?php echo $firstname;?>" placeholder="First Name" required readonly>
                                        </div>
                                        <div class="col-sm-4 form-group required">
                                            <label class="control-label">Middle Name </label> <br>
                                            <input type="text" class="form-control" name="mname"  value="<?php echo $middlename;?>" placeholder="Middle Name" required readonly>
                                        </div>
                                
                                        <div class="col-sm-6 form-group required">
                                            <label class="control-label">Permanent Address </label> <br>
                                            <input type="text" class="form-control" name="permanentadd"  value="<?php echo $permanentadd;?>" placeholder="Permanent Address" required readonly>
                                        </div>
                                    
                                        <div class="col-sm-6 form-group required">
                                            <label class="control-label">Residential Address </label> <br>
                                            <input type="text" class="form-control" name="residentialadd"  value="<?php echo $residentialadd;?>"placeholder="Residential Address" required readonly>
                                        </div>

                                        
                                        <div class="col-sm-4 form-group required">
                                            <label class="control-label">Birthdate </label> <br>
                                            <input type="date" id="bday" onchange="computeage()" class="form-control" value="<?php echo $bday;?>" name="bday"  placeholder="Birthdate" readonly>
                                        </div>
                                        <div class="col-sm-4 form-group required">
                                            <label class="control-label">Age </label> <br>
                                            <input type="number" id="age" class="form-control" name="age"  placeholder="Age"  value="<?php echo $age;?>" required readonly>
                                        </div>

                                            
                                        <div class="col-sm-4 form-group required">
                                            <label class="control-label">Gender</label> <br>
                                            
                                            <input type="text" name="gender" class="form-control" value="<?php echo $gender?>" readonly>
                                        </div>

                                        <div class="col-sm-4 form-group required">
                                            <label class="control-label">Contact Number </label> <br>
                                            <input type="number" class="form-control" name="contactno" value="<?php echo $contactno;?>"  placeholder="Contact No." required readonly>
                                        </div>
                                        <div class="col-sm-4 form-group required">
                                            <label class="control-label">Personal Email </label> <br>
                                            <input type="email" class="form-control" name="email" value="<?php echo $email;?>"  placeholder="Personal Email" required readonly>
                                        </div>

                                        <div class="col-sm-4 form-group required">
                                            <label id= class="control-label">Civil Status </label> <br>
                                            <select name="civilstat" id="civilstat" class="form-control" onchange=csdiv()  required readonly>
                                                <?php 
                                                switch ($civilstat) {
                                                    case "Single":
                                                        $single = 'selected';
                                                        break;
                                                    case "Widowed":
                                                        $widowed = 'selected';
                                                        break;
                                                    case "Divorced":
                                                        $divorced = 'selected';
                                                        break;
                                                    case "Married":
                                                        $married = 'selected';
                                                        break;
                                                
                                                }
                                                if($civilstat == 'Married' || $civilstat == 'Widowed' || $civilstat == 'Divorced'){
                                                $dissingle = 'disabled';
                                                }

                                                ?>
                                                
                                                <option value="Single" <?php echo $single; echo $dissingle; ?>> Single </option>
                                                <option value="Married" <?php echo $married?>> Married </option>
                                                <option value="Widowed" <?php echo $widowed?>> Widowed </option>
                                                <option value="Divorced" <?php echo $divorced?>> Divorced </option>
                                            </select>
                                        </div>

                                        <div id="civilstatbox" style="width:98%; margin: 0 auto;">
                                            <div class="row">
                                                <div class="col-sm-6">
                                                    <label class="control-label">Spouse's Name </label> <br>
                                                    <input type="text" class="form-control" name="spouse"  placeholder="Spouse Name"  value="<?php echo $spouse?>" readonly>
                                                    </div>
                                                    <div class="col-sm-6">
                                                    <label class="control-label">Date of Birth</label> <br>
                                                    <input type="date" class="form-control" name="spousebday"  placeholder="Spouse Birthdate" value="<?php echo $spousebday?>" readonly>
                                                </div>
                                            </div>
                                        </div>

                                    

                                        
                                        <div class="col-sm-6 form-group required">
                                            <label class="control-label">Mother's Maiden Name </label> <br>
                                            <input type="text" class="form-control" name="mothersname"  placeholder="Mother's Maiden Name" value="<?php echo $mothersname;?>" required readonly>
                                        </div>

                                        <div class="col-sm-6 form-group required">
                                            <label class="control-label">Occupation </label> <br>
                                            <input type="text" class="form-control" name="motheroccu"  placeholder="Occupation" value="<?php echo $motheroccu;?>" required readonly>
                                        </div>

                                        <div class="col-sm-6 form-group required">
                                            <label class="control-label">Father's Name </label> <br>
                                            <input type="text" class="form-control" name="fathersname"  placeholder="Father's Name" value="<?php echo $fathersname;?>" required readonly>
                                        </div>
                                        <div class="col-sm-6 form-group required">
                                            <label class="control-label">Occupation </label> <br>
                                            <input type="text" class="form-control" name="fatheroccu"  placeholder="Occupation" value="<?php echo $fatheroccu;?>" required readonly>
                                        </div>

                                        <div class="col-sm-12 form-group required">
                                            <h5> <b> EMERGENCY CONTACT </b></h5>
                                        </div>
                                        <div class="col-sm-6 form-group required">
                                            <label class="control-label">Name</label> <br>
                                            <input type="text" class="form-control" name="ename"  placeholder="Name" value="<?php echo $ename;?>" required readonly>
                                        </div>
                                        <div class="col-sm-6 form-group required">
                                            <label class="control-label">Relationship </label> <br>
                                            <input type="text" class="form-control" name="erelationship"  placeholder="Relationship" value="<?php echo $erelatioship;?>" required readonly>
                                        </div>

                                        <div class="col-sm-6 form-group required">
                                            <label class="control-label">Complete Address</label> <br>
                                            <input type="text" class="form-control" name="eaddress"  placeholder="Address" value="<?php echo $eaddress;?>" required readonly>
                                        </div>
                                        <div class="col-sm-6 form-group required">
                                            <label class="control-label">Contact Number</label> <br>
                                            <input type="text" class="form-control" name="econtact"  placeholder="Contact Number" value="<?php echo $econtactno;?>" required readonly>
                                        </div>
                                        <div class="col-sm-12 form-group required">
                                            <h5> <b> EMPLOYEE DETAILS</b></h5>
                                        </div>
                                        <div class="col-sm-4 form-group required">
										<label class="control-label">Hired Date</label> <br>
										<input type="text" id="hireddate" class="form-control" name="hireddate" value="<?php echo date('m/d/Y', strtotime($hireddate));?>" placeholder="Hired Date" required readonly>

										</div>
										<div class="col-sm-4 form-group required">
											<label class="control-label">3rd Month</label> <br>
											<input type="text" id="thirdmonth"  class="form-control" name="thirdmonth"  placeholder="3rd Month" value="<?php echo date('m/d/Y', strtotime($thirdmonth));?>" required readonly>
										</div>
										<div class="col-sm-4 form-group required">
											<label class="control-label">5th Month</label> <br>
											<input type="text" id="fifthmonth" class="form-control" name="fifthmonth"  placeholder="5th Month" value="<?php echo date('m/d/Y', strtotime($fifthmonth));?>" required readonly>
										</div>
                                        <div class="col-sm-4 form-group required">
                                            <label class="control-label">Tenure </label> <br>
                                                <select name="tenure" class="form-control" required readonly>
                                                    <?php switch ($tenure) {
                                                            case "Regular":
                                                                $regular = 'selected';
                                                                break;
                                                            case "Probationary":
                                                                $prob = 'selected';
                                                                break;
                                                                case "Intern":
                                                                $int= 'selected';
                                                                break;
                                                                case "Casual":
                                                                $cas = 'selected';
                                                                break;
                                                        
                                                        }

                                                    ?>
                                                    <option value="" disabled selected>Tenure</option>
                                                    <option value="Regular" <?php echo $regular?>>Regular</option>
                                                    <option value="Probationary" <?php echo $prob?>>Probationary </option>
                                                    <option value="Intern" <?php echo $int?>>Intern </option>
                                                    <option value="Casual" <?php echo $cas?>>Casual </option>
                                                
                                                </select>
                                        </div>
                                    
                                        <div class="col-sm-4 form-group required">
                                        <label class="control-label">Level </label> <br>
                                            <select name="level" class="form-control" required readonly>
                                            <?php switch ($level) {
                                                        case "Executive":
                                                        $exe= 'selected';
                                                        break;
                                                        case "Supervisor":
                                                        $super = 'selected';
                                                        break;
                                                        case "Rank and File":
                                                        $rf = 'selected';
                                                        break;
                                            
                                                
                                                }

                                            ?>
                                            <option value="" disabled selected>Level</option>
                                                <option value="Executive" <?php echo $exe?>>Executive</option>
                                                <option value="Supervisor" <?php echo $super?>>Supervisor</option>
                                                <option value="Rank and File" <?php echo $rf?>>Rank and File</option>
                                            
                                            </select>
                                        </div>
                                        <div class="col-sm-4 form-group required">
                                        <label class="control-label">Department </label> <br>
                                            <select name="department" class="form-control" required readonly>
                                            <?php switch ($department) {
                                                    case "Operation":
                                                        $op= 'selected';
                                                        break;
                                                    case "Support":
                                                        $sup= 'selected';
                                                        break;
                                            } ?>
                                            <option value="" disabled selected>Department</option>
                                            <option value="Operation"<?php echo $op?>>Operation</option>
                                                <option value="Support"<?php echo $sup ?>>Support</option>
                                    
                                            </select>
                                        </div>
                                        <div class="col-sm-4 form-group required" >
                                        <label class="control-label">Team</label> <br>
                                            <?php 
                                            $query = "SELECT * FROM team";                                                
                                            $result = mysqli_query ($conn,$query); 
                                            echo "<select name='team'  class='form-control' readonly>"; 
                                            echo "<option value='' disabled selected> Team </option>";
                                            while($r = mysqli_fetch_array($result)) {
                                                if($team==$r['name']){
                                                    echo "<option value='".$r['name']."' selected='selected'>".$r['name']."</option>";
                                            
                                                }
                                            else{
                                                echo "<option value='".$r['name']."' >".$r['name']."</option>";
                                            }
                                                
                                            }
                                            echo "</select>"; ?>
                                        </div>
                                        <div class="col-sm-4 form-group required">
                                        <label class="control-label">General Position </label> <br>
                                            <?php 
                                            $query = "SELECT * FROM generalpos";                                                
                                            $result = mysqli_query ($conn,$query); 
                                            echo "<select name='genpos'  class='form-control' readonly>"; 
                                            echo "<option value='' disabled selected> General Position </option>";
                                            while($r = mysqli_fetch_array($result)) {
                                                if($genpos==$r['name']){
                                                    echo "<option value='".$r['name']."' selected='selected'>".$r['name']."</option>";
                                            
                                                }
                                            else{
                                                echo "<option value='".$r['name']."' >".$r['name']."</option>";
                                            }
                                                
                                            }
                                            echo "</select>"; ?>
                                        </div>
                                        <div class="col-sm-4 form-group required">
                                        <label class="control-label">Job Title</label> <br>
                                            <?php 
                                            $query = "SELECT * FROM jobtitle";                                                
                                            $result = mysqli_query ($conn,$query); 
                                            echo "<select name='jobtitle'  class='form-control' readonly>"; 
                                            echo "<option value='' disabled selected> Job Title </option>";
                                            while($r = mysqli_fetch_array($result)) {
                                                if($jobtitle==$r['name']){
                                                    echo "<option value='".$r['name']."' selected='selected'>".$r['name']."</option>";
                                            
                                                }
                                            else{
                                                echo "<option value='".$r['name']."' >".$r['name']."</option>";
                                            }
                                                
                                            }
                                            echo "</select>"; ?>
                                    
                                        </div>

                                        
                                        <div class="col-sm-6 form-group required">
                                            <label class="control-label">Immediate Supervisor</label> <br>
                                            <?php 
                                            $query = "SELECT * FROM supervisor";                                                
                                            $result = mysqli_query ($conn,$query); 
                                            echo "<select name='supervisor' value='' class='form-control' readonly>"; 
                                            while($r = mysqli_fetch_array($result)) {
                                                if($supervisor==$r['supervisors']){
                                                    echo "<option value='".$r['supervisors']."' selected='selected'>".$r['supervisors']."</option>";
                                            
                                                }
                                            else{
                                                echo "<option value='".$r['supervisors']."' >".$r['supervisors']."</option>";
                                            }
                                                
                                            }
                                            echo "</select>"; ?>
                                            
                                            
                                        </div>
                                        <div class="col-sm-3 form-group required">
                                            <label class="control-label">Status</label> <br>
                                            <select name="status" id="status" class="form-control"  onchange='inactive()' required  readonly>
                                            <?php switch ($status) {
                                                    case "Active":
                                                    $act= 'selected';
                                                    $activedis  = 'style="display: block"';
                                                    $inactivedis = 'style="display: none"';
                                                    break;
                                                    
                                                    case "Inactive":
                                                    $iact= 'selected';
                                                    $activedis  = 'style="display: none" readOnly';
                                                    $inactivedis = 'style="display: block" readOnly';
                                                    break; 

                                                        }
                                                        ?>
                                                    <option value="Active" <?php echo $act?>>Active</option>
                                                    <option value="Inactive" <?php echo $iact?>>Inactive</option>
                                            
                                            </select>

                                        </div>
                                        <div class="col-sm-3 form-group required">
                                            <label class="control-label" id='inactivelbl'>Date</label> <br>
                                            <input type="date" id="activedate" class="form-control" name="hireddate" value="<?php echo $hireddate?>"  placeholder="Hired Date"  <?php echo $activedis ?> required readonly>
                                            <input type="date" id="inactivedate" class="form-control" name="inactivedate" value="<?php echo $inactivedate?>"  placeholder="Hired Date" <?php echo $inactivedis?>>

                                        </div>

                                        

                                    
                                    </div>
                                                    <!--- PERSONAL INFORMATION MODAL -->
                                    <div class="modal fade" id="personalinfomodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                        <div class="modal-dialog modal-dialog-centered" role="document">
                                            <div class="modal-content">
                                            <div class="modal-header">
                                                <h5 class="modal-title" id="exampleModalLabel">Update Employee Information</h5>
                                                <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">×</span>
                                                </button>
                                            </div>
                                                <div class="modal-body">Are you sure you want to update  <?php echo $firstname.' '.$surname?> Information ?</div>
                                                    <div class="modal-footer">
                                                    <input type="submit" class="btn btn-success" name="saveinfo" value="✓ Yes" style="margin-right: 5px;" >
                                                        <button class="btn btn-danger" type="button" data-dismiss="modal"><i class='fas fa-close'></i> No</button>
                                                                    
                                                    </div>
                                                </div>
                                        </div>
                                    </div>
                        </form>               
                    </div>
                    <!-- END OF PERSONAL INFORMATION TAB-->
                




                    <!-- END PERSONAL INFORMATION MODAL -->

                    <!-- GOVERNMENT INFO TAB-->
                    <div id="govinfo" class="tabcontent" <?php echo $_GET['gi']; ?>>

                            <form method="post" enctype="multipart/form-data" >
                                <h3>Government Information</h3>  
                                <div class="row">
                                    <div class="col-sm-12 form-group required" >
                    
                                
                    
                                    </div>
                                    <div class="col-sm-6 form-group required">
                                        <label class="control-label">SSS</label> <br>
                                        <input type="text" id="sss" class="form-control" name="sss"  placeholder="SSS" value="<?php echo $getsss?>" required readonly>
                                    </div>
                                    <div class="col-sm-6 form-group required">
                                        <label class="control-label">TIN</label> <br>
                                        <input type="text" id="tin" class="form-control" name="tin"  placeholder="TIN" value="<?php echo $gettin?>" readonly>
                                    </div>
                                    <div class="col-sm-6 form-group required">
                                        <label class="control-label">Philhealth</label> <br>
                                        <input type="text" id="philhealth" class="form-control" name="philhealth"  placeholder="Philhealth" value="<?php echo $getphilhealth?>"required readonly>
                                    </div>
                                    <div class="col-sm-6 form-group required">
                                        <label class="control-label">Pag-ibig</label> <br>
                                        <input type="text" id="pagibig" class="form-control" name="pagibig"  placeholder="Pag-ibig" value="<?php echo $getpagibig?>" required readonly>
                                    </div>

                                
                            
                                </div>
                                <div class="modal fade" id="govinfomodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                        <div class="modal-dialog modal-dialog-centered" role="document">
                                            <div class="modal-content">
                                            <div class="modal-header">
                                                <h5 class="modal-title" id="exampleModalLabel">Update Government Info </h5>
                                                <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">×</span>
                                                </button>
                                            </div>
                                                <div class="modal-body">Are you sure you want to update  <?php echo $firstname.' '.$surname?> Government Information ?</div>
                                                    <div class="modal-footer">
                                                    <input type="submit" class="btn btn-success" name="savegov" value="✓ Yes" style="margin-right: 5px;" > 
                                                        <button class="btn btn-danger" type="button" data-dismiss="modal"><i class='fas fa-close'></i> No</button>
                                                                    
                                                    </div>
                                                </div>
                                        </div>
                                </div>
                            </form>
                        </div>

                        <div id="preemp" class="tabcontent" <?php echo $_GET['pe']?>>
                            <div class="tab">
                                <button class="tab1" id="upb" onclick="openup()" >Upload</button>
                                <button class="tab1" id="chb" onclick="opencheck()">Checklist</button>
                            </div>
                        
                            <div id="document" class="tabcontent1" <?php echo $_GET['doc']?>>
                                <form method="post" enctype="multipart/form-data" >               
                                    <div class="col-sm-12 form-group required">
                        
                                    </div>
                                    

                                        <script>
                                        function checkb() {
                    
                
                                                        if (document.getElementById("na").checked == true) {
                                                            document.getElementById("doc").disabled = true;
                                                        } else {
                                                            document.getElementById("doc").disabled = false;
                                                        }
                                                
                                            }
                                        </script>
                                        <div class="col-sm-12 form-group required">
                                        <table class="table table-hover">
                                            <thead class="thead-dark">
                                                <tr>
                                                
                                    
                                                <th scope="col">Name</th>
                                                <th scope="col">Action</th>
                                            
                                                
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                $documentsql = "SELECT * FROM documents WHERE empid = '$empID' AND status='check'";
                                                $result = mysqli_query($conn, $documentsql);
                                            
                                                    while($row = mysqli_fetch_assoc($result)) {
                                                        
                                                        echo'
                                                        <tr>
                                                
                                                        <td>'.$row['name'].'</td>
                                                        <td> <a href="viewdoc.php?docid='.$row['document'].'" target="_blank" class="btn btn-primary"> <i class="fa fa-eye"></i> View </a>   
                                                        </td>
                                        
                                                        </tr>
                                                    
                                                        ';

                                                    }
                                                
                                                ?>
                                        
                                            </tbody>
                                        </table>
                                        
                                        

                                        </div>
                                        


                                        <!-- MODAL PRE EMPLOYMENT -->
                                        <div class="modal fade" id="preemployment" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                            <div class="modal-dialog modal-dialog-centered" role="document">
                                                <div class="modal-content">
                                                <div class="modal-header">
                                                    <h5 class="modal-title" id="exampleModalLabel">Save Documents</h5>
                                                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">×</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body">Are you sure you want to save  <?php echo $firstname.' '.$surname?> documents?</div>
                                                <div class="modal-footer">
                                                <input type="submit" class="btn btn-success" name="savedoc" value="✓ Yes" style="margin-right: 5px;" > 
                                                    <button class="btn btn-danger" type="button" data-dismiss="modal"><i class='fas fa-close'></i> No</button>
                                                    
                                                </div>
                                                </div>
                                            </div>
                                        </div>


                                </form>

                                    
                                
                            </div>
                        
                        <div id="checklist" class="tabcontent1" <?php echo $_GET['ch']?> >
                            <form method="post" enctype="multipart/form-data">

                                    <div class="col-sm-12 form-group required">
                                        <h5>Checklist</h5>
                                        <table class="table table-hover">
                                        <thead class="thead-dark">
                                            <th>Name</th>
                                            <th>Date</th>
                                            <th>Status</th>
                                        </thead>
                                        <tbody>
                                            <?php 
                                                $documentsql = "SELECT * FROM documents WHERE empid = '$empID'";
                                                $result = mysqli_query($conn, $documentsql);
                                            
                                                    while($row = mysqli_fetch_assoc($result)) {
                                                        
                                                        echo'
                                                
                                                        
                                                        <tr>
                                                
                                                        <td>'.$row['name'].'</td>';
                                                    
                                                        if($row['date'] == '0000-00-00'){
                                                            echo '<td>---</td>';
                                                        }
                                                        else{
                                                            echo '<td>'.$row['date'].'</td>';
                                                        }
                                                        if($row['status'] == 'check'){
                                                            echo '<td><i class="fa fa-check" style="font-size:25px; color: #28a745;"></i></td>';
                                                        }
                                                        elseif($row['status'] == 'N/A'){
                                                            echo '<td><i style="font-size:20px; color: #fc9700; "><strong>N/A</strong></i></td>';
                                                        }
                                                        else{
                                                            echo '<td><i class="fa fa-close" style="color:red; font-size:25px; "></i></td>';
                                                        }
                                                    
                                                
                                                    

                                                    }
                                                
                                            ?>
                                            
                                        </tbody>


                                    </table>
                                    
                                    </div>
                                
                                </div>
                                <!-- CHECKLIST MODAL-->
                                <div class="modal fade" id="conchecklist" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                    <div class="modal-dialog modal-dialog-centered" role="document">
                                                <div class="modal-content">
                                                <div class="modal-header">
                                                    <h5 class="modal-title" id="exampleModalLabel">Update Employee Checklist</h5>
                                                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">×</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body">Are you sure you want to update  <?php echo $firstname.' '.$surname?> Checklist ?</div>
                                                <div class="modal-footer">
                                                    <input type="submit" class="btn btn-success" value="✓ Yes" name="savecheck" style="margin-right: 5px;" > 
                                                    <button class="btn btn-danger" type="button" data-dismiss="modal"><i class='fas fa-close'></i> No</button>
                                                    
                                                </div>
                                                </div>
                                    </div>
                                </div>


                                <!-- CHECK LIST MODAL-->
                            </form>
                        </div>

                    <!-- END OF GOVERNMENT INFO TAB-->
                    <!-- COMPENSATION & BENEFIT TAB-->
                    <link href = "../css/style.css" rel = "stylesheet">
                    <div id="compb" class="tabcontent"  <?php echo $_GET['cb']; echo $cb; echo $_GET['cbben'];;?>>
                    <div class="tab">
                            <button class="tab1" id="compensation" onclick="opencompen()" >Compensation</button>
                            <button class="tab1" id="benefits" onclick="openbene()">Benefits</button>
                        </div>
                    

                        
                        <div id="compendiv" class="tabcontent1" <?php echo $_GET['cb']; echo $cb; ?>>
                            <div class="tab">
                                <button class="tab1" id="curb" onclick="opencur()" >Current</button>
                                <button class="tab1" id="hisb" onclick="openhis()">History</button>
                            </div>
                            <div id="current" class="tabcontent1" <?php echo $_GET['cr']; echo $cr; ?>>


                                <div class="col-sm-12 form-group required">
                                    <?php 
                                        $salaryempsql ="SELECT * FROM salaryemp WHERE empid='$empID' AND effectivitydate <= CURDATE() ORDER BY effectivitydate DESC LIMIT 1";
                                        $salaryempres = mysqli_query($conn,$salaryempsql);
                                        $salaryemprow = mysqli_fetch_assoc($salaryempres);
                                        $cursalarycode = $salaryemprow['salarycode'];
                                        $ceffectivitydate = $salaryemprow['effectivitydate'];


                                        $compensql = "SELECT * FROM compensation JOIN monetary ON compensation.monetaryid = monetary.monetaryid WHERE salarycode='$cursalarycode' ORDER BY compensation.monetaryid";
                                        $compenresult = mysqli_query($conn, $compensql);
                                
                                    
                                            
                                    ?>
            
                                    <h5>Current Salary</h5>
                                    <p> <?php echo $cursalarycode?> | <?php echo $ceffectivitydate ?></p>
                                    <table class="table table-hover">
                                        <thead class="thead-dark">
                                            <tr>
                                            <?php 
                                                if (mysqli_num_rows($compenresult) > 0) {
                        
                                                    while($compenrow = mysqli_fetch_assoc($compenresult)) {
                                                    
                                                        echo'
                                                        
                                                        
                                                        <th>'.$compenrow['name'].'</th>
                                                    
                                                    
                                                        
                                                    
                                                        
                                                        ';
                                                    

                                                    }
                                                } 
                        
                                            ?>
                                            <th> TOTAL </th>

                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                            <?php 
                                    
                                                $amountsql = "SELECT * FROM compensation WHERE salarycode='$cursalarycode'  ORDER BY monetaryid";
                                                $amountresult = mysqli_query($conn, $amountsql);

                                                    

                                                if (mysqli_num_rows($amountresult) > 0) {
                                                
                                                    while($amountrow = mysqli_fetch_assoc($amountresult)) {
                                                        echo'<td>₱ '.$amountrow['amount'].'</td> ';
                                                        $amount = $amountrow['amount'];
                                                        $amounts = str_replace(',','',$amount);

                                                        $total += $amounts;

                                                    }
                                                } 
                                                echo '<td> &#8369 &nbsp'.number_format($total,2).'</td>';
                                            
                                            ?>
                                            
                                            </tr>
                                        
                                        </tbody>
                                    </table>

                                </div>
                            
                            </div>
                            <div id="history" class="tabcontent1" <?php echo $_GET['his']?>>
                                <div class="row"  style="padding: 0px 30px;">
                                <div class="col-sm-6 form-group required"> <br>
                                    <h4>History</h4>
                                        <table class="table table-hover">
                                            <thead class="thead-dark">
                                                <tr>
                                                        
                                            
                                                    <th scope="col">Salary Code</th>
                                                    <th scope="col">Effectivity Date</th>
                                                    <th scope="col">Action</th>
                                                    
                                                        
                                                </tr>
                                            </thead>
                                            <tbody>
                                            
                                                <?php 
                                                            
                                                    $compsql = "SELECT * FROM `salaryemp` WHERE empid='$empID'";
                                                    $compresult = mysqli_query($conn, $compsql);
                                                    if (mysqli_num_rows($compresult) > 0) {
                                                        while($row = mysqli_fetch_assoc($compresult)) {
                                                            /*<form action="updateemp1.php?ID='.$empID.'&salarycode='.$row['salarycode'].'">  */
                                                            

                                                            $histyle ="style='display:block;'";
                                                            $cr ="style='display:none;'";
                                                                    echo'
                                                                    
                                                                    <tr>
                                                                    <td>'.$row['salarycode'].'</td>
                                                                    <td>'.$row['effectivitydate'].'</td>
                                                                    <td> <a class="btn btn-primary" href="viewprofile.php?ID='.$empID.'&salarycode='.$row['salarycode'].'&cb='.$histyle.'&his='.$histyle.'&cr='.$cr.'" > <i class="fa fa-eye"></i>   View</a>
                                                                    </td>
                                                                    </tr>
                                                                    </form>';
                                                                    
                                                                
                                                                    
                                            
                                                                }
                                                                
                                                    } 
                                                
                                                ?>
                                        
                                                
                                            </tbody>
                                        </table>

                                </div>
                                <div class="col-sm-6 form-group required">
                                    <br>
                                    <h4>Details</h4>
                                    <table class="table table-hover">
                                        <thead class="thead-dark">
                                        <tr>
                                            <th>Items</th>
                                            <th> Amount </th>
                                        </tr>
                                        </thead>
                                        <tbody>

                                        <?php 
                                        $compsql = "SELECT * FROM `compensation` JOIN monetary ON compensation.monetaryid = monetary.monetaryid WHERE salarycode='$scode'";
                                        $compresult = mysqli_query($conn, $compsql);
                                        if (mysqli_num_rows($compresult) > 0) {
                                            while($row = mysqli_fetch_assoc($compresult)) {
                                                        echo'
                                            
                                                        <tr>
                                                        <td>'.$row['name'].'</td>
                                                        <td>₱ '.$row['amount'].'</td>
                                                    
                                                    
                                                        </tr>
                                                        </form>
                                                        
                                                    
                                                        ';
                                                        $amount = $row['amount'];
                                                        $amounts = str_replace(',','',$amount);

                                                        $total27 += $amounts;
                                
                                                    }
                                        } 
                                        ?>
                                        <tr> 
                                        <td><strong>TOTAL: </strong></td>
                                        <td><strong>₱ <?php echo number_format($total27,2)?></strong></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            
                            </div>
                            </div>                         
                        </div>

                        <div id="benediv" class="tabcontent1" <?php echo $benetab; echo $_GET['benetab'];?>>
                        <h5> Benefits </h5>
                        
                                <div class="row"> 

                                
                                
                        
                                    <div class="col-12">

                                    <table class="table table-bordered">
                                    <thead class="thead-dark">
                                    <tr>
                                    <th>Leave</th>
                                    <th>Earned </th>
                                    <th>Used </th>
                                    <th>Available</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    
                                    <?php 
                                    $sqlbenefit = "SELECT * FROM pto WHERE empid='$empID'";
                                    $benefitres = mysqli_query($conn, $sqlbenefit);
                                    while($benefitrow = mysqli_fetch_assoc($benefitres)){
                                        echo '<tr>';
                                        echo'<td>'.$benefitrow['name'].'</td>';
                                        echo'<td>'.$benefitrow['ptoearned'].'</td>';
                                        echo'<td>'.$benefitrow['usedpto'].'</td>';
                                        echo'<td>'.$benefitrow['availablepto'].'</td>';
                                        echo'</tr>';

                                    }
                                    ?>
                                
                                    </tbody>
                                    </table>

                                    </div>


                                </div>
                                                                                <!---BENEFITS MODAL  -->
                                <div class="modal fade" id="benefitsmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                    <div class="modal-dialog modal-dialog-centered" role="document">
                                        <div class="modal-content">
                                        <div class="modal-header">
                                            <h5 class="modal-title" id="exampleModalLabel">Update Employee Benefits</h5>
                                            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true">×</span>
                                            </button>
                                        </div>
                                            <div class="modal-body">Are you sure you want to update  <?php echo $firstname.' '.$surname?> Benefits ?</div>
                                                <div class="modal-footer">
                                                <input type="submit" class="btn btn-success" name="savebenefits" value="✓ Yes" style="margin-right: 5px;" >
                                                    <button class="btn btn-danger" type="button" data-dismiss="modal"><i class='fas fa-close'></i> No</button>
                                                                
                                                </div>
                                            </div>
                                    </div>
                                </div>





                        </div>

                        

                        

                    

                    <!-- END OF COMPENSATION AND BENEFIT TAB-->
                    
                    </div>
                    
                                                            
                    <!--- END CURRENT TAB -->
                    <!-- HISTORY TAB -->

                    <!-- TOOLS  TAB-->
                    <div id="emptools" class="tabcontent" <?php echo $tls; echo $_GET['tls']?>>

                        <div class="tab">
                                    <button class="tab1" id="indi" onclick="openindi()" >Individual</button>
                                    <button class="tab1" id="shrd" onclick="openshrd()">Shared</button>
                        </div>
                            
                        <div id="individual" class="tabcontent1" <?php echo $tabindi; echo $_GET['indi']?>>
                            <h5>Individual Tools</h5>
                            <form method="post" enctype="multipart/form-data"> 
                                <div class="row">
                                
                    
                                
                                
                                        
                                
                    
                            


                                    <div class="col-sm-12">
                                    <?php 
                                    //////////////VIEW INDIVIDUAL/////////////////////
                                    if(isset($_POST['viewindi'])){
                                

                                    echo'<table class="table table-hover"> 
                                    <thead class="thead-dark">
                                    
                                    <th> Name </th>
                                    <th> Description </th>
                    

                                    

                                    </thead>
                                    <tbody>
                                    ';
                                    $viewindiq = "SELECT * FROM individualshared WHERE id='$selindi'";
                                    $resultviewindi  = mysqli_query($conn, $viewindiq);
                    
                                    
                    
                                    if (mysqli_num_rows($resultviewindi) > 0) {
                                
                                        while($rowviewindi = mysqli_fetch_assoc($resultviewindi)) {
                                            
                                            $toolsname = $rowviewindi['name'];
                                            
                                            echo'
                                            
                                            
                                            
                                            <td>'.$rowviewindi['name'].'</td>
                                            <td>'.$rowviewindi['description'].'</td>

                            
                                            
                                            
                                            ';
                                        
                                        
                    
                                        }
                                    } 
                                    echo'</tbody> 
                                    
                                    </table>
                                    <hr>
                                    ';

                                    }
                                    ?>
                                    </div>
                                
                                    <!-- INDIVIDUAL TOOLS TABLE-->
                                
                                
                                    <div class="col-sm-12">
                                
                                    <table class="table table-hover"> 
                                    <thead class="thead-dark">
            
                                    <th> Name </th>
                                    <th> Description </th>
                                    <th> Username </th>
                                    <th> Password </th>

                                    

                                    </thead>
                                    <tbody>
                                    <?php 
                                    $indiq = "SELECT * FROM emptools JOIN individualshared ON emptools.idtools = individualshared.id WHERE empid='$empID' AND type ='Individual'";
                                    $resultviewindi  = mysqli_query($conn, $indiq);
                    
                                    
                    
                                    if (mysqli_num_rows($resultviewindi) > 0) {
                                
                                        while($rowviewindi = mysqli_fetch_assoc($resultviewindi)) {
                                            echo'
                                            <tr>
                                            
                                        
                                            <td>'.$rowviewindi['name'].'</td>
                                            <td>'.$rowviewindi['description'].'</td>
                                            <td>'.$rowviewindi['username'].'</td>
                                            <td>'.$rowviewindi['password'].'</td>
                            
                                            </tr>
                                            
                                            ';
                                            
                                        
                                        
                    
                                        }
                                    }
                                    else{

                                        echo '<tr> <td> No Data Found </td></tr>';
                                    }
                                

                                

                                    
                                    
                                    ?>

                                    </tbody>
                                    </table>

                                    </div>
                                

                                

                                </div>
                                <!-- INDIVIDUAL TOOLS MODAL -->
                                <div class="modal fade" id="indimodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                            <div class="modal-dialog modal-dialog-centered" role="document">
                                                <div class="modal-content">
                                                <div class="modal-header">
                                                    <h5 class="modal-title" id="exampleModalLabel">Add Employee Individual Tools</h5>
                                                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">×</span>
                                                    </button>
                                                </div>
                                                    <div class="modal-body">
                                                        <div class="row">
                                                            <div class="col-sm-6">
                                                                <label for="toolsusername" >Tools</label>
                                                                <input type="text" class="form-control" name="toolsname" id="toolsname" value="<?php echo $toolsname?>" placeholder="Tools" readonly>
                                                                <input type="hidden" value="<?php echo $toolsid ?>" name="toolsid">
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <label for="toolsusername" >Type</label>
                                                                <input type="text" class="form-control" name="toolstype" value="Individual" placeholder="Password" readonly>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <label for="toolsusername" >Username</label>
                                                                <input type="text" class="form-control" name="toolusername" placeholder="Username">
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <label for="toolpassword" >Password</label>
                                                                <input type="text" class="form-control" name="toolpassword" placeholder="Password">
                                                            </div>
                                                            <div class="col-sm-12">
                                                                <label for="toolsdesc" >Description</label>
                                                                <textarea name="toolsdesc" class="form-control"   cols="30" rows="5" placeholder="Description"></textarea>
                                                            </div>
                                                        </div>



                                                    </div>
                                                    <script>

                                                    function displaydata(){

                                            
                                                        var toolsname =  document.getElementById('selindi');
                                                    var textHolder = toolsname.options[toolsname.selectedIndex].text


                    

                                                    document.getElementById('toolsname').value = textHolder;
                                                    }

                                                    </script>
                                                        <div class="modal-footer">
                                                        <input type="submit" class="btn btn-success" name="addindi" value="✓ Yes" style="margin-right: 5px;" >
                                                            <button class="btn btn-danger" type="button" data-dismiss="modal"><i class='fas fa-close'></i> No</button>
                                                                        
                                                        </div>
                                                    </div>
                                            </div>
                                </div>
                                
                            </form>


                        </div>
                        <div id="shared" class="tabcontent1" <?php echo $tabshrd; echo $_GET['shrd']?>>
                            <h5>Shared Tools</h5>
                                <form method="post" enctype="multipart/form-data"> 
                                    <div class="row">
                                    


                                        <script>
                                        function shareddisplay(){

                                            var toolsname =  document.getElementById('selshrd');
                                                    var textHolder = toolsname.options[toolsname.selectedIndex].text


                    

                                                    document.getElementById('sharedname').value = textHolder;

                                        }
                                        </script>
                                    
                
                                        <div class="col-sm-12">
                                        <?php 
                                        //////////////VIEW INDIVIDUAL/////////////////////
                                        if(isset($_POST['viewshrd'])){
                                    

                                        echo'<table class="table table-hover"> 
                                        <thead class="thead-dark">
                                        <th> ID </th>
                                        <th> Name </th>
                                        <th> Description </th>
                    

                                        

                                        </thead>
                                        <tbody>
                                        ';
                                        $viewindiq = "SELECT * FROM individualshared WHERE id= '$selshrd'";
                                        $resultviewindi  = mysqli_query($conn, $viewindiq);
                        
                                        
                        
                                        if (mysqli_num_rows($resultviewindi) > 0) {
                                    
                                            while($rowviewindi = mysqli_fetch_assoc($resultviewindi)) {
                                                $sharedname = $rowviewindi['name'];
                                                $sharedid = $rowviewindi['id'];
                                                echo'

                                                
                                                
                                                
                                                <td>'.$rowviewindi['id'].'</td>
                                                <td>'.$rowviewindi['name'].'</td>
                                                <td>'.$rowviewindi['description'].'</td>

                                
                                                
                                                
                                                ';
                                            
                                            
                        
                                            }
                                        } 
                                        echo'</tbody> 
                                        
                                        </table>
                                        <hr>
                                        ';

                                        }
                                        ?>
                                        </div>
                                    
                                        <!-- INDIVIDUAL TOOLS TABLE-->
                                    
                                    
                                        <div class="col-sm-12">
                            
                                        <table class="table table-hover"> 
                                        <thead class="thead-dark">
                                    
                                        <th> Name </th>
                                        <th> Description </th>
                                        <th> Username </th>
                                        <th> Password </th>

                                        

                                        </thead>
                                        <tbody>
                                        <?php 
                                        $shrdq = "SELECT * FROM emptools JOIN individualshared ON emptools.idtools = individualshared.id WHERE emptools.empid='$empID' AND  type='Shared'";
                                        $resultshrd  = mysqli_query($conn, $shrdq);
                        
                                        
                        
                                        if (mysqli_num_rows($resultshrd) > 0) {
                                    
                                            while($rowshrd = mysqli_fetch_assoc($resultshrd)) {
                                                echo'
                                                <tr>
                                                
                                            
                                                <td>'.$rowshrd ['name'].'</td>
                                                <td>'.$rowshrd ['description'].'</td>
                                                <td>'.$rowshrd ['username'].'</td>
                                                <td>'.$rowshrd ['password'].'</td>
                                
                                                </tr>
                                                
                                                ';
                                            
                                            
                        
                                            }
                                        } 
                                        else{

                                            echo '<tr> <td> No Data Found </td></tr>';
                                        }
                                    

                                        
                                        
                                        ?>

                                        </tbody>
                                        </table>

                                        </div>
                                    

                                    

                                    </div>
                                    <!-- INDIVIDUAL TOOLS MODAL -->
                                    <div class="modal fade" id="shrdmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                                <div class="modal-dialog modal-dialog-centered" role="document">
                                                    <div class="modal-content">
                                                    <div class="modal-header">
                                                        <h5 class="modal-title" id="exampleModalLabel">Add Employee Shared Tools</h5>
                                                        <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">×</span>
                                                        </button>
                                                    </div>
                                                        <div class="modal-body">
                                                        <div class="row">
                                                            <div class="col-sm-6">
                                                                <label for="toolsusername" >Tools</label>
                                                                <input type="text" class="form-control" name="sharedname"  id="sharedname"placeholder="Tools" readonly>
                                                                <input type="hidden" value="<?php echo $sharedid ?>" name="sharedid">
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <label for="toolsusername" >Type</label>
                                                                <input type="text" class="form-control" name="sharedtype" value="Shared" placeholder="Password" readonly>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <label for="toolsusername" >Username</label>
                                                                <input type="text" class="form-control" name="sharedusername" placeholder="Username">
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <label for="toolpassword" >Password</label>
                                                                <input type="text" class="form-control" name="sharedpassword" placeholder="Password">
                                                            </div>
                                                            <div class="col-sm-12">
                                                                <label for="toolsdesc" >Description</label>
                                                                <textarea name="shareddesc" class="form-control" rows="4" cols="50" placeholder="Description"></textarea>
                                                            </div>

                                                    
                                                        </div>
                                                            <div class="modal-footer">
                                                            <input type="submit" class="btn btn-success" name="addshrd" value="✓ Yes" style="margin-right: 5px;" >
                                                                <button class="btn btn-danger" type="button" data-dismiss="modal"><i class='fas fa-close'></i> No</button>
                                                                            
                                                            </div>
                                                        </div>
                                                </div>
                                    </div>
                                </form>



                        </div>
                    
                    
                    </div> <!-- END OF TOOLS TAB-->
                    </div>

                    <div id="poshis" class="tabcontent" style="display: none">

                        <h5> Position History </h5>

                        <table class="table">
                            <thead class="thead-dark">
                                        <th>Position </th>
                                        <th>Date </th>

                            </thead>
                            <tbody>
                                
                                    <?php
                                        $poshis = "SELECT * FROM positionhistory WHERE empid='$empID' ORDER BY date DESC";
                                        $poshisres = mysqli_query($conn, $poshis);

                                        while($poshisrow = mysqli_fetch_assoc($poshisres)){
                                            echo '<tr><td>'.$poshisrow['position'].'</td>';
                                            echo '<td>'.date('m/d/Y', strtotime($poshisrow['date'])).'</td></tr>';
                                        }
                                    
                                    
                                    ?>
                                
                            
                                
                            
                            </tbody>

                        </table>



                    </div>


               
         
        <script>
            // Date Validation effectdate.min = new Date().toISOString().split("T")[0]; 
            
        </script>
      
        <!-- /.container-fluid -->

        <!-- Sticky Footer -->
    

      </div>
      <!-- /.content-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
      <i class="fas fa-angle-up"></i>
    </a>

    <!-- Logout Modal-->
    <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">×</span>
            </button>
          </div>
          <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
          <div class="modal-footer">
            <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
            <a class="btn btn-primary" href="login.html">Logout</a>
          </div>
        </div>
      </div>
    </div>

    <!-- Bootstrap core JavaScript-->
    <script src="../vendor/jquery/jquery.min.js"></script>
    <script src="../vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <script src="../vendor/jquery-easing/jquery.easing.min.js"></script>

    <!-- Page level plugin JavaScript-->
    <script src="../vendor/chart.js/Chart.min.js"></script>
    <script src="../vendor/datatables/jquery.dataTables.js"></script>
    <script src="../vendor/datatables/dataTables.bootstrap4.js"></script>

    <!-- Custom scripts for all pages-->
    <script src="../js/sb-admin.min.js"></script>

    <!-- Demo scripts for this page-->
    <script src="../js/demo/datatables-demo.js"></script>
    <script src="../js/demo/chart-area-demo.js"></script>

   
    
    
 


          <script language="javascript" type="text/javascript">
            $(document).ready(function(){
            $("form").on("submit", function(){
                $("#pageloader").fadeIn();
            });//submit

             $('#preloader').fadeOut();
            });//document ready



        </script>
</body>

</html>
