{% extends '@RxConnexion/Admin/global.html.twig' %}
{% block body %}
    <h3 class="report-header"><strong>{{ page_title }}</strong></h3>
    {% 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 %}
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script>
        //<![CDATA[
        jQ(document).ready(function(){
            report_preview.init();
        });
        //]]>
    </script>
{% endblock %}