<?php
include("../include/session.php");
if(!$session->isAdmin() && !$session->isRadstoneReceptionUser()){
		header("Location: ../Store/productionMenu.php");
}
else {
	include("../reportHeader.php");
//	include("../include/db.php");
	$start = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : "";

	$end = isset($_REQUEST["date2"]) ? $_REQUEST["date2"] : "";

	//		$start = mysql_real_escape_string($_POST['startDate']);
	//		$end = mysql_real_escape_string($_POST['endDate']);
	$q = "SELECT * FROM overtime WHERE date > '$start' AND date < '$end'";
	$result = execsql($q);
	$num = mysql_num_rows($result);
	$i = 0;
	$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="../include/tablesort.js"></script>
<h3>Showing who did overtime between the dates <?php echo "$start and $end"?></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-numeric">Hours</th>
			<th class="sortable-numeric">Bonus</th>
			<th class="sortable-date-ymd">Details</th>
			<th class="sortable-text">Date</th>
			<th>Delete</th>
		</tr>
	</thead>
	<tbody>
	<?php
	while($i < $num){
		$f1=mysql_result($result,$i, "timeId");
		$f2=mysql_result($result,$i,"empId");
		$f3=mysql_result($result,$i,"hours");
		$f4=mysql_result($result,$i,"bonus");
		$f5=mysql_result($result,$i,"details");
		$f6=mysql_result($result, $i, "date");

		?>



		<tr>
			<td><a href="../HR/searchAndDisplayE.php?id=<?=$f2?>"><?=$empArray[$f2]?></a></td>
			<td><?=$f3?></td>
			<td><?=$f4?></td>
			<td><?=$f5?></td>
			<td><?=$f6?></td>
			<td><a href="manipulate/deleteOvertime.php?id=<?=$f1?>">Delete?</a></td>

		</tr>
		<?php
		$i++;
	}
	?>
	</tbody>
</table>
	<?php
	include("../footer.html");
}
?>