<?php
include($_SERVER['DOCUMENT_ROOT'] . "/API-Others/connection/conn.php");
header('content-type:application/json');
$warehouse = $_GET["warehouse"];
if(!empty($warehouse)){
    $warehouseSearch = "WHERE warehouse = '$warehouse'";
}
$query = mysqli_query($conn, "SELECT * FROM stockwarehouses $warehouseSearch ORDER BY category, item");
$stock_list = array();
while ($spec = mysqli_fetch_assoc($query)) {
    $stock_list[] =  $spec;
}

$resultData = array('code' => $statusCode, 'message' => $statusMessage, 'stock_list' => $stock_list);
echo json_encode($resultData);