<?php
session_start();
require_once '../../../config.php';
load('middleware', 'user');
if ($_SESSION['user']['level'] !== "Admin") {
    header('location:' . base_url('id'));
}
$check_provider = $db->query("SELECT * FROM provider ORDER BY id DESC");

$id = $_GET['id'];
if(!isset($id))
    die('No direct script access allowed!');
$query = mysqli_query($db, "SELECT * FROM users WHERE id = '$id'");
$q = mysqli_fetch_assoc($query);
?>

<form method="POST">
<div class="form-group mb-3">
        <label>ID</label>
        <input type="text" class="form-control" value="<?= $q['id']; ?>" name="id" readonly>
    </div>
<div class="form-group mb-3">
        <label>Username</label>
        <input type="text" class="form-control" value="<?= $q['username']; ?>" readonly>
    </div>
<div class="form-group mb-3">
        <label>Email</label>
        <input type="text" class="form-control" value="<?= $q['email']; ?>" readonly>
    </div>
<div class="form-group mb-3">
        <label>Phone</label>
        <input type="text" class="form-control" value="<?= $q['phone']; ?>" readonly>
    </div>
    <div class="form-group mb-3">
        <label>Saldo</label>
        <input type="text" class="form-control" name="saldoo" value="<?= $q['saldo']; ?>">
    </div>
    <div class="form-group mb-3">
        <label>Level</label>
        <select class="form-control" name="level">
				<option value="0">- Select Level -</option>
				<option value="Member" <?= $q['level'] == "Member" ? "selected" : "";?>>Member</option>
				<option value="Reseller" <?= $q['level'] == "Reseller" ? "selected" : "";?>>Reseller</option>
				<option value="Vip" <?= $q['level'] == "Vip" ? "selected" : "";?>>Vip</option>
				<option value="Admin" <?= $q['level'] == "Admin" ? "selected" : "";?>>Admin</option>
		</select>
    </div>
    <hr>
    <div class="float-right">
                <button type="button" data-bs-dismiss="modal" aria-label="Close" class="btn btn-block bg-light fw-bold">BACK</button>
                <button type="submit" name="edit_user" class="btn btn-block text-white bg-primary fw-bold">CHANGE</button>
    </div>
</form>
