<?php
define('SUPPRESS_ERRORS', true);
header('Content-Type: application/json');

include_once('../../includes/config.php');

$query = "SELECT * FROM tblsuppliers WHERE Status = 'Active' ORDER BY SupplierName";
$result = mysqli_query($con, $query);

if ($result) {
    $suppliers = [];
    while ($row = mysqli_fetch_assoc($result)) {
        $suppliers[] = $row;
    }
    echo json_encode(['success' => true, 'data' => $suppliers]);
} else {
    echo json_encode(['success' => false, 'message' => 'Failed to fetch suppliers']);
}
?>
