<?php
include("../include/session.php");
if(!$session->isAdmin() && !$session->isRadstoneReceptionUser() && !$session->isRadstoneStoreUser()){
		header("Location: ../Store/productionMenu.php");
}
else {
//	include("../include/db.php");
	include("../reportHeader.php");
	$q= "SELECT * FROM loan";
	$result = execsql($q);
	$i = 0;
	$num = mysql_num_rows($result);
	$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++;
	}
	
$q1 = "SELECT productId, productName FROM products";
	$resultPro = execsql($q1);
	$numPro = mysql_num_rows($resultPro);
	$k = 0;
	$proArray = array();
	while($k < $numPro){
		$proArray[mysql_result($resultPro, $k, "productId")] = mysql_result($resultPro, $k, "productName");
		$k++;
	}
	?>
<script
	type="text/javascript" src="../include/tablesort.js"></script>
<h3>Items on loan</h3>


<table id="test1" cellpadding="0" cellspacing="0" border="0"
	class="rowstyle-alt colstyle-alt no-arrow">
	<thead>
		<tr>
			<th class="sortable-text">Product Name</th>
			<th class="sortable-text">Employee Name</th>
			<th class="sortable-numeric">Quantity</th>
			<th class="sortable-date-ymd">Date</th>
		</tr>
	</thead>
	<tbody>
	<?php
	while($i < $num){
		$b2 = mysql_result($result, $i, "productId");
		$b3 = mysql_result($result, $i, "empId");
		$b4 = mysql_result($result, $i, "quantity");
		$b5 = mysql_result($result, $i, "date");

		?>
		<tr class="alt">
			<td><a href="../Store/showProduct.php?productId=<?=$b2?>"><?=$proArray[$b2]?></a></td>
			<td><a href="../HR/searchAndDisplayE.php?id=<?=$b3?>"><?=$empArray[$b3]?></a></td>
			<td><?=$b4?></td>
			<td><?=$b5?></td>
		</tr>

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

?>
?>
