Commit 2a8731ed by Damien Moulard

Merge branch '6936-desactiver-cotisation-comptoir-cas-user-inactif' into 'develop'

user must be active to be found by comptoir during payment procedure

See merge request cooperatic/kohinos-tav!119
parents 856eb656 8a05b737
......@@ -16,13 +16,15 @@ class VenteEmlcAdherentFormType extends VenteEmlcFormType
if (empty($this->security) || empty($this->security->getUser())) {
throw new \Exception('[FORM VENTE EMLC ADHERENT] Opération impossible !');
}
$tav = $this->container->getParameter('tav_env');
$adherentRepo = $this->em->getRepository(Adherent::class);
$builder
->add('destinataire', EntityType::class, [
'class' => Adherent::class,
'choices' => $this->em->getRepository(Adherent::class)->findOrderByName(),
'placeholder' => $this->container->getParameter('tav_env') ? 'Habitant' : 'Adherent',
'choices' => $tav ? $adherentRepo->findOrderByNameExcludeInactiveUser() : $adherentRepo->findOrderByName(),
'placeholder' => $tav ? 'Habitant' : 'Adherent',
'required' => true,
'label' => $this->container->getParameter('tav_env') ? 'Habitant :' : 'Adherent :',
'label' => $tav ? 'Habitant :' : 'Adherent :',
])
->add('reference', HiddenType::class, [
'data' => 'Achat e' . $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_SYMBOL) . ' Adhérent',
......
......@@ -112,6 +112,21 @@ class AdherentRepository extends ServiceEntityRepository
;
}
public function findOrderByNameExcludeInactiveUser()
{
$qb = $this->createQueryBuilder('p');
return $qb
->leftjoin('p.user', 'u')
->where('p.enabled = :enabled')
->andWhere('u.enabled = :userEnabled')
->setParameters(['enabled' => true, 'userEnabled' => true])
->orderBy('u.lastname', 'ASC')
->getQuery()
->getResult()
;
}
/**
* @return Adherent[] Returns an array of Adherent objects
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment