<table width="100%" style="font-size:12pt;">
 <tr>
 <td width="20%">
<img src="<?= base_url('images/logo2.png') ?>" width="70" height="70" alt="">
 </td>
<td>
<h3  style="margin-top: -6px;">KLINIK PRATAMA dr.ABDUL RADJAK UNIT KALIDERES</h3>
<p style="margin-top: -10px;">Jl. Peta Selatan No.2, RT.10/RW.14, Kalideres, Kec. Kalideres, Kota Jakarta Barat,</p>
<p style="margin-top: -10px;"> Daerah Kabupaten Bogor</p>
<p style="margin-top: -10px;">Kode Pos 11840 Telp : (021) 5456027 (Hunting) </p>
</td></tr></table>
<hr>
<?php
date_default_timezone_set("Asia/Jakarta");
$tgll = date('Y-m-d', strtotime(@$id['TTL']));
$tanggal_lahir = new DateTime($tgll);
$sekarang = new DateTime("today");
if ($tanggal_lahir > $sekarang) {
    $thn = "0";
    $bln = "0";
    $tgl = "0";
}
$thn = $sekarang->diff($tanggal_lahir)->y;
$bln = $sekarang->diff($tanggal_lahir)->m;
$tgl = $sekarang->diff($tanggal_lahir)->d;

$c = $id['CompanyCode'];
$com = $this->db->query("SELECT * FROM Company WHERE CompanyCode = '$c'")->row_array();
$case = $id['ID'];
$idS = $this->uri->segment(3);
$dList = $this->db->query("SELECT * FROM [Activity Apotik] AA, Pharmacy PC WHERE AA.[DrugsID]=PC.PharmacyCode AND [TransactionID] = '$idS'")->result_array();
?>
<table border="0" style="border-collapse: collapse; width:100mm">
    <tr>
        <td>No.MR</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $id['MR']; ?></td>

        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;No.Reg</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $id['ID']; ?></td>
    </tr>
    <tr>
        <td>Nama</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $id['Nama']; ?></td>

        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tanggal Kunjungan</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= date('d-m-Y', strtotime($id['Kunjungan'])); ?></td>
    </tr>
    <tr>
        <td>Tanggal Lahir</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td>
            <?php
            if ($id['TTL'] == '') {
            } else {
                echo date('d-m-Y', strtotime($id['TTL']));
            }
            ?>
        </td>

        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Umur</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $thn . ' th ' . $bln . ' bulan ' . $tgl . ' hari'; ?></td>
    </tr>
    <tr>
        <td>Dokter</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $id['Dokter']; ?></td>

        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pembayar</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $com['CompanyName']; ?></td>
    </tr>
    <tr>
        <td>Poli</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $id['Poli']; ?></td>

        <?php
        $idS = $this->uri->segment(3);
        $sIds = $this->db->query("SELECT * FROM ApotikHeader WHERE TransactionID = '$idS'")->row_array();
        ?>

        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Waktu Transaksi</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $sIds['Transaction_Time']; ?></td>
    </tr>
</table>
<hr>
<?php
$caseid= $this->uri->segment(3);
$list = $this->db->query("SELECT epf.case_id , epf.erm_pemeriksaan_fisik_id, c2.CompanyName , p.FirstName , c.[Patient Status] , pr.header, pr.status , pr.createDate, epf.obat  FROM pemeriksaanRecord pr LEFT JOIN erm_pemeriksaan_fisik epf on epf.case_id = pr.caseId
JOIN Cases c on c.[Case ID] = epf.case_id JOIN Patient p on p.PatientCode = c.PatientCode JOIN Company c2 on c2.CompanyCode = c.CompanyCode 
WHERE epf.case_id = '$caseid' ")->result_array();
?>
<table border="1" style="border-collapse: collapse;">
    <tr>
        <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NamaObat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
        <!-- <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catatan</th> -->
    </tr>
    <?php
    foreach ($list as $data) :
    ?>
        <tr>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="font-size:7pt"><?= strip_tags((!empty($data['obat'])) ? $data['obat'] : '' ); ?></label> </td>
            <!-- <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catatan&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> -->
        </tr>
    <?php
    endforeach;
    ?>
    <tr>
        <td colspan="1" align="right">
            <small><i>**cetak <?= date('d-m-Y H:i:s'); ?></i></small>
        </td>
    </tr>
</table>