<?php
include 'koneksi.php';
include 'auth.php'; // Pastikan user sudah login dan berhak

$data = json_decode(file_get_contents('php://input'), true);

if (!$data || !isset($data['id'])) {
    echo json_encode(['success' => false, 'message' => 'ID tidak ditemukan']);
    exit;
}

$id = intval($data['id']);

$stmt = $koneksi->prepare("DELETE FROM orders WHERE id = ?");
$stmt->bind_param("i", $id);

if ($stmt->execute()) {
    echo json_encode(['success' => true]);
} else {
    echo json_encode(['success' => false, 'message' => 'Gagal menghapus data']);
}
$stmt->close();
$koneksi->close();
?>
