<!-- 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
                                $resepId = $TansID['PresNo'];
                                $case = $TansID['Case ID'];
                                $cases = $this->db->query("SELECT * FROM Cases WHERE [Case ID] = '$case'")->row_array();
                                $resepRacik = $this->db->query("SELECT * FROM Resep_Racikan_H WHERE ResepId = '$resepId'")->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>Nama Racikan</th>
                                            <th>Qty</th>
                                            <th>Dosis</th>
                                            <th>Cara Pakai</th>
                                            <th></th>
                                        </tr>
                                        <tr>
                                            <td><?= $resepRacik['NamaRacikan']; ?></td>
                                            <td><?= $resepRacik['QtyRacikan']; ?></td>
                                            <td><?= $resepRacik['Frekuensi']; ?></td>
                                            <td><?= $resepRacik['Cara']; ?></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/cetakTiketRacikan/' . $resepRacik['ResepId']); ?>">Paper 60 x 60</a></li>
                                                            <li><a target="_blank" href="<?= base_url('cetakFR/cetakTiketKecilRacikan/' . $resepRacik['ResepId']); ?>">Paper 60 x 40</a></li>
                                                            <li><a target="_blank" href="<?= base_url('cetakFR/cetakTiketKecilRacikanA/' . $resepRacik['ResepId']); ?>">Paper 95 x 39</a></li>

                                                        </ul>
                                                    </div>
                                                <?php
                                                }
                                                ?>
                                            </td>
                                        </tr>
                                    </table>
                                </small>
                            </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>

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

                                            </tr>

                                        <?php
                                        endforeach;
                                        ?>
                                    </table>
                                </small>
                            </td>
                        </tr>

                        <tr>
                            <td colspan="6">
                                <?php
                                if ($TansID['LockStatus'] == 0) {
                                ?>
                                    <a href="<?= base_url('apotik/prosesPembuatanRacikan/' . $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 disabled href="#" 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 RACIKAN</a>
                                    <a target="_blank" href="<?= base_url('cetakFR/cetakAllRacikan/' . $TansID['TransactionID'] . '/' . $TansID['Case ID'] . '/' . $resepRacik['IdRacikan']); ?>" class="btn btn-sm btn-info"><i class="fa fa-fw fa-print"></i> PRINT ALL E-TIKET RACIKAN</a>
                                <?php
                                } else {
                                ?>
                                <?php
                                }
                                ?>
                            </td>
                        </tr>

                    </tbody>

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

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


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