<?php
declare(strict_types=1);
require_once __DIR__ . '/../helpers.php';

$conn = db();
$result = $conn->query('SELECT id, sku, barcode, item_type, name, description, quality, price, quantity, updated_at FROM items ORDER BY CASE WHEN item_type = "sale" THEN 0 ELSE 1 END, name ASC');
$data = [];
while ($row = $result->fetch_assoc()) {
    $data[] = $row;
}
respond(['success' => true, 'data' => $data]);
