<?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><?= $catatanKb['Description']; ?></td>
                                    </tr>
                                    <tr>
                                        <td>No.RM Pasien</td>
                                        <td>:</td>
                                        <td><?= $catatanKb['PatientCode']; ?></td>
                                    </tr>
                                    <tr>
                                        <td>Tanggal Lahir / Umur</td>
                                        <td>:</td>
                                        <td>
                                            <?= date('d F Y', strtotime($catatanKb['DOB'])); ?> /
                                            <?php
                                            // tanggal lahir
                                            $dob = date('Y-m-d', strtotime($catatanKb['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><?= $catatanKb['HomeAddress1']; ?></td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                    <p align="center"><b>Catatan Riwayat KB</b></p>
                    </div>
                    <table border="1" style="width: 100%; border-collapse: collapse;">
                        <tr>
                            <td colspan="3" style="text-align: center;"><b>Riwayat Haid</b></td>
                        </tr>
                        <tr>
                            <td>Menerche</td>
                            <td>:</td>
                            <td><?= $catatanKb['menerche']; ?></td>
                        </tr>
                        <tr>
                            <td>Lamanya</td>
                            <td>:</td>
                            <td><?= $catatanKb['lamanya']; ?></td>
                        </tr>
                        <tr>
                            <td>Banyaknya</td>
                            <td>:</td>
                            <td><?= $catatanKb['banyaknya']; ?></td>
                        </tr>
                        <tr>
                            <td>Dysmenore</td>
                            <td>:</td>
                            <td><?= $catatanKb['dysmenore']; ?></td>
                        </tr>
                        <tr>
                            <td>Haid Terakhir</td>
                            <td>:</td>
                            <td><?= $catatanKb['haid_terakhir']; ?></td>
                        </tr>
                        <tr>
                            <td colspan="3" style="text-align: center;"><b> Riwayat Penyakit / Keluarga </b></td>
                        </tr>
                        <tr>
                            <td>Jantung</td>
                            <td>:</td>
                            <td><?= $catatanKb['Jantung']; ?></td>
                        </tr>
                        <tr>
                            <td>Paru - Paru</td>
                            <td>:</td>
                            <td><?= $catatanKb['Paru']; ?></td>
                        </tr>
                        <tr>
                            <td>Hipertensi</td>
                            <td>:</td>
                            <td><?= $catatanKb['Hipertensi']; ?></td>
                        </tr>
                        <tr>
                            <td>Diabetes Militus</td>
                            <td>:</td>
                            <td><?= $catatanKb['Diabet']; ?></td>
                        </tr>
                        <tr>
                            <td>Pms</td>
                            <td>:</td>
                            <td><?= $catatanKb['Pms']; ?></td>
                        </tr>
                        <tr>
                            <td colspan="3" style="text-align: center;"><b> Riwayat KB </b></td>
                        </tr>
                        <tr>
                            <td>Metode KB</td>
                            <td>:</td>
                            <td><?= $catatanKb['metode_kb']; ?></td>
                        </tr>
                        <tr>
                            <td>Lamanya Haid</td>
                            <td>:</td>
                            <td><?= $catatanKb['lamanya1']; ?></td>
                        </tr>
                        <tr>
                            <td>Keluhan</td>
                            <td>:</td>
                            <td><?= $catatanKb['keluhan']; ?></td>
                        </tr>
                        <tr>
                            <td>KB Pilihan Saat Ini</td>
                            <td>:</td>
                            <td><?= $catatanKb['kbpilihan']; ?></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>
            </table>
                </div>
            </div>
        </div>
    </section>
</div>
<script>
        window.onload = function() {
            window.print();
            setTimeout(window.close, 500);
        };
</script>