<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: 2px;"><?= $abdulradjak['NamaPerusahaan']; ?></h3>
            <p style="margin-top: -10px;"><?= $abdulradjak['AlamatPerusahaan']; ?></p>
            <p style="margin-top: -10px;"> Daerah Kabupaten Bogor</p>
            <p style="margin-top: -10px;"><?= $abdulradjak['TeleponPerusahaan']; ?>, Fax : <?= $abdulradjak['FaxPerusahaan']; ?></p>
        </td>
    </tr>
</table>
<hr>
<br>

<?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" 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>

        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Penjamin</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>
    </tr>
</table>

       <?php
        $idS = $this->uri->segment(3);
        $sIds = $this->db->query("SELECT * FROM ApotikHeader WHERE TransactionID = '$idS'")->row_array();
        ?>
<hr><br>
<table border="1" style="padding: 5px;" align="center">
<tr>
    <td colspan="4"  align="center"><b>Lab Result</b></td>
</tr>
    <tr> 
        <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PEMERIKSAAN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
        <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HASIL PEMERIKSAAN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
        <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NILAI NORMAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
    </tr>

    <?php foreach ($group as $group) : ?>
        <tr>
            <td colspan="3"  align="center"><b><?= $group['BahasaLC'] ?></b></td>
        </tr>
        <?php endforeach; ?>
        <?php foreach($viewlab as $d) : ?>
            <tbody>
    <tr>
            <td><?= $d['Bahasa']; ?></td>
            <td><?= $d['ResultValue']; ?></td>
            <td><?= $d['Normalvalue']; ?></td>
            <!-- <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catatan</th> -->
        </tbody>
    </tr>

    <?php 
endforeach; ?>

    <tr>
        <td colspan="4" align="right">
            <small><i>**cetak <?= date('d-m-Y H:i:s'); ?></i></small>
        </td>
    </tr>
</table>
<br><br>
<br><br>
        <table width="100%">
                    <tr>
                        <td align="center"></td>
                        <td align="center">
                            Jakarta, <?= date('d F Y'); ?> <br>
                            Jam <?= date('H:i'); ?>
                            <br><br>
                        </td>
                    </tr>
                    <tr>
                        <td align="center">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        </td>
                        <td align="center">
                        <img width="156" height="147" src="<?= base_url('images/uploadsign/laboratorium/tandatanganpetugas.png'); ?>" alt="">
                            <br>
                            <p>
                                (nama jelas)
                            </p>
                        </td>
                    </tr>
                </table>



<script>
            window.onload = function() {
                window.print();
                setTimeout(window.close, 500);
            };
        </script>