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


    <div class="page-breadcrumb">
        <div class="row">
            <div class="col-5 align-self-center">
                <h4 class="page-title">Daftar Berita</h4>
            </div>
            <div class="col-7 align-self-center">
                <div class="d-flex align-items-center justify-content-end">
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item">
                                <a href="#">Daftar Berita</a>
                            </li>
                            <li class="breadcrumb-item active" aria-current="page">Menu Daftar Berita</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>
    </div>

    <div class="container-fluid">

        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-body">
                        <div style="float: right;">
                            <a href="?page=tambah_berita" class="btn btn-primary">Tambah Data Berita</a>
                        </div>
                        <h4 class="card-title">Daftar Berita</h4>
                        
                    </div>
                    <div class="table-responsive">
                        <table id="zero_config" class="table table-striped table-bordered ">
                            <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Judul</th>
                                    <th scope="col">Tanggal</th>
                                    <th scope="col">Status</th>
                                    <th scope="col">Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $query = mysqli_query($koneksi, "SELECT * FROM tb_news ");
                                $no = 1;
                                while ($data = mysqli_fetch_array($query)) {
                                    ?>
                                    
                                    <tr>
                                        <th scope="row"><?php echo $no++; ?></th>
                                        <td><?php echo $data['judul']; ?></td>
                                        <td><?php echo $data['tanggal']; ?></td>
                                        <td><?php echo $data['status']; ?></td>
                                        <td>
                                            <a href="?page=edit_berita&id=<?php echo $data['id'] ?>" class="btn btn-warning btn-small">Edit</a>
                                            <a href="?page=hapus_berita&id=<?php echo $data['id'] ?>" class="btn btn-danger btn-small">Delete</a>
                                        </td>
                                    </tr>
                                    
                                    <?php
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

    </div>

    <?php
}else{
    ?>
    <script type="text/javascript">
        window.location = "?page=dashboard";
    </script>
    <?php
}
?>
