<?php
include_once '../db/koneksi.php';

if (isset($_GET['action']) && $_GET['action'] === 'update_kyc') {
    $id_anggota = isset($_GET['id']) ? intval($_GET['id']) : 0;
    $status = isset($_GET['status']) ? intval($_GET['status']) : -1;

    if ($id_anggota > 0 && in_array($status, [0, 1, 2])) {
        $query = mysqli_query($koneksi, "UPDATE anggota SET statusverif = '$status' WHERE id_anggota = '$id_anggota'");
        
        if ($query) {
            echo '<script>
                alert("Status berhasil diperbarui");
                window.location.replace("'.$alamat_admin.'kyc");
            </script>';
        } else {
            echo '<script>
                alert("Gagal memperbarui status");
                window.location.replace("'.$alamat_admin.'kyc");

            </script>';
        }
    } else {
        echo '<script>
            alert("Data tidak valid");
            window.location.replace("'.$alamat_admin.'kyc");
        </script>';
    }
    exit;
}
