<!-- 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>

    <?php
    extract($_GET);
    $detailApotik = $this->db->query("SELECT AA.ID, AA.TransactionID, AA.[Case ID], AA.Unit,AA.DrugsID,P.Description,AA.Charge,AA.Qty,AA.Charge,AA.BasicPrice,AA.Dosis,AA.Cara,P.PharmacyUnit,AA.Ket
    FROM [Activity Drugs] AA, Pharmacy P WHERE AA.DrugsID=P.PharmacyCode AND TransactionID = '$isi'")->result_array();
    $editObat = $this->db->query("SELECT * FROM [Activity Drugs] WHERE ID = '$Idt'")->row_array();
    ?>

    <!-- Main content -->
    <section class="content">
        <!-- Default box -->
        <div class="box">
            <div class="box-body">
                <small>
                    <form action="<?= base_url('apotik/prosesUpdatePharmacy/' . $editObat['ID']); ?>" method="post">
                        <table class="table table-striped">
                            <tr>
                                <th style="display: none;">Transaction ID</th>
                                <th style="display: none;">Case ID</th>

                                <th>Pharmacy</th>
                                <th>Qty</th>
                                <th>Dosis / Frekuensi</th>
                                <th>Cara</th>
                                <th>Ket. </th>
                            </tr>
                            <tr>
                                <td style="display: none;">
                                    <input autofocus type="text" name="TransactionID" class="form-control" value="<?= $isi; ?>">
                                    <input type="text" name="UserCreated" value="<?= $user['UserName']; ?>">
                                </td>
                                <td style="display: none;">
                                    <input type="text" name="caseID" class="form-control" value="<?= $pasienDetail['Case ID']; ?>">
                                </td>

                                <td>
                                    <select name="DrugsId" class="teanganData" required data-live-search="true">
                                        <option value=""></option>
                                        <?php
                                        foreach ($obat as $list) :
                                            if ($editObat['DrugsID'] == $list['PharmacyCode']) {
                                        ?>
                                                <option selected value="<?= $list['PharmacyCode']; ?>"><?= $list['PharmacyCode']; ?> - <?= $list['Description']; ?></option>
                                            <?php
                                            } else {
                                            ?>
                                                <option value="<?= $list['PharmacyCode']; ?>"><?= $list['Description']; ?></option>
                                        <?php
                                            }
                                        endforeach;
                                        ?>
                                    </select>
                                </td>
                                <td>
                                    <input type="number" name="Qty" value="<?= $editObat['Qty']; ?>" class="form-control" required>
                                </td>
                                <td>
                                    <select name="dosis" class="teanganData" required data-live-search="true">
                                        <option value=""></option>
                                        <?php
                                        foreach ($dosis as $dosisP) :
                                            if ($editObat['Dosis'] == $dosisP['AturanPakai']) {
                                        ?>
                                                <option selected value="<?= $dosisP['AturanPakai']; ?>"><?= $dosisP['AturanPakai']; ?></option>
                                            <?php
                                            } else {
                                            ?>
                                                <option value="<?= $dosisP['AturanPakai']; ?>"><?= $dosisP['AturanPakai']; ?></option>
                                        <?php
                                            }

                                        endforeach;
                                        ?>
                                    </select>
                                </td>
                                <td>
                                    <select name="caraPakai" required class="teanganData " data-live-search="true">
                                        <option value=""></option>
                                        <?php
                                        foreach ($caraPakai as $pakai) :
                                            if ($editObat['Cara'] == $pakai['CaraPakai']) {
                                        ?>
                                                <option selected value="<?= $pakai['CaraPakai']; ?>"><?= $pakai['CaraPakai']; ?></option>
                                            <?php
                                            } else {
                                            ?>
                                                <option value="<?= $pakai['CaraPakai']; ?>"><?= $pakai['CaraPakai']; ?></option>
                                        <?php
                                            }
                                        endforeach;
                                        ?>
                                    </select>
                                </td>
                                <td>
                                    <input type="text" value="<?= $editObat['Ket']; ?>" class="form-control" name="ket">
                                    <input type="hidden" name="IdUser" value="<?= $user['username']; ?>">
                                    <input type="hidden" name="IdComp" value="<?= $pasienDetail['CompanyCode']; ?>">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="6">
                                    <button type="submit" class="btn btn-sm btn-success">Update Pharmacy</button>
                                    <a href="<?= base_url('apotik/transaksiPharmacy/' . $pasienDetail['Case ID'] . '?isi=' . $isi); ?>" class="btn btn-sm btn-danger">Selesai</a>
                                </td>
                            </tr>
                        </table>
                    </form>
                </small>
            </div><!-- /.box-body -->
        </div><!-- /.box -->

        <div class="box">
            <div class="box-body">
                <small>
                    <table class="table table-striped">
                        <tr>
                            <th></th>
                            <th>Pharmacy</th>
                            <th>Satuan</th>
                            <th>Qty</th>
                            <th>Charge</th>
                            <th>Dosis / Frekuensi</th>
                            <th>Cara</th>
                            <th>Ket. </th>
                        </tr>
                        <?php
                        foreach ($detailApotik as $details) :
                        ?>
                            <tr>
                                <td>
                                    <a href="<?= base_url('apotik/editPharmacy/' . $pasienDetail['Case ID'] . '?isi=' . $isi . '&Idt=' . $details['ID']); ?>" class="btn btn-sm btn-primary">
                                        <i class="fa fa-fw fa-pencil"></i>
                                    </a>
                                    <a href="<?= base_url('apotik/hapusPharmacy/' . $details['ID']); ?>" onclick="return confirm('Hapus item obat <?= $details['Description']; ?> ?')" class="btn btn-sm btn-danger">
                                        <i class="fa fa-fw fa-trash"></i>
                                    </a>
                                </td>
                                <td><?= $details['Description']; ?></td>
                                <td><?= $details['PharmacyUnit']; ?></td>
                                <td><?= $details['Qty']; ?></td>
                                <td><?= $details['Charge']; ?></td>
                                <td><?= $details['Dosis']; ?></td>
                                <td><?= $details['Cara']; ?></td>
                                <td><?= $details['Ket']; ?></td>

                            </tr>
                        <?php
                        endforeach;
                        ?>

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

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

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