{# List school year #}

{% extends 'admin/_base_admin.html.twig' %}
{% set menu_room = true %}
{% block title %}Salle{% endblock %}
{% block content %}
    <div class="row">
        <div class="col-md-12">
            <div class="bgc-white bd bdrs-3 p-20 mB-20">
                <div class="row">
                    <div class="col-md-6">
                        <h4 class="c-grey-900 mB-20">Liste des réservations</h4>
                    </div>
                    <div class="col-md-6 text-right">
                        <a href="{{ path('room_reservation',{'id':room.id}) }}" class="btn btn-primary">Nouveau</a>
                    </div>
                </div>
                <table id="dataTable" class="table table-bordered" cellspacing="0" width="100%">
                    <thead>
                    <tr>
                        <th>Description</th>
                        <th>Début</th>
                        <th>Fin</th>
                        <th>Status</th>
                        {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_DIRECTION') %}
                            <th>Action</th>
                        {% endif %}
                    </tr>
                    </thead>
                    <tfoot>
                    <tr>
                        <th>Description</th>
                        <th>Début</th>
                        <th>Fin</th>
                        <th>Status</th>
                        {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_DIRECTION') %}
                            <th>Action</th>
                        {% endif %}
                    </tr>
                    </tfoot>
                    <tbody>
                    {% for reservation in reservations %}
                        <tr>
                            <td>{{ reservation.description }}</td>
                            <td>{{ reservation.start|date('Y-m-d H:i') }}</td>
                            <td>{{ reservation.end|date('Y-m-d H:i') }}</td>
                            <td>
                                {% if reservation.isValid == false %}
                                    <span class="badge badge-primary">En attente validation</span>
                                {% else %}
                                    <span class="badge badge-success">Validé</span>
                                {% endif %}
                            </td>
                            {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_DIRECTION') %}
                            <td>
                                {% if reservation.fin != true %}
                                    {% if reservation.isValid != true %}
                                        <a class="btn btn-outline-primary btn-sm" title="Modifier"
                                           href="{{ path('room_reservation_update',{'id':reservation.id}) }}">
                                            <i class="ti-pencil"></i>
                                        </a>
                                        <a class="btn btn-outline-secondary btn-sm" title="Valider"
                                           href="{{ path('reservation_room_valid',{'id':reservation.id}) }}">
                                            <i class="ti-check-box"></i>
                                        </a>
                                    {% endif %}
                                    <a class="btn btn-outline-danger btn-sm" title="Terminer"
                                       href="{{ path('reservation_room_end',{'id':reservation.id}) }}">
                                        <i class="ti-trash"></i>
                                    </a>
                                {% else %}
                                    <span class="badge badge-success">Terminé</span>
                                {% endif %}
                            </td>
                            {% endif %}
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock %}