<?php

include 'includes/auth.php';
include 'db.php';
include 'includes/header.php';

$result = $conn->query("
SELECT
d.*,
u.username,
du.username AS deleted_by_name
FROM deleted_k_requisitions d

LEFT JOIN users u
ON d.requested_by=u.id

LEFT JOIN users du
ON d.deleted_by=du.id

ORDER BY deleted_at DESC
");

?>

<div class="container mt-4">

<h3>
Deleted Kitchen Requisitions
</h3>

<table class="table table-bordered">

<tr>

<th>ID</th>
<th>Original ID</th>
<th>Requested By</th>
<th>Status</th>
<th>Created</th>
<th>Deleted By</th>
<th>Deleted At</th>
<th>Items</th>

</tr>

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

<tr>

<td><?= $row['id'] ?></td>

<td><?= $row['original_id'] ?></td>

<td><?= htmlspecialchars($row['username']) ?></td>

<td><?= $row['status'] ?></td>

<td><?= $row['created_at'] ?></td>

<td><?= htmlspecialchars($row['deleted_by_name']) ?></td>

<td><?= $row['deleted_at'] ?></td>

<td>

<a
href="deleted_kitchen_requisition_view.php?id=<?= $row['id'] ?>"
class="btn btn-info btn-sm">

View Items

</a>

</td>

</tr>

<?php endwhile; ?>

</table>

</div>

<?php include 'includes/footer.php'; ?>