<?php

session_start();
require_once "../Config/session_check.php";

$_SESSION["last_Active"] = time();

$ID = "";
if (isset($_GET["ID"])) {
    $ID = $_GET["ID"];

} else {
    header("location: ../");
}
$AddedItemID = "";
if (isset($_GET["AddedItemID"])) {
    $AddedItemID = $_GET["AddedItemID"];

} else {
    header("location: ../");
}

require_once "../Config/config.php";
$SQL = "DELETE FROM recived_stock WHERE Recived_Stock_ID = ?";
if ($stmt = mysqli_prepare($link, $SQL)) {

    mysqli_stmt_bind_param($stmt, "s", $AddedItemID);
    // Attempt to execute the prepared statement
    if (mysqli_stmt_execute($stmt)) {
        // Close connection
        mysqli_close($link);
        header("location: ../Invoices/DetailView.php?ID=" . $ID . "");
        exit;
    } else {
        echo "Something got in the way.";
    }
}

