<?php
// File: API_KONEKSI/admin/promo/hapus_promo.php
header('Content-Type: application/json');
include '../../config/koneksi.php';
include '../../config/middleware.php';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $promo_id = $_POST['promo_id'] ?? '';
    $payload = authenticateJWT();
    $user_id = $payload['user_id'] ?? ''; 
    if (!empty($promo_id)) {
        $stmt = $conn->prepare("UPDATE mst_promo SET deleted_st = 1, deleted_at = CURRENT_TIMESTAMP, deleted_by = ? WHERE promo_id = ?");
        $stmt->bind_param("ss", $user_id, $promo_id);
        
        if ($stmt->execute()) {
            echo json_encode(["status" => "sukses", "pesan" => "Promo berhasil dihapus", "data" => []]);
        } else {
            echo json_encode(["status" => "gagal", "pesan" => "Gagal menghapus promo", "data" => []]);
        }
        $stmt->close();
    }
}
$conn->close();
?>
