<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
include '../connection.php';
$sql = "SELECT id, name, icon FROM tbl_product_type ORDER BY name ASC";
$result = $conn->query($sql);

$productTypes = [];

if ($result && $result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $productTypes[] = $row;
    }
    echo json_encode(["success" => true, "product_types" => $productTypes]);
} else {
    echo json_encode(["success" => false, "message" => "No product types found"]);
}

$conn->close();
?>