<?php
include('../include/headscript.php');
include('../class/company.php');
$conn = new mysqli($servername, $username, $password, $database);

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $idlab = $_POST['idlab'];

    $stmt = $conn->prepare("SELECT * FROM laboratories WHERE idlab = ?");
    $stmt->bind_param("i", $idlab);
    $stmt->execute();
    $result = $stmt->get_result();
    $lab = $result->fetch_assoc();

    if ($lab) {
        echo json_encode([
            "status" => "success",
            "name" => $lab['name'],
            "country" => $lab['country'],
            "status" => $lab['status']
        ]);
    } else {
        echo json_encode(["status" => "error", "message" => "Laboratory not found"]);
    }
    $stmt->close();
}
$conn->close();
