Merge branch 'main' into Marvin
# Conflicts: # src/Repository/SortieRepository.php # templates/sortie/list.html.twig
This commit is contained in:
@@ -17,45 +17,59 @@ class SortieRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Sortie::class);
|
||||
}
|
||||
|
||||
public function findWithFilters($search, $siteId, $startDate, $endDate, $organisateur, $inscrit, $nonInscrit, $passees, $user)
|
||||
public function findWithFilters($search, $siteId, $startDate, $endDate, $organisateur, $inscrit, $nonInscrit, $passees, $userConnect)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('s');
|
||||
$qb = $this->createQueryBuilder('s')
|
||||
->leftJoin('s.etat', 'e')
|
||||
->addSelect('e')
|
||||
->leftJoin('s.participants', 'p')
|
||||
->addSelect('p')
|
||||
->where('e.libelle != :annulee')
|
||||
->setParameter('annulee', 'Annulée');
|
||||
|
||||
if ($search) {
|
||||
// Filtre par nom
|
||||
if (!empty($search)) {
|
||||
$qb->andWhere('s.nom LIKE :search')
|
||||
->setParameter('search', '%' . $search . '%');
|
||||
}
|
||||
|
||||
if ($siteId) {
|
||||
// Filtre par site
|
||||
if (!empty($siteId)) {
|
||||
$qb->andWhere('s.site = :siteId')
|
||||
->setParameter('siteId', $siteId);
|
||||
}
|
||||
|
||||
if ($startDate) {
|
||||
// Filtre par date de début
|
||||
if (!empty($startDate)) {
|
||||
$qb->andWhere('s.dateHeureDebut >= :startDate')
|
||||
->setParameter('startDate', new \DateTime($startDate));
|
||||
->setParameter('startDate', $startDate);
|
||||
}
|
||||
|
||||
if ($endDate) {
|
||||
// Filtre par date de fin
|
||||
if (!empty($endDate)) {
|
||||
$qb->andWhere('s.dateHeureDebut <= :endDate')
|
||||
->setParameter('endDate', new \DateTime($endDate));
|
||||
->setParameter('endDate', $endDate);
|
||||
}
|
||||
|
||||
if ($organisateur) {
|
||||
$qb->andWhere('s.organisateur = :user')
|
||||
->setParameter('user', $user);
|
||||
// Filtre par organisateur
|
||||
if ($organisateur && $userConnect) {
|
||||
$qb->andWhere('s.organisateur = :organisateur')
|
||||
->setParameter('organisateur', $userConnect);
|
||||
}
|
||||
|
||||
if ($inscrit) {
|
||||
$qb->andWhere(':user MEMBER OF s.participants')
|
||||
->setParameter('user', $user);
|
||||
// Filtre par inscription
|
||||
if ($inscrit && $userConnect) {
|
||||
$qb->andWhere(':userConnect MEMBER OF s.participants')
|
||||
->setParameter('userConnect', $userConnect);
|
||||
}
|
||||
|
||||
if ($nonInscrit) {
|
||||
$qb->andWhere(':user NOT MEMBER OF s.participants')
|
||||
->setParameter('user', $user);
|
||||
// Filtre par non-inscription
|
||||
if ($nonInscrit && $userConnect) {
|
||||
$qb->andWhere(':userConnect NOT MEMBER OF s.participants')
|
||||
->setParameter('userConnect', $userConnect);
|
||||
}
|
||||
|
||||
// Filtre par sorties passées
|
||||
if ($passees) {
|
||||
$qb->andWhere('s.dateHeureDebut < :now')
|
||||
->setParameter('now', new \DateTime());
|
||||
@@ -67,6 +81,36 @@ class SortieRepository extends ServiceEntityRepository
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function findForDashboard()
|
||||
{
|
||||
return $this->createQueryBuilder('s')
|
||||
->orderBy('s.dateLimiteInscription', 'ASC')
|
||||
->andWhere('s.dateHeureDebut >= :lastMonth')
|
||||
->setParameter('lastMonth', (new \DateTime())->modify('-1 month'))
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findUserParticipation($userConnect)
|
||||
{
|
||||
return $this->createQueryBuilder('s')
|
||||
->leftJoin('s.participants', 'p')
|
||||
->where('p.idParticipant = :user')
|
||||
->setParameter('user', $userConnect->getIdParticipant())
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findUserOrganisation($userConnect)
|
||||
{
|
||||
return $this->createQueryBuilder('s')
|
||||
->leftJoin('s.organisateur', 'o')
|
||||
->where('o.idParticipant = :user')
|
||||
->setParameter('user', $userConnect->getIdParticipant())
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
public function findAllSites()
|
||||
{
|
||||
return $this->getEntityManager()
|
||||
|
||||
@@ -5,16 +5,46 @@
|
||||
<title>Liste des sorties</title>
|
||||
{% block stylesheets %}
|
||||
{{ encore_entry_link_tags('app') }}
|
||||
<style>
|
||||
.pin-creee {
|
||||
background-color: #4CAF50;
|
||||
}
|
||||
.pin-ouverte {
|
||||
background-color: #2196F3;
|
||||
}
|
||||
.pin-archivee {
|
||||
background-color: #FF9800;
|
||||
}
|
||||
.pin-en-cours {
|
||||
background-color: #FFC107;
|
||||
}
|
||||
.pin-terminee {
|
||||
background-color: #9E9E9E;
|
||||
}
|
||||
.pin-annulee {
|
||||
background-color: #f44336;
|
||||
}
|
||||
.pin-default {
|
||||
background-color: #E0E0E0;
|
||||
}
|
||||
.pin {
|
||||
display: inline-block;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
margin-right: 8px;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
</head>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container mx-auto p-6 bg-gray-50 rounded-lg shadow-lg mt-6">
|
||||
<h1 class="text-3xl font-bold text-center text-gray-800 mb-8">🎉 Liste des sorties</h1>
|
||||
<div class="container mx-auto p-4 sm:p-6 bg-gray-50 rounded-lg shadow-lg mt-4 sm:mt-6">
|
||||
<h1 class="text-2xl sm:text-3xl font-bold text-center text-gray-800 mb-6 sm:mb-8">🎉 Liste des sorties</h1>
|
||||
|
||||
<form method="GET" action="{{ path('home') }}" class="bg-white rounded-lg shadow-md p-4 mb-6">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 sm:gap-6">
|
||||
<div>
|
||||
<label for="search" class="block text-sm font-medium text-gray-700">🔍 Recherche</label>
|
||||
<input type="text" name="search" id="search" value="{{ app.request.query.get('search', '') }}"
|
||||
@@ -47,7 +77,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div class="mt-4 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div class="flex items-center">
|
||||
<input type="checkbox" name="organisateur" id="organisateur" value="1"
|
||||
{% if app.request.query.get('organisateur') %}checked{% endif %}
|
||||
@@ -84,14 +114,36 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-6">
|
||||
<a href="/sortie/creates">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 sm:gap-6">
|
||||
<a href="/sortie/creates" class="hidden sm:block">
|
||||
<div class="bg-white rounded-lg shadow-md p-4 text-center">
|
||||
<img src="/img/add.svg" alt="Créer une sortie" class="w-40 h-40 mx-auto mb-4">
|
||||
<img src="/img/add.svg" alt="Créer une sortie" class="w-24 h-24 mx-auto mb-4">
|
||||
<h2 class="text-lg font-semibold">Créer une sortie</h2>
|
||||
</div>
|
||||
</a>
|
||||
{% for sortie in sorties %}
|
||||
<div class="bg-white rounded-lg shadow-md p-4">
|
||||
<div class="flex items-center mb-2">
|
||||
<div class="pin
|
||||
{% if sortie.etat.libelle == 'Créée' %}
|
||||
pin-creee
|
||||
{% elseif sortie.etat.libelle == 'Ouverte' %}
|
||||
pin-ouverte
|
||||
{% elseif sortie.etat.libelle == 'Archivée' %}
|
||||
pin-archivee
|
||||
{% elseif sortie.etat.libelle == 'En cours' %}
|
||||
pin-en-cours
|
||||
{% elseif sortie.etat.libelle == 'Terminée' %}
|
||||
pin-terminee
|
||||
{% elseif sortie.etat.libelle == 'Annulée' %}
|
||||
pin-annulee
|
||||
{% else %}
|
||||
pin-default
|
||||
{% endif %}
|
||||
"></div>
|
||||
<h2 class="text-lg font-semibold text-gray-800">{{ sortie.nom }}</h2>
|
||||
</div>
|
||||
<a href="{{ path('sortie_view', { id: sortie.idSortie }) }}" class="text-blue-500 hover:text-blue-700 font-medium">
|
||||
<div class="bg-white rounded-lg shadow-md p-4">
|
||||
<h2 class="text-lg font-semibold text-gray-800">{{ sortie.nom }}</h2>
|
||||
<p class="mt-2 text-gray-600">
|
||||
@@ -100,13 +152,33 @@
|
||||
<strong>Inscriptions max :</strong> {{ sortie.nbInscriptionsMax }}<br>
|
||||
<strong>Infos :</strong> {{ sortie.infosSortie }}
|
||||
</p>
|
||||
<div class="mt-4 flex justify-end">
|
||||
<a href="{{ path('sortie_view', { id: sortie.idSortie }) }}" class="text-blue-500 hover:text-blue-700 font-medium">Voir plus</a>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% else %}
|
||||
<p class="text-gray-600 text-center col-span-6">Aucune sortie ne correspond à vos critères.</p>
|
||||
<p class="text-gray-600 text-center col-span-4">Aucune sortie ne correspond à vos critères.</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% block javascripts %}
|
||||
{{ encore_entry_script_tags('app') }}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const inscritCheckbox = document.getElementById('inscrit');
|
||||
const nonInscritCheckbox = document.getElementById('non_inscrit');
|
||||
|
||||
inscritCheckbox.addEventListener('change', () => {
|
||||
if (inscritCheckbox.checked) {
|
||||
nonInscritCheckbox.checked = false;
|
||||
}
|
||||
});
|
||||
|
||||
nonInscritCheckbox.addEventListener('change', () => {
|
||||
if (nonInscritCheckbox.checked) {
|
||||
inscritCheckbox.checked = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user