{% 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>Patient</th>
            <th>City</th>
            <th>Province</th>
            <th>Postal Code</th>
            <th>Branch</th>
            <th>Company</th>
            <th>Patient Insurance</th>
            <th>Status</th>
        </tr>
        </thead>
        <tbody>
        {% set totalCount = 0 %}
        {% for record in records %}
            {% set trC = loop.index > 1 and loop.index % 2 == 0 ? 'even' : 'odd' %}
            {% set totalCount = totalCount + 1 %}
            <tr class="{{ trC }}">
                <td><a href="{{ path('patient_detail', {patient_id : record.patientId|base64Encode}) }}" target="_blank">{{ record.fullName }}</a></td>
                <td>{{ record.cityDesc }}</td>
                <td>{{ record.patientProvince }}</td>
                <td>{{ record.postalCode }}</td>
                <td>{{ record.patientBranch }}</td>
                <td>{{ record.companyDesc }}</td>
                <td>{{ record.patientInsurance }}</td>
                <td>{{ record.is_active ? 'Active' : 'Inactive' }}</td>
            </tr>
        {% endfor %}
    </table>
    <div>Total Records: {{ totalCount }}</div>
    <br>
    <h3>Summary</h3>
    <div style="border: 1px solid; padding: 25px; margin: 10px;">
        {% if sum_branch != 'null' %}
            <ul>
                {% for key,br in summary.branch %}
                    <li>
                        {{ key }}: {{ br }}
                    </li>
                {% endfor %}
            </ul>
        {% endif %}

        {% if sum_prov != 'null' %}
            <ul>
                {% for key,prov in summary.province %}
                    <li>
                        {{ key }}: {{ prov }}
                    </li>
                {% endfor %}
            </ul>
        {% endif %}

        <ul>
            <li>Active: {{ active_count ? active_count.active : '0' }}</li>
            <li>Inactive: {{ active_count ? active_count.inactive : '0' }}</li>
        </ul>

        {% if sum_post != 'null' %}
            <ul>
                {% for key,pos in summary.postal_code %}
                    <li>
                        {{ key }}: {{ pos }}
                    </li>
                {% endfor %}
            </ul>
        {% endif %}
    </div>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script>
        //<![CDATA[
        jQ(document).ready(function(){
            report_preview.init();
        });
        //]]>
    </script>
{% endblock %}