<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Sistem Klinik
            <small>Rekam Medis</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Klinik</a></li>
            <li class="active">Dashboard</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <!-- Default box -->
        <div class="box">
        <div class="box-tools pull-right">
        <div class="box-header with-border">
        <?php 
            $CaseID =  $this->uri->segment(3);
            $resepid = $this->uri->segment(4);
            $cases =   $this->db->query("Select * From Cases Where [Case ID] = '$CaseID' ")->row_array();
            $mr = $cases['PatientCode'];
            $r = $this->db->query("SELECT * FROM Resep_Header where ResepId ='$resepid'")->row_array();
        ?>
            <?php
         if($r['AddTrans'] == 0) {
            ?>
        <a href="" data-toggle='modal' data-target='.bd-example-modal-lg' class="btn btn-sm btn-success"><i class="fa fa-fw fa-plus"></i> Tambah Obat</a>
        <?php }else{ ?>
        <?php } ?>
        </div>
        </div>
            <table style="margin-top: 5px;" class="table table-striped table-hover">
                        <tr>
                            <th>Nama Racikan</th>
                            <th>Qty</th>
                            <th>Dosis</th>
                            <th>Aturan Pakai</th>
                            <th></th>
                            <th></th>
                        </tr>
                       
                                <tr style="background-color: gray;color:white">
                                    <td><?= $headerRacik['NamaRacikan']; ?></td>
                                    <td><?= $headerRacik['QtyRacikan']; ?></td>
                                    <td><?= $headerRacik['Frekuensi']; ?></td>
                                    <td><?= $headerRacik['Cara']; ?></td>
                                    <?php
                                      if($r['AddTrans'] == 0) {
                                    ?>
                                    <td><a href="<?= base_url('Apotik/hapusobatracikdokter/' . $headerRacik['IdRacikan'] .'/'. $headerRacik['Case ID']); ?>"" onclick="return confirm('Hapus?')" style="color:yellow"><i class="fa fa-fw fa-trash"></i></a></td>
                                    <?php }else{ ?>

                                    <?php } ?>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td colspan="4">
                                        <table class="table table-strived">
                                            <tr>
                                                <th width="40%">Nama Obat</th>
                                                <th width="40%">Satuan</th>
                                                <th width="15%">Jumlah</th>
                                                <th>~</th>
                                            </tr>
                                            <?php foreach($tampilracik as $d) : ?>
                                                <tr>
                                                    <td><?= $d['Description']; ?></td>
                                                    <td><?= $d['Satuan']; ?></td>
                                                    <td><?= $d['Jumlah']; ?></td>
                                                    <?php
                                                    if($r['AddTrans'] == 0) {
                                                    ?>
                                                    <td> <td><a href="<?= base_url('Apotik/hapusracikandokter/' . $d['PharmacyCode'] .'/'. $headerRacik['Case ID']); ?>"" onclick="return confirm('Hapus?')" style="color:red"><i class="fa fa-fw fa-trash"></i></a></td></td>
                                                    <?php }else{ ?>
                                                    <?php } ?>
                                                </tr>
                                            <?php endforeach; ?>
                                        </table>
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td colspan="4">
                                    <a href="<?= base_url('RekamMedis/pemeriksaan/' . $CaseID .'/'. $mr); ?>" class="btn btn-danger">Kembali</a>
                                    </td>
                                </tr>        
                            </table>
                        </div>
                    </section>
                </div>
        <?php 
        $this->load->view('apotek/modalRacik');
        ?>