<!-- Content Wrapper. Contains page content -->
<style>
    .link:hover {
        color: #3C8DBC;
        font-weight: bold;
    }
</style>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            General Consent
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> HIS</a></li>
            <li class="active">General Consent</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">


        <div class="box">
            <div class="box-body">

                <table class="table table-striped table-hover" id="example1" style="font-size: 9pt;">
                    <thead>
                        <tr>
                            <th>No.</th>
                            <th>Case ID</th>
                            <th>No.MR</th>
                            <th>Nama</th>
                            <th>Category</th>
                            <th>Case Status</th>
                            <th>Intake Date</th>
                            <th>Intake Time</th>
                            <th>Penjamin</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $no = 1;
                        foreach ($cases as $data) :
                        ?>
                            <tr data-toggle="modal" data-target="#modal<?= $data['Case ID']; ?>" style="cursor: pointer;" class="link">
                                <td><?= $no++; ?>.</td>
                                <td><?= $data['Case ID']; ?></td>
                                <td><?= $data['PatientCode']; ?></td>
                                <td><?= $data['Description']; ?></td>
                                <td><?= $data['Category']; ?></td>
                                <td><?= $data['Case Status']; ?></td>
                                <td><?= date('d M Y', strtotime($data['Intake Date'])); ?></td>
                                <td><?= date('H:i', strtotime($data['Intake Time'])); ?></td>
                                <td><?= $data['CompanyName']; ?></td>
                            </tr>
                        <?php
                        endforeach;
                        ?>
                    </tbody>
                </table>


            </div><!-- /.box-body -->
        </div><!-- /.box -->

    </section><!-- /.content -->
</div><!-- /.content-wrapper -->

<script>
    document.addEventListener("DOMContentLoaded", () => {
        const rows = document.querySelectorAll("tr[data-href]");
        rows.forEach(row => {
            row.addEventListener("click", () => {
                window.location.href = row.dataset.href;
            });
        });
    });
</script>
<?php
foreach ($cases as $modal) :
?>
    <div class="modal fade" id="modal<?= $modal['Case ID']; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <div class="modal-body text-center">
                    <p>Pilih <b><u>General Consent</u></b> atau <b><u>Informed Consent</u></b></p>
                    <a href="<?= base_url('generalConsent/ttd/' . $modal['Case ID']); ?>" class="btn btn-sm btn-primary">General Consent</a>
                    <a href="<?= base_url('informedConsent/ttd/' . $modal['Case ID']); ?>" class="btn btn-sm btn-primary">Informed Consent</a>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
<?php
endforeach;
?>