<?php


$c = $id['CompanyCode'];
$com = $this->db->query("SELECT * FROM Company WHERE CompanyCode = '$c'")->row_array();
$case = $this->uri->segment(4);
$dList = $this->db->query("SELECT AA.[Case ID] AS ID, C.PatientCode AS MR, C.Description AS Nama, C.[Intake Date] AS Kunjungan , P.DOB AS TTL FROM [Activity Drugs] AA, Pharmacy PC, Cases C, Patient P WHERE AA.[DrugsID]=PC.PharmacyCode AND AA.[Case ID]=C.[Case ID] AND C.PatientCode=P.PatientCode AND AA.[Case ID] = '$case'")->row_array();

$tgll = date('Y-m-d', strtotime(@$dList['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;
?>
<table>
    <tr>
        <td style="width:110px;">
            <b style="font-size:9px;">NO :
                <?= $dList['ID']; ?>
            </b>
        </td>
        <td align="right"  style="width:160px;">
            <label style=" font-size:9px;"><?= date('d-m-Y h:i:s', strtotime($dList['Kunjungan'])); ?></label>
        </td>
    </tr>
</table>
<table>
    <tr>
        <td style="width:160px;">
            <b style="font-size:9px;"><?= $dList['Nama']; ?></b>
        </td>
        <td align="right" style="width:260px;">
            <label style=" font-size:9px;"><?= $dList['MR']; ?></label>
        </td>
    </tr>
</table>
<table>
    <tr>
        <td align="center">
            <b style="font-size:9px">
                <?php
                if ($dList['TTL'] == '') {
                } else {
                    echo $thn . ' tahun ' . $bln . ' bulan ' . $tgl . ' hari';
                }
                ?>
            </b>
        </td>
        <td align="center" width="20px">
            <label style="margin-top: 2px; font-size:9px;"></label>
        </td>
        <td align="center" width="20px">
            <label style=" font-size:9px;"></label>
        </td>
    </tr>
</table>
<hr style="  border: none;
  border-top: 1px dotted #f00;
  color: #000;
  background-color: #fff;
  height: 1px;
  width: 50%;">

<table style="margin:0px;" align="center">
    <tr>
        <td align="center">
            <label style='font-size:12px;font-weight:bold;'><?= $Obat['Description']; ?></label>
        </td>
    </tr>
    <tr>
        <td align="center">
            <label style='font-size:8px'><?= $Obat['Aturan']; ?></label>
        </td>
    </tr>
    <tr>
        <td align="center">
            <label style='font-size:8px'><?= $Obat['Cara']; ?></label>
        </td>
    </tr>
    <tr>
        <td align="center">
            <label style='font-size:8px'><?= $Obat['Ket']; ?></label>
        </td>
    </tr>
    <tr>
        <td align="center">
            <label style='font-size:7px'>Semoga Lekas Sembuh
            </label>
        </td>
    </tr>
</table>
<br>