<?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);
////////////////////////////////////////////////

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

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


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

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

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

}




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

$gid =$row['gid'];
$surname = $row['surname'];
$firstname = $row['firstname'];
$middlename = $row['middlename'];
$permanentadd = $row['permanentadd'];
$residentialadd = $row['residentialadd'];
$bday = $row['bday'];
$age = $row['age'];
$gender = $row['gender'];
$contactno = $row['contactno'];
$email = $row['email'];
$civilstat = $row['civilstat'];
$spouse = $row['spouse'];
$spousebday = $row['spousebday'];
$mothersname = $row['mothersmaiden'];
$motheroccu = $row['mothersoccu'];
$fathersname = $row['fathersname'];
$fatheroccu = $row['fathersoccu'];
$ename = $row['ename'];
$erelatioship = $row['erel'];
$eaddress = $row['eadd'];
$econtactno = $row['econtactno'];
$hireddate = $row['hireddate'];
$thirdmonth = $row['thirdmonth'];
$fifthmonth = $row['fourthmonth'];
$tenure = $row['tenure'];
$level = $row['level'];
$department = $row['department'];
$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']; 


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

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

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

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

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


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



    $na = $_POST['na'];

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

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

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




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


    


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

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


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

}



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

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

    

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

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


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

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

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

    ///get data
 

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

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


    }

}

////ROBINSONS PAYROLL

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

else{
    $bdisabled ="";

}

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

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

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

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



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

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

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

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

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

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

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

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

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


    


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

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

    $usersql = "UPDATE `individualshared` SET `empid`='$empID' WHERE ID = '$selindi'";

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

}

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


     
    $checkshrd = "SELECT * FROM shared WHERE id = '$selshrd' AND empid='$empID'";
    $resultshrd = mysqli_query($conn, $checkshrd);
    if (mysqli_num_rows($resultshrd) > 0) {
        $tabshrd = 'style="display: block;"';
        $alert ="<div class='alert alert-danger'>
        <strong style='font-size:12pt;'>Shared Tools Already Exist</strong> 
      </div>";
     
    }

    else{

        $usersql = "INSERT INTO `shared`(`id`, `empid`) VALUES ('$selshrd','$empID')";

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

    }



    

}

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


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

  <head>

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

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

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

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

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


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

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

    <script>

    

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

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

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

        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('shared').style.display = 'none';
        document.getElementById('peb').style.backgroundColor = '#f1f1f1';
         document.getElementById('pib').style.backgroundColor = '#f1f1f1';
        document.getElementById('cbb').style.backgroundColor = '#f1f1f1';
        document.getElementById('gib').style.backgroundColor = '#f1f1f1';
        document.getElementById('upb').style.backgroundColor = '#f1f1f1';
        document.getElementById('chb').style.backgroundColor = '#f1f1f1';
        document.getElementById('ts').style.backgroundColor = '#dddddd';
        document.getElementById('indi').style.backgroundColor = '#dddddd';
        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;

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


  </head>

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

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

      <!-- Sidebar -->
      
      <?php 
        $emp = 'active';
        $employee = '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">Update</li>
          </ol>

          <!--DIV CONTAINER-->
            <div class="container">
                <?php echo $_GET['alert']; echo $alert ?>
                <div class="tab">
                    <button class="tablinks " id="pib" onclick="openpi()" >Personal Information</button>
                    <button class="tablinks" id="gib" onclick="opengi()">Government Info</button>
                    <button class="tablinks" id="cbb" onclick="opencb()">Compensation & Benefit</button>
                    <button class="tablinks" id="peb" onclick="openpe()">Pre Employement</button>
                    <button class="tablinks" id="ts" onclick="opents()">Tools</button>
                    
                </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"> <i class="fas fa-upload"></i>  Update 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>
                                    </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>
                                    </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>
                                    </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>
                                    </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>
                                    </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" >
                                    </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>
                                    </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>
                                    </div>

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

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

                                    <div id="civilstatbox" style="width:98%; margin: 0 auto;">
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <label class="control-label">Spouse's Name </label> <br>
                                                <input type="text" class="form-control" name="spouse"  placeholder="Spouse Name"  value="<?php echo $spouse?>">
                                                </div>
                                                <div class="col-sm-6">
                                                <label class="control-label">Date of Birth</label> <br>
                                                <input type="date" class="form-control" name="spousebday"  placeholder="Spouse Birthdate" value="<?php echo $spousebday?>" >
                                            </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>
                                    </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>
                                    </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>
                                    </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>
                                    </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>
                                    </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>
                                    </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>
                                    </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>
                                    </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>
                                                <?php switch ($tenure) {
                                                        case "Regular":
                                                            $regular = 'selected';
                                                            break;
                                                        case "Probationary":
                                                            $prob = 'selected';
                                                            break;
                                                            case "Intern":
                                                            $int= 'selected';
                                                            break;
                                                            case "Casual":
                                                            $cas = 'selected';
                                                            break;
                                                    
                                                    }

                                                ?>
                                                <option value="" disabled selected>Tenure</option>
                                                <option value="Regular" <?php echo $regular?>>Regular</option>
                                                <option value="Probationary" <?php echo $prob?>>Probationary </option>
                                                <option value="Intern" <?php echo $int?>>Intern </option>
                                                <option value="Casual" <?php echo $cas?>>Casual </option>
                                            
                                            </select>
                                    </div>
                                  
                                    <div class="col-sm-4 form-group required">
                                    <label class="control-label">Level </label> <br>
                                        <select name="level" class="form-control" required>
                                        <?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>
                                        <?php switch ($department) {
                                                case "Operation":
                                                    $op= 'selected';
                                                    break;
                                                case "Support":
                                                    $sup= 'selected';
                                                    break;
                                        } ?>
                                        <option value="" disabled selected>Department</option>
                                        <option value="Operation"<?php echo $op?>>Operation</option>
                                            <option value="Support"<?php echo $sup ?>>Support</option>
                                
                                        </select>
                                    </div>
                                    <div class="col-sm-4 form-group required">
                                    <label class="control-label">Team</label> <br>
                                        <?php 
                                        $query = "SELECT * FROM team";                                                
                                        $result = mysqli_query ($conn,$query); 
                                        echo "<select name='team'  class='form-control'>"; 
                                        echo "<option value='' disabled selected> Team </option>";
                                        while($r = mysqli_fetch_array($result)) {
                                            if($team==$r['name']){
                                                echo "<option value='".$r['name']."' selected='selected'>".$r['name']."</option>";
                                         
                                            }
                                           else{
                                            echo "<option value='".$r['name']."' >".$r['name']."</option>";
                                           }
                                            
                                        }
                                        echo "</select>"; ?>
                                    </div>
                                    <div class="col-sm-4 form-group required">
                                    <label class="control-label">General Position </label> <br>
                                        <?php 
                                        $query = "SELECT * FROM generalpos";                                                
                                        $result = mysqli_query ($conn,$query); 
                                        echo "<select name='genpos'  class='form-control'>"; 
                                        echo "<option value='' disabled selected> General Position </option>";
                                        while($r = mysqli_fetch_array($result)) {
                                            if($genpos==$r['name']){
                                                echo "<option value='".$r['name']."' selected='selected'>".$r['name']."</option>";
                                         
                                            }
                                           else{
                                            echo "<option value='".$r['name']."' >".$r['name']."</option>";
                                           }
                                            
                                        }
                                        echo "</select>"; ?>
                                    </div>
                                    <div class="col-sm-4 form-group required">
                                    <label class="control-label">Job Title</label> <br>
                                        <?php 
                                        $query = "SELECT * FROM jobtitle";                                                
                                        $result = mysqli_query ($conn,$query); 
                                        echo "<select name='jobtitle'  class='form-control'>"; 
                                        echo "<option value='' disabled selected> Job Title </option>";
                                        while($r = mysqli_fetch_array($result)) {
                                            if($jobtitle==$r['name']){
                                                echo "<option value='".$r['name']."' selected='selected'>".$r['name']."</option>";
                                         
                                            }
                                           else{
                                            echo "<option value='".$r['name']."' >".$r['name']."</option>";
                                           }
                                            
                                        }
                                        echo "</select>"; ?>
                                  
                                    </div>

                                    
                                    <div class="col-sm-6 form-group required">
                                        <label class="control-label">Immediate Supervisor</label> <br>
                                        <?php 
                                        $query = "SELECT * FROM supervisor";                                                
                                        $result = mysqli_query ($conn,$query); 
                                        echo "<select name='supervisor' value='' class='form-control'>"; 
                                        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 >
                                        <?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 class="col-sm-12 form-group required">
                                        <div class="row justify-content-end">
                                                
                                            <!-- <input type="submit" class="btn btn-success" name="saveinfo" value="Save" style="margin-right: 5px;" > -->
                                            <button type="button" class="btn btn-success" data-toggle="modal" data-target="#personalinfomodal" > <i class='fas fa-check'></i> Save</button> &nbsp
                                        
                                            <a href="employee.php" class="btn btn-danger" role="button" style="margin-right: 5px;">  <i class='fas fa-close'></i> Cancel </a>
                                        </div>
                                    </div>
                                
                                </div>
                                                <!--- PERSONAL INFORMATION MODAL -->
                                <div class="modal fade" id="personalinfomodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                    <div class="modal-dialog modal-dialog-centered" role="document">
                                        <div class="modal-content">
                                        <div class="modal-header">
                                            <h5 class="modal-title" id="exampleModalLabel">Update Employee Information</h5>
                                            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true">×</span>
                                            </button>
                                        </div>
                                            <div class="modal-body">Are you sure you want to update  <?php echo $firstname.' '.$surname?> Information ?</div>
                                                <div class="modal-footer">
                                                <input type="submit" class="btn btn-success" name="saveinfo" value="✓ Yes" style="margin-right: 5px;" >
                                                    <button class="btn btn-danger" type="button" data-dismiss="modal"><i class='fas fa-close'></i> No</button>
                                                                
                                                </div>
                                            </div>
                                    </div>
                                </div>
                    </form>               
                </div>
                <!-- END OF PERSONAL INFORMATION TAB-->
               




                <!-- END PERSONAL INFORMATION MODAL -->

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

                        <form method="post" enctype="multipart/form-data" >
                            <h3>Government Information</h3>  
                            <div class="row">
                                <div class="col-sm-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>
                                </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?>">
                                </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>
                                </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>
                                </div>
                                <div class="col-sm-12 form-group required">
                                    <div class="row justify-content-end">
                                            
                                        
                                    <button type="button" class="btn btn-success" data-toggle="modal" data-target="#govinfomodal" > <i class='fas fa-check'></i> Save</button> &nbsp
                                        <a href="employee.php" class="btn btn-danger" role="button" style="margin-right: 5px;"> <i class='fas fa-close'></i> Cancel </a>
                                    </div>
                                </div>
                            
                        
                            </div>
                            <div class="modal fade" id="govinfomodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                    <div class="modal-dialog modal-dialog-centered" role="document">
                                        <div class="modal-content">
                                        <div class="modal-header">
                                            <h5 class="modal-title" id="exampleModalLabel">Update Government Info </h5>
                                            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true">×</span>
                                            </button>
                                        </div>
                                            <div class="modal-body">Are you sure you want to update  <?php echo $firstname.' '.$surname?> Government Information ?</div>
                                                <div class="modal-footer">
                                                <input type="submit" class="btn btn-success" name="savegov" value="✓ Yes" style="margin-right: 5px;" > 
                                                    <button class="btn btn-danger" type="button" data-dismiss="modal"><i class='fas fa-close'></i> No</button>
                                                                
                                                </div>
                                            </div>
                                    </div>
                            </div>
                        </form>
                    </div>

                    <div id="preemp" class="tabcontent" <?php echo $_GET['pe']?>>
                        <div class="tab">
                            <button class="tab1" id="upb" onclick="openup()" >Upload</button>
                            <button class="tab1" id="chb" onclick="opencheck()">Checklist</button>
                        </div>
                      
                        <div id="document" class="tabcontent1" <?php echo $_GET['doc']?>>
                            <form method="post" enctype="multipart/form-data" >               
                                <div class="col-sm-12 form-group required">
                       
                                </div>
                                
                                    <div class="col-sm-6 form-group required">
                                        <h5> Upload Documents </h5>
                                        <label class="control-label">Documents</label> <br>
                                            <select name="document" class="form-control" id="document" required>
                                                <option value="" disabled selected>Select Document </option>
                                                <?php 

                                        
                                             
                                                    $documentlistsql = "SELECT * FROM documents WHERE empid = '$empID' AND status IN ('none','n/a')";
                                                
                                           
                                              

                                                
                                                
                                                 $resultlist = mysqli_query($conn, $documentlistsql);
                                             
                                                     while($rowlist = mysqli_fetch_assoc($resultlist)) {
                                                        echo '<option value="'.$rowlist['name'].'">'.$rowlist['name'].' </option>';

                                                     }
                                                ?>
                                            </select>
                                    
                                            
                                                

                                    </div>
                                    <div class="row">
                                        <div class="col-sm-12 form-inline required" style="margin-bottom: 10px;">
                                        &nbsp &nbsp <input type="checkbox" id="na"  name="nacheck" value="check" onclick="checkb()" style="height: 25px; width: 25px;" >&nbsp <h5>  N/A </h5>&nbsp 
                                        
                                        &nbsp  <input type="file" name="doc" id="doc"  class="form-control" name="file" accept="image/*"  required>
                                        </div>
                                    </div>
                                    <script>
                                     function checkb() {
                   
             
                                                    if (document.getElementById("na").checked == true) {
                                                        document.getElementById("doc").disabled = true;
                                                    } else {
                                                        document.getElementById("doc").disabled = false;
                                                    }
                                            
                                        }
                                    </script>
                                    <div class="col-sm-12 form-group required">
                                    <table class="table table-hover">
                                        <thead 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="fa fa-eye"></i> View </a>   
                                                    </td>
                                    
                                                    </tr>
                                                  
                                                    ';

                                                }
                                            
                                            ?>
                                    
                                        </tbody>
                                    </table>
                                    
                                    

                                    </div>
                                    

                                    <div class="col-sm-12 form-group required">
                                        <div class="row justify-content-end">
                                        <button type="button" class="btn btn-success" data-toggle="modal" data-target="#preemployment" ><i class='fas fa-check'></i> Save</button> &nbsp
                                          
                                        
                                            <a href="employee.php" class="btn btn-danger" role="button" style="margin-right: 5px;"><i class="fa fa-close"></i> Cancel </a>
                                        </div>
                                    </div>

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


                            </form>

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

                                <div class="col-sm-12 form-group required">
                                    <h5>Checklist</h5>
                                    <table class="table table-hover">
                                    <thead 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:20px; color: #fc9700; "><strong>N/A</strong></i></td>';
                                                    }
                                                    else{
                                                        echo '<td><i class="fa fa-close" style="color:red; font-size:25px; "></i></td>';
                                                    }
                                                 
                                            
                                                   

                                                }
                                            
                                        ?>
                                        
                                    </tbody>


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


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

                <!-- END OF GOVERNMENT INFO TAB-->
                <!-- COMPENSATION & BENEFIT TAB-->
                <link href = "../css/style.css" rel = "stylesheet">
                <div id="compb" class="tabcontent"  <?php echo $_GET['cb']; echo $cb; ?>>
                    <div class="tab">
                        <button class="tab1" id="curb" onclick="opencur()" >Current</button>
                        <button class="tab1" id="hisb" onclick="openhis()">History</button>
                    </div>
                    <div id="current" class="tabcontent1" <?php echo $_GET['cr']; echo $cr; ?>>
                        
                        <div class="row" style="padding: 10px 30px;">
                            <form method="post" enctype="multipart/form-data">
                                <div class="row">
                                    <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?>" >
                                    </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?>" >
                                    </div>
                                    <div class="col-sm-4 form-group required">
                                        <label class="control-label">Type</label> <br>
                                        <select class="form-control" name="paytype">
                                                <?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>
                                    <div class="col-sm-12 form-group required">
                                        <div class="row justify-content-end">
                                            <button type="button"  class="btn btn-success" data-toggle="modal"  data-target="#addpaymodal" <?php echo $addisabled?>> <i class='fas fa-plus'></i> Add </button> &nbsp
                                            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#updatepaymodal" <?php echo $updisabled?>> <i class="fas fa-edit"></i> Update </button> &nbsp
                                            <button type="reset"  class="btn btn-danger"><i class="fas fa-close"></i> Cancel </button>
                                        </div>
                                    </div>
                                </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"><i class='fas fa-close'></i>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"><i class='fas fa-close'></i> No</button>
                                            
                                        </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);
                        
                              
                                    
                            ?>
                            <div class="dropdown-divider"></div>
                            <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> &#8369 &nbsp'.number_format($total,2).'</td>';
                                    
                                    ?>
                                    
                                    </tr>
                                
                                </tbody>
                            </table>

                        </div>
                        <div class="dropdown-divider"></div>
                        <div class="col-sm-12 form-group required">
                            <h5>Update Salary Package</h5>
                        </div>
                        
                            <form method="post" enctype="multipart/form-data">
                                <div class="row">
                                    <div class="col-sm-6 form-group required">
                                        <label class="control-label">Salary Code</label> <br>
                                            <select name="salarycode" class="form-control" required>
                                            <option value="" disabled selected>Salary Code</option>
                                            <!--- PHP populated -->
                                            <?php 
                                            $sql = "SELECT * FROM `salarypackage` WHERE level ='$level'";
                                            $result = mysqli_query($conn, $sql);
                                          
                                            
                                            if (mysqli_num_rows($result) > 0) {
                                                // output data of each row
                                                while($row = mysqli_fetch_assoc($result)) {
                                                    
                                                    if($_POST["salarycode"]==$row['salarycode'])
                                                    echo "<option value='".$row['salarycode']."' selected='selected'>".$row['salarycode']."</option>";
                                                  else
                                                    echo "<option value='".$row['salarycode']."' >".$row['salarycode']."</option>";
                                                }
                                            } else {
                                                echo "0 results";
                                            }
                                            
                                            ?>  
                                            </select>
                                        
                                    </div>
                                    <div class="col-sm-6 form-group required">
                                        <label class="control-label">Effectivity Date</label> <br>
                                        <input type="date" id="effectdate" name="effectdate" class="form-control" value="<?php echo $effectdate?>" required>
                                    </div>
                                    <div class="col-sm-12 form-group required">
                                        <h5>
                                            <?php 
                                            $salarycode = $_POST['salarycode'];
                                            echo $salarycode?></h5> 
                                            <table class="table table-hover">
                                                <thead style="background-color: #09223b; color: white;">
                                                    <?php 
                                            
                                                    if(isset($_POST['viewcomp'])){
                                                       
                                                     
                                                        
                                                        $cb = 'style="display: block;"';
                                                        $cr = 'style="display: block"';
                                                        $_GET['cr'] ='';
                                                       

                                                        $compensql = "SELECT * FROM compensation JOIN monetary ON compensation.monetaryid = monetary.monetaryid WHERE salarycode='$salarycode' ORDER BY compensation.monetaryid";
                                                        $compenresult = mysqli_query($conn, $compensql);

                                                        if (mysqli_num_rows($compenresult) > 0) {
                                                    
                                                            while($compenrow = mysqli_fetch_assoc($compenresult)) {
                                                                echo'
                                                                
                                                                
                                                                <th>'.$compenrow['name'].'</th>
                                                
                                                                
                                                                
                                                                ';

                                                            }

                                                            echo '<th> TOTAL </th>';
                                                        
                                                        } 
                                                        

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

                                                        

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

                                                                $total1 += $amounts;

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

                                                        
                                                    
                                                
                                                   
                                                   
                                                    
                                    </div>
                                    <div class="col-sm-12 form-group required">
                                        <div class="row justify-content-end">
                                            <button type="submit" class="btn btn-primary" name="viewcomp" style="margin-right: 5px;" > <i class='fa fa-eye'></i> View </button>
                                            <button type="button" class="btn btn-success" data-toggle="modal" onclick="view()" data-target="#compensationbenefit"> <i class="fas fa-plus"></i>  Add </button> &nbsp
                                            <a href="employee.php" class="btn btn-danger" role="button" style="margin-right: 5px;"> <i class='fas fa-close'></i> Cancel </a>
                                        </div>

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

                            </div>
                            <div class="col-sm-6 form-group required">
                                <br>
                                <h4>Details</h4>
                                <table class="table table-hover">
                                    <thead 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>
                                                    </form>
                                                    
                                                
                                                    ';
                                                    $amount = $row['amount'];
                                                    $amounts = str_replace(',','',$amount);

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

                    

                    

                

                <!-- END OF COMPENSATION AND BENEFIT TAB-->
                
                </div>
                <!-- TOOLS  TAB-->
                <div id="emptools" class="tabcontent" <?php echo $tls; echo $_GET['tls']?>>

                <div class="tab">
                            <button class="tab1" id="indi" onclick="openindi()" >Individual</button>
                            <button class="tab1" id="shrd" onclick="openshrd()">Shared</button>
                </div>
                      
                <div id="individual" class="tabcontent1" <?php echo $tabindi; echo $_GET['indi']?>>
                    <h5>Individual Tools</h5>
                    <form method="post" enctype="multipart/form-data"> 
                        <div class="row">
                        
                            <div class="col-sm-6 form-group required">
                                <?php 
                                        $qt = "SELECT * FROM individualshared WHERE type='Individual' AND empID IS NULL ";                                                
                                        $rt = mysqli_query ($conn,$qt); 
                                        echo "<select name='selindi' class='form-control' required>"; 
                                        echo "<option value='' disabled selected> Individual </option>";
                                  
                                        while($r = mysqli_fetch_array($rt)) {
                                            if($selindi == $r['id']){
                                                echo "<option value='".$r['id']."' selected='selected'>".$r['name']." ".$r['description']."</option>";
                                         
                                            }
                                           else{
                                            echo "<option value='".$r['id']."' >".$r['name']." ".$r['description']."</option>";
                                           }
                                            
                                        }
                                        echo "</select>"; ?>
                            </div>
                         
                            <div class="col-sm-6 form-inline required">
                                   
                          
            
                                <button type="submit" name="viewindi" class="btn btn-primary"> <i class="fa fa-eye"></i> View </button>&nbsp


                                <button type="button" class="btn btn-success" data-toggle="modal"  data-target="#indimodal"> <i class="fa fa-plus"></i> Add</button> &nbsp
                 
                     
                          
                           
                     
                                <button type="reset"  class="btn btn-danger"> <i class="fa fa-close"></i> Cancel </button>

                            </div>
                            <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">
                            <h5>List of Individual Tools</h5>
                            <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">
                            
                                <div class="col-sm-6 form-group required">
                                    <?php 
                                            $qt = "SELECT * FROM individualshared WHERE type='Shared'";                                                
                                            $rt = mysqli_query ($conn,$qt); 
                                            echo "<select name='selshrd' class='form-control' required>"; 
                                            echo "<option value='' disabled selected> Shared </option>";
                                    
                                            while($r = mysqli_fetch_array($rt)) {
                                                if($selshrd == $r['id']){
                                                    echo "<option value='".$r['id']."' selected='selected'>".$r['name']." ".$r['description']."</option>";
                                            
                                                }
                                            else{
                                                echo "<option value='".$r['id']."' >".$r['name']." ".$r['description']."</option>";
                                            }
                                                
                                            }
                                            echo "</select>"; ?>
                                </div>
                            
                                <div class="col-sm-6 form-inline required">
                                    
                            
                
                                    <button type="submit" name="viewshrd" class="btn btn-primary"> <i class="fa fa-eye"></i> View </button>&nbsp


                                    <button type="button" class="btn btn-success" data-toggle="modal"  data-target="#shrdmodal"> <i class="fa fa-plus"></i> Add</button> &nbsp
                    
                        
                            
                            
                        
                                    <button type="reset"  class="btn btn-danger"> <i class="fa fa-close"></i> Cancel </button>

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

                                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= '$selshrd'";
                                $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">
                                <h5>List of Shared Tools</h5>
                                <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> <!-- END OF TOOLS TAB-->
                     
               
         
        <script>
            // Date Validation effectdate.min = new Date().toISOString().split("T")[0]; 
            
        </script>
      
        <!-- /.container-fluid -->

        <!-- Sticky Footer -->
    

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

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

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

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

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

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

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

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

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

   
    
    
    <!--MODAL 
    
    <div id="view-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none">
         <div class="modal-dialog modal-dialog-centered" style="width: 100%;"> 
              <div class="modal-content"> 
            
                    <div class="modal-header">
                        <h5 class="modal-title" id="salaryinfo"></h5>
                            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">×</span>
                            </button>
                    </div>
                   <div class="modal-body"> 
                   
                          <div id="modal-loader" style="display: none; text-align: center;">
                              <img src="ajax-loader.gif">
                          </div>
                   
                          <div id="dynamic-content">
                                    
                       <div class="row"> 
                            
                            <div class="col-md-12"> 
                            
                            <div class="table-responsive">
                            
                            <table class="table table-bordered" style="width:95%; margin: 0 auto;">
                               <tr>
                            <p id="salaryinfo"></p>
                            <input type="text" id="saldcode" name="saldcode" hidden> 
                        
                            </tr>
                            <tr>
                                <th> Items</th>
                                <th> Amount </th>

                            </tr>
                            /*
                            <?php ?>
                            /*
                                    $sc = $_POST['saldcode'];
                                     echo $sc;
                                    $sql = "SELECT * FROM compensation JOIN monetary ON compensation.monetaryid = monetary.monetaryid WHERE compensation.salarycode='$sc'";
                                    $result = mysqli_query($conn, $sql);

                                    if (mysqli_num_rows($result) > 0) {
                                        // output data of each row
                                        while($row = mysqli_fetch_assoc($result)) {
                                            
                                            echo '<tr><td>'.$row['salarycode'].'</td>
                                                    <td>'.$row['amount'].'</td></tr>
                                            
                                            ';
                                        }
                                    } else {
                                        echo "0 results";
                                    }
                                                
                            ?>
                           
                                           
                            </table>
                            
                            </div>
                                   
                            </div> 
                      </div>
                      
                      </div> 
                         
                    </div> 
                    <div class="modal-footer"> 
                          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>  
                    </div> 
                    <script>
                    function getd(){
                        var values= document.getElementById("salaryinfo").innerHTML;
                        document.getElementById("saldcode").value = values;

                    }
                    
                    </script>
                    
             </div> 
          </div>
   </div>
   
   /.modal -->    
<!--
</div>





<script>

$(document).ready(function(){

$(document).on('click', '#getUser', function(e){
    
    e.preventDefault();
    
    var uid = $(this).data('id'); // get id of clicked row
    
    $('#dynamic-content').hide(); // hide dive for loader
    $('#modal-loader').show();  // load ajax loader
    
    $.ajax({
        url: 'getuser.php',
        type: 'POST',
        data: 'id='+uid,
        dataType: 'json'
    })
    .done(function(data){
        console.log(data);
        $('#dynamic-content').hide(); // hide dynamic div
        $('#dynamic-content').show(); // show dynamic div
        $('#salaryinfo').html(data.salarycode);
        $('#effectivitydate').html(data.effectivitydate);
        $('#txt_lname').html(data.id);
        $('#txt_email').html(data.effectivitydate);
        $('#txt_position').html(data.position);
        $('#txt_office').html(data.office);
        $('#modal-loader').hide();    // hide ajax loader
    })
    .fail(function(){
        $('.modal-body').html('<i class="glyphicon glyphicon-info-sign"></i> Something went wrong, Please try again...');
    });
    
});

});


 


</script>

-->

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

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



        </script>
</body>

</html>
