<?php

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

$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 Report</title>

<script src="https://cdn.tailwindcss.com"></script>

<style>

@media print{

button{
display:none;
}

body{
background:white;
}

}

</style>

</head>

<body class="bg-gray-100 p-8">

<div class="max-w-7xl mx-auto">

<div class="flex justify-between mb-6">

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

Disciplinary Report

</h1>

<button
onclick="window.print()"
class="bg-black text-white px-6 py-3 rounded">

Print Report

</button>

</div>

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

<table class="w-full">

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

<tr>

<th class="p-4">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>