<?php
include('../includes/config.php');

$customerId = intval($_GET['id']);
$sql = "
    SELECT receipt_number, total_amount, created_at, transaction_type 
    FROM sales_transactions 
    WHERE customer_id = ? 
    ORDER BY created_at DESC 
    LIMIT 5
";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $customerId);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows === 0) {
    echo "<em>No recent transactions.</em>";
} else {
    echo "<ul class='list-group'>";
    while ($row = $result->fetch_assoc()) {
        echo "<li class='list-group-item bg-dark text-white'>
            <strong>#{$row['receipt_number']}</strong> - 
            {$row['transaction_type']} | 
            <span class='text-success'>MWK {$row['total_amount']}</span><br>
            <small>{$row['created_at']}</small>
        </li>";
    }
    echo "</ul>";
}
?>
