<?php

require_once ('process/dbh.php');

//$sql = "SELECT * from `transport`";
$sql = "Select employee.id, employee.firstName, employee.lastName, transport.travel_date, transport.route, transport.start_location, transport.reason, transport.token,transport.status1 From employee, transport Where employee.id = transport.id order by transport.token";

//echo "$sql";
$result = mysqli_query($conn, $sql);

?>



<html>
<head>
	<title>Transport Details </Details> | Admin Panel | Employee Management System</title>
	<link rel="stylesheet" type="text/css" href="styleview.css">
</head>
<body>
	
	<header>
		<nav>
			<h1>EMS</h1>
			<ul id="navli">
				<li><a class="homeblack" href="aloginwel.php">HOME</a></li>
				
				<li><a class="homeblack" href="addemp.php">Add Employee</a></li>
				<li><a class="homeblack" href="viewemp.php">View Employee</a></li>
				<li><a class="homeblack" href="assign.php">Assign Activity</a></li>
				<li><a class="homeblack" href="assignproject.php">Activity Status</a></li>
				<li><a class="homered" href="transportdetails.php">Transport Details</a></li>
				<li><a class="homeblack" href="empleave.php">Employee Leave</a></li>
				<li><a class="homeblack" href="alogin.html">Log Out</a></li>
			</ul>
		</nav>
	</header>
	 
	<div class="divider"></div>
	<div id="divimg">
		<table>
			<tr>
				<th>Emp. ID</th>
				<th>Token</th>
				<th>Name</th>
				<th>Travel Date</th>
				<th>Route</th>
				<th>Start Location</th>
				<th>Reason</th>
				<th>Status</th>
				<th>Options</th>
			</tr>

			<?php
				while ($employee = mysqli_fetch_assoc($result)) {

				$date1 = new DateTime($employee['travel_date']);
				
				//echo "difference " . $interval->days . " days ";

					echo "<tr>";
					echo "<td>".$employee['id']."</td>";
					echo "<td>".$employee['token']."</td>";
					echo "<td>".$employee['firstName']." ".$employee['lastName']."</td>";
					
					echo "<td>".$employee['travel_date']."</td>";
					echo "<td>".$employee['route']."</td>";
					echo "<td>".$employee['start_location']."</td>";
					
					echo "<td>".$employee['reason']."</td>";
					echo "<td>".$employee['status1']."</td>";
					echo "<td><a href=\"approve_transport.php?id=$employee[id]&token=$employee[token]\"  onClick=\"return confirm('Are you sure you want to Approve the request?')\">Approve</a> | <a href=\"cancel_transport.php?id=$employee[id]&token=$employee[token]\" onClick=\"return confirm('Are you sure you want to Canel the request?')\">Cancel</a></td>";

				}


			?>

		</table>
		
	</div>
</body>
</html>