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

    <table>
        <thead>
        <tr>
            <th style="background-color: #b2b2b2"><span style="color: #000000">Activity/Services</span></th>
            {% for record in records %}
                {% for userBilling in record.auBilling %}
                    <th style="background-color: #b2b2b2"><span style="color: #000000">{{ userBilling.name }}</span></th>
                {% endfor %}
            {% endfor %}
            <th style="background-color: #b2b2b2"><span style="color: #000000">Total Actual Number</span></th>
        </tr>
        </thead>
        <tbody>
        {% set subTotal = 0 %}
        {% for record in records %}
            {% for chartType in record.chartTypes %}

                {% set total_activity = 0 %}
                {% set count = null %}

                <tr>
                    <td style="background-color: #b2b2b2"><span style="color: #000000">{{ chartType.description }}</span></td>
                    {% for userBilling in record.auBilling %}
                        {% set hasTD = false %}
                        {% for auB in chartType.auBilling if userBilling.id == auB.auBilling_id %}
                            {% set hasTD = true %}
                            {% set total_activity = auB.totalCount %}
                            <td>{{ auB.totalCount }}</td>
                        {% 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 userBilling in record.auBilling  %}
                    {% set totalPercentage = null %}
                    {% set total_auBilling = 0 %}
                    {% for chartType in record.chartTypes  %}
                        {% for auB in chartType.auBilling if userBilling.id == auB.auBilling_id %}
                            {% set hasTD = true %}
                            {% set total_auBilling = total_auBilling + auB.totalCount %}
                            {% set subTotal = subTotal + auB.totalCount %}
                        {% endfor %}
                    {% endfor %}
                    <td><strong>{{ total_auBilling }}</strong></td>
                {% endfor %}
                <td><strong style="font-size: 15px">{{ subTotal }}</strong></td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

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