Admin_KeluhanMasuk.php 4.94 KB
Newer Older
Dany Panegratia committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
<?php
session_start();
if (!isset($_SESSION["login"])) {
    header("Location: login.php");
    exit;
}
require 'header.php';

?>

<?php

// paginition
// konfigurasi
$jumlahDataPerHalaman = 5;
$jumlahData = count(query("SELECT * FROM keluhan"));
$jumlahHalaman = ceil($jumlahData / $jumlahDataPerHalaman);
if (isset($_GET["halaman"])) {
    $halamanAktif = $_GET["halaman"];
} else {
    $halamanAktif = 1;
}
$awalData = ($jumlahDataPerHalaman * $halamanAktif) - $jumlahDataPerHalaman;

$mhs = query("SELECT * FROM keluhan order by status LIMIT $awalData, $jumlahDataPerHalaman");

?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Daftar keluhan</title>
</head>

<body>
    <div class="container">



        <!-- navigasi -->
        <center>
            <?php if ($halamanAktif > 1) : ?>
                <a href="?halaman=<?= $halamanAktif - 1; ?>">&laquo;</a>
            <?php endif; ?>


            <?php
            for ($i = 1; $i <= $jumlahHalaman; $i++) : ?>
                <?php if ($i == $halamanAktif) : ?>
                    <a href="?halaman=<?php echo $i; ?>" style="font-weight: bold; color: red;"><?= $i; ?></a>
                <?php else : ?>
                    <a href="?halaman=<?php echo $i; ?>"><?= $i; ?></a>
                <?php endif; ?>
            <?php endfor; ?>

            <?php if ($halamanAktif < $jumlahHalaman) : ?>
                <a href="?halaman=<?= $halamanAktif + 1; ?>">&raquo;</a>
            <?php endif; ?>

        </center>
        <br>


        <table class="table table-striped">
            <thead>
                <tr>
                    <th scope="col">No.</th>
                    <th scope="col">Kategori</th>
                    <th scope="col">Username</th>
                    <th scope="col">Subjek</th>
                    <th scope="col">Date</th>
                    <th scope="col">Status</th>
                    <th scope="col">Aksi</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <?php $i = 1 ?>
                    <?php foreach ($mhs as $row) : ?>
                        <?php
                        $coba = $row['id_jenis'];
                        $cobalagi = query("SELECT * FROM jeniskeluhan WHERE id_jenis = $coba");
                        ?>
                        <td><?php echo $i; ?></td>
                        <td>
                            <?php foreach ($cobalagi as $row33) : ?>
                                <?= $row33["jenis"]; ?>
                            <?php endforeach; ?>
                        </td>
                        <?php
                        $coba22 = $row['id_user'];
                        $cobalagi22 = query("SELECT * FROM user WHERE id = $coba22");
                        ?>
                        <td>
                            <?php foreach ($cobalagi22 as $row22) : ?>
                                <?= $row22["username"]; ?>
                            <?php endforeach; ?>
                        </td>
                        <td>
                            <a href="Admin_MenjawabKeluhan.php?id_keluhan=<?php echo $row["id_keluhan"] ?>" class="tulisan"><?= $row["subjek"]; ?></a>
                        </td>
                        <td>
                            <?= $row["tanggal"]; ?>
                        </td>
                        <td>
                            <?php
                            $status = $row["status"] == "sudah";
                            ?>
                            <?php if ($status) : ?>
                                <button type="button" class="btn btn-outline-success">ANSWERED</button>
                            <?php endif; ?>
                            <?php if (!$status) : ?>
                                <button type="button" class="btn btn-outline-danger">WAIT</button>
                            <?php endif; ?>

                        </td>
                        <td>
                            <?php
                            $status = $row["status"] == "sudah";
                            ?>
                            <?php if ($status) : ?>
                                <a href="Admin_UbahJawaban.php?id_keluhan=<?php echo $row["id_keluhan"] ?>">ubah</a> |
                                <a href="Admin_HapusKeluhan.php?id=<?php echo $row["id_keluhan"] ?>" onclick="return confirm('yakin?');">hapus</a>
                            <?php endif; ?>
                            <?php if (!$status) : ?>
                                <a href="Admin_HapusKeluhan.php?id=<?php echo $row["id_keluhan"] ?>" onclick="return confirm('yakin?');">hapus</a>
                            <?php endif; ?>
                        </td>
                        <?php
                        ?>
                </tr>
                <?php $i++; ?>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</body>

<?php
require 'footer.php';
?>

</html>