
<!----------------------------------Login------------------------------------>
<?php
include 'php/db_connection.php';

// শুধুমাত্র লগইন করা ইউজার পেজ দেখতে পারবে
if (!isset($_SESSION['user_id'])) {
    header("Location: login.php");
    exit();
}

$userName = $_SESSION['user_name'];
$role = $_SESSION['role']; // ✅ এখানে role সেভ করা হচ্ছে
$userId = $_SESSION['user_id'];


$isAdmin = ($_SESSION['role'] == 'admin');

?>

<!---------------------------------কন্টেন------------------------------------>
<?php
// Delete Sale Data
if (isset($_GET['id'])) {
    $sale_id = $conn->real_escape_string($_GET['id']);

    // Delete associated sales items
    $delete_items_sql = "DELETE FROM sales_items WHERE sales_id = $sale_id";
    $conn->query($delete_items_sql);

    // Delete the sale itself
    $delete_sale_sql = "DELETE FROM sales WHERE id = $sale_id";
    if ($conn->query($delete_sale_sql) === TRUE) {
        echo "Sale deleted successfully!";
        header("Location: sales_all_data.php");
        
    } else {
        echo "Error deleting sale: " . $conn->error;
        header("Location:print_customer.php");
    }
} else {
    echo "No sale ID provided.";
}


$conn->close();
?>


