<?php
extract($_GET);
?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Apotik Pharmacy
            <small><?= $abdulradjak['NamaPerusahaan']; ?> - <?= $abdulradjak['KodePPK']; ?></small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Vclaim</a></li>
            <li class="active">Data Pasien</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <!-- Default box -->
        <div class="row">
            <div class="col-md-6">
                <h4>Transaction Pharmacy * <a href="" data-toggle="modal" data-target="#cariPasien" class="btn btn-sm btn-primary">Cari Pasien</a></h4>
            </div>
            <div class="col-md-6" align="right">
                <form class="form-inline" method="get" action="<?= base_url('apotek/pharmacy'); ?>">
                    <div class="form-group mx-sm-3 mb-2">
                        <input type="date" class="form-control" value="" name="tgl" id="inputPassword2" required>
                    </div>
                    <button type="submit" class="btn btn-primary mb-2">Cari</button>
                </form>
            </div>
        </div>
        <div class="box">
            <div class="box-body">
                <table id="example1" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>Case ID</th>
                            <th>No.MR</th>
                            <th>Nama</th>
                            <th>Ketegori</th>
                            <th>Case Status</th>
                            <th>Penjamin</th>
                            <th>Opsi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        foreach ($cases as $data) :
                            $categ = $data['CompanyCode'];
                            $sCateg = $this->db->query("SELECT * FROM Company WHERE CompanyCode = '$categ'")->row_array();
                        ?>
                            <tr style="font-size: 9pt;">
                                <td><?= $data['Case ID']; ?></td>
                                <td><?= $data['PatientCode']; ?></td>
                                <td><?= $data['Description']; ?></td>
                                <td>
                                    <?php
                                    if ($data['Category'] == "IP") {
                                        echo "R.Inap";
                                    } else if ($data['Category'] == "OP") {
                                        echo "R.Jalan";
                                    } else {
                                        echo "";
                                    }
                                    ?>
                                </td>
                                <td><?= $data['Case Status']; ?></td>
                                <td><?= $sCateg['CompanyName']; ?></td>
                                <td>
                                    <?php
                                    if ($data['Case Status'] == 'CLOSED' || $data['Case Status'] == 'Cancel') {
                                    ?>
                                        <button class="btn btn-sm btn-primary" disabled>Detail</button>
                                    <?php
                                    } else {
                                    ?>
                                        <a href="<?= base_url('apotik/transaksiPharmacy/' . $data['Case ID']); ?>" class="btn btn-sm btn-primary"> Detail</a>
                                    <?php
                                    }
                                    ?>
                                </td>
                            </tr>
                        <?php
                        endforeach;
                        ?>
                    </tbody>

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

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

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

<div class="modal fade" id="cariPasien" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <form action="<?= base_url('apotik/cari'); ?>" method="get">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Cari Pasien</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">

                    <input type="text" name="mr" class="form-control" required placeholder="no mr...">

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="submit" class="btn btn-primary">Cari</button>
                </div>
            </div>
        </form>
    </div>
</div>