{% extends '@RxConnexion/Admin/global.html.twig' %}
{% block body %}
    <h3 class="report-header"><strong>{{ page_title }}</strong> From: {{ dateFrom }} To: {{ dateTo }}</h3>

    {% for record in records %}
        <div>
            <h4 style="background-color: #4ccfdd"><strong style="color: #0a0a0a;">{{ record.description }}</strong></h4>
        </div>
        <table>
            <thead>
                <tr>
                    <th style="background-color: #b2b2b2"><span style="color: #000000">Activity/Services</span></th>
                    {% for provider in record.providers %}
                        <th style="background-color: #b2b2b2"><span style="color: #000000">{{ provider.name }}</span></th>
                    {% endfor %}
                    <th style="background-color: #b2b2b2"><span style="color: #000000">Total</span></th>
                </tr>
            </thead>
            <tbody>
            {% for chartType in record.chartTypes %}
                {% set total_activity = 0 %}
                <tr>
                    <td style="background-color: #b2b2b2"><span style="color: #000000">{{ chartType.description }}</span></td>
                    {% for provider in record.providers %}
                        {% set hasTD = false %}
                        {% for pr in chartType.providers if pr.id == provider.id %}
                            {% set hasTD = true %}
                            <td>{{ pr.count }}</td>
                            {% set total_activity = total_activity + pr.count %}
                        {% endfor %}
                        {% if not hasTD %}
                            <td>0</td>
                        {% endif %}
                    {% endfor %}
                    <td><strong>{{ total_activity }}</strong></td>
                </tr>
            {% endfor %}

            <tr style="border-top: 1px solid #aaaaaa;">
                <td><b>Total:</b></td>
                {% for provider in record.providers  %}
                    {% set total_prov = 0 %}
                    {% for chartType in record.chartTypes  %}
                        {% for pr in chartType.providers if pr.id == provider.id  %}
                            {% set total_prov = total_prov + pr.count %}
                        {% endfor %}
                    {% endfor %}
                    <td><strong>{{ total_prov }}</strong></td>
                {% endfor %}
            </tr>
            </tbody>
        </table>
    {% endfor %}

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