<?php
include("connection.php");
if (isset($_POST['add'])) {
    $reseller_notice = $_POST['reseller_notice'];
    $currentDateTime = date('Y-m-d H:i:s');
    // Prepare the insert statement
    $sql="INSERT INTO reseller_notice (reseller_notice,date_time) VALUES ('$reseller_notice','$currentDateTime')";
    $result=mysqli_query($conn,$sql);
    if ($result) {
        header("Location: add_reseller_notice.php?msg=1");
    } else {
        header("Location: add_reseller_notice.php?msg=2");
    }
    
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $itemId = $_POST['item_id'];
    
    if (isset($_POST['activate'])) {
        $status = 1;
    } elseif (isset($_POST['block'])) {
        $status = 0;
    }
    
    $updateQuery = "UPDATE reseller_notice SET status = $status WHERE id = $itemId";
    mysqli_query($conn, $updateQuery);
    
    // Redirect back to the view table page
    header('Location: add_reseller_notice.php');
    exit();
}

?>
