

	<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" initial-scale=1.0>
	<title>Admin Page</title>
</head>
<body>
	<h1>Admin Page</h1>
	
	<style>
		table {
			border-collapse: collapse;
		}
		th, td {
			padding: 10px;
			border: 1px solid black;
		}
		td {
		    color:white;
		    font-weight:bold;
		}
		th {
			background-color: #ccc;
			width:100%;
		}
		h1 {
		    text-align:center;
		}
		body {
		    background-color: grey;
		}
	</style>
	<table>
		<tr>
			<th>Name</th>
			<th>Email</th>
			<th>ID CARD</th>
			<th>PASSPORT</th>
			<th>Status</th>
			<th>Approve</th>
			<th>Decline</th>
			<th>Delete</th>
		</tr>
		<?php
		// Connect to the database
		require_once('db.php');

		// Retrieve all submissions from the database
		$sql = "SELECT * FROM submissions";
		$result = $conn->query($sql);

		if ($result->num_rows > 0) {
			// Output each submission as a table row
			while($row = $result->fetch_assoc()) {
				echo '<tr>';
				echo '<td>' . $row['name'] . '</td>';
				echo '<td>' . $row['email'] . '</td>';
				echo '<td><a href="uploads/' . $row['document1'] . '"><p style="color:blue">VIEW ID CARD</p></a></td>';
				echo '<td>';
				if($row['document2']) {
					echo '<a href="uploads/' . $row['document2'] . '"><p> VIEW DRIVING LICENCE</p></a>';
				} else {
					echo '-';
				}
				echo '</td>';
				echo '<td>' . $row['status'] . '</td>';
				echo '<td><form action="approve.php" method="post">';
				echo '<input type="hidden" name="id" value="' . $row['id'] . '">';
				echo '<input type="submit" name="approve" value="Approve">';
				echo '</form></td>';
				echo '<td><form action="decline.php" method="post">';
				echo '<input type="hidden" name="id" value="' . $row['id'] . '">';
				echo '<input type="submit" name="decline" value="Decline">';
				echo '</form></td>';
				echo '<td><form action="delete.php" method="post">';
				echo '<input type="hidden" name="id" value="' . $row['id'] . '">';
				echo '<input type="hidden" name="document1" value="' . $row['document1'] . '">';
				echo '<input type="hidden" name="document2" value="' . $row['document2'] . '">';
				echo '<input type="submit" name="delete" value="Delete">';
				echo '</form></td>';
				echo '</tr>';
			}
		} else {
			echo '<tr><td colspan="8">No submissions to display.</td></tr>';
		}

		$conn->close();
		?>
	</table>
</body>
</html>
