{% extends 'admin/layouts/base.html.twig' %}

{% block title %}Admin - {{ context.get['app'] ? context.get['app'].name : company_name }} - {{ title }}{% endblock %}
{% block pageheader %}
    <div class="page-header page-header-light">
        <div class="page-header-content header-elements-md-inline">
            <div class="page-title d-flex">
                <h4><i class="icon-users mr-2"></i>
                    <span class="font-weight-semibold">Type d'appartements</span>
                </h4>
                <a href="javascript:" class="header-elements-toggle text-default d-md-none">
                    <i class="icon-more"></i>
                </a>
            </div>

            <div class="header-elements d-none">
                <div class="d-flex justify-content-center">
                    {% include 'admin/partials/_action_global_btn.html.twig' %}
                    <a data-toggle="tooltip" title="{{ libelle_ajouter }}" href="{{ path('admin.typesproperties.new') }}"
                       class="btn btn-success btn-sm btn-icon ml-5">
                        <i class="icon-plus2"></i>
                    </a>
                </div>
            </div>
        </div>

        <div class="breadcrumb-line breadcrumb-line-light header-elements-md-inline">
            {{ fil_arial(title, 'Type d\'appartements') }}
        </div>
    </div>
{% endblock %}
{% block body %}
    <div class="row">
        <div class="col-md-8 offset-2">
            <div class="card">
                <div class="card-header header-elements-inline">
                    <h6 class="card-title"><i class="icon-coins"></i> {{ title }}</h6>
                </div>

                <table class="datatable-show-all table">
                    <thead class="{{ class }}">
                    <tr>
                        <th>Libellé</th>
                        <th>Status</th>
                        <th>Date</th>
                        <th style="width: 100px!important;">Actions</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for typespropertie in typesproperties %}
                        <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="{{ typespropertie.name }}" href="{{ path('admin.typesproperties.edit', {'id': typespropertie.id}) }}">
                                        {{ typespropertie.name }}
                                    </a>
                                </div>
                            </td>
                            <td>
                                <div class="custom-control custom-switch">
                                    <input type="checkbox" data-id="{{ typespropertie.id }}" class="custom-control-input js-status-input" id="status-{{ typespropertie.id }}" {% if typespropertie.isActif %}checked{% endif %}>
                                    <label class="custom-control-label position-static p-0" for="status-{{ typespropertie.id }}"></label>
                                </div>
                            </td>
                            <td>{{ typespropertie.createdAt|date('d/m/Y') }}</td>
                            <td style="text-align: center!important;display: flex; flex-direction: row; justify-content: space-between; 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(typespropertie, path('admin.typesproperties.edit', {'id': typespropertie.id}), 'Modifier', 'icon-pencil5') }}
                                            {{ delete_form(typespropertie, path('admin.typesproperties.delete', {'id': typespropertie.id}), 'Etes vous sûr de vouloir supprimer cette typespropertie?', 'Supprimer la typespropertie') }}
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    {% else %}
                        <tr>
                            <td colspan="3">{{ data_none }}</td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock %}
{% block javascripts %}
    <script type="module">
        import Save from "{{ asset('js/modules/module.js') }}";
        Save('/admin/api/types/properties/check-status')
    </script>
{% endblock %}
