23 lines
503 B
PHP
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);
|