<style>
    .link:hover {
        color: #3C8DBC;
        font-weight: bold;
    }
</style>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Rujukan<label style="font-weight: normal; font-size:15px" id="timer"></label>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Sis-RS</a></li>
            <li class="active">Rujukan</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> <b>Report Rujukan</b>
            </div>
            <div class="col-md-4" align="right">
            
            </div>
        </div>
        <div class="box">
            <div class="box-body">
                <?= $this->session->flashdata('message'); ?>
                <div class="table-responsive">
                        <table id="example1" class="table table-striped table-hover">
                    <thead>
                        <tr>
                            <th>No</th>
                            <th>Nama Pasien</th>
                            <th>Case ID</th>
                            <th>Penjamin</th>
                            <th>Category</th>
                            <th>Case Status</th>
                            <th>Intake Time</th>
                            <th>Intake Date</th>
                            <th>Tujuan RS</th>
                            <th>Tujuan Poli</th>
                            <th>Print</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
                        $no = 1;
                        foreach($pasien as $d) : 
                        ?>
                        <tr  data-toggle="modal" data-target="" style="cursor: pointer;" class="link">
                            <td><?= $no++; ?></td>
                            <td><?= $d['Description']; ?></td>
                            <td><?= $d['Case ID']; ?></td>
                            <td><?= $d['CompanyName']; ?></td>
                            <td><?= $d['Category']; ?></td>
                            <td><?= $d['Case Status']; ?></td>
                            <td><?= date('H:i', strtotime($d['Intake Time'])); ?></td>
                            <td><?= date('d-m-Y', strtotime($d['Intake Date'])); ?></td>
                            <td><?= $d['instansi_tujuan']; ?></td>
                            <td><?= $d['poli_tujuan']; ?></td>
                            <td><a href="<?= base_url('DashboardLaporan/cetakrujukan/'.$d['Case ID']); ?>" target="_blank" class="btn btn-success" ><i class="fa fa-print"></i></a></td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
                <table class="table table-striped">
                    <tbody>
                    <tr>
                            <td><b><h3>Total</h3></b></td>
                            <td><center><h3><?= $total['total']; ?></h3></center></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </section>
</div>

<script>
    document.addEventListener("DOMContentLoaded", () => {
        const rows = document.querySelectorAll("tr[data-href]");
        rows.forEach(row => {
            row.addEventListener("click", () => {
                window.location.href = row.dataset.href;
            });
        });
    });
</script>