<!DOCTYPE html>
<html>

<head>
    <title>Print Invoice</title>

    <style>
        body {
            font-family: monospace;
            font-size: 14px;
        }

        .page {
            width: 64%;
            margin: 0 auto;
        }

        @page {
            size: A4;
            margin: 0;
        }

        @media print {

            html,
            body {
                font-family: Arial, Helvetica, sans-serif;
            }

            .page {
                width: 64%;
                margin: 0 auto;
                border: initial;
                border-radius: initial;
                min-height: initial;
                box-shadow: initial;
                background: initial;
                page-break-after: always;
            }
        }

        .patient_copy {
            page-break-after: always;
            display: block;
            margin-top: 100px;
        }

        .diagnostic_copy {
            display: block;
            margin-top: 100px;
        }

        .title {
            width: 80%;
            font-size: 14px;
            font-weight: bold;
            border: 1px solid #333;
            padding: 5px;
            font-family: monospace;
            text-transform: uppercase;
            letter-spacing: 2px;
            border-radius: 3px;
            text-align: center;
            margin: 3px auto;
        }

        .paid {
            width: 25%;
            margin: 30px auto 0 auto;
            text-align: center;
            font-size: 25px;
            font-weight: bold;
            background: #eee;
            border: 1px solid #000;
            padding: 3px 10px;
            font-family: monospace;
            text-transform: uppercase;
            letter-spacing: 5px;
            border-radius: 3px;
        }

        .table {
            font-size: 14px;
            width: 100%;
            border-collapse: collapse;
        }

        .patient_table {
            width: 100%;
            text-align: left;
            border-collapse: collapse;
            margin-top: 5px;
        }

        .patient_table tbody td {
            color: #000;
            padding: 2px;
            vertical-align: top;
            
        }

        /* test_table */
        .test_table {
            margin-top: 10px;
            width: 100%;
            text-align: left;
            border-collapse: collapse;
            border: 1px solid #000;
        }

        .test_table tbody td {
            color: #000;
            padding: 0px 4px;
            vertical-align: top;
            border-top: 1px solid #000;
        }

        /*  payment_info*/
        .payment_table {
            font-size: 14px;
            width: 100%;
            text-align: left;
        }

        .payment_table tbody td {
            vertical-align: top;
            border: 0;
        }
    </style>
</head>

<body>
    <div class="page">
        <div class="patient_copy">
          	<table class="table top-header" style="text-align: center; margin-top:5px;">
                <tbody>
                    <img src="<?php echo IMG_URL; ?>bill_head.png" alt="h" width="100%">
                </tbody>
            </table>
          <table class="table">
          	<tr>
              <td style="width: 25%;">
                <img align="left" src="<?php echo site_url('opd/set_barcode/' . $patient->patient_unique_id); ?>" alt="" height="30" width="80%">
              </td>
              <td>
              	<div class="title">Patient Copy</div>
              </td>
              <td style="width: 25%;">
              	<img align="right" src="<?php echo site_url('opd/set_barcode/' . $patient->patient_unique_id); ?>" alt="" height="30" width="80%">
              </td>            
            </tr>
          </table>  
            
            <!-- Patient Info Start-->
            <table class="table patient_table" style="border: 1px solid #000;">
                <tr>
                  	<td style="width: 50%;">
                        <span>Name :</span>
                        <span style="text-transform: uppercase; font-weight: bold;"><?php echo $patient->patient_name; ?></span>
                    </td>
                    <td style="width: 35%;">
                        <span>Patient ID :</span>
                        <span style="text-transform: uppercase; font-weight: bold;"><?php echo $patient->patient_unique_id; ?></span>
                    </td>
                    
                </tr>
                <tr>
                    <td>
                        <span>Age :</span>
                        <span style="text-transform: uppercase; font-weight: bold;"><?php echo $patient->dob != NULL ? floor((time() - strtotime($patient->dob)) / 31556926) : ''; ?>Y</span>
                    </td>
                  	<td>
                        <span>Date :</span>
                        <span><?php echo date('d/m/Y h:i A'); ?></span>
                    </td>
                </tr>
                <tr>                    
                    <td>
                        <span>Gender :</span>
                        <span style="text-transform: capitalize; font-weight: bold;"><?php echo $this->lang->line($patient->gender); ?></span>
                    </td>
                    <td>
                        <span>Contact No :</span>
                        <span style="text-transform: uppercase; font-weight: bold;"><?php echo $patient->phone; ?></span>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <span>Ref. By :</span>
                        <span style="font-size:12px; text-transform: uppercase; font-weight: bold;">
                            <?php echo $patient->doctor ? $patient->doctor . ', ' . $patient->specialist : ''; ?>
                        </span>
                    </td>
                </tr>
            </table>
            <!-- Patient Info End-->



            <?php if (isset($invoices) & !empty($invoices)) { ?>
                <table class="test_table">
                    <tbody>
                        <tr>
                            <td width="15%" align="left"><b>SL. No</b></td>
                            <td width="25%" align="left"><b>Invoice No</b></td>
                            <td width="45%" align="left"><b>Date</b></td>
                            <td width="15%" align="left"><b>Amount</b></td>
                        </tr>
                        <?php
                        $count = 1;
                        $total = 0; ?>
                        <?php foreach ($invoices as $obj) {
                            $total  += $obj->amount; ?>
                            <tr>
                                <td align="left"><?php echo $count++; ?></td>
                                <td align="left"><?php echo $obj->custom_invoice_id; ?></td>
                                <td align="left"><?php echo date('d/m/Y h:i A', strtotime($obj->payment_date)); ?></td>
                                <td align="right"><?php echo $obj->amount; ?></td>
                            </tr>
                        <?php } ?>

                        <tr>
                            <td colspan="4">
                                <table class="table">
                                    <tr>
                                        <td width="62%" style="border: 0;">
                                            <div class="paid" style="margin-bottom: 0; padding-bottom: 0;">
                                                Paid
                                            </div>
                                            <p style="text-align: center; margin-bottom: 20px;"><b>In Word:</b> <span style="font-size: 12px;"><?php echo $this->numbertowords->convert_number($total); ?> Taka Only.</span></p>
                                        </td>
                                        <td width="38%" style="border: 0;">
                                            <table class="table">
                                                <tr>
                                                    <td style="border-top: 1px dashed #ccc;text-align: left;">Total Advance Tk.</td>
                                                    <td style="border-top: 1px dashed #ccc;text-align: right;"><?php echo $total; ?></td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </tbody>
                </table>
            <?php } ?>
            <p style="margin-top:30px;">
                <span style="font-size: 14px; font-weight: bold;">Prepared By:</span>
                <?php echo $this->session->userdata('name'); ?>
            </p>
        </div>
    </div>
</body>

</html>