<?php

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

$employeeId = intval($_GET['employee_id'] ?? 0);

$employee = $conn->query("
SELECT *
FROM employees
WHERE id=$employeeId
")->fetch_assoc();

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

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

<?php include '../sidebar.php'; ?>

<div class="flex-1 p-8" id="main-content">

<h1 class="text-3xl font-bold mb-6">

<?= htmlspecialchars($employee['name']) ?>

Disciplinary History

</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>