{% set absUrl = app.request.getSchemeAndHttpHost() ~ app.request.baseUrl|replace({'/app_dev.php': ''}) %}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="{{ absUrl ~ asset('bundles/rxconnexion/admin/css/report/report_wkpdf.css') }}" />
</head>
<body>
<h2><strong>{{ page_title }}</strong></h2>
    <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</span></th>
        </tr>
        </thead>
        <tbody>
        {% set subTotal = 0 %}
        {% for record in records %}
            {% for chartType in record.chartTypes %}

                {% set total_activity = 0 %}
                {% set percentage = 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>

</body>
</html>