<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Laboratorium <label style="font-weight: normal; font-size:15px" id="timer"></label>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i></a></li>
            <li class="active">Laboratorium</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row" style="margin-bottom: 10px;">
            <div class="col-md-8">
                <i class="fa fa-fw fa-calendar"></i> HISTORY <b>LABORATORIUM</b>


            </div>
            <div class="col-md-4" align="right">
                <form action="<?= base_url('Laboratorium/caridatalab'); ?>" method="get">
                    <table>
                        <tr>
                            <td><input type="date" class="form-control" name="tgl" value="<?= date('Y-m-d'); ?>"></td>
                            <td><button style="border-radius: 0px;" type="submit" class="btn btn-sm btn-primary">Cari</button></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="box">
            <div class="box-body">
                <?= $this->session->flashdata('message'); ?>
                <table id="example1" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>No</small></th>
                            <th>Case ID</th>
                            <th>Patient Code</th>
                            <th>Pasien</th>
                            <th>Dokter</th>
                            <th>ID Header</th>
                            <th>Tanggal Distribusi</th>
                            <th>Waktu Distribusi</th>
                            <!-- <th>Status</th> -->
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $no = 1;
                        foreach ($pasien as $p) { ?>
                            <tr style="font-size: 9pt;">
                                <td><?= $no ?></td>
                                <td><?= $p['CaseID'] ?></td>
                                <td><?= $p['PatientCode'] ?></td>
                                <td><?= $p['Description'] ?></td>
                                <td><?= $p['FirstName'] . '' . $p['LastName']; ?></td>
                                <td><?= $p['IdRequestHeader'] ?></td>
                                <td><?= date('d M Y', strtotime($p['tglRequest'])) ?></td>
                                <td><?= date('H:i:s', strtotime($p['jamRequest'])) ?> WIB</td>
                                <td>
                                <a target="_blank" href="<?= base_url('Laboratorium/cetaklab/'. $p['CaseID'] ); ?>" class="btn btn-sm btn-warning"><i class="fa fa-fw fa-print"></i> PRINT HASIL </a>
                                <?php
                                $caseid = $p['CaseID'];
                                   $qdata = $this->db->query("select lh.IdRequestHeader, ld.PackedID, pd.Description, lh.[status]
                                    from LabRequestHeader lh join LabRequestDetail ld on lh.IdRequestHeader = ld.IdRequestHeader
                                    join tblLabPacked pd on pd.PackedID = ld.PackedID where lh.CaseID = '$caseid' ")->row_array();
                                ?>
                                </td>
                            </tr>
                        <?php $no++;
                        } ?>
                    </tbody>
                </table>
            </div>
        </div>

    </section>
</div>

<script type="text/javascript">
    var count = 60;
    var periode = 1;
    var counter = setInterval(timer, 500);

    function timer() {
        count = count - 1;
        if (count <= 0) {
            clearInterval(counter);
            location.reload();
        }

        document.getElementById("timer").innerHTML = 'Akan memuat pada <strong style="color:orange;">' + count + "</strong> detik";
    }
    $(document).ready(function() {
        timer();
    });
</script>

<script>
    function blink_text() {
        $('#status').fadeOut(700);
        $('#status').fadeIn(700);
    }
    setInterval(blink_text, 750);
</script>