<?php
include '../config/koneksi.php';
include '../helpers/functions.php';

if (!isLogin() || !isAdmin()) redirect('../auth/login.php');

if (isset($_POST['update'])) {
    $id = $_POST['id'];
    $saldo = $_POST['saldo'];

    if ($saldo < 0) {
        setFlash("Saldo tidak boleh minus", "danger");
        redirect('data_client.php');
    }

    mysqli_query($conn, "UPDATE users SET saldo='$saldo' WHERE id='$id'");

    setFlash("Saldo berhasil diupdate", "success");
    redirect('data_client.php');
}