<table class="table table-hover table-striped table-condensed table-bordered table-sm">
    <thead class="{{ class }}">
    <tr>
        <th>Nom & Prénoms</th>
        <th>Caractéristiques de la maison</th>
        <th>Status</th>
        <th>Loyer</th>
        <th>Charges</th>
        <th>Total</th>
    </tr>
    </thead>
    <tbody>
    {% set totalGeneralLoyer = 0 %}
    {% set totalGeneralCharge = 0 %}
    {% set totalGeneral = 0 %}
    {% for location in locations %}
        <tr class="{{ class }}">
            <th class="text-left" colspan="6">
                <div style="display: flex; flex-direction: row; justify-content: space-between; align-items: center;">
                    <strong class="text-white">{{ location.name|upper }}</strong>
                    <strong class="text-white">{{ pluralize(location.properties.count, 'Appartement') }}</strong>
                </div>
            </th>
        </tr>
        {% if quittances[location.id]|length > 0 %}
            {% set totalLoyer = 0 %}
            {% set totalCharge = 0 %}
            {% for quittance in quittances[location.id] %}
                <tr>
                    <td>
                        <a href="{{ path('admin.acteurs.locataires.edit', {'id': quittance.locataires.id}) }}">
                            {{ quittance.locataires.name }}
                        </a>
                    </td>
                    <td>{{ quittance.properties.name }}</td>
                    <td>
                        <span class="badge badge-xs light badge-primary" style="background-color: {{ quittance.etats.color }};!important;">
                            <i class="{{ quittance.etats.icon }}"></i> {{ quittance.etats.name }}
                        </span>
                    </td>
                    <td style="width: 250px!important;">{{ (quittance.total * quittance.periode)|format_currency(currency()) }}</td>
                    <td>{{ quittance.totalCharges|format_currency(currency()) }}</td>
                    <td>{{ (quittance.total * quittance.periode)|format_currency(currency()) }}</td>
                </tr>
                {% set totalLoyer = totalLoyer + (quittance.total * quittance.periode) %}
                {% set totalCharge = totalCharge + quittance.totalCharges  %}
            {% endfor %}
            {% set totalGeneralLoyer = totalGeneralLoyer + totalLoyer %}
            {% set totalGeneralCharge = totalGeneralCharge + totalCharge %}
            {% set totalGeneral = totalGeneral + (totalLoyer + totalCharge) %}
            <tr class="bg-success">
                <th colspan="3">TOTAL {{ location.name|upper }}</th>
                <th>{{ totalLoyer|format_currency(currency()) }}</th>
                <th>{{ totalCharge|format_currency(currency()) }}</th>
                <th>{{ (totalLoyer + totalCharge)|format_currency(currency()) }}</th>
            </tr>
        {% endif %}
    {% else %}
        <tr>
            <td colspan="6">{{ data_none }}</td>
        </tr>
    {% endfor %}
    </tbody>
    <tr><td colspan="6"></td></tr>
    <tr><td colspan="6"></td></tr>
    <tr class="{{ class }}">
        <th colspan="3">TOTAL GENERAL</th>
        <th>{{ totalGeneralLoyer|format_currency(currency()) }}</th>
        <th>{{ totalGeneralCharge|format_currency(currency()) }}</th>
        <th>{{ totalGeneral|format_currency(currency()) }}</th>
    </tr>
</table>