{% extends '@RxConnexion/Admin/global.html.twig' %}
{% block body %}
    <h5 class="report-header">{{ page_title }}</h5>
    <table class="report-data" width="100%">
        <thead class="header">
        <tr>
            <th>Previous System Invoice No.</th>
            <th>Previous System Invoice Branch</th>
            <th>Payment Type</th>
            <th>Company</th>
            <th>Branch</th>
            <th>Patient</th>
            <th>Pay Date</th>
            <th style="text-align: right">Amount</th>
            <th>Status</th>
            <th>Note</th>
        </tr>
        </thead>
        <tbody>
        {% set totalCount = 0 %}
        {% set totalAmount = 0 %}
        {% for record in records %}
            {% set trC = loop.index > 1 and loop.index % 2 == 0 ? 'even' : 'odd' %}
            {% set totalCount = totalCount + 1 %}
            {% set totalAmount = totalAmount + record.amount %}
            <tr class="{{ trC }}">
                <td>{{ record.prev_sys_invoice_no }}</td>
                <td>{{ record.prev_sys_invoice_branch }}</td>
                <td>{{ record.pay_type }}</td>
                <td>{{ record.companyDesc }}</td>
                <td>{{ record.branchDesc }}</td>
                <td><a href="{{ path('patient_detail', {patient_id : record.patientId|base64Encode, tab : 'b'}) }}" target="_blank">{{ record.patientName }}</a></td>
                <td>{{ record.pay_date }}</td>
                <td class="text-right">{{ record.amount|number_format(2, '.', ',') }}</td>
                <td>{{ record.payment_status }}</td>
                <td>{{ record.note|raw }}</td>
            </tr>
        {% endfor %}
        <tr>
            <td colspan="6" style="text-align: right">
                <strong>{{ totalAmount|number_format(2, '.', ',') }}</strong>
            </td>
            <td></td>
            <td></td>
        </tr>
    </table>
    <div>Total Record(s): {{ totalCount }}</div>

    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script>
        //<![CDATA[
        jQ(document).ready(function(){
            report_preview.init();
        });
        //]]>
    </script>
{% endblock %}