<!-- 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>
                        <?php
                        foreach ($TansID as $data) :
                            $tr = $data['TransactionID'];
                            $sDetail = $this->db->query("SELECT * FROM [Activity Drugs] AA, Pharmacy P WHERE AA.DrugsID=P.PharmacyCode AND TransactionID = '$tr'")->result_array();
                            $resepId = $data['PresNo'];
                            $resepRacik = $this->db->query("SELECT * FROM Resep_Racikan_H WHERE ResepId = '$resepId'")->row_array();
                      ?>
                            <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><?= $data['TransactionID']; ?></td>
                                <td><?= $data['Case ID']; ?></td>
                                <td><?= $data['PresNo']; ?></td>
                                <td><?= $data['Description']; ?></td>
                                <td><?= $data['DoctorID'] . ' ~ ' . $data['FirstName']; ?></td>
                                <td><?= $data['Transaction_Date']; ?></td>
                            </tr>
                            <tr>
                                <td colspan="7">
                                    <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
                                            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 ($data['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'] . '/' . $data['Case ID']); ?>">Paper 60 x 60</a></li>
                                                                    <li><a target="_blank" href="<?= base_url('cetakFR/cetakTiketKecil/' . $trx['ID'] . '/' . $data['Case ID']); ?>">Paper 60 x 40</a></li>
                                                                    <li><a target="_blank" href="<?= base_url('cetakFR/cetakTiketKecilB/' . $trx['ID'] . '/' . $data['Case ID']); ?>">Paper 95 x 39</a></li>

                                                                </ul>
                                                            </div>
                                                        <?php
                                                        }
                                                        ?>
                                                    </td>
                                                </tr>
                                            <?php
                                            endforeach;
                                            ?>
                                        </table>
                                    </small>
                                </td>
                            </tr>
                            <tr>
                            <?php
                                 $case = $data['Case ID'];
                                $cases = $this->db->query("SELECT * FROM Cases WHERE [Case ID] = '$case'")->row_array();
                            ?>
                                <td colspan="6">
                                    <?php
                                    if ($data['LockStatus'] == 0) {
                                    ?>
                                        <a href="<?= base_url('apotik/prosesPembuatan/' . $data['TransactionID'] . '/' . $data['Case ID']); ?>" class="btn btn-sm btn-primary"><i class="fa fa-fw fa-spinner"></i> PROSES PEMBUATAN</a>
                                    <?php
                                    } else if ($data['LockStatus'] == 1) {
                                    ?>
                                        <!-- <a disabled href="#" class="btn btn-sm btn-success"><i class="fa fa-fw fa-spinner"></i>SELESAI</a> -->

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

                                    <?php
                                    } else {
                                    ?>
                                    <?php
                                    }
                                    if($resepRacik['Jenis']=='Racikan'){
                                    ?>
                                           <a target="_blank" href="<?= base_url('cetakFR/cetakAllRacikan/' . $data['TransactionID'] . '/' . $data['Case ID'] . '/' . $resepRacik['IdRacikan']); ?>" class="btn btn-sm btn-info"><i class="fa fa-fw fa-print"></i> PRINT E-TIKET RACIKAN</a>
                                     <?php }else{ ?>
                                     <?php } ?>      
                                </td>
                            </tr>
                            <tr>
                                <td colspan="6"><br></td>
                            </tr>
                        <?php
                        endforeach;
                        ?>
                    </tbody>

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

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


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