des trucs
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,7 @@ class SortieRepository extends ServiceEntityRepository
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
|
||||
public function findAllSites()
|
||||
{
|
||||
return $this->getEntityManager()
|
||||
|
||||
Reference in New Issue
Block a user