<?php
// Initialize the page and include necessary files
require_once('includes/load.php');
page_require_level(3);

// Check if the ID is set in the GET request
if (isset($_GET['id'])) {
    $id = (int)$_GET['id'];
    
    // Query to delete the schedule from the database
    $query = "DELETE FROM production_schedule WHERE id = '{$id}' LIMIT 1";
    
    if ($db->query($query)) {
        // If deletion is successful, redirect with success message
        $session->msg("s", "Schedule deleted successfully.");
        redirect('schedule.php');
    } else {
        // If deletion fails, redirect with error message
        $session->msg("d", "Failed to delete schedule.");
        redirect('schedule.php');
    }
} else {
    // If ID is not set, redirect with error message
    $session->msg("d", "Missing schedule ID.");
    redirect('schedule.php');
}
?>
