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

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

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

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

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

$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'];
$inactivedate = $row['inactivedate'];

//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'];
	
	
?>
<!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">


  </head>

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

    <?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 active">
         User Profile
            </li>
            
          </ol>

            <ul class="nav nav-tabs card-header-tabs" id="myTab" role="tablist">
            <li class="nav-item">
                <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true"><i class="fas fa-user"> </i> Personal Information</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false"><i class="fas fa-landmark"> </i>  Government Information</a>
            </li>


            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-money-bill-wave"> </i>  Compensation & Benefits </a>
                <div class="dropdown-menu" style="width: 100%;">
                <h6 class="dropdown-header">Compensation</h6>

                <a class="dropdown-item" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false" >Current</a>
                <a class="dropdown-item" id="history-tab" data-toggle="tab" href="#history" role="tab" aria-controls="history" aria-selected="false" >History</a>
    
                <div class="dropdown-divider"></div>
                <h6 class="dropdown-header">Benefits</h6>
                <a class="dropdown-item" id="benefits-tab" data-toggle="tab" href="#benefits" role="tab" aria-controls="benefits" aria-selected="false" >Benefits</a>
                </div>
            </li>



            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="tab" aria-controls="preemp" aria-selected="false"><i class="fas fa-file-image"> </i> Pre Employement</a>
                <div class="dropdown-menu" style="width: 100%;">
    
                <a class="dropdown-item" id="preemp-tab" data-toggle="tab" href="#preemp" role="tab" aria-controls="preemp" aria-selected="false" >Upload</a>
                <a class="dropdown-item" id="checklist-tab" data-toggle="tab" href="#checklist" role="tab" aria-controls="checklist" aria-selected="false" >Checklist</a>
    
              
                </div>
            </li>

            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="tab" aria-controls="preemp" aria-selected="false"><i class="fas fa-user-cog"> </i> Tools </a>
                <div class="dropdown-menu" style="width: 100%;">
    
                <a class="dropdown-item" id="indi-tab" data-toggle="tab" href="#indi" role="tab" aria-controls="indi" aria-selected="false" > Individual</a>
                <a class="dropdown-item" id="shared-tab" data-toggle="tab" href="#shared" role="tab" aria-controls="shared" aria-selected="false" > Shared</a>
    
              
                </div>
            </li>



            </ul>
            <div class="tab-content" id="myTabContent">
            <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
                <div class= "p-5 col-12-sm col-12-md col-12-lg">
                    <h5> Personal information </h5>
                    <form method="post" enctype="multipart/form-data"> 
                   
                        <div class="row justify-content-lg-center"  >
                            <img id="output_image" style="height: 150px; width: 150px; border-radius:100px;" src="../files/pictures/<?php echo $userpic;?>" alt="hello"/> 
                        </div>

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

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

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

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

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

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

                            <?php 
                            if($civilstat == 'Single'){

                                $civibox = 'width: 98%; margin:0 auto; display: none;';
                            }else{
                                $civibox = 'width: 98%; margin:0 auto; display: block;';
                            }
                            ?>

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

                        

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

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

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

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

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

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

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

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

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

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

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

                            </div>

                            

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


            </div>

            <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
                <div class= "p-5 col-12-sm col-12-md col-12-lg">
                    <form method="post" enctype="multipart/form-data" >
                        <h5>Government Information</h5>  
                        <div class="row">
                            <div class="col-sm-12 form-group required" >
            
                        
            
                            </div>
                            <div class="col-sm-6 form-group required">
                                <label class="control-label">SSS</label> <br>
                                <input type="text" id="sss" class="form-control" name="sss"  placeholder="SSS" value="<?php echo $getsss?>" required readonly>
                            </div>
                            <div class="col-sm-6 form-group required">
                                <label class="control-label">TIN</label> <br>
                                <input type="text" id="tin" class="form-control" name="tin"  placeholder="TIN" value="<?php echo $gettin?>" readonly>
                            </div>
                            <div class="col-sm-6 form-group required">
                                <label class="control-label">Philhealth</label> <br>
                                <input type="text" id="philhealth" class="form-control" name="philhealth"  placeholder="Philhealth" value="<?php echo $getphilhealth?>"required readonly>
                            </div>
                            <div class="col-sm-6 form-group required">
                                <label class="control-label">Pag-ibig</label> <br>
                                <input type="text" id="pagibig" class="form-control" name="pagibig"  placeholder="Pag-ibig" value="<?php echo $getpagibig?>" required readonly>
                            </div>

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

            <div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
                <div class= "p-5 col-12-sm col-12-md col-12-lg">
                                        <?php 
                                            $salaryempsql ="SELECT * FROM salaryemp WHERE empid='$empID' AND effectivitydate <= CURDATE() ORDER BY effectivitydate DESC LIMIT 1";
                                            $salaryempres = mysqli_query($conn,$salaryempsql);
                                            $salaryemprow = mysqli_fetch_assoc($salaryempres);
                                            $cursalarycode = $salaryemprow['salarycode'];
                                            $ceffectivitydate = $salaryemprow['effectivitydate'];


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

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

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

                                                        

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

                                                            $total += $amounts;

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

                    
                </div>
            </div>

            <div class="tab-pane fade" id="history" role="tabpanel" aria-labelledby="history-tab">
                <div class= "p-5 col-12-sm col-12-md col-12-lg">
                    <div class="row">
                  
                        <div class="col-sm-6 form-group required"> <br>
                            <h5>History</h5>
                                <table class="table table-hover">
                                    <thead class="thead-dark">
                                        <tr>
                                                
                                    
                                            <th scope="col">Salary Code</th>
                                            <th scope="col">Effectivity Date</th>
                                            <th scope="col">Action</th>
                                            
                                                
                                        </tr>
                                    </thead>
                                    <tbody>
                                    
                                        <?php 
                                                    
                                            $compsql = "SELECT * FROM `salaryemp` WHERE empid='$empID'";
                                            $compresult = mysqli_query($conn, $compsql);
                                            if (mysqli_num_rows($compresult) > 0) {
                                                while($row = mysqli_fetch_assoc($compresult)) {
                                                    /*<form action="updateemp1.php?ID='.$empID.'&salarycode='.$row['salarycode'].'">  */
                                                    

                                                    $histyle ="style='display:block;'";
                                                    $cr ="style='display:none;'";
                                                            echo'
                                                            
                                                            <tr>
                                                            <td>'.$row['salarycode'].'</td>
                                                            <td>'.$row['effectivitydate'].'</td>
                                                            <td> <a class="btn btn-primary" href="viewprofile1.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>
                            <h5>Details</h5>
                            <table class="table table-hover">
                                <thead class="thead-dark">
                                <tr>
                                    <th>Items</th>
                                    <th> Amount </th>
                                </tr>
                                </thead>
                                <tbody>

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

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

                    </div>
             
                </div>

            </div>

            <div class="tab-pane fade" id="benefits" role="tabpanel" aria-labelledby="benefits-tab">
                <div class= "p-5 col-12-sm col-12-md col-12-lg">
                    <h5>Benefits</h5>

                        <table class="table table-bordered">
                        <thead class="thead-dark">
                        <tr>
                        <th>Leave</th>
                        <th>Earned </th>
                        <th>Used </th>
                        <th>Available</th>
                        </tr>
                        </thead>
                        <tbody>

                        <?php 
                        $sqlbenefit = "SELECT * FROM pto WHERE empid='$empID'";
                        $benefitres = mysqli_query($conn, $sqlbenefit);
                        while($benefitrow = mysqli_fetch_assoc($benefitres)){
                            echo '<tr>';
                            echo'<td>'.$benefitrow['name'].'</td>';
                            echo'<td>'.$benefitrow['ptoearned'].'</td>';
                            echo'<td>'.$benefitrow['usedpto'].'</td>';
                            echo'<td>'.$benefitrow['availablepto'].'</td>';
                            echo'</tr>';

                        }
                        ?>

                        </tbody>
                        </table>



                </div>

                                    

            </div>

            <div class="tab-pane fade" id="preemp" role="tabpanel" aria-labelledby="preemp-tab">
                <div class= "p-5 col-12-sm col-12-md col-12-lg">
                    <h5>Upload</h5>
                    <table class="table table-hover">
                        <thead class="thead-dark">
                            <tr>
                            
                
                            <th scope="col">Name</th>
                            <th scope="col">Action</th>
                        
                            
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
                            $documentsql = "SELECT * FROM documents WHERE empid = '$empID' AND status='check'";
                            $result = mysqli_query($conn, $documentsql);
                        
                                while($row = mysqli_fetch_assoc($result)) {
                                    
                                    echo'
                                    <tr>
                            
                                    <td>'.$row['name'].'</td>
                                    <td> <a href="viewdoc.php?docid='.$row['document'].'" target="_blank" class="btn btn-primary"> <i class="fa fa-eye"></i> View </a>   
                                    </td>
                    
                                    </tr>
                                
                                    ';

                                }
                            
                            ?>
                    
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="tab-pane fade" id="checklist" role="tabpanel" aria-labelledby="checklist-tab">

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

                                    }
                                
                            ?>
                            
                        </tbody>


                        </table>
                </div>
                


            </div>
            <div class="tab-pane fade" id="indi" role="tabpanel" aria-labelledby="indi-tab">
                <div class= "p-5 col-12-sm col-12-md col-12-lg">

                    <h5>Individual</h5>
              
                                
                        <table class="table table-hover"> 
                        <thead class="thead-dark">

                        <th> Name </th>
                        <th> Description </th>
                        <th> Username </th>
                        <th> Password </th>

                        

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

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

                    

                        
                        
                        ?>

                        </tbody>
                        </table>
                </div>

               

            </div>

            <div class="tab-pane fade" id="shared" role="tabpanel" aria-labelledby="shared-tab">
                <div class= "p-5 col-12-sm col-12-md col-12-lg">
                    <h5>Shared</h5>
                    <table class="table table-hover"> 
                                        <thead class="thead-dark">
                                    
                                        <th> Name </th>
                                        <th> Description </th>
                                        <th> Username </th>
                                        <th> Password </th>

                                        

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

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

                                        
                                        
                                        ?>

                                        </tbody>
                                        </table>


                </div>

            </div>
            
            </div>


            




               
         

      
        <!-- /.container-fluid -->

        <!-- Sticky Footer -->
    

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

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

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

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

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

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

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

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

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

   

                <script>
                    $('#myTab a').click(function(e) {
                      e.preventDefault();
                      $(this).tab('show');
                    });
                    
                    // store the currently selected tab in the hash value
                    $("ul.nav-tabs > li > a").on("shown.bs.tab", function(e) {
                      var id = $(e.target).attr("href").substr(1);
                      window.location.hash = id;
                    });
                    
                    // on load of the page: switch to the currently selected tab
                    var hash = window.location.hash;
                    $('#myTab a[href="' + hash + '"]').tab('show');
                </script>



    
 


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

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



        </script>
</body>

</html>
