{% set absUrl = app.request.getSchemeAndHttpHost() ~ app.request.baseUrl|replace({'/app_dev.php': ''}) %}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="{{ absUrl ~ asset('bundles/rxconnexion/admin/css/report/report_wkpdf.css') }}" />
</head>
<body>
    <h2><strong>{{ page_title }}</strong></h2>
    <table class="report-data" width="100%">
        <thead class="header">
        <tr>
            <th>
                {% if userData.type == 'Super Admin' or 'Admin Report Transfer' in userData.accesses %}
                    <input type="checkbox" id="check_all">
                    &nbsp;
                {% endif %}
                Patient
            </th>
            <th>City</th>
            <th>Province</th>
            <th>Postal Code</th>
            <th>Branch</th>
            <th>Company</th>
            <th>Phone No.</th>
            <th>Email Address</th>
            <th>Referring Physician</th>
            <th>Referring Affiliate</th>
            <th>Primary Clinician</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>
                    {% if userData.type == 'Super Admin' or 'Admin Report Transfer' in userData.accesses %}
                        <input type="checkbox" data-id="{{ record.patientId|base64Encode }}">
                        &nbsp;
                    {% endif %}
                    <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.phoneNo }}</td>
                <td>{{ record.email }}</td>
                <td>{{ record.referringProvider }}</td>
                <td>{{ record.referringHealthFacility }}</td>
                <td>{{ record.primaryClinician }}</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>
</body>
</html>