<nav class="navbar navbar-expand-md" style="background: #e6ffec;">
    <ul class="navbar-nav me-auto mb-1 mb-sm-0">
        <div class="container-fluid">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0  h5 mb-2 text-gray-800">
                <li class="dropdown">
                    <a href="#" class="nav-link h5 mb-2 text-gray-800 dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Input
                        <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-dark">
                        <li>
                            <a href="#myUser" data-bs-toggle="modal" class=" dropdown-item">Input User </a>
                        </li>
                        <li>
                            <a href="#myModal" data-bs-toggle="modal" class=" dropdown-item">Input Perawat </a>
                        </li>

                    </ul>
                </li>
                <li class="dropdown">
                    <a href="#" class="nav-link h5 mb-2 text-gray-800 dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Report
                        <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-dark">

                        <li>
                            <a href="#tindakan" data-bs-toggle="modal" class=" dropdown-item">Tindakan</a>
                        </li>
                        <li role="separator"></li>
                        <li>
                            <a href="#pasien" data-bs-toggle="modal" class="dropdown-item">Pasien</a>
                        </li>
                        <li role="separator"></li>
                        <li>
                            <a href="#perawat" data-bs-toggle="modal" class="dropdown-item">Supervisi</a>
                        </li>
                        <li class="divider"></li>

                    </ul>
                </li>

            </ul>
        </div>
    </ul>
</nav>
<script>
    $(document).ready(function() {
        load_modal_manajer();

        function load_modal_manajer() {
            $.ajax({
                type: "GET",
                url: "modalmanajer.php",
                method: "post",
                success: function(data) {
                    $('#mymodalmanajer').html(data);
                }
            })
        }
    });
</script>
<!-- ================================= -->
<div class="container-fluid">
    <table id="datatab" class='table table-stripped table-hover datatab'>
        <thead>
            <tr>
                <th>No</th>
                <th>Triage | Kode</th>
                <th>Nama</th>
                <th>Register</th>
                <th>SMF</th>
                <th>Pengkajian</th>
                <th>Rencana</th>
                <th>Keluar</th>
                <th>Waktu Tunggu</th>
            </tr>
        </thead>
        <tbody>

            <?php
            date_default_timezone_set('Asia/Jakarta'); //Menyesuaikan waktu dengan tempat kita tinggal
            include "model/koneksi.php";

            $query = $open->query("SELECT id_pasien, nama, register, smf, ruang, triage,nik,tanggal FROM datapasien WHERE  status_tunggu='menunggu'");
            $no = 0;
            while ($data = mysqli_fetch_assoc($query)) {
                $no++;
                $tsql = "SELECT * FROM tb_tindakan WHERE id_pasien='$data[id_pasien]' AND masalah='belum'";
                $sqlcount = mysqli_num_rows(mysqli_query($open, $tsql));
                if ($sqlcount > 0)

                    $awal  = date_create($data['tanggal']);
                $akhir = date_create(); // waktu sekarang
                $diff  = date_diff($awal, $akhir);
                $hour = $diff->h < 6;
                $day = $diff->d == 0;

                if ($hour && $day) {
                    $btnprolong = "btn btn-success";
                } else {
                    $btnprolong = "btn btn-danger";
                }
                echo
                "<tr style='font-size: 10pt;'>
        <td><a class='btn btn-light' href='index.php?link=dataview.php&id_pasien=$data[id_pasien]&register=$data[register]&nama=$data[nama]'>$no</a></td>
        <td>$data[triage] | $data[nik]</td>
        <td><a class='btn btn-light' href='index.php?link=dataview.php&id_pasien=$data[id_pasien]&register=$data[register]&nama=$data[nama]'>$data[nama]</a></td>
    
        
        <td>$data[register]</td>
        <td>$data[smf]</td>
        <td><a class='btn btn-light position-relative' onclick='warning()'href=''>Pengkajian</a></td>
        <td><a class='btn btn-light position-relative' onclick='warning()'href=''>Tindakan<span class='position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger'>$sqlcount</span></a></td>
        <td><a class='btn btn-light' href='' onclick='warning()'data-bs-toggle='modal' data-bs-target=''>keluar</a></td>
        <td><a class= '$btnprolong'href='' data-bs-toggle='modal' data-bs-target='#prolong$data[id_pasien]'> $diff->d hari- $diff->h jam- $diff->i menit</a></td>
        </tr>";
            }
            ?>
        </tbody>

    </table>

</div>
<?php
include "modalmanajer.php";

//Tutup koneksi engine MySQL
mysqli_close($open);
?>

</div>
<p id="mymodalmanajer"></p>
<script src="js/jquery-1.12.0.min.js"></script>
<script src="js/jquery.dataTables.min.js"></script>
<script>
    $(document).ready(function() {
        $('.datatab').DataTable();
    });
</script>
<script>
    function warning() {
        alert("maaf anda bukan admin ruangan");
    }
</script>

<script>
    $(document).ready(function() {
        load_modal();

        function load_modal() {
            $.ajax({
                type: "GET",
                url: "modal.php",
                method: "post",
                success: function(data) {
                    $('#mymodalmanajer').html(data);
                }
            })
        }
    });
</script>