{% set patient = patientPayment.patient %}
{% set patientBilling = patientPayment.patientBilling %}
<!DOCTYPE html>
<html class="no-js" lang="en" dir="ltr">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Payment No. {{ patientPayment.paymentNoParsed }}</title>
</head>
<body style="font-family:'Arial'; font-size:15px;">
<div style="width: 816px; height: 1056px; box-sizing:border-box; padding:80px; margin: 0 auto; box-shadow:3px 1px 10px 1px; margin-top:25px;">
    {% set branch = patientPayment.patientBilling.healthFacilityForAddress|default('') %}
    {% set company = patientPayment.patientBilling.healthFacilityForAddress.company|default('') %}
    {% set street = patientPayment.patientBilling.healthFacilityForAddress.street|default('') %}
    {% set city = patientPayment.patientBilling.healthFacilityForAddress.city.desciption|default('') %}
    {% set postalCode = patientPayment.patientBilling.healthFacilityForAddress.postalCode.desciption|default('') %}

    {% if hasPrintBtn is defined and hasPrintBtn %}
        <div style="text-align: right; margin-bottom: 25px;">
            <a style="display: inline-block; padding: 10px 20px; border: 1px solid #e0e0e0; border-radius: 3px; color: #353535;" href="{{ path('patient_payment_receipt_print', {id: patientPayment.idEncoded}) }}">Download</a>
        </div>
    {% endif %}
    <div style="width:100%; height:175px;">
        <div style="width:50%; float: left;">
            <p style="font-size:16px; font-weight:500; margin-top:0; margin-bottom:5px;"><b>{{ company.description|default('') }}</b></p>
            {#<p style="font-size:16px; font-weight:500; margin-top:0; margin-bottom:5px;"><b>{{ branch.description|default('') }}</b></p>#}
            <p style=" margin:3px 0; font-size: 12px;">{{ street }}</p>
            <p style=" margin:3px 0; font-size: 12px;">{{ city }} {{ postalCode }}</p>
            <p style=" margin:3px 0; font-size: 12px;">{{ branch.concatenatedPhoneNo|default('') }}</p>
            <p style=" margin:3px 0; font-size: 12px;">{{ branch.concatenatedMobileNo|default('') }}</p>
        </div>
        <div style="width:50%; height:auto; float: right; text-align: right;">
            <img src="{{ app.request.getSchemeAndHttpHost() ~ company.photoWebPath }}" style="width: 40%;"/>
        </div>
    </div>
    <div style="width:100%; height:100px; margin-top: 20px;">
        <div style="width:50%; float: left;">
            <p style="font-size:18px; font-weight:500; margin-top:0; margin-bottom:5px;">Received from</p>
            <p style=" margin:3px 0;">{{ patient.firstName }} {{ patient.lastName }}</p>
        </div>
        <div style="width:50%; height:auto; float: right; text-align: right;">
            <p><strong>Date :</strong> {{ patientPayment.payDateAsString }}</p>
            <p>Reference No: {{ patientPayment.paymentNoParsed }}</p>
        </div>
    </div>
    <div style="width:100%; height:auto;">
        <table style="width:100%; border-collapse: collapse;">
            <thead>
            <tr style="border-bottom: 1px dashed #676767;">
                <td style="padding: 5px;">Invoice Number</td>
                <td style="padding: 5px;">Invoice Date</td>
                <td style="padding: 5px;">Due Date</td>
                <td style="text-align: right; padding: 5px;">Original Amount</td>
                <td style="text-align: right; padding: 5px;">Balance</td>
                <td style="text-align: right; padding: 5px;">Payment</td>
            </tr>
            </thead>
            <tr>
                <td style="padding: 5px;">{{ patientBilling.invoiceNo }}</td>
                <td style="padding: 5px;">{{ patientBilling.billingDateAsString }}</td>
                <td style="padding: 5px;">{{ patientBilling.dueDateAsString }}</td>
                <td style="text-align: right; padding: 5px;">{{ patientPayment.billDueAmount|number_format(2, '.', ',') }}</td>
                <td style="text-align: right; padding: 5px;">{{ patientPayment.billBalAmount|number_format(2, '.', ',') }}</td>
                <td style="text-align: right; padding: 5px;">{{ patientPayment.amount|number_format(2, '.', ',') }}</td>
            </tr>
        </table>
        <h4 style="margin-bottom: 0">Breakdown</h4>
        <table style="width:100%; border-collapse: collapse;">
            <thead>
            <tr style="border-bottom: 1px dashed #676767;">
                <td style="padding: 5px;">Item</td>
                <td style="text-align: right; padding: 5px;">Qty</td>
                {#<td style="text-align: right; padding: 5px;">Balance</td>#}
                <td style="text-align: right; padding: 5px;">Amount</td>
            </tr>
            </thead>
            {% for ppb in patientPayment.patientPaymentBreakdowns if ppb.amount > 0 %}
                {% set pbb = ppb.patientBillingBreakdown %}
                {% set isReturn = pbb.status == constant('RxconnexionBundle\\Entity\\PatientBillingBreakdownEntity::STATUS_RETURN') ? true : false %}
                {% if pbb.type == constant('RxconnexionBundle\\Entity\\PatientBillingBreakdownEntity::TYPE_CHART_PROCEDURE') %}
                    {% set item = pbb.patientChart.idAndChartDateAndChartType|default('') %}
                {% elseif pbb.type == constant('RxconnexionBundle\\Entity\\PatientBillingBreakdownEntity::TYPE_ITEM') %}
                    {% set item = pbb.item.description|default('') %}
                {% elseif pbb.type == constant('RxconnexionBundle\\Entity\\PatientBillingBreakdownEntity::TYPE_OTHER') %}
                    {% set item = pbb.description %}
                {% else %}
                    {% set item = '' %}
                {% endif %}
                <tr {{ isReturn == true ? 'style="text-decoration: line-through;cursor:help;color:#666" title="This Invoice Item is returned" ' }} >
                    <td style="padding: 5px;">{{ item }}</td>
                    <td style="text-align: right; padding: 5px;">{{ pbb.quantity }}</td>
                    {#<td style="text-align: right; padding: 5px;">{{ (pbb.amountBalance < 0 ? 0 : pbb.amountBalance)|number_format(2, '.', ',') }}</td>#}
                    <td style="text-align: right; padding: 5px;">{{ ppb.amount|number_format(2, '.', ',') }}</td>
                </tr>
            {% endfor %}
        </table>
    </div>
    <div style="width:100%; height:175px;">
        <div style="width:50%; height: 155px; float:left;">
            <br>
            <h5>Payment: {{ patientPayment.payTypeForPrint }}</h5>
            <h5>ALL SALES ARE FINAL</h5>
        </div>
        <div style="width:50%; height: 155px; float:right;">
            <br>
            <table style="width:100%">
                {#<tr>
                    <td style="width:50%;">Amount Credited</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td style="text-align: right;">0.00</td>
                </tr>#}
                <tr>
                    <td>Total</td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td style="text-align: right; font-size:20px;">{{ patientPayment.amount|number_format(2, '.', ',') }}</td>
                </tr>
            </table>
        </div>
    </div>
</div>
</body>
</html>