35607-vm/_get_sale_items.php
Flatlogic Bot 9b5a06451f SInarKasih
2025-11-10 04:11:47 +00:00

23 lines
503 B
PHP

<?php
header('Content-Type: application/json');
require_once 'db/config.php';
if (!isset($_GET['sale_id'])) {
echo json_encode(['error' => 'Sale ID not provided.']);
exit;
}
$sale_id = $_GET['sale_id'];
$pdo = db();
$stmt = $pdo->prepare("
SELECT si.quantity, si.price, p.name as product_name
FROM sale_items si
JOIN products p ON si.product_id = p.id
WHERE si.sale_id = ?
");
$stmt->execute([$sale_id]);
$items = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($items);