{% extends '@RxConnexion/Admin/global.html.twig' %}
{% block body %}
    <h5 class="report-header">{{ page_title }}</h5>
    {% for branch in records.branch %}
        {% for record in records.counts %}
            {% if branch.id == record.health_facility_id %}
                <h4 class="report-header">{{ branch.description }}</h4>
                <table class="report-data" width="100%">
                    <thead class="header">
                    <tr>
                        <th>Appointments</th>
                        {% set start_date = date_from|date('d-m-Y') %}
                        {% set end_date = date_to|date('d-m-Y') %}
                        {% for x in range(start_date|date('U'), end_date|date('U'), 86400 ) %}
                            <th>
                                <div>{{ x|date('l') }}</div>
                                <div>{{ x|date('m/d/Y') }}</div>
                            </th>
                        {% endfor %}
                    </tr>
                    </thead>
                    <tbody>
                    {% for record in records.counts %}
                        <tr>
                            <td>{{ record.chartType }}</td>
                            {% for x in range(start_date|date('U'), end_date|date('U'), 86400 ) %}
                                {% for record2 in records.counts %}
                                    {% if x|date('m/d/Y') == record2.scheduleDate|date('m/d/Y') and record.chartType == record2.chartType %}
                                        <td>{{ record.cnt }}</td>
                                    {% endif %}
                                {% endfor %}
                            {% endfor %}
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            {% endif %}
        {% endfor %}
    {% endfor %}

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