{% extends '@RxConnexion/Admin/global.html.twig' %}
{% block body %}
    <h5 class="report-header">{{ page_title }}</h5>
    {% if userData.type == 'Super Admin' or 'Admin Report Transfer' in userData.accesses %}
        <div class="text-right">
            <a class="href-transfer-form href-new-action button" href="javascript:void(0)" >Transfer</a>
        </div>
    {% endif %}
    <table class="report-data" id="patient-report-list" 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>Mobile 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.mobileNo }}</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>
    <div class="reveal small" id="modal-small" style="top: -12% !important;" data-reveal>
        <div id="modal-content-small"></div>
        <button class="close-button" data-close aria-label="Close modal" type="button">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script>
        //<![CDATA[
        jQ(document).ready(function(){
            report_preview.settings.transfer_formUrl= '{{ path('report_transfer') }}' ;
            report_preview.settings.transfer_formActionUrl= '{{ path('report_transfer_save') }}';
            report_preview.init();
        });
        //]]>
    </script>
{% endblock %}