<?php 


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

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


//VARIABLES
$empID = $_GET['ID'];
$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);
////////////////////////////////////////////////

$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'];
$team = $row['team'];
$genpos = $row['generalpos'];
$jobtitle =  $row['jobtitle'];
$supervisor = $row['supervisor'];
$status = $row['status'];
$date = $row['date'];
$userpic = $row['picture'];

$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'];

$salarycode = $_POST['salarycode']; 

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

    //update profile picture
    
    $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)
                   {
                    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
                 } 
                
    
    $Pspousebday = date('Y/m/d');
    $sql = "UPDATE `empinfo` SET `surname`='$Psurname',`firstname`='$Pfirstname',
    `middlename`='$Pmiddlename',`permanentadd`='$Ppermanentadd',`residentialadd`='$residentialadd',`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' WHERE `detailid`='$empID'";
    
    if (mysqli_query($conn, $sql) && mysqli_query($conn, $updateemp) ) {
       $alert='<div class="alert alert-success" role="alert">
        Employe Information Sucessfully Saved
          </div>';
          header('location: updateemp.php?ID='.$empID.'');
    } else {
        echo "Error updating record: " . mysqli_error($conn);
    }
    
    
    
}
//PRE EMPLOYMENT
if(isset($_POST['savedoc'])){

    $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>";




}
$docsql= "INSERT INTO `documents`(`docid`, `name`, `document`, `empid`) VALUES ('$docID', '$documents', '$doc', '$empID')";

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

 } 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'])){
    $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>";
      header('location: updateemp.php?ID='.$empID.'');
    } else {
        echo "Error: " . $sql . "<br>" . mysqli_error($conn);
    }

    ///get data
 

}
//COMPENSATION & BENEFIT
if(isset($_POST['addcomp'])){

   
    $checkcomp = "SELECT * FROM salaryemp WHERE salarycode='$salarycode' AND empid='$empID' AND effectivitydate='$effectdate'";
    $resultcomp = mysqli_query($conn, $checkcomp);
    if (mysqli_num_rows($result) > 0) {
        $alert ="<div class='alert alert-danger'>
        <strong style='font-size:12pt;'>Salary Package Exist</strong> 
      </div>";

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


    }

}

////ROBINSONS PAYROLL

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

else{
    $bdisabled ="";

}

if(isset($_POST['uppayroll'])){
    $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 Successfully Update.</strong>
        </div> ";

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

if(isset($_POST['adpayroll'])){
    $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 Add.</strong>
      </div> ";
    }
    else {
        echo "Error: " . $paysql . "<br>" . mysqli_error($conn);
    }



}

?>
<!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>Admin | View 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 openCity(evt, cityName) {
        var i, tabcontent, tablinks;
        tabcontent = document.getElementsByClassName("tabcontent");
        for (i = 0; i < tabcontent.length; i++) {
            tabcontent[i].style.display = "none";
        }
        tablinks = document.getElementsByClassName("tablinks");
        for (i = 0; i < tablinks.length; i++) {
            tablinks[i].className = tablinks[i].className.replace(" active", "");
        }
        document.getElementById(cityName).style.display = "block";
        evt.currentTarget.className += " active";
    }
    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;

    }
        effectdate.min = new Date().toISOString().split("T")[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('govinfo').style.display = 'none';
        document.getElementById('preemp').style.display = 'none';
        document.getElementById('compb').style.display = 'none';
        document.getElementById('ts').style.backgroundColor = '#f1f1f1';
        document.getElementById('emptools').style.display = 'none';
        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('govinfo').style.display = 'block';
        document.getElementById('preemp').style.display = 'none';
        document.getElementById('compb').style.display = 'none';
        document.getElementById('ts').style.backgroundColor = '#f1f1f1';
        document.getElementById('emptools').style.display = 'none';
        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('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('ts').style.backgroundColor = '#f1f1f1';
        document.getElementById('curb').style.backgroundColor = '#dddddd';
         document.getElementById('hisb').style.backgroundColor = '#f1f1f1';
         document.getElementById('emptools').style.display = 'none';
        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('ts').style.backgroundColor = '#f1f1f1';
        document.getElementById('curb').style.backgroundColor = '#dddddd';
         document.getElementById('hisb').style.backgroundColor = '#f1f1f1';
         document.getElementById('emptools').style.display = 'none';
        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('ts').style.backgroundColor = '#f1f1f1';
        document.getElementById('curb').style.backgroundColor = '#f1f1f1';
        document.getElementById('emptools').style.display = 'none';
         document.getElementById('hisb').style.backgroundColor = '#dddddd';
        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('checklist').style.display = 'none';
        document.getElementById('emptools').style.display = 'none';
        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('checklist').style.display = 'none';
        document.getElementById('emptools').style.display = 'none';
    

        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';
        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('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';
        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';

    }
    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('shrd').style.backgroundColor = '#dddddd';
    }
    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;

    }
    
    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";
    }

    }
    </script>


  </head>

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

    <?php include('uppernav.php')?>

    

      <!-- Sidebar -->
      
      <?php 
        $employee = 'active';
        $emp = 'active';
      include('sidebar.php');
      ?>
      <div id="content-wrapper">

        <div class="container-fluid">

          <!-- Breadcrumbs-->
          <ol class="breadcrumb">
            <li class="breadcrumb-item">
              <a href="employee.php">Employee</a>
            </li>
            <li class="breadcrumb-item active">View</li>
          </ol>

          <!--DIV CONTAINER-->
            <div class="container">
                <?php echo $error.$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>
                    
                </div>
                <!--- PERSONAL INFORMATION TAB-->
                <div id="empinfo" class="tabcontent" <?php echo $_GET['pi']?>>
                    <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">
                            
                                    <!--<label class="btn btn-primary btn-sm"> Upload Profile Picture
                                    <input type="file" name="userpic" style="display: none;" onchange="preview_image(event)"  accept="image/*" alt="PROFILE PICTURE" />
                                    </label> -->
                                </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 disabled>
                                    </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 disabled>
                                    </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 disabled>
                                    </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 disabled>
                                    </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 disabled>
                                    </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" disabled>
                                    </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 disabled>
                                    </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 disabled>
                                    </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="toggle()"  required disabled>
                                            <?php 
                                            switch ($civilstat) {
                                                case "Single":
                                                    $single = 'selected';
                                                    break;
                                                case "Widowed":
                                                    $widowed = 'selected';
                                                    break;
                                                case "Divorced":
                                                    $divorced = 'selected';
                                                    break;
                                                case "Married":
                                                    $married = 'selected';
                                                    break;
                                            
                                            }

                                            ?>
                                            <option value="Single" <?php echo $single?>> 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="married" class="Married box" style="width:98%; margin: 0 auto; display:hide;">
                                        <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;?>"  disabled>
                                                </div>
                                                <div class="col-sm-6">
                                                <label class="control-label">Date of Birth</label> <br>
                                                <input type="date" class="form-control" name="spousebday"  placeholder="Birthdate" value="<?php echo $spousebday;?>"  disabled>
                                            </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 disabled>
                                    </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 disabled>
                                    </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 disabled>
                                    </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 disabled>
                                    </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 disabled>
                                    </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 disabled>
                                    </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 disabled>
                                    </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 disabled>
                                    </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 $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 $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 $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 disabled>
                                        <?php switch ($tenure) {
                                                case "Regular":
                                                    $regular = 'selected';
                                                    break;
                                                case "Probationary":
                                                    $prob = 'selected';
                                                    break;
                                            
                                            }

                                        ?>
                                            <option value="" disabled selected>Tenure</option>
                                            <option value="Regular" <?php echo $regular?>>Regular</option>
                                            <option value="Probationary" <?php echo $prob?>>Probationary </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 disabled>
                                        <?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 disabled>
                                        <?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>
                                        <select name="team" class="form-control" required disabled>
                                        <?php switch ($team) {
                                                case "Accounting":
                                                    $acc= 'selected';
                                                    break;
                                                case "Audit":
                                                    $au= 'selected';
                                                    break;
                                                case "HR/Admin":
                                                    $ad= 'selected';
                                                    break;
                                                case "IT/Data Analytics":
                                                    $it= 'selected';
                                                    break;
                                                case "Management":
                                                    $mm= 'selected';
                                                    break;
                                                case "OLT":
                                                    $olt= 'selected';
                                                    break;
                                                case "Special Project":
                                                    $sp= 'selected';
                                                    break;
                                                case "Support Specialist":
                                                    $spl= 'selected';
                                                    break;
                                        } ?>
                                        <option value="" disabled selected>Team</option>
                                            <option value="Accounting" <?php echo $acc?>>Accounting</option>
                                            <option value="Audit" <?php echo $au?>>Audit</option>
                                            <option value="HR/Admin" <?php echo $ad?>>HR/Admin</option>
                                            <option value="IT/Data Analytics" <?php echo $it?>>IT/Data Analytics</option>
                                            <option value="Management" <?php echo $mm?>>Management</option>
                                            <option value="OLT" <?php echo $olt?>>OLT</option>
                                            <option value="Special Project" <?php echo $sp?>>Special Project</option>
                                            <option value="Support Specialist" <?php echo $spl?>>Support Specialist</option>
                                        
                                        </select>
                                    </div>
                                    <div class="col-sm-4 form-group required">
                                    <label class="control-label">General Position </label> <br>
                                        <select name="genpos" class="form-control" required disabled>
                                        <?php switch ($genpos) {
                                                case "Accounting Specialist":
                                                $accs= 'selected';
                                                    break;
                                                case "Associate Director of Shared Services":
                                                $adss= 'selected';
                                                    break;
                                                case "Data Analyst":
                                                $da= 'selected';
                                                    break;
                                                case "Director of Shared Services":
                                                $dss= 'selected';
                                                    break;
                                                case "Executive Assistant":
                                                $ea= 'selected';
                                                    break;
                                                case "HR Associate":
                                                $hra= 'selected';
                                                    break;
                                                case "IT Associate":
                                                $ita= 'selected';
                                                    break;
                                                case "Process Owner":
                                                $po= 'selected';
                                                    break;
                                                case "Team Head":
                                                $th= 'selected';
                                                    break;
                                                case "Support Specialist":
                                                $ss= 'selected';
                                                    break;
                                        }
                                        ?>
                                        
                                            <option value="Accounting Specialist" <?php echo $accs?>>Accounting Specialist</option>
                                            <option value="Associate Director of Shared Services" <?php echo $adss?>>Associate Director of Shared Services</option>
                                            <option value="Data Analyst" <?php echo $da?>>Data Analyst</option>
                                            <option value="Director of Shared Services" <?php echo $dss?>>Director of Shared Services</option>
                                            <option value="Executive Assistant" <?php echo $ea?>>Executive Assistant</option>
                                            <option value="HR Associate" <?php echo $hra?>>HR Associate</option>
                                            <option value="IT Associate"<?php echo $ita?>>IT Associate</option>
                                            <option value="Process Owner" <?php echo $po?>>Process Owner</option>
                                            <option value="Team Head" <?php echo $th?>>Team Head</option>
                                            <option value="Support Specialist" <?php echo $ss?>>Support Specialist</option>

                                        
                                        </select>
                                    </div>
                                    <div class="col-sm-4 form-group required">
                                    <label class="control-label">Job Title</label> <br>
                                    <select name="jobtitle" class="form-control" required disabled>
                                        <?php switch ($jobtitle) {
                                                case "Accounting Specialist":
                                                $accs= 'selected';
                                                    break;
                                                case "Associate Director of Shared Services":
                                                $adss= 'selected';
                                                    break;
                                                case "Data Analyst":
                                                $da= 'selected';
                                                    break;
                                                case "Director of Shared Services":
                                                $dss= 'selected';
                                                    break;
                                                case "Executive Assistant":
                                                $ea= 'selected';
                                                    break;
                                                case "HR Associate":
                                                $hra= 'selected';
                                                    break;
                                                case "IT Associate":
                                                $ita= 'selected';
                                                    break;
                                                case "Process Owner":
                                                $po= 'selected';
                                                    break;
                                                case "Team Head":
                                                $th= 'selected';
                                                    break;
                                                case "Support Specialist":
                                                $ss= 'selected';
                                                    break;
                                        } 
                                        ?>
                                        
                                            <option value="Accounting Specialist" <?php echo $accs?>>Accounting Specialist</option>
                                            <option value="Associate Director of Shared Services" <?php echo $adss?>>Associate Director of Shared Services</option>
                                            <option value="Data Analyst" <?php echo $da?>>Data Analyst</option>
                                            <option value="Director of Shared Services" <?php echo $dss?>>Director of Shared Services</option>
                                            <option value="Executive Assistant" <?php echo $ea?>>Executive Assistant</option>
                                            <option value="HR Associate" <?php echo $hra?>>HR Associate</option>
                                            <option value="IT Associate"<?php echo $ita?>>IT Associate</option>
                                            <option value="Process Owner" <?php echo $po?>>Process Owner</option>
                                            <option value="Team Head" <?php echo $th?>>Team Head</option>
                                            <option value="Support Specialist" <?php echo $ss?>>Support Specialist</option>

                                        
                                        </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='suprevisor' value='' class='form-control' disabled>"; 
                                        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" class="form-control" required disabled >
                                        <?php switch ($status) {
                                                case "Active":
                                                $act= 'selected';
                                                    break;
                                                case "Inactive":
                                                $iact= 'selected';
                                                        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">Date</label> <br>
                                        <input type="text" id="hdate" class="form-control" name="hireddate" value="<?php echo $hireddate?>"  placeholder="Hired Date" required readonly>

                                    </div>
                             
                                
                                </div>
                    </form>               
                </div>
                <!-- END OF PERSONAL INFORMATION TAB-->

                <!-- GOVERNMENT INFO TAB-->
                <div id="govinfo" class="tabcontent" >

                        <form method="post" enctype="multipart/form-data">
                            <h3>Government Information</h3>  
                            <div class="row">
                                <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 disabled>
                                </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?>" disabled>
                                </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 disabled>
                                </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 disabled>
                                </div>
                          
                            
                        
                            </div>
                        </form>
                    </div>

                    <div id="preemp" class="tabcontent" <?php echo $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 $up?>>
                            <form method="post" enctype="multipart/form-data">               
                                <div class="col-sm-12 form-group required">
                       
                                </div>
                                
                                 
                                    <div class="col-sm-12 form-group required">
                                    <table class="table table-hover">
                                        <thead style="background-color: #09223b; color: white;">
                                            <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="far fa-eye"> </i> View </a>   
                                        
                                                    </td>
                                    
                                                    </tr>
                                                  
                                                    ';

                                                }
                                            
                                            ?>
                                    
                                        </tbody>
                                    </table>
                                    

                                    </div>
                                    

                                   
                            </form>

                                
                            
                        </div>
                        <?php 
                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='NBI Clearance'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $nbistat = $checkrow['status'];
                        $nbid = $checkrow['date'];

                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='NSO/PSA Birth Certificate'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $nsostat = $checkrow['status'];
                        $nsod = $checkrow['date'];

                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='Pre Employement Medical Exam'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $medstat = $checkrow['status'];
                        $medd = $checkrow['date'];

                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='BIR 1905 and 2305'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $birstat = $checkrow['status'];
                        $bird = $checkrow['date'];


                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='Updated MDR'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $mdrstat = $checkrow['status'];
                        $mdrd = $checkrow['date'];


                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='Updated MDF'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $mdfstat = $checkrow['status'];
                        $mdfd = $checkrow['date'];


                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='Marriage Certificate'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $mcstat = $checkrow['status'];
                        $mcsd = $checkrow['date'];


                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='Children Birth Certificate'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $cbcstat = $checkrow['status'];
                        $cbcd = $checkrow['date'];

                        
                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='Account Opening Form'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $aofstat = $checkrow['status'];
                        $aofd = $checkrow['date'];
                        
                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='Certificate of Employment' ";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $coestat = $checkrow['status'];
                        $coed = $checkrow['date'];
                        
                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='ITR'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $itrstat = $checkrow['status'];
                        $itrd = $checkrow['date'];
                        
                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='TOR/DIPLOMA'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $torstat = $checkrow['status'];
                        $tord = $checkrow['date'];
                        
                        $checksql="SELECT * FROM checklist WHERE empid ='$empID' AND document='Valid ID'";
                        $checkresult = mysqli_query($conn, $checksql);
                        $checkrow = mysqli_fetch_assoc($checkresult);
                        $vstat = $checkrow['status'];
                        $vd = $checkrow['date'];
                        
                        


                        
                        
                        

                        ?>
                    <div id="checklist" class="tabcontent1" <?php echo $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 style="background-color: #09223b; color:white; ">
                                        <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:15px; 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>

                                                           
                           
                            <!-- 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">No</button>
                                                
                                            </div>
                                            </div>
                                </div>
                            </div>


                            <!-- CHECK LIST MODAL-->
                        </form>
                    </div>
                </div>
                <!-- END OF GOVERNMENT INFO TAB-->
                <!-- COMPENSATION & BENEFIT TAB-->
          
                <div class="tabcontent" id="compb" <?php echo $_GET['his']?>>
                    <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">
                        
                        <div class="row">
                            <form method="post" enctype="multipart/form-data">
                                <div class="row" style="padding: 30px 30px">
                                    <div class="col-sm-12 form-group required">
                                        <h5> Robinsons Payroll Information </h5>
                                    </div>
                                    <div class="col-sm-4 form-group required">
                                        <label class="control-label">ATM Number</label> <br>
                                        <input type="text" id="atm" name="atm" class="form-control" value="<?php echo $atm1?>"  disabled>
                                    </div>
                                    <div class="col-sm-4 form-group required">
                                        <label class="control-label">Bank Account Number</label> <br>
                                        <input type="text" id="bankaccount" name="bankaccount" class="form-control" value="<?php echo $bank1?>"  disabled>
                                    </div>
                                    <div class="col-sm-4 form-group required">
                                        <label class="control-label">Type</label> <br>
                                        <select class="form-control" name="paytype" disabled>
                                                <?php 
                                                switch($type1){
                                                    case 'Savings Account' :
                                                    $savacc = "selected";
                                                    break;
                                                    case 'Checking Account' :
                                                    $chacc = "selected";
                                                    break ;
                                                }
                                                ?>
                                            <option value="Savings Account" <?php echo $savacc?>>Savings Account</option>
                                            <option value="Checking Account" <?php echo $chacc?>> Checking Account </option>
                                        </select>
                                    </div>
                            
                              

                                <!--- PAYROLL INFORMATION MODAL -->
                                    <!---Update Payroll -->
                                    <div class="modal fade" id="updatepaymodal" 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 Payroll 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?> Payroll Information?</div>
                                        <div class="modal-footer">
                                            <input type="submit" class="btn btn-success" value="Yes" name="uppayroll" style="margin-right: 5px;" > 
                                            <button class="btn btn-danger" type="button" data-dismiss="modal">No</button>
                                            
                                        </div>
                                        </div>
                                    </div>
                                    </div>
                                    <!---Add Payroll Information -->
                                    <div class="modal fade" id="addpaymodal" 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 Payroll 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 add Payroll Information of <?php echo $firstname.' '.$surname?> ?</div>
                                        <div class="modal-footer">
                                            <input type="submit" class="btn btn-success" value="Yes" name="adpayroll" style="margin-right: 5px;" > 
                                            <button class="btn btn-danger" type= "button" data-dismiss="modal">No</button>
                                            
                                        </div>
                                        </div>
                                    </div>
                                    </div>
                                </div>
                                <!--- PAYROLL INFORMATION MODAL -->   
                            </form>
                        </div>
                        <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 style="background-color: #09223b; color: white;">
                                    <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> <strong> &#8369 &nbsp'.number_format($total, 2).' </strong></td>';
                                    
                                    ?>
                                    
                                    </tr>
                                
                                </tbody>
                            </table>

                        </div>
                       
                                    
                              
                                <!--- CONFIRM MODAL COMPENSATION AND BENEFIT -->
                                <div class="modal fade" id="compensationbenefit" 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">Confirm Salary Package</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 wan to add <?php echo $salarycode?> salary package to Employee <?php echo $firstname.' '.$surname?>?</div>
                                    <div class="modal-footer">
                                        <input type="submit" class="btn btn-success" value="Yes" name="addcomp" style="margin-right: 5px;" > 
                                        <button class="btn btn-danger" type="button" data-dismiss="modal">No</button>
                                        
                                    </div>
                                    </div>
                                </div>
                                </div>
                                <!-- CONFIRM MODAL END -->
                            </form>

                    </div>
                                                        
                   <!--- END CURRENT TAB -->
                   <!-- HISTORY TAB -->
                   <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 style="background-color: #09223b; color: white;">
                                            <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;'";
                                                        
                                                                echo'
                                                                
                                                                <tr>
                                                                <td>'.$row['salarycode'].'</td>
                                                                <td>'.$row['effectivitydate'].'</td>
                                                                <td> <a class="btn btn-primary" href="viewemp.php?ID='.$empID.'&salarycode='.$row['salarycode'].'&his='.$histyle.' " ><i class="far 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 style="background-color: #09223b; color: white;">
                                    <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>
                                                
                                                    
                                                
                                                    ';
                                                    $amount = $row['amount'];
                                                    $amounts = str_replace(',','',$amount);
    
                                                    $total1 += $amounts;
                            
                                                }
                                    } 
                                    echo '<td> <strong> TOTAL:  </td> <td><strong> &#8369 &nbsp'.number_format($total1,2).' </strong></td>';
                                    ?>
                                    </tbody>
                                </table>
                            </div>
                           
                        </div>                         
                    </div>

                    

                

                </div>
                <!-- END OF COMPENSATION AND BENEFIT 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 style="background-color: #09223b; color:white;">
                               <th> ID </th>
                               <th> Name </th>
                               <th> Description </th>
                               <th> Username </th>
                               <th> Password </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)) {
                                       echo'
                                       
                                       
                                       <td>'.$rowviewindi['id'].'</td>
                                       <td>'.$rowviewindi['name'].'</td>
                                       <td>'.$rowviewindi['description'].'</td>
                                       <td>'.$rowviewindi['username'].'</td>
                                       <td>'.$rowviewindi['password'].'</td>
                       
                                       
                                       
                                       ';
                                   
                                 
               
                                   }
                               } 
                               echo'</tbody> 
                               
                               </table>
                               <hr>
                               ';

                            }
                            ?>
                            </div>
                        
                            <!-- INDIVIDUAL TOOLS TABLE-->
                         
                           
                            <div class="col-sm-12">
                          
                            <table class="table table-hover"> 
                               <thead style="background-color: #09223b; color:white;">
                               <th> ID </th>
                               <th> Name </th>
                               <th> Description </th>
                               <th> Username </th>
                               <th> Password </th>

                            

                               </thead>
                               <tbody>
                               <?php 
                               $indiq = "SELECT * FROM individualshared 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['id'].'</td>
                                       <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">Are you sure you want to add employee individual tools?</div>
                                                <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">
                            
                                
                               
                            
                                <!-- INDIVIDUAL TOOLS TABLE-->
                            
                            
                                <div class="col-sm-12">
                         
                                <table class="table table-hover"> 
                                <thead style="background-color: #09223b; color:white;">
                                <th> ID </th>
                                <th> Name </th>
                                <th> Description </th>
                                <th> Username </th>
                                <th> Password </th>

                                

                                </thead>
                                <tbody>
                                <?php 
                                $shrdq = "SELECT * FROM shared JOIN individualshared ON shared.id = individualshared.id WHERE shared.empid='$empID'";
                                $resultshrd  = mysqli_query($conn, $shrdq);
                
                                
                
                                if (mysqli_num_rows($resultshrd) > 0) {
                            
                                    while($rowshrd = mysqli_fetch_assoc($resultshrd)) {
                                        echo'
                                        <tr>
                                        
                                        <td>'.$rowshrd ['id'].'</td>
                                        <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">Are you sure you want to add shared tools to employee <?php echo $firstname.' '.$surname?>?</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>
                   
                

            </div>
            

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

        <!-- Sticky Footer -->
    
      <!-- /.content-wrapper -->

    
    <!-- /#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>
