<?php
require_once("database.php"); // Ensure the database connection is included

// Get job_id from the URL
if (isset($_GET['job_id'])) {
    $job_id = $_GET['job_id'];

    // Step 1: Get job_reference_id from the job table using job_id
    $result = $database->query("SELECT job_reference_id FROM job WHERE id = $job_id");

    if ($result) {
        $row = mysqli_fetch_assoc($result);
        $job_reference_id = $row['job_reference_id'];

        // Step 2: Update the job_reference table's order_ref field with "cantdo"
        $update_query = "UPDATE job_reference SET order_ref = 'cantdo' WHERE id = $job_reference_id";

        if ($database->query($update_query)) {
            echo "Job reference updated to 'cantdo'.";
        } else {
            echo "Error updating job reference: " . mysqli_error($database->getConnection());
        }
    } else {
        echo "Job not found.";
    }
} else {
    echo "No job_id specified.";
}
?>
