<?php
require_once 'databaseConnection.php';

if (isset($_GET['jobNumber'])) {
    $jobNumber = $_GET['jobNumber'];

    $mysqli = db_connect();
    if (!$mysqli) {
        die(json_encode(["status" => "error", "message" => "Database connection failed"]));
    }

    // Fetch full job details
    $stmt = $mysqli->prepare("SELECT * FROM customerField WHERE job_number = ?");
    $stmt->bind_param("s", $jobNumber);
    $stmt->execute();
    $result = $stmt->get_result();

    if ($row = $result->fetch_assoc()) {
        echo json_encode($row);
    } else {
        echo json_encode(["status" => "error", "message" => "Job not found"]);
    }
}
?>
