<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Record 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">Record Pharmacy</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <!-- Default box -->
        <div class="box">
            <div class="box-body">

                <table class="table table-bordered table-striped">
                    <thead>

                    </thead>
                    <tbody>

                        <tr>
                            <th>Transaction ID</th>
                            <th>Case ID</th>
                            <th>Resep ID</th>
                            <th>Nama</th>
                            <th>Dokter Pengirim</th>
                            <th>Tanggal Transaction</th>

                        </tr>
                        <tr>
                            <td><?= $TansID['TransactionID']; ?></td>
                            <td>
                                <?php
                                $case = $TansID['Case ID'];
                                $cases = $this->db->query("SELECT * FROM Cases WHERE [Case ID] = '$case'")->row_array();
                                echo $case;
                                ?>
                            </td>
                            <td><?= $TansID['PresNo']; ?></td>
                            <td><?= $cases['Description']; ?></td>
                            <td>
                                <?php
                                $dokter = $TansID['DoctorID'];
                                $dok = $this->db->query("SELECT * FROM Doctor WHERE DoctorID = '$dokter'")->row_array();
                                echo $dok['FirstName'];
                                ?>
                            </td>
                            <td><?= $TansID['Transaction_Date']; ?></td>
                        </tr>

                        <tr>
                            <td colspan="6">
                                <small>
                                    <table width="100%">
                                        <tr>
                                            <th>Drugs</th>
                                            <th>Charge</th>
                                            <th>Qty</th>
                                            <th>Basic Price</th>
                                            <th>Unit Price</th>
                                            <th>PPN</th>
                                            <th>Aturan</th>
                                            <th>Cara Pakai</th>
                                            <th>Satuan Pakai</th>
                                            <th>Ket.</th>
                                            <th></th>
                                        </tr>
                                        <?php
                                        $tr = $TansID['TransactionID'];
                                        $sDetail = $this->db->query("SELECT * FROM [Activity Drugs] AA, Pharmacy P WHERE AA.DrugsID=P.PharmacyCode AND TransactionID = '$tr'")->result_array();
                                        foreach ($sDetail as $trx) :
                                        ?>
                                            <tr>
                                                <td><?= $trx['Description']; ?></td>
                                                <td><?= $trx['Charge']; ?></td>
                                                <td><?= $trx['Qty']; ?> <?= $trx['PharmacyUnit']; ?></td>
                                                <td><?= $trx['BasicPrice']; ?></td>
                                                <td><?= $trx['UnitPrice']; ?></td>
                                                <td><?= $trx['PPN']; ?></td>
                                                <td><?= $trx['Dosis']; ?></td>
                                                <td><?= $trx['Cara']; ?></td>
                                                <td><?= $trx['PharmacyUnit']; ?></td>
                                                <td><?= $trx['Ket']; ?></td>
                                                <td>
                                                    <?php
                                                    if ($TansID['LockStatus'] == '1') {
                                                    ?>
                                                        <div style="margin-bottom: 2px;" class="dropdown">
                                                            <button class="btn btn-sm btn-primary dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                                                <i class="fa fa-fw fa-print"></i>PRINT E-TIKET
                                                                <span class="caret"></span>
                                                            </button>
                                                            <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                                                                <li><a target="_blank" href="<?= base_url('cetakFR/cetakTiket/' . $trx['ID'] . '/' . $TansID['Case ID']); ?>">Paper 60 x 60</a></li>
                                                                <li><a target="_blank" href="<?= base_url('cetakFR/cetakTiketKecil/' . $trx['ID'] . '/' . $TansID['Case ID']); ?>">Paper 60 x 40</a></li>
                                                                <li><a target="_blank" href="<?= base_url('cetakFR/cetakTiketKecilB/' . $trx['ID'] . '/' . $TansID['Case ID']); ?>">Paper 95 x 39</a></li>
                                                            </ul>
                                                        </div>
                                                    <?php
                                                    }
                                                    ?>
                                                </td>
                                            </tr>
                                        <?php
                                        endforeach
                                        ?>
                                    </table>
                                </small>
                            </td>
                        </tr>
                        <?php
                           $case = $TansID['Case ID'];
                           $cases = $this->db->query("SELECT * FROM Cases WHERE [Case ID] = '$case'")->row_array();
                         ?>
                        <tr>
                            <td colspan="6">
                                <?php
                                if ($TansID['LockStatus'] == 0) {
                                ?>
                                    <a href="<?= base_url('apotik/prosesPembuatan/' . $TansID['TransactionID'] . '/' . $TansID['Case ID']); ?>" class="btn btn-sm btn-primary"><i class="fa fa-fw fa-spinner"></i> PROSES PEMBUATAN</a>
                                <?php
                                } else if ($TansID['LockStatus'] == 1) {
                                ?>
                                    <a href="<?= base_url('apotek/proses_selesai/' . $TansID['TransactionID'] . '/' . $TansID['Case ID']); ?>" class="btn btn-sm btn-success"><i class="fa fa-fw fa-spinner"></i> PROSES SELESAI</a>

                                    <a target="_blank" href="<?= base_url('cetakFR/cetakObat/' . $TansID['TransactionID'] . '/' . $TansID['Case ID']); ?>" class="btn btn-sm btn-info"><i class="fa fa-fw fa-print"></i> PRINT RESEP</a>

                                    <a target="_blank" href="<?= base_url('cetakFR/cetakAllObat/' . $TansID['TransactionID'] . '/' . $TansID['Case ID']); ?>" class="btn btn-sm btn-warning"><i class="fa fa-fw fa-print"></i> PRINT ALL E-TIKET</a>

                                <?php
                                } else {
                                ?>
                                <?php
                                }
                                ?>
                            </td>
                        </tr>

                    </tbody>

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

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


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