<?php
include 'db.php';
$result = $conn->query("SELECT p.*, e.name 
                        FROM payments p 
                        JOIN employees e ON p.employee_id = e.id 
                        ORDER BY p.created_at DESC");
?>

<h2>All Payments (Transaction Logs)</h2>
   <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<table border="1" cellpadding="8">
    <tr>
        <th>ID</th>
        <th>Employee</th>
        <th>Amount</th>
        <th>Date</th>
        <th>Method</th>
        <th>Remarks</th>
        <th>Created At</th>
    </tr>
    <?php while($row = $result->fetch_assoc()): ?>
        <tr>
            <td><?= $row['id'] ?></td>
            <td><?= $row['name'] ?></td>
            <td><?= $row['amount'] ?></td>
            <td><?= $row['payment_date'] ?></td>
            <td><?= $row['method'] ?></td>
            <td><?= $row['remarks'] ?></td>
            <td><?= $row['created_at'] ?></td>
        </tr>
    <?php endwhile; ?>
</table>

<br>
<a href="export_pdf.php">Export to PDF</a>