<?php
include("../include/session.php");
if(!$session->isAdmin() && !$session->isRadstoneReceptionUser()){
		header("Location: ../Store/productionMenu.php");
}else{
//include("../include/db.php");
	include("../reportHeader.php");
$dDay = date("d");
$dMonth = date("m");
$dYear = date("y");

	$queryLate = "SELECT * FROM timekeeping WHERE day = '".$dDay."' AND month = '".$dMonth."' AND year ='".$dYear."' ORDER BY date DESC";
	$resultLate = execsql($queryLate);
	$numLate = mysql_num_rows($resultLate);

	$q = "SELECT empId, empFName, empLName FROM employees";
	$resultEmp = execsql($q);
	$numEmp = mysql_num_rows($resultEmp);
	$j = 0;
	$empArray = array();
	while($j < $numEmp){
		$empArray[mysql_result($resultEmp, $j, "empId")] = mysql_result($resultEmp, $j, "empFName") ." ". mysql_result($resultEmp, $j, "empLName");
		$j++;
	}

?>


<script type="text/javascript" src="images/tablesort.js"></script>
      <h3>Employees late today</h3>

<table id="test1" cellpadding="0" cellspacing="0" border="0" class="rowstyle-alt colstyle-alt no-arrow">
    <thead>
      <tr>
        <th class="sortable-text">Employee Name</th>
        <th class="sortable-text">Permission</th>
        <th class="sortable-text">Details</th>
        <th class="sortable-numeric">Hours</th>
        <th class="sortable-date-ymd">Date</th>
        <th>Delete?</th>
      </tr>
    </thead>
    <tbody>
<?php
    $i = 0;
    while($i < $numLate){

       $b1 = mysql_result($resultLate, $i, "empId");
       $b2 = mysql_result($resultLate, $i, "permission");
       if($b2 < 1){
           $permission = "No";
       }else {
           $permission = "Yes";
       }
       $b3 = mysql_result($resultLate, $i, "details");
       $b4 = mysql_result($resultLate, $i, "hours");
       $b5 = mysql_result($resultLate, $i, "date");
       $b6 = mysql_result($resultLate, $i, "timeId");
      // echo "<tr><td class="sortable-numeric">$b1</td><td>$b2</td><td>$permission</td><td>$b4</td><td>$b5</td><td>$b6</td></tr>";
      // $i++;
   // }
?>
		<tr class="alt">
        <td><a href="../HR/searchAndDisplayE.php?id=<?=$b1?>"><?php echo $empArray[$b1] ?></a></td>
        <td><?=$permission?></td>
        <td><?=$b3?></td>
        <td><?=$b4?></td>
        <td><?=$b5?></td>
        <td><a href="deleteLate.php?id=<?=$b6?>">Delete</a></td>
        </tr> 
<?php
    $i++;
    }
?>
</tbody>
</table>

<?php
    include "../footer.html";
}
?>
