<?php
include("../include/session.php");
if(!$session->isAdmin()) {
	header("Location: ../main.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 nam_minorviolations WHERE vioDate > '$start' AND vioDate < '$end'";
	$result = execsql($q);
	$num = mysql_num_rows($result);
	$i = 0;
	$q = "SELECT empId, empFName, empLName FROM nam_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++;
	}


	?>
	<h3>Violation Search By Date</h3>
<script
	type="text/javascript" src="../include/tablesort.js"></script>
<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">Violation Type</th>
			<th class="sortable-text">Details</th>
			<th class="sortable-text">Date</th>
		</tr>
	</thead>
	<tbody>
	<?php
	while($i < $num){
		$f1=mysql_result($result, $i, "empId");
		$f2=mysql_result($result,$i,"vioType");
		$f3=mysql_result($result,$i,"vioDetails");
		//			$f4=mysql_result($result,$i,"v");
		$f4=mysql_result($result,$i,"vioDate");


		?>



		<tr>
			<td><a href="../HR/searchAndDisplayE.php?id=<?php echo $f1?>"><?php echo $empArray[$f1]?></a></td>
			<td><?php echo $f2?></td>
			<td><?php echo $f3?></td>
			<td><?php echo $f4?></td>

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