<?php 
 ob_start();
 session_start();
include('../dbconnect.php');
//window.open
//VARIABLES
$empID = $_GET['ID'];
$scode = $_GET['salarycode'];

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

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

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

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

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

$salarycode = $_POST['salarycode']; 

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

    //update profile picture
    
    $imgFile = $_FILES['userpic']['name'];
    $tmp_dir = $_FILES['userpic']['tmp_name'];
    $imgSize = $_FILES['userpic']['size'];
    
    if($imgFile)
                 {
                  $upload_dir = 'files/pictures/'; // upload directory 
                  $imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension
                  $valid_extensions = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions
                  $Puserpic = $empID.".".$imgExt;
                  if(in_array($imgExt, $valid_extensions))
                  {   
                   if($imgSize < 5000000)
                   {
                    unlink($upload_dir.$userpic);
                    move_uploaded_file($tmp_dir,$upload_dir.$Puserpic);
                   }
                   else
                   {
                    $errMSG = "Sorry, your file is too large it should be less then 5MB";
                   }
                  }
                  else
                  {
                   $errMSG = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";  
                  } 
                 }
    
                 else
                 {
                  // if no image selected the old image remain as it is.
                  $Puserpic = $userpic; // old image from database
                 } 
                
    
    $Pspousebday = date('Y/m/d');
    $sql = "UPDATE `empinfo` SET `surname`='$Psurname',`firstname`='$Pfirstname',
    `middlename`='$Pmiddlename',`permanentadd`='$Ppermanentadd',`residentialadd`='$residentialadd',`bday`='$Pbday',
    `age`='$Page',`gender`='$Pgender',`contactno`='$Pcontactno',`email`='$Pemail',`civilstat`='$Pcivilstat',
    `mothersmaiden`='$Pmothersname',`fathersname`='$Pfathersname',`mothersoccu`='$Pmotheroccu',`fathersoccu`='$Pfatheroccu',
    `ename`='$Pename',`erel`='$Perelatioship',`eadd`='$Peaddress',`econtactno`='$Pecontactno',`picture`='$Puserpic',`spouse`='$Pspouse',`spousebday`='$Pspousebday' WHERE empid = '$empID'";
    
    //update employee details
    
    $updateemp = "UPDATE `empdetails` SET `hireddate`='$Phireddate',`thirdmonth`='$Pthirdmonth',`fourthmonth`='$Pthirdmonth',
    `tenure`='$Ptenure',`level`='$Plevel',`department`='$Pdepartment',`team`='$Pteam',`generalpos`='$Pgenpos',`jobtitle`='$Pjobtitle',`supervisor`='$Psupervisor',
    `status`='$Pstatus' WHERE `detailid`='$empID'";
    
    if (mysqli_query($conn, $sql) && mysqli_query($conn, $updateemp) ) {
       $alert='<div class="alert alert-success" role="alert">
        Employe Information Sucessfully Saved
          </div>';
          header('location: updateemp.php?ID='.$empID.'');
    } else {
        echo "Error updating record: " . mysqli_error($conn);
    }
    
    
    
}
//PRE EMPLOYMENT
if(isset($_POST['savedoc'])){

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

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




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

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

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

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

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

    

if(isset($_POST['savegov'])){
    $gid = $empID;
    $SSS = $_POST['sss'];
    $TIN = $_POST['tin'];
    $philhealth = $_POST['philhealth'];
    $pagibig = $_POST['pagibig'];

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

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

    ///get data
 

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

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

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


    }

}

////ROBINSONS PAYROLL

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

else{
    $bdisabled ="";

}

if(isset($_POST['uppayroll'])){
    $uppaysql = "UPDATE `payrollinfo` SET `atm`='$atm',`bank`='$bank',`type`='$type'WHERE empid='$empID'";

    if (mysqli_query($conn, $uppaysql)){
        $alert ="<div class='alert alert-success'>
        <strong style='font-size:12pt;'>Payroll Successfully Update.</strong>
        </div> ";

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

if(isset($_POST['adpayroll'])){
    $paysql = "INSERT INTO `payrollinfo`( `atm`, `bank`, `type`, `empid`) VALUES ('$atm','$bank','$type','$empID')";

    if (mysqli_query($conn, $paysql)){
        $alert ="<div class='alert alert-success'>
        <strong style='font-size:12pt;'>Payroll Successfully Add.</strong>
      </div> ";
    }
    else {
        echo "Error: " . $paysql . "<br>" . mysqli_error($conn);
    }



}

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

  <head>

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

    <title>Add 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>


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

    $(document).ready(function(){
            $("select").change(function(){
                $(this).find("option:selected").each(function(){
                    var optionValue = $(this).attr("value");
                    if(optionValue){
                        $(".box").not("." + optionValue).hide();
                        $("." + optionValue).show();
                    } else{
                        $(".box").hide();
                    }
                });
            }).change();
    });

    function openCity(evt, cityName) {
        var i, tabcontent, tablinks;
        tabcontent = document.getElementsByClassName("tabcontent");
        for (i = 0; i < tabcontent.length; i++) {
            tabcontent[i].style.display = "none";
        }
        tablinks = document.getElementsByClassName("tablinks");
        for (i = 0; i < tablinks.length; i++) {
            tablinks[i].className = tablinks[i].className.replace(" active", "");
        }
        document.getElementById(cityName).style.display = "block";
        evt.currentTarget.className += " active";
    }
    function computeage(){
            var bday = document.getElementById("bday").value;
            var getbday = new Date(bday);
            var today = new Date();
            var age = today.getFullYear() - getbday.getFullYear();
            var  m = today.getMonth() - getbday.getMonth();
            document.getElementById("age").value = age;

    }
        effectdate.min = new Date().toISOString().split("T")[0];
        function tabs(evt, cityName) {
        var i, tabcontent, tablinks;
        tabcontent = document.getElementsByClassName("tabcontent1");
        for (i = 0; i < tabcontent.length; i++) {
            tabcontent[i].style.display = "none";
        }
        tablinks = document.getElementsByClassName("tab1");
        for (i = 0; i < tablinks.length; i++) {
            tablinks[i].className = tablinks[i].className.replace(" active", "");
        }
        document.getElementById(cityName).style.display = "block";
        evt.currentTarget.className += " active";
        }
    
    </script>


  </head>

   <body id="page-top">
	<div id="preloader">
   		<img src="../images/loaderS.gif" alt="processing..." height="150px" width="200px"/>
	</div>

  <div id="pageloader">
   <img src="../images/loaderS.gif" alt="processing..." height="150px" width="200px"/>
</div>

<div id="preloader">
   <img src="../images/loaderS.gif" alt="processing..." height="150px" width="200px"/>
</div>

    <nav class="navbar navbar-expand navbar-dark bg-dark static-top">

      <a class="navbar-brand mr-1" href="index.html">Super Admin</a>

      <button class="btn btn-link btn-sm text-white order-1 order-sm-0" id="sidebarToggle" href="#">
        <i class="fas fa-bars"></i>
      </button>

      <!-- Navbar Search -->
    

      <!-- Navbar -->
      <ul class="navbar-nav ml-auto ml-md-0">
       

    </nav>

    <div id="wrapper">

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

        <div class="container-fluid">

          <!-- Breadcrumbs-->
          <ol class="breadcrumb">
            <li class="breadcrumb-item">
              <a href="#">Dashboard</a>
            </li>
            <li class="breadcrumb-item active">Overview</li>
          </ol>

          <!--DIV CONTAINER-->
            <div class="container">
                <?php echo $error.$alert?>
                <div class="tab">
                    <button class="tablinks " onclick="openCity(event, 'empinfo')" >Personal Information</button>
                    <button class="tablinks" onclick="openCity(event, 'govinfo')">Government Info</button>
                    <button class="tablinks" onclick="openCity(event, 'compb')">Compensation & Benefit</button>
                    <button class="tablinks" onclick="openCity(event, 'preemp')">Pre Employement</button>
                </div>
                <!--- PERSONAL INFORMATION TAB-->
                <div id="empinfo" class="tabcontent">
                    <form method="post" enctype="multipart/form-data"> 
                                <h3>Personal Information</h3>
                                <div class="row justify-content-lg-center"  >
                                    <img id="output_image" style="height: 150px; width: 150px; border-radius:100px;" src="../files/pictures/<?php echo $userpic;?>" alt="hello"/> 
                                </div>
                                <div class="row justify-content-lg-center">
                            
                                    <!--<label class="btn btn-primary btn-sm"> Upload Profile Picture
                                    <input type="file" name="userpic" style="display: none;" onchange="preview_image(event)"  accept="image/*" alt="PROFILE PICTURE" />
                                    </label> -->
                                </div>
                                <div class="row justify-content-lg-center">
                                    <div class="col-sm-3">
                                        <input type="text" id="empid" name="empid" class="form-control" value="<?php echo $empID;?>" readonly/>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-sm-4 form-group required">
                                        <label class="control-label"> Surname </label> <br>
                                        <input type="text" class="form-control" name="sname"  value="<?php echo $surname;?>" placeholder="Surname" required>
                                    </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="toggle()"  required>
                                            <?php 
                                            switch ($civilstat) {
                                                case "Single":
                                                    $single = 'selected';
                                                    break;
                                                case "Widowed":
                                                    $widowed = 'selected';
                                                    break;
                                                case "Divorced":
                                                    $divorced = 'selected';
                                                    break;
                                                case "Married":
                                                    $married = 'selected';
                                                    break;
                                            
                                            }

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

                                    <div id="married" class="Married box" style="width:98%; margin: 0 auto; display:hide;">
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <label class="control-label">Spouse's Name </label> <br>
                                                <input type="text" class="form-control" name="spouse"  placeholder="Spouse Name" value="<?php echo $spouse;?>"  >
                                                </div>
                                                <div class="col-sm-6">
                                                <label class="control-label">Date of Birth</label> <br>
                                                <input type="date" class="form-control" name="spousebday"  placeholder="Birthdate" value="<?php echo $spousebday;?>" >
                                            </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;
                                            
                                            }

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

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

                                        
                                        </select>
                                    </div>

                                    
                                    <div class="col-sm-6 form-group required">
                                        <label class="control-label">Immediate Supervisor</label> <br>
                                        <input type="text" id="hdate" class="form-control" name="supervisor" value="<?php echo $supervisor?>"  placeholder="Supervisor" required >

                                        
                                    </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;" > 
                                        
                                            <a href="employee.php" class="btn btn-danger" role="button" style="margin-right: 5px;">Cancel </a>
                                        </div>
                                    </div>
                                
                                </div>
                    </form>               
                </div>
                <!-- END OF PERSONAL INFORMATION TAB-->

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

                        <form method="post" enctype="multipart/form-data">
                            <h3>Government Information</h3>  
                            <div class="row">
                                <div class="col-sm-6 form-group required">
                                    <label class="control-label">SSS</label> <br>
                                    <input type="text" id="sss" class="form-control" name="sss"  placeholder="SSS" value="<?php echo $getsss?>" required>
                                </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">
                                            
                                        <input type="submit" class="btn btn-success" name="savegov" value="Save" style="margin-right: 5px;" > 
                                    
                                        <a href="employee.php" class="btn btn-danger" role="button" style="margin-right: 5px;">Cancel </a>
                                    </div>
                                </div>
                            
                        
                            </div>
                        </form>
                    </div>

                    <div id="preemp" class="tabcontent" <?php echo $pe?>>
                        <form method="post" enctype="multipart/form-data">  
                            <h3>Pre-Employement</h3>
                        
                                <div class="col-sm-12 form-group required">
                                    <?php echo $error.$alert?>
                                </div>
                                
                                    <div class="col-sm-6 form-group required">
                                        <label class="control-label">Documents</label> <br>
                                            <select name="document" class="form-control" id="document">
                                                <option value="NBI Clearance">NBI Clearance</option>
                                                <option value="NSOPSA Birth Certificate">NSO/PSA Birth Certificate</option>
                                                <option value="Pre Employement Medical Exam">Pre Employement Medical Exam</option>
                                                <option value="BIR 1905 and 2305">BIR 1905 and 2305</option>
                                                <option value="Updated MDR">Updated MDR</option>
                                                <option value="Updated MDF">Updated MDF</option>
                                                <option value="Marriage Certificate">Marriage Certificate</option>
                                                <option value="Children Birth Certificate">Children Birth Certificate</option>
                                                <option value="Account Opening Form">Account Opening Form</option>
                                                <option value="Valid ID">Valid ID</option>
                                                <option value="Certificate of Employement">Certificate of Employement</option>
                                                <option value="ITR">ITR</option>
                                                <option value="TORDIPLOMA">TOR/DIPLOMA</option>
                                            </select>
                                    
                                            
                                                

                                    </div>
                                    <div class="col-sm-6 form-group required">
                                        <input type="file" name="doc" class="form-control" name="file"  required>
                                    </div>
                                    <div class="col-sm-12 form-group required">
                                    <table class="table table-hover">
                                        <thead>
                                            <tr>
                                            
                                  
                                            <th scope="col">Name</th>
                                            <th scope="col">Action</th>
                                        
                                            
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php 
                                            $documentsql = "SELECT * FROM documents WHERE empid = '$empID' AND status !='none'";
                                            $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'].'" class="btn btn-primary"> View </a>   
                                                    </td>
                                                    </tr>';

                                                }
                                            
                                            ?>
                                    
                                        </tbody>
                                    </table>
                                    

                                    </div>

                                    <div class="col-sm-12 form-group required">
                                        <div class="row justify-content-end">
                                                
                                            <input type="submit" class="btn btn-success" name="savedoc" value="Save" style="margin-right: 5px;" > 
                                        
                                            <a href="employee.php" class="btn btn-danger" role="button" style="margin-right: 5px;">Cancel </a>
                                        </div>
                                    </div>


                                
                            
                        </form>
                </div>
           
                            <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:36px; color: #28a745;"></i></td>';
                                                    }
                                                    elseif($row['status']=='N/A'){
                                                        echo '<td><i style="font-size:26px; color: #fc9700; "><strong>N/A</strong></i></td>';
                                                    }
                                                    else{
                                                        echo '<td><i class="fa fa-close" style="color:red; font-size:36px; "></i></td>';
                                                    }
                                                 
                                            
                                                   

                                                }
                                            
                                        ?>
                                        
                                    </tbody>


                                </table>
                            </div>
                        

                <!-- END OF GOVERNMENT INFO TAB-->
                <!-- COMPENSATION & BENEFIT TAB-->
                <link href = "../css/style.css" rel = "stylesheet">
                <div id="compb" class="tabcontent" style="display: block;">
                    <div class="tab">
                        <button class="tab1" onclick="tabs(event, 'current')" >Current</button>
                        <button class="tab1" onclick="tabs(event, 'history')">History</button>
                    </div>
                    <div id="current" class="tabcontent1" style="display: none; border: 1px solid #ccc; padding: 30px; 30px;">
                        
                        <div class="row">
                            <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?>>Add+ </button> &nbsp
                                            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#updatepaymodal" <?php echo $updisabled?>>Update </button> &nbsp
                                            <input type="reset" value="Cancel" class="btn btn-danger">
                                        </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">No</button>
                                            
                                        </div>
                                        </div>
                                    </div>
                                    </div>
                                    <!---Add Payroll Information -->
                                    <div class="modal fade" id="addpaymodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                    <div class="modal-dialog modal-dialog-centered" role="document">
                                        <div class="modal-content">
                                        <div class="modal-header">
                                            <h5 class="modal-title" id="exampleModalLabel">Add Payroll Information</h5>
                                            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true">×</span>
                                            </button>
                                        </div>
                                        <div class="modal-body">Are you sure you want to add Payroll Information of <?php echo $firstname.' '.$surname?> ?</div>
                                        <div class="modal-footer">
                                            <input type="submit" class="btn btn-success" value="Yes" name="adpayroll" style="margin-right: 5px;" > 
                                            <button class="btn btn-danger" type= "button" data-dismiss="modal">No</button>
                                            
                                        </div>
                                        </div>
                                    </div>
                                    </div>
                                <!--- PAYROLL INFORMATION MODAL -->   
                            </form>
                        </div>
                        <div class="col-sm-12 form-group required">
                            <?php 
                                $salaryempsql ="SELECT * FROM salaryemp WHERE empid='$empID' AND effectivitydate <= CURDATE() ORDER BY effectivitydate DESC LIMIT 1";
                                $salaryempres = mysqli_query($conn,$salaryempsql);
                                $salaryemprow = mysqli_fetch_assoc($salaryempres);
                                $cursalarycode = $salaryemprow['salarycode'];
                                $ceffectivitydate = $salaryemprow['effectivitydate'];


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

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

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

                                            

                                        if (mysqli_num_rows($amountresult) > 0) {
                                        
                                            while($amountrow = mysqli_fetch_assoc($amountresult)) {
                                                echo'<td>'.$amountrow['amount'].'</td> ';
                                                    $total += $amountrow['amount'];

                                            }
                                        } 
                                            echo '<td>'.$total.'</td>';
                                    
                                    ?>
                                    
                                    </tr>
                                
                                </tbody>
                            </table>

                        </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)) {
                                                    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?>" name="tin">
                                    </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'])){
                                                        

                                                        $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>
                                                                ';
                                                                $total1 += $row['amount'];

                                                            }
                                                        } 
                                                        echo '<td>'.$total1.'</td>';
                                                    ?>
                                                </tbody>
                                            </table>
        
                                    </div>
                                    <div class="col-sm-12 form-group required">
                                        <div class="row justify-content-end">
                                            <input type="submit" class="btn btn-primary" value="View" name="viewcomp" style="margin-right: 5px;" > 
                                            <button type="button" class="btn btn-success" data-toggle="modal" onclick="view()" data-target="#compensationbenefit">Add+ </button> &nbsp
                                            <a href="employee.php" class="btn btn-danger" role="button" style="margin-right: 5px;">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">No</button>
                                        
                                    </div>
                                    </div>
                                </div>
                                </div>
                                <!-- CONFIRM MODAL END -->
                            </form>

                    </div>
                                                        
                   <!--- END CURRENT TAB -->
                   <!-- HISTORY TAB -->
                   <div id="history" class="tabcontent1" style="display: block; border: 1px solid #ccc; " >
                        <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'].'">  */
                                                        

                                                        
                                                                echo'
                                                                
                                                                <tr>
                                                                <td>'.$row['salarycode'].'</td>
                                                                <td>'.$row['effectivitydate'].'</td>
                                                                <td> <a class="btn btn-primary" href="updateemp1.php?ID='.$empID.'&salarycode='.$row['salarycode'].'">  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>
                                                    
                                                
                                                    ';
                            
                                                }
                                    } 
                                    mysqli_close($conn);
                                    ?>
                                    </tbody>
                                </table>
                            </div>
                           
                        </div>                         
                    </div>

                    

                

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

            </div>

        <script>
            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>
