{% extends 'base.html.twig' %}
{% block title %}
Les groupes
{% endblock %}
{% block main %}
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
<h4 class="mb-sm-0">
Liste des groupes
</h4>
</div>
</div>
</div>
<div class="row">
{% form_theme searchForm 'bootstrap_5_layout.html.twig' %}
{{ form_start(searchForm) }}
<div class="card">
<div class="card-header align-items-center d-flex">
<h4 class="card-title mb-0 flex-grow-1">Recherche</h4>
</div>
<div class="card-body">
<div class="row gy-4">
<div class="col-md-12">
<div class="row">
<div class="col-md-3 col-xs-12">
{{ form_row(searchForm.depart)}}
</div>
<div class="col-md-3 col-xs-12">
{{ form_row(searchForm.retour)}}
</div>
<div class="col-md-2 col-xs-12">
{{ form_row(searchForm.dateD)}}
</div>
<div class="col-md-2 col-xs-12">
{{ form_row(searchForm.dateR)}}
</div>
<div class="col-md-2 col-xs-12">
{{ form_row(searchForm.typeGroupe)}}
</div>
</div>
</div>
</div>
<div class="mb-3 d-flex justify-content-between">
<div class="mb-3">
<a class="btn btn-light" href="{{ path('groupe_list') }}">Réinitialiser</a>
</div>
{{ form_row(searchForm.rechercher) }}
</div>
</div>
</div>
{{ form_end(searchForm, {'render_rest': true}) }}
</div>
<div class="row">
<div class="col-12">
{% for group,messages in app.flashes %}
{% for message in messages %}
<div class="alert alert-{{ group }}" role="alert">{{ message }}
</div>
{% endfor %}
{% endfor %}
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header align-items-center d-flex">
<h4 class="card-title mb-0 flex-grow-1">Résultats</h4>
</div>
<div class="card-body">
<div class="table-responsive table-card mt-3 mb-1">
<table class="table align-middle table-nowrap" id="last-groups-table">
<thead class="table-light">
<tr>
<th>Reférence</th>
<th>Départ</th>
<th>Date</th>
<th>Destination</th>
<th>Date retour</th>
<th>Kilomètres</th>
<th>Nb Clients</th>
<th>État</th>
<th>Action</th>
</tr>
</thead>
<tbody class="list form-check-all">
{# Boucle sur le tableau passé par le controller #}
{% for group in groupes %}
<tr>
<td>
{# Si utilisateur connecté - lien détail disponible #}
{% if app_user %}
<a class="link-info " href="{{ path('groupe_details', {'id': group.id }) }}">ref {{ group.id }}</a>
{# Sinon #}
{% else %}
<a class="link-dark " href="#">ref {{ group.id }}</a>
{% endif %}
</td>
<td class="depart">{{ group.adresseDepart.ville|upper }}</td>
<td class="date_depart">{{ group.dateDepart | date("d/m/Y")}}</td>
<td class="destination">{{ group.adresseRetour.ville| upper }}</td>
<td class="date_retour">{{ group.dateRetour | date("d/m/Y")}}</td>
<td class="kilometres">{{ group.kilometres | default("Non renseigné")}}</td>
<td class="nb_clients">{{ group.nbPersonnes }}</td>
<td class="etat">
{% if group.annule == true %}
<span class="badge badge-soft-danger text-uppercase">Annulé</span>
{% else %}
<span class="badge badge-soft-success text-uppercase">Active</span>
{% endif %}
</td>
<td>
<div class="hstack gap-3 fs-15">
{# Pas d'utilisateur connecté #}
{% if not app_user %}
<a href="#" class="disabled" title="Détail"><i class="ri-eye-line"></i></a>
<a href="#" class="disabled" title="Déposer offre"><i class="ri-file-add-line"></i></a>
{# Utilisateur connecté #}
{% else %}
<a href="{{ path('groupe_details', {'id': group.id} ) }}" class="link-info" title="Détail"><i class="ri-eye-line"></i></a>
{% if app_user == group.user %}
{# Si offre déposee par utilisateur boutons modifier#}
<a href="{{ path('groupe_update', {'id': group.id} ) }}" class="link-warning" title="Modifier"><i class="ri-edit-2-line"></i></a>
<a href="#" class="link-danger" title="Supprimer"><i class="ri-delete-bin-line"></i></a>
{% else %}
<a href="#" class="link-primary" title="Déposer offre"><i class="ri-file-add-line"></i></a>
{% endif %}
{% endif %}
</div>
</td>
</tr>
{% endfor %}
{# fin boucle #}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function myFunction() {
document.getElementById("searchForm").reset();
}
</script>
{% endblock %}