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

if(isset($_POST['id']) && isset($_POST['status'])) {
    $id = (int)$_POST['id'];
    $status = $db->escape($_POST['status']);
    
    $db->query("UPDATE material_forecasts SET status = '{$status}' WHERE id = {$id}");
    
    if($db->affected_rows() > 0) {
        echo json_encode(['success' => true]);
    } else {
        echo json_encode(['error' => 'Update failed']);
    }
} else {
    echo json_encode(['error' => 'Invalid request']);
}
?>