<?php
include 'db.php';
header('Content-Type: application/json');

$stmt = $pdo->query("
    SELECT id, inv_date, item, department, vendor, unit, price, terms
    FROM transactions
    ORDER BY inv_date DESC
");

$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

echo json_encode([
    'success' => true,
    'rows' => $rows
]);
