ok i receive items through table  SELECT `purchase_order_id`, `purchase_date`, `productname`, `price`, `quantity`, `subtotal`, `invo_id` , `product_id` , `category` FROM `purchase_orders`
this items are updated in the  products table  by adding to the respective quantities  then when sold they are stored in the sales table  then the quantity in the product table is updated we also have 
product_update table  SELECT `update_id`, `update_date`, `productname`, `price`, `quantity`, `product_id`, `category` FROM `product_update` this will form the variance  we also have disposed_items  
SELECT `di_id`, `product_name`, `quantity`, `dispose_id`, `dispose_date` , `category` FROM `disposed_items`  i think with rthis info we can create acode to o generate a comprehensive stock movement report with the specified columns (opening stock, opening stock value, received stock qty, received stock value, total available, available value, sold quantity, sold stock value, closing quantity, closing value, physical closing stock, physical closing value, variance qty, variance value), you'll need to structure your SQL query and PHP code to calculate and aggregate these values correctly. here is the products tables which are beverages and ingredients in the sales and in all tables we have the category column which is to state if its food or beverages   // Handle food deduction
                $sqlGetIngredients = "SELECT * FROM `food_ingredients` WHERE `food_id` = '$productid'";
                $result = mysqli_query($conn, $sqlGetIngredients);
                if ($result && mysqli_num_rows($result) > 0) {
                    while ($ingredient = mysqli_fetch_assoc($result)) {
                        $ingredientId = $ingredient['ingredient_id'];
                        $ingredientQuantity = $ingredient['quantity_required'] * $itemQuantity;

                        $sqlUpdateIngredient = "UPDATE ingredients SET quantity = quantity - '$ingredientQuantity' WHERE id = '$ingredientId'";
                        if (!mysqli_query($conn, $sqlUpdateIngredient)) {
                            throw new Exception("Error updating ingredient: " . mysqli_error($conn));
                        }
                    }
                } else {
                    throw new Exception("Ingredients not found for food item.");
                }
            }

            // Insert a sales record into item_sales table
            $sqlInsertItemSales = "INSERT INTO sales (trans_id, product_name, product_id, quantity, selling_price, subtotal,category) VALUES ('$stid', '$itemName', '$productid', '$itemQuantity', '$price', '$subtotal','$cat')";
            if (!mysqli_query($conn, $sqlInsertItemSales)) {
                throw new Exception("Error inserting item sales: " . mysqli_error($conn));
            } this is how we are deducting the pbfood ingredients after food has been sold 