<?php
date_default_timezone_set("Asia/Jakarta");
?>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <!-- Main content -->
    <section class="content">


        <div class="card" style="padding: 15px; background-color: white;border-radius: 5px;">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-7">
                        <table>
                            <tr>
                                <td>
                                    <img src="<?= base_url('images/logo.png'); ?>" height="80px">
                                </td>
                                <td valign="top">
                                    <h4 style="font-weight: bold;">
                                        <?= $abdulradjak['NamaPerusahaan']; ?>
                                    </h4>
                                    <p>
                                        <?= $abdulradjak['AlamatPerusahaan']; ?>
                                    </p>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="col-md-5">
                        <div class="card" style="padding: 10px; border: 1px solid gray; border-radius: 5px; font-size: 9pt;">
                            <div class="card-body">
                                <table width="100%">
                                    <tr>
                                        <td width="30%">Nama</td>
                                        <td width="5%">:</td>
                                        <td><?= $datahamil['Description']; ?></td>
                                    </tr>
                                    <tr>
                                        <td>No.RM Pasien</td>
                                        <td>:</td>
                                        <td><?= $datahamil['PatientCode']; ?></td>
                                    </tr>
                                    <tr>
                                        <td>Tanggal Lahir / Umur</td>
                                        <td>:</td>
                                        <td>
                                            <?= date('d F Y', strtotime($datahamil['DOB'])); ?> /
                                            <?php
                                            // tanggal lahir
                                            $dob = date('Y-m-d', strtotime($datahamil['DOB']));
                                            $tanggal = new DateTime($dob);

                                            // tanggal hari ini
                                            $today = new DateTime('today');

                                            // tahun
                                            $y = $today->diff($tanggal)->y;

                                            // bulan
                                            $m = $today->diff($tanggal)->m;

                                            // hari
                                            $d = $today->diff($tanggal)->d;
                                            echo  $y . " tahun ";
                                            ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Alamat</td>
                                        <td>:</td>
                                        <td><?= $datahamil['HomeAddress1']; ?></td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                <p align="center"><b>Kehamilan Saat Ini</b></p>
                <p align="center"><b>Catatan Awal Kehamilan</b></p>
            </div>
            <table border="1" style="width: 100%; border-collapse: collapse;">
            <tr>
                <td>Hari Pertama Haid Terakhir (HPHT)</td>
                <td>:</td>
                <td><?= $datahamil['hpht']; ?></td>
            </tr>
            <tr>
                <td>Hari Taksiran Peralinan(HTP)</td>
                <td>:</td>
                <td><?= $datahamil['htp']; ?></td>
            </tr>
            <tr>
                <td>GolonganDarah</td>
                <td>:</td>
                <td><?= $datahamil['GolonganDarah']; ?></td>
            </tr>
            <tr>
                <td>Penggunaan Kontrasepsi Sebelum Hamil</td>
                <td>:</td>
                <td><?= $datahamil['namakontrasepsi']; ?></td>
            </tr>
            <tr>
                <td>Riwayat Penyakit yang Diderita Ibu</td>
                <td>:</td>
                <td><?= $datahamil['penyakitygdiderita']; ?></td>
            </tr>
            <tr>
                <td>Riwayat Alergi</td>
                <td>:</td>
                <td><?= $datahamil['riwayatalergi']; ?></td>
            </tr>
            <tr>
                <td>Status Imunisasi Tetanus (T) Terakhir</td>
                <td>:</td>
                <td><?= $datahamil['statusimunisasi']; ?></td>
            </tr>
            </table>
            <table border="1" style="width: 100%; border-collapse: collapse; text-align:center;">
            <tr>
                <td>G</td>
                <td><?= $datahamil['g']; ?></td>

                <td>P</td>
                <td><?= $datahamil['p']; ?></td>

                <td>A</td>
                <td><?= $datahamil['a']; ?></td>

                <td>TB</td>
                <td><?= $datahamil['tb']; ?></td>
            </tr>
            </table>

            <br><br>
            <table align="center" width="90%" style="font-size: 12pt;">
                <tr align="center">
                    <td>
                        <?php
                        date_default_timezone_set("Asia/Jakarta");
                        $tgl =  date("d/m/Y");
                        'Bogor' . ', ' . $tgl; ?><br>
                        Mengetahui,
                        <br><br><br><br><br>
                        ( ................... )
                    </td>
                    <td></td>
                    <td>
                        <br>
                        Pasien,
                        <br><br><br><br><br>
                        ( ..................... )
                    </td>
                </tr>
                <tr>
                    <td colspan="4" align="right">
                        <small><i>**cetak <?= date('d-m-Y H:i:s'); ?></i></small>
                    </td>
                </tr>
            </table>
        </div>
    </section>
</div>
<script>
        window.onload = function() {
            window.print();
            setTimeout(window.close, 500);
        };
</script>