<?php
require("../connection.php");
include("../user.php");
$user_id=$_SESSION['user'];
$username=$_SESSION['user_name'];
$branch_id=$_SESSION['branch_id'];
$ho_access=$_SESSION['ha'];	
$branch=$_SESSION['division_name'];
$location=$_SESSION['location'];

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $transaction_id = $_POST['transaction_id'];
    $category = $_POST['category'];
    $quantity = $_POST['quantity'];
    $location = $_POST['location'];

    // Prepare and execute the query
    $return_date = date('Y-m-d H:i:s');

    // Prepare the SQL statement with explicit return_date
    $stmt = $con->prepare("INSERT INTO return_stock (transaction_id, category, quantity, location, return_date) VALUES (?, ?, ?, ?, ?)");

    // Bind parameters
    $stmt->bind_param("ssiss", $transaction_id, $category, $quantity, $location, $return_date);


    if ($stmt->execute()) {
        echo "Success";
    } else {
        echo "Error: " . $stmt->error;
    }

    $stmt->close();
    $con->close();
}
?>
