<?php
if ($c['level'] == "superadmin") {
?>

<div class="page-breadcrumb">
    <div class="row">
        <div class="col-5 align-self-center">
            <h4 class="page-title">Data API Provider</h4>
        </div>
    </div>
</div>

<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">Data API Provider</h4>

                    <?php
                    $query = mysqli_query($koneksi, "SELECT * FROM tb_api");
                    while ($data = mysqli_fetch_array($query)) {
                    ?>
                    <form class="form p-t-20" action="?page=update_api" method="POST">

                        <input type="hidden" name="id" value="<?= $data['id']; ?>">

                        <div class="form-group">
                            <label>Agent Kode</label>
                            <div class="input-group mb-3">
                                <span class="input-group-text"><i class="ti-user"></i></span>
                                <input type="text" class="form-control" 
                                       name="agent_code" 
                                       value="<?= $data['agent_code']; ?>" required>
                            </div>
                        </div>
                        
                             <div class="form-group">
                            <label>Agent token</label>
                            <div class="input-group mb-3">
                                <span class="input-group-text"><i class="ti-user"></i></span>
                                <input type="text" class="form-control" 
                                       name="agent_token" 
                                       value="<?= $data['agent_token']; ?>" required>
                            </div>
                        </div>

                        <div class="form-group">
                            <label>API endpoint</label>
                            <div class="input-group mb-3">
                                <span class="input-group-text"><i class="ti-link"></i></span>
                                <input type="text" class="form-control" 
                                       name="endpoint" 
                                       value="<?= $data['endpoint']; ?>" required>
                            </div>
                        </div>

                        <button type="submit" name="upload" class="btn btn-success">Submit</button>
                        <button type="reset" class="btn btn-dark">Cancel</button>
                    </form>
                    <?php } ?>

                </div>
            </div>
        </div>
    </div>
</div>

<?php
} else {
    echo "<script>window.location='?page=dashboard';</script>";
}
?>?>
