<?php

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

if(!isset($_SESSION['user_id'])){
    header("Location: ../login.php");
    exit;
}

$res = $conn->query("
SELECT

dc.*,
e.name employee_name

FROM disciplinary_cases dc

LEFT JOIN employees e
ON e.id=dc.employee_id

ORDER BY dc.issue_date DESC
");
?>

<!DOCTYPE html>
<html>
<head>
<title>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">
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 text-left">Employee</th>
<th class="p-4">Case 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['employee_name']) ?>
</td>

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