<?php
require_once("../config/config.php");

$project_id = (int)($_GET['project_id'] ?? 0);
$item_id = (int)($_GET['item_id'] ?? 0);

$res = $conn->query("
    SELECT serial_no 
    FROM project_inventory_serials 
    WHERE project_id = $project_id 
    AND item_id = $item_id 
    AND status = 'IN'
");

$serials = [];
while ($row = $res->fetch_assoc()) {
    $serials[] = $row['serial_no'];
}

echo json_encode([
    "success" => true,
    "serials" => $serials
]);