{% 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>
{% for record in records %}
    <div>
        <h4 style="background-color: #4ccfdd"><strong style="color: #0a0a0a;">{{ record.fullName }}</strong></h4>
    </div>
    <table>
        <thead>
        <tr>
            <th style="background-color: #b2b2b2"><span style="color: #000000">Activity/Services</span></th>
            {% for internalStatus in record.internalStatuses %}
                <th style="background-color: #b2b2b2"><span style="color: #000000">{{ internalStatus.description }}</span></th>
            {% endfor %}
            <th style="background-color: #b2b2b2"><span style="color: #000000">Total</span></th>
        </tr>
        </thead>
        <tbody>
        {% set subTotal = 0 %}
        {% for chartType in record.chartTypes %}
            {% set total_activity = 0 %}
            <tr>
                <td style="background-color: #b2b2b2"><span style="color: #000000">{{ chartType.description }}</span></td>
                {% for intstat in record.internalStatuses %}
                    {% set hasTD = false %}
                    {% for ins in chartType.internalStatuses if ins.id == intstat.id %}
                        {% set hasTD = true %}
                        <td>{{ ins.count }}</td>
                        {% set total_activity = total_activity + ins.count %}
                        {% set subTotal = subTotal + ins.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 intstat in record.internalStatuses  %}
                {% set total_ins = 0 %}
                {% for chartType in record.chartTypes  %}
                    {% for ins in chartType.internalStatuses if ins.id == intstat.id  %}
                        {% set total_ins = total_ins + ins.count %}
                    {% endfor %}
                {% endfor %}
                <td><strong>{{ total_ins }}</strong></td>
            {% endfor %}
            <td><strong style="font-size: 15px">{{ subTotal }}</strong></td>
        </tr>
        </tbody>
    </table>
{% endfor %}
</body>
</html>