

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel='stylesheet prefetch' href='https://use.fontawesome.com/releases/v5.0.10/css/all.css'>
    <link rel="stylesheet" type="text/css" media="screen" href="main.css" />
</head>

<body>

    <div class="logo">
        <img src="logo-banner.png" alt="" srcset="">
    </div>

    <div class="tabs">
        <div class="tabs-nav">
            <ul>
                <li class="is-active">Overtime</li>
                <li>OB</li>
                <li>Leave</li>
            </ul>
        </div>

        
        <div class="tabs-content">
            <div class="is-active">
                <!-- Set of nested tabs -->
                <div class="tabs">  
                    <div class="tabs-nav">
                        <ul>
                            <li class="is-active">Apply for Overtime</li>
                            <li>My Overtime</li>
                        </ul>
                    </div>
                    <div class="tabs-content">
                        <div class="tabs-form is-active">

                            <form action="OTAction.php" method="post">
                                <div class="form-control">
                                <ul class="wrapper">
                                    <h3>Date</h3>
                                    <li class="form-row">
                                        
                                        <input type="date" id="date_from" name="date_from"  required>
                                    </li>
                                </ul>

                                <ul class="wrapper">
                                    <h3>Time (From - To)</h3>
                                    <li class="form-row">
                                        <label for="">From</label>
                                        <input type="time" name="time_in" id="  " >
                                    </li>

                                    <li class="form-row">
                                        <label for="">To</label>
                                        <input type="time" name="time_out" id="time_out">
                                    </li>
                                </ul>

                                <ul class="wrapper">
                                    <h3>Total Hours</h3>
                                    <li class="form-row">
                                    
                                        <input type="number" name="total_hours">
                                    </li>
                                </ul>

                                <ul class="wrapper">
                                    <h3>Purpose</h3>
                                    <li class="form-row">
                                    
                                        <textarea name="ot_comment" id="ot_comment" cols="35" rows="3"></textarea>
                                    </li>
                                </ul>

                                </div>
                                
                                    <input type="submit" value="Apply" class="btn">
                                
                            </form>


                        </div>
                        <div>
                            <table class="table hover" id="resultTable">

                                <thead>
                                    <tr>
                                        <th>Id</th>
                                        <th rowspan="1" style="width:24%"><span class="headerCell">UserId</span></th>
                                        <th rowspan="1" style="width:18%"><span class="headerCell">Date</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">Time in</span></th>
                                        <th rowspan="1" style="width:9%"><span class="headerCell">Time out</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">Total Hours</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">Purpose</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">Status</span></th>
                                 

                                    </tr>
                                </thead>

                                <tbody>
                                    <tr>
                                        <td colspan="8"></td>
                                    </tr>


                                    <?php
include 'DBConnection.php';


$sql       = 'select * from ot';
$results   = mysqli_query($connection, $sql);
$row_count = mysqli_num_rows($results);
$id = 0;

while ($row = mysqli_fetch_array($results)) {
    echo '<tr><td><a href="OTApprove.php?id='.$row['Id'].'">'.$row['Id'].'</a></td>';
    echo '<td>'.$row['userid'].'</td>';
    echo '<td>'.$row['date_from'].'</td>';
    echo '<td>'.$row['time_in'].'</td>';
     echo '<td>'.$row['time_out'].'</td>';
    echo '<td>'.$row['total_hours'].'</td>';
    echo '<td>'.$row['ot_comment'].'</td>';
    echo '<td>'.$row['Status'].'</td>';
}
?>

                                    
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <!-- End nested tabs -->
            </div>

            <div>
                 <div class="tabs">
                    <div class="tabs-nav">
                        <ul>
                            <li class="is-active">Apply for OB</li>
                            <li>My OB</li>
                        </ul>
                    </div>
                    <div class="tabs-content">
                        <div class="is-active">
                            <form action="OBAction.php" method="post">
                                <table border="1" cellpadding="10px" style="width:100%;">
                                    <tbody>
                                    <tr>
                                        <td style=" background-color: rgb(199, 199, 199);" colspan="2"><strong>ITINERARY</strong></td>
                                        <td style=" background-color: rgb(199, 199, 199);" colspan="2" rowspan="2"><strong>PURPOSE(S)</strong></td>
                                        <td style=" background-color: rgb(199, 199, 199);" colspan="2"><strong>TIME OF</strong></td>
                                    </tr>
                                    <tr>
                                        <td style="background-color: rgb(199, 199, 199);"><strong>FROM</strong></td>
                                        <td style="background-color: rgb(199, 199, 199);"><strong>TO</strong></td>
                                        <td style="background-color: rgb(199, 199, 199);"><strong>DEPARTURE</strong></td>
                                        <td style="background-color: rgb(199, 199, 199);"><strong>RETURN</strong></td>
                                    </tr>
                                    <tr> 
                                        <td style=""><input type="text" name ="from_dept"></td>
                                        <td style=""><input type="text" name ="to_dept"></td>
                                        <td style="" colspan="2"><input type="text" name="purpose"></td>
                                        <td style=""> <input type="datetime-local" name="from_time" id=""></td>
                                        <td style=""> <input type="datetime-local" name="to_time" id=""></td>
                                    </tr>
                                    </tbody>
                                </table>

                                <input  type = "submit" name="submit" value="Apply" class="btn">
                            </form>
                        </div>
                        <div>
                            <table class="table hover" id="resultTable">

                                <thead>
                                    <tr>
                                       <center><H1> PENDING REQUESTS </H1></center>  
                                        <th rowspan="1" style="width:24%"><span class="headerCell">OB Form Id</span></th> 
                                        <th rowspan="1" style="width:18%"><span class="headerCell">Employee ID</span></th>
                                        <th rowspan="1" style="width:10%"><span class="headerCell">Depart From</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">Arrive To</span></th>
                                        <th rowspan="1" style="width:9%"><span class="headerCell">Purpose</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">Time From</span></th>
                                        <th rowspan="1" style="width:17%"><span class="headerCell">Time To</span></th>
                                        <th rowspan="1" style="width:10%"><span class="headerCell">Status</span></th>
                                    </tr>
                                </thead>
                                  

                                <tbody>

                                    <tr>
                                        <td colspan="8"></td>


                                    <?php
include 'DBConnection.php';


$sql       = 'select * from obform where status = "pending"';
$results   = mysqli_query($connection, $sql);
$row_count = mysqli_num_rows($results);
$id = 0;

while ($row = mysqli_fetch_array($results)) {
    echo '<tr><td><a href="OBApprove.php?id='.$row['obid'].'">'.$row['obid'].'</a></td>';
    echo '<td>'.$row['emp_id'].'</td>';
    echo '<td>'.$row['dept_from'].'</td>';
    echo '<td>'.$row['dept_to'].'</td>';
    echo '<td>'.$row['purpose'].'</td>';
    echo '<td>'.$row['dept_time'].'</td>';
    echo '<td>'.$row['return_time'].'</td>';
    echo '<td>'.$row['Status'].'</td></tr>';
}
?>
                                    </tr>
                                </tbody>
                            </table>

                                  <table class="table hover" id="resultTable">

                                <thead>
                                    <tr>
                                      <center><H1> COMPLETED REQUESTS </H1></center>  
                                        <th rowspan="1" style="width:24%"><span class="headerCell">OB Form Id</span></th> 
                                        <th rowspan="1" style="width:18%"><span class="headerCell">Employee ID</span></th>
                                        <th rowspan="1" style="width:10%"><span class="headerCell">Depart From</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">Arrive To</span></th>
                                        <th rowspan="1" style="width:9%"><span class="headerCell">Purpose</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">Time From</span></th>
                                        <th rowspan="1" style="width:17%"><span class="headerCell">Time To</span></th>
                                        <th rowspan="1" style="width:10%"><span class="headerCell">Status</span></th>
                                    </tr>
                                </thead>
                                  

                                <tbody>

                                    <tr>
                                        <td colspan="8"></td>
                                    </tr>

                                                                        <?php
include 'DBConnection.php';


$sql       = 'select * from obform where status ="1" or status="0   "';
$results   = mysqli_query($connection, $sql);
$row_count = mysqli_num_rows($results);
$id = 0;

while ($row = mysqli_fetch_array($results)) {
    echo '<tr><td>'.$row['obid'].'</a></td>';
    echo '<td>'.$row['emp_id'].'</td>';
    echo '<td>'.$row['dept_from'].'</td>';
    echo '<td>'.$row['dept_to'].'</td>';
    echo '<td>'.$row['purpose'].'</td>';
    echo '<td>'.$row['dept_time'].'</td>';
    echo '<td>'.$row['return_time'].'</td>';
    echo '<td>'.$row['Status'].'</td></tr>';
}
?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
               
            </div> <!--closing tab -->






<!--- LEAVE TAB ---->
<div>
                 <div class="tabs">
                    <div class="tabs-nav">
                        <ul>
                            <li class="is-active">Apply Leave</li>
                            <li>My Leave</li>
                        </ul>
                    </div>
                    <div class="tabs-content">
                        <div class="is-active">
                            <form action="LeaveAction.php" method="post">
                                <div class="form-control">
                                <ul class="wrapper">
                                            <h3>Leave Type</h3>
                                            <li class="form-row1">
                                            <input type="radio" name="purpose" value="undertime" id=""> Undertime 
                                            </li>
                                            <li class="form-row1">
                                            <input type="radio" name="purpose" value="halftime" id=""> Half-Day 
                                            </li>
                                            <li class="form-row1">
                                            <input type="radio" name="purpose" value="lwp" id=""> Leave w/ Pay
                                            </li>
                                            <li class="form-row1">
                                            <input type="radio" name="purpose" value="lwop" id=""> Leave w/out Pay
                                            </li>
                                            
                                </ul>
                                    
                                    <ul class="wrapper">
                                            <h3>Reason</h3>
                                            <li class="form-row">
                                                <input type="text" id="reason" name="reason"  required>
                                            </li>
                                        </ul>

                                        <ul class="wrapper">
                                            <h3>Date & Time (From - To)</h3>
                                            <li class="form-row">
                                                <label for="">From</label>
                                                <input type="datetime-local" name="date_from" id="date_from" required>
                                            </li>

                                            <li class="form-row">
                                                <label for="">To</label>
                                                <input type="datetime-local" name="date_to" id="date_to" required>
                                            </li>
                                        </ul>

                                        <ul class="wrapper">
                                            <h3>For HR Department Only</h3>
                                            <li class="form-row">
                                                <label for="">Leave Credit Balance-To Date</label>
                                                <input type="text" name="leave_credit">
                                                </li>
                                                <li class="form-row">
                                                <label for="">Less This Application</label>
                                                <input type="text" name="less_application">
                                                </li>
                                                <li class="form-row">
                                                <label for="">Balance</label>
                                                <input type="text" name="leave_balance">
                                                </li>
                                        </ul>
                                </div>
                                

                                    <input type="submit" name="submit" value="Apply" id="button-3" class="btn">
                                </form>
                        </div>
                        <div>
                            <table class="table hover" id="resultTable">

                                <thead>
                                    <tr>
                                       <center><H1> PENDING REQUESTS </H1></center>  
                                        <th rowspan="1" style="width:24%"><span class="headerCell">Leave Id</span></th> 
                                        <th rowspan="1" style="width:18%"><span class="headerCell">Employee ID</span></th>
                                        <th rowspan="1" style="width:10%"><span class="headerCell">Purpose</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">Reason</span></th>
                                        <th rowspan="1" style="width:9%"><span class="headerCell">From Date</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">To Date</span></th>
                                        <th rowspan="1" style="width:17%"><span class="headerCell">Duration</span></th>
                                        <th rowspan="1" style="width:17%"><span class="headerCell">Leave Credit Balance</span></th>
                                        <th rowspan="1" style="width:17%"><span class="headerCell">Leave Balance</span></th>
                                        <th rowspan="1" style="width:10%"><span class="headerCell">Status</span></th>
                                    </tr>
                                </thead>
                                  

                                <tbody>

                                    <tr>
                                        <td colspan="8"></td>






                          <?php
include 'DBConnection.php';


$sql       = 'select * from leaveform where status = "pending"';
$results   = mysqli_query($connection, $sql);
$row_count = mysqli_num_rows($results);
$id = 0;

while ($row = mysqli_fetch_array($results)) {
    echo '<tr><td><a href="LeaveApprove.php?id='.$row['leaveid'].'">'.$row['leaveid'].'</a></td>';
    echo '<td>'.$row['emp_id'].'</td>';
    echo '<td>'.$row['purpose'].'</td>';
    echo '<td>'.$row['reason'].'</td>';
    echo '<td>'.$row['from_date'].'</td>';
    echo '<td>'.$row['to_date'].'</td>';
    echo '<td>'.$row['duration'].'</td>';
    echo '<td>'.$row['leave_credit_balance'].'</td>';
      echo '<td>'.$row['leave_balance'].'</td>';
        echo '<td>'.$row['Status'].'</td></tr>';
}
?>
                                    </tr>
                                </tbody>
                            </table>
<center>
                                  <table class="table hover" id="resultTable">
                        
                                <thead>
                                    <tr>
                                      <center><H1> COMPLETED REQUESTS </H1></center>  
                                        <th rowspan="1" style="width:24%"><span class="headerCell">Leave Id</span></th> 
                                        <th rowspan="1" style="width:18%"><span class="headerCell">Employee ID</span></th>
                                        <th rowspan="1" style="width:10%"><span class="headerCell">Purpose</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">Reason</span></th>
                                        <th rowspan="1" style="width:9%"><span class="headerCell">From Date</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">To Date</span></th>
                                        <th rowspan="1" style="width:17%"><span class="headerCell">Duration</span></th>
                                        <th rowspan="1" style="width:17%"><span class="headerCell">Leave Credit Balance</span></th>
                                        <th rowspan="1" style="width:17%"><span class="headerCell">Leave Balance</span></th>
                                        <th rowspan="1" style="width:10%"><span class="headerCell">Status</span></th>
                                    </tr>
                                </thead>
                                  

                                <tbody>

                                    <tr>
                                        <td colspan="8"></td>
                                    </tr>

                                                                        <?php
include 'DBConnection.php';


$sql       = 'select * from leaveform where status = "1" or status = "0"';
$results   = mysqli_query($connection, $sql);
$row_count = mysqli_num_rows($results);
$id = 0;

while ($row = mysqli_fetch_array($results)) {
    echo '<tr><td>'.$row['leaveid'].'</a></td>';
   echo '<td>'.$row['emp_id'].'</td>';
    echo '<td>'.$row['purpose'].'</td>';
    echo '<td>'.$row['reason'].'</td>';
    echo '<td>'.$row['from_date'].'</td>';
    echo '<td>'.$row['to_date'].'</td>';
    echo '<td>'.$row['duration'].'</td>';
    echo '<td>'.$row['leave_credit_balance'].'</td>';
      echo '<td>'.$row['leave_balance'].'</td>';
        echo '<td>'.$row['Status'].'</td></tr>';
}

?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
               
            </div> <!--closing tab -->

        </div>
    </div>

<center>

<form method="POST">
                                  <table class="table hover" id="resultTable">
                                      <center><H1> ATTENDANCE RECORD </H1></center> 
 <label for="">Enter User ID: </label>
  <input type="text" name="attendance_id">
    <input type="submit" name="submit" value="Apply" id="button-3" class="btn">
  <h1></h1>
                                <thead>
                                    <tr>
                                    <!--Header Sorting-->
                                        <th rowspan="1" style="width:24%"><span class="headerCell">Id</span></th> 
                                        <th rowspan="1" style="width:18%"><span class="headerCell">User Id</span></th>
                                        <th rowspan="1" style="width:10%"><span class="headerCell">Attendance In</span></th>
                                        <th rowspan="1" style="width:12%"><span class="headerCell">Attendance Out</span></th>
                                        <th rowspan="1" style="width:9%"><span class="headerCell">Hours</span></th>
                                    
                                </thead>
                                  

                                <tbody>

                                    <tr>
                                        <td colspan="8"></td>
                                    </tr>
</center>
</form>

                                                                        <?php
include 'DBConnection2.php';


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

    $id =$_POST["attendance_id"];
    $hours = 0;

  
if (empty($_POST['attendance_id'])){

    $sql       = 'select * from attendanceformatted';
    $sql1       = 'select emp_lastname from hs_hr_employee where emp_number = $id';


$results   = mysqli_query($connection, $sql);
$row_count = mysqli_num_rows($results);


 
while ($row = mysqli_fetch_array($results)) {
    echo '<tr><td>'.$row['Id'].'</a></td>';
   echo '<td>'.$row['userid'].'</td>';
    echo '<td>'.$row['att_in'].'</td>';
   if($row['att_out'] == "0001-01-01 00:00:00"){
        echo '<td>'."No punch Out Available".'</td>';
   }
   else {
      echo '<td>'.$row['att_out'].'</td>';
   }

   if($row['att_out'] == "0001-01-01 00:00:00"){
       $hourss = 0;
   } else {
      $dateDiff = intval((strtotime($row['att_in'])-strtotime($row['att_out']))/60);

$hours = intval($dateDiff/60);
$hourss = abs($hours);

   }

 
     echo '<td>'.$hourss.'</td>';
}
} else if (!empty($_POST['attendance_id'])){

    $sql       = "select * from attendanceformatted where userid='$id'";
$results   = mysqli_query($connection, $sql);
$row_count = mysqli_num_rows($results);
$id = 0;

while ($row = mysqli_fetch_array($results)) {
    echo '<tr><td>'.$row['Id'].'</a></td>';
   echo '<td>'.$row['userid'].'</td>';
    echo '<td>'.$row['att_in'].'</td>';
   if($row['att_out'] == "0001-01-01 00:00:00"){
        echo '<td>'."No punch Out Available".'</td>';
   }else {
      echo '<td>'.$row['att_out'].'</td>';
   }

      if($row['att_out'] == "0001-01-01 00:00:00"){
       $hourss = 0;
   } else {
      $dateDiff = intval((strtotime($row['att_in'])-strtotime($row['att_out']))/60);

$hours = intval($dateDiff/60);
$hourss = abs($hours);

   }

   
    echo '<td>'.$hourss.'</td>';
 
}

$sql = "UPDATE attendanceformatted SET `hours` = '$hourss' where Id = '$id'";
     mysqli_query($connection, $sql);


}



}






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


    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="main.js"></script>
</body>

</html>