<?php
include("../include/session.php");
if(!$session->isAdmin()) {
	header("Location: ../main.php");
}
else {
	include("../reportHeader.php");
//	include("../include/db.php");
	$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++;
	}

	$type = mysql_real_escape_string($_POST['vioType']);
	$q = "SELECT * FROM minorViolations WHERE vioType = '$type'";
	if($type == "All"){
		$q = "SELECT * FROM minorViolations";
	}

	$result = execsql($q);
	$num = mysql_num_rows($result);
	$i = 0;

	?>
<script
	type="text/javascript" src="../include/tablesort.js"></script>
	<h3>Violation Search By Type</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">Violation Type</th>
			<th class="sortable-text">Details</th>
			<th class="sortable-date-ymd">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, "vioDate");
		?>


		<tr class="alt">
			<td><a href="../HR/searchAndDisplayE.php?id=<?=$f1?>"><? echo $empArray[$f1]?></a></td>
   			<td><?=$f2?></td>
			<td><?=$f3?></td>
			<td><?=$f4?></td>
		</tr>
		<?php
		$i++;
	}
	?>
	</tbody>
</table>
	<?php
	include("../footer.html");
}
?>