<?php
ob_start();
include("configa.php");
session_start();

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $track_number   = $_POST['track_number'];
    $total          = $_POST['total'];
    $deliveryCharge = $_POST['deliveryCharge'];
    $grandTotal     = $_POST['grandTotal'];

    $sql = "UPDATE final_order_summary 
            SET total = ?, delivery_charge = ?, grand_total = ? 
            WHERE track_number = ?";
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("dddi", $total, $deliveryCharge, $grandTotal, $track_number);

    if ($stmt->execute()) {
        echo "✅ ডাটা সফলভাবে আপডেট হয়েছে";
        // চাইলে redirect করতে পারেন:
        // header("Location: view.php?track_number=".$track_number);
    } else {
        echo "❌ আপডেট ব্যর্থ: " . $stmt->error;
    }
}
?>
