<table class="table table-sm table-bordered">
    <thead>
        <th>Grup</th>
        <th>Sub Menu</th>
        <th>Akses</th>
        <th>Data</th>
        <th>Unduh</th>
    </thead>
    <tbody>
        <?php
        foreach ($grup as $g) {
            echo "<tr>";
            echo "<td>" . $g['grup'] . "</td>";
            echo "<td>";
            foreach ($sub as $s) {
                if ($g['id_grup'] == $s['id_grup']) {
                    echo $s['submenu'] . "<br>";
                }
            }
            echo "</td>";

            echo "<td>";
            foreach ($sub as $s) {
                if ($g['id_grup'] == $s['id_grup']) {
                    foreach ($usr as $u) {
                        if ($u['id_sub'] == $s['id_sub']) {
                            if ($s['akses'] == 1) {
                                if ($u['akses'] == 1) {
                                    echo "<i class='bi bi-check-circle' style='color:blue;cursor:pointer;' onclick='tutup_akses(\"" . $id . "\"," . $s['id_sub'] . ")'></i><br>";
                                }
                                if ($u['akses'] == 0) {
                                    echo "<i class='bi bi-x-circle' style='color:red;cursor:pointer;' onclick='buka_akses(\"" . $id . "\"," . $s['id_sub'] . ")'></i><br>";
                                }
                            }
                            if ($s['akses'] == 0) {
                                echo "<i class='bi bi-dash-circle'></i><br>";
                            }
                        }
                    }
                }
            }
            echo "</td>";

            echo "<td>";
            foreach ($sub as $s) {
                if ($g['id_grup'] == $s['id_grup']) {
                    foreach ($usr as $u) {
                        if ($u['id_sub'] == $s['id_sub']) {
                            if ($s['dml'] == 1) {
                                if ($u['dml'] == 1) {
                                    echo "<i class='bi bi-check-circle' style='color:blue;cursor:pointer;' onclick='tutup_dml(\"" . $id . "\"," . $s['id_sub'] . ")'></i><br>";
                                }
                                if ($u['dml'] == 0) {
                                    echo "<i class='bi bi-x-circle' style='color:red;cursor:pointer;' onclick='buka_dml(\"" . $id . "\"," . $s['id_sub'] . ")'></i><br>";
                                }
                            }
                            if ($s['dml'] == 0) {
                                echo "<br>";
                            }
                        }
                    }
                }
            }
            echo "</td>";
            echo "<td>";
            foreach ($sub as $s) {
                if ($g['id_grup'] == $s['id_grup']) {
                    foreach ($usr as $u) {
                        if ($u['id_sub'] == $s['id_sub']) {
                            if ($s['unduh'] == 1) {
                                if ($u['unduh'] == 1) {
                                    echo "<i class='bi bi-check-circle' style='color:blue;cursor:pointer;' onclick='tutup_unduh(\"" . $id . "\"," . $s['id_sub'] . ")'></i><br>";
                                }
                                if ($u['unduh'] == 0) {
                                    echo "<i class='bi bi-x-circle' style='color:red;cursor:pointer;' onclick='buka_unduh(\"" . $id . "\"," . $s['id_sub'] . ")'></i><br>";
                                }
                            }

                            if ($s['unduh'] == 0) {
                                echo "<br>";
                            }
                        }
                    }
                }
            }
            echo "</td>";

            echo "</tr>";
        }
        ?>
    </tbody>
</table>