{% extends '@RxConnexion/Admin/global.html.twig' %}
{% block body %}
    <h5 class="report-header" style=" width:100%">{{ page_title }}</h5>
    {% if type == 'an' %}
        <table class="report-data" width="100%">
            <thead class="header">
            <tr>
                <th>Date/Time</th>
                <th>Fax No.</th>
                <th>Patient</th>
                <th></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>{{ record.createdAt }}</td>
                    <td>{{ record.faxNo }}</td>
                    <td><a href="{{ path('patient_detail', {patient_id : record.patientId|base64Encode}) }}" target="_blank">{{ record.patientName }}</a></td>
                    <td><a href="{{ path('appointment_fax_preview', {anf_id : record.anfId|default('null')|base64Encode}) }}" target="_blank">View</a></td>
                </tr>
            {% endfor %}
        </table>
    {% endif %}

    {% if type == 'pl' %}
        <table class="report-data" width="100%">
            <thead class="header">
            <tr>
                <th>Date/Time</th>
                <th>Fax No.</th>
                <th>Patient</th>
                <th>Letter Type</th>
                <th></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>{{ record.createdAt }}</td>
                    <td>{{ record.faxNo }}</td>
                    <td><a href="{{ path('patient_detail', {patient_id : record.patientId|base64Encode,tab:'pl'}) }}" target="_blank">{{ record.patientName }}</a></td>
                    <td>{{ record.letter_type }}</td>
                    <td><a href="{{ path('patient_letter_preview', {patientLetter_id : record.patientId|default('null')|base64Encode, letter_type : record.letter_type|default('null')}) }}" target="_blank">View</a></td>
                </tr>
            {% endfor %}
        </table>
    {% endif %}

    {% if type == 'fo' %}
        <table class="report-data" width="100%">
            <thead class="header">
            <tr>
                <th>Date/Time</th>
                <th>Fax No.</th>
                <th>Patient</th>
                <th></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>{{ record.createdAt }}</td>
                    <td>{{ record.faxNo }}</td>
                    <td><a href="{{ path('patient_detail', {patient_id : record.patientId|base64Encode}) }}" target="_blank">{{ record.patientName }}</a></td>
                    <td><a href="{{ path('faxing_option_preview', {faxingOption_id : record.faxingOption_id|default('null')|base64Encode}) }}" target="_blank">View</a></td>
                </tr>
            {% endfor %}
        </table>
    {% endif %}
    <div>Total Records: {{ totalCount }}</div>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script>
        //<![CDATA[
        jQ(document).ready(function(){
            report_preview.init();
        });
        //]]>
    </script>
{% endblock %}