<table class="datatable-show-all table">
    <thead class="{{ class }}">
    <tr>
       
            <th>
                <div style="white-space: normal!important; display: flex; flex-direction: row; justify-content: space-between;align-items: center;">
                    <span>Appart.</span>
                    <span>N° App.</span>
                </div>
            </th>
            <th>Occupé par</th>
            <th>Zone</th>
            <th>Mt. du loyer</th>
            <th>Commission</th>
            <th>Démarcheur</th>
            <th>Status</th>
            <th>Actions</th>
    </tr>
    </thead>
    <tbody>
        {% set total = 0 %}
        {% for propertie in properties %}
       
       <tr>
                <td>
                    <div style="white-space: normal!important; display: flex; flex-direction: row; justify-content: space-between;align-items: center;">
                        <a data-toggle="tooltip" title="{{ propertie.name }}" href="{{ path('admin.properties.edit', {'id': propertie.id}) }}">
                            {{ propertie.name }}
                        </a>
                        <span class="badge-pill badge-warning">{{ propertie.numAppartement ?? propertie.code }}</span>
                    </div>
                </td>
                <td>
                    {% if propertie.locataires %}
                       <div style="display: flex;flex-direction: row;justify-content: space-between; align-items: center;">
                           <a data-toggle="tooltip" class="text-info" title="{{ propertie.locataires.name }}"
                              href="{{ path('admin.acteurs.locataires.edit', {'id': propertie.locataires.id}) }}">
                               {{ propertie.locataires.name }}
                           </a>
                           {% if total_is_impayer_locataire(propertie.locataires) > 0 %}
                               <small class="text-danger">Arrièrés en cours</small>
                           {% endif %}
                       </div>
                    {% else %}
                        <span class="badge badge-danger">Non occupé</span>
                    {% endif %}
                </td>
                <td>
                    {% if propertie.locations %}
                        
                        <a data-toggle="tooltip" class="text-success" title="{{ propertie.locations.name }}"
                           href="{{ path('admin.locations.edit', {'id': propertie.locations.id}) }}">
                            {{ propertie.locations.name }}
                        </a>
                    {% else %}
                        <span class="badge badge-danger">Aucune zone</span>
                    {% endif %}
                </td>
                <td>{{ propertie.montantLoyer|format_currency(currency()) }}</td>
                  
                <td>{{ (propertie.proprietaires.commission / 100) * propertie.montantLoyer }} FCFA</td>
                   <td>{{ propertie.bien.demarcheur.nom }} {{ propertie.bien.demarcheur.prenom }}</td>
                   
                <td>
                    <div class="custom-control custom-switch">
                        <input type="checkbox" data-id="{{ propertie.id }}"
                               class="custom-control-input js-status-input"
                               id="status-{{ propertie.id }}" {% if propertie.isActif %}checked{% endif %}>
                        <label class="custom-control-label position-static p-0" for="status-{{ propertie.id }}"></label>
                    </div>
                </td>
                <td style="text-align: center!important;display: flex; flex-direction: row; justify-content: center; align-items: center;">
                    <div class="list-icons">
                        <div class="dropdown">
                            <a href="javascript:" class="list-icons-item" data-toggle="dropdown">
                                <i class="icon-menu9"></i>
                            </a>
                            <div class="dropdown-menu dropdown-menu-right">
                                {{ action_form(propertie, path('admin.properties.edit', {'id': propertie.id}), 'Modifier', 'icon-pencil5') }}
                                {% if
                                    propertie.cautionGestionnaire and
                                    propertie.cautionPeriode > 0 and
                                    propertie.cautionMois > 0
                                %}
                                    {{ action_form(propertie, path('admin.propertie.facture.generate', {'id': propertie.id}), 'Imprimer', 'icon-file-pdf') }}
                                {% endif %}
                                {{ delete_form(propertie, path('admin.properties.delete', {'id': propertie.id}), 'Etes vous sûr de vouloir supprimer cet appartement?', 'Supprimer') }}
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
    {% else %}
        <tr>
            <td colspan="8">{{ data_none }}</td>
        </tr>
    {% endfor %}
    </tbody>
</table>
<script type="module">
    import Save from "{{ asset('js/modules/module.js') }}";
    Save('/admin/api/locataires/check-status')
</script>