<?php
if ($c['level'] == "superadmin") {
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $roda_hadiah = (int) $_POST['roda_hadiah'];

        // Validasi nilai roda hadiah
        $allowed_values = [
            1000, 5000, 10000, 20000, 25000, 50000, 100000, 277000, 900000
        ];

        if (!in_array($roda_hadiah, $allowed_values)) {
            echo "<script>alert('Nilai roda hadiah tidak valid');window.history.back();</script>";
            exit;
        }

        $query = mysqli_query($koneksi, "UPDATE tb_user SET roda_hadiah = '$roda_hadiah'");

        if ($query) {
            echo "<script>alert('Berhasil update roda hadiah semua user');window.location='?page=roda_hadiah';</script>";
        } else {
            echo "<script>alert('Gagal update roda hadiah semua user');window.history.back();</script>";
        }
    } else {
        echo "<script>window.location='?page=roda_hadiah';</script>";
    }
} else {
    echo "<script>window.location='?page=dashboard';</script>";
}
?>