<?php
require_once('includes/load.php');
page_require_level(2);

if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['product']) && isset($_GET['child'])) {
    $product = $db->escape($_GET['product']);
    $child = $db->escape($_GET['child']);

    // Delete the child BOM from the bom_level table
    $sql = "DELETE FROM bom_level WHERE parent_bom = '$product' AND child_bom = '$child'";
    $db->query($sql);

    // Redirect back to the BOM View page
    header("Location: view_bom.php");
    exit();
} else {
    // Invalid request, redirect to home page or show an error message
    header("Location: index.php"); // Change to your desired page
    exit();
}
?>
