<?php

require '../config.php';
session_start();
session_write_close();

$userId = intval($_SESSION['user_id']);

$emp = $conn->query("
SELECT employee_id
FROM users
WHERE id=$userId
")->fetch_assoc();

$employeeId = intval($emp['employee_id']);

$res = $conn->query("
SELECT *
FROM disciplinary_cases
WHERE employee_id=$employeeId
ORDER BY issue_date DESC
");
?>

<!DOCTYPE html>
<html>
<head>
<title>My Disciplinary Records</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100">

<div class="max-w-6xl mx-auto p-8">

<h1 class="text-3xl font-bold mb-6">
My Disciplinary Records
</h1>

<div class="bg-white rounded-xl shadow overflow-hidden">

<table class="w-full">

<thead class="bg-gray-100">

<tr>

<th class="p-4">Type</th>
<th class="p-4">Subject</th>
<th class="p-4">Date</th>
<th class="p-4">Status</th>

</tr>

</thead>

<tbody>

<?php while($row=$res->fetch_assoc()): ?>

<tr class="border-b">

<td class="p-4">
<?= htmlspecialchars($row['case_type']) ?>
</td>

<td class="p-4">
<?= htmlspecialchars($row['subject']) ?>
</td>

<td class="p-4">
<?= date('d M Y',strtotime($row['issue_date'])) ?>
</td>

<td class="p-4">
<?= htmlspecialchars($row['status']) ?>
</td>

</tr>

<?php endwhile; ?>

</tbody>

</table>

</div>

</div>

</body>
</html>