From e55f9fcdfe68c1f6c697c46daceb581ab9a725a1 Mon Sep 17 00:00:00 2001 From: vgreb Date: Thu, 23 Jul 2026 21:39:11 +0200 Subject: [PATCH 1/4] Migration du namespace GeneralMeeting vers AssembleeGenerale --- sources/Afup/Utils/PDF_AG.php | 2 +- .../AssembleeGenerale/Dto/Attendee.php | 95 ++++ .../AssembleeGeneraleRepository.php | 33 ++ .../Entity/Repository/PresenceRepository.php | 266 +++++++++++ ...stionFormType.php => QuestionFormType.php} | 2 +- .../GeneralMeetupNotificationCommand.php | 6 +- .../AppBundle/Controller/Admin/HomeAction.php | 4 +- .../Members/GeneralMeeting/ListAction.php | 4 +- .../Members/GeneralMeeting/ListingAction.php | 4 +- .../Members/GeneralMeeting/PrepareAction.php | 6 +- .../GeneralMeetingQuestion/AddAction.php | 4 +- .../GeneralMeetingQuestion/EditAction.php | 4 +- .../Members/GeneralMeetingVote/ListAction.php | 4 +- .../Controller/Website/Member/IndexAction.php | 4 +- .../Membership/GeneralMeeting/IndexAction.php | 16 +- .../Membership/GeneralMeeting/VoteAction.php | 8 +- sources/AppBundle/GeneralMeeting/Attendee.php | 108 ----- .../GeneralMeeting/GeneralMeeting.php | 59 --- .../GeneralMeetingRepository.php | 420 ------------------ sources/AppBundle/Slack/MessageFactory.php | 4 +- .../membership/generalmeeting.html.twig | 4 +- 21 files changed, 432 insertions(+), 625 deletions(-) create mode 100644 sources/AppBundle/AssembleeGenerale/Dto/Attendee.php rename sources/AppBundle/AssembleeGenerale/Form/{GeneralMeetingQuestionFormType.php => QuestionFormType.php} (95%) delete mode 100644 sources/AppBundle/GeneralMeeting/Attendee.php delete mode 100644 sources/AppBundle/GeneralMeeting/GeneralMeeting.php delete mode 100644 sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php diff --git a/sources/Afup/Utils/PDF_AG.php b/sources/Afup/Utils/PDF_AG.php index 47af2c938..0a38259c1 100644 --- a/sources/Afup/Utils/PDF_AG.php +++ b/sources/Afup/Utils/PDF_AG.php @@ -5,7 +5,7 @@ namespace Afup\Site\Utils; use Afup\Site\Comptabilite\PDF; -use AppBundle\GeneralMeeting\Attendee; +use AppBundle\AssembleeGenerale\Dto\Attendee; class PDF_AG extends PDF { diff --git a/sources/AppBundle/AssembleeGenerale/Dto/Attendee.php b/sources/AppBundle/AssembleeGenerale/Dto/Attendee.php new file mode 100644 index 000000000..08089b9d1 --- /dev/null +++ b/sources/AppBundle/AssembleeGenerale/Dto/Attendee.php @@ -0,0 +1,95 @@ +id; + } + + public function getEmail(): string + { + return $this->email; + } + + public function getLogin(): string + { + return $this->login; + } + + public function getLastname(): string + { + return $this->lastname; + } + + public function getFirstname(): string + { + return $this->firstname; + } + + public function getNearestOffice(): string + { + return $this->nearestOffice; + } + + public function getConsultationDate(): ?DateTimeImmutable + { + return $this->consultationDate; + } + + public function getPresence(): int + { + return $this->presence; + } + + public function isPresent(): bool + { + return $this->presence === PresenceEtat::Present->value; + } + + public function isAbsent(): bool + { + return $this->presence === PresenceEtat::NonPresent->value; + } + + public function getPowerId(): ?int + { + return $this->powerId; + } + + public function getPowerLastname(): ?string + { + return $this->powerLastname; + } + + public function getPowerFirstname(): ?string + { + return $this->powerFirstname; + } + + public function getHash(): string + { + return md5($this->id . '_' . $this->email . '_' . $this->login); + } +} diff --git a/sources/AppBundle/AssembleeGenerale/Entity/Repository/AssembleeGeneraleRepository.php b/sources/AppBundle/AssembleeGenerale/Entity/Repository/AssembleeGeneraleRepository.php index 28236ea56..9322cf7eb 100644 --- a/sources/AppBundle/AssembleeGenerale/Entity/Repository/AssembleeGeneraleRepository.php +++ b/sources/AppBundle/AssembleeGenerale/Entity/Repository/AssembleeGeneraleRepository.php @@ -56,4 +56,37 @@ public function upsert(\DateTimeInterface $date, string $description): void $assemblee->description = $description; $this->save($assemblee); } + + public function prepare(\DateTimeInterface $date, string $description): bool + { + $conn = $this->getEntityManager()->getConnection(); + + $members = $conn->executeQuery('SELECT id FROM afup_personnes_physiques WHERE etat = 1')->fetchAllAssociative(); + $insertQuery = $conn->prepare('INSERT INTO afup_presences_assemblee_generale (id_personne_physique, date) VALUES (:id, :date)'); + $insertQuery->bindValue('date', $date->getTimestamp()); + + $success = 0; + foreach ($members as $row) { + $alreadyExists = $conn->prepare('SELECT id FROM afup_presences_assemblee_generale WHERE id_personne_physique = :id AND date = :date'); + $alreadyExists->bindValue('id', $row['id']); + $alreadyExists->bindValue('date', $date->getTimestamp()); + + if (!is_array($alreadyExists->executeQuery()->fetchAssociative())) { + $insertQuery->bindValue('id', $row['id']); + if ($insertQuery->executeStatement()) { + $success++; + } + } + } + + if (0 === $success) { + return false; + } + + $replaceQuery = $conn->prepare('REPLACE INTO afup_assemblee_generale (`date`, `description`) VALUES (:date, :description)'); + $replaceQuery->bindValue('date', $date->getTimestamp()); + $replaceQuery->bindValue('description', $description); + + return $replaceQuery->executeStatement() > 0; + } } diff --git a/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php b/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php index 209c56c7a..14df7df35 100644 --- a/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php +++ b/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php @@ -4,9 +4,12 @@ namespace AppBundle\AssembleeGenerale\Entity\Repository; +use AppBundle\AssembleeGenerale\Dto\Attendee; use AppBundle\AssembleeGenerale\Entity\Presence; use AppBundle\Association\Model\User; use AppBundle\Doctrine\EntityRepository; +use DateTimeImmutable; +use DateTimeInterface; use Doctrine\Persistence\ManagerRegistry; /** @@ -30,4 +33,267 @@ public function getByUser(User $user): array ->getQuery() ->getResult(); } + + /** + * @return DateTimeInterface[] + */ + public function getAllDates(): array + { + $result = $this->getEntityManager()->getConnection()->executeQuery(<<<'SQL' +SELECT DISTINCT apag.date +FROM afup_presences_assemblee_generale apag +ORDER BY apag.date DESC +SQL + ); + + return array_map( + static fn(array $row): DateTimeImmutable => new DateTimeImmutable('@' . $row['date']), + $result->fetchAllAssociative(), + ); + } + + public function getLatestAttendanceDate(): ?DateTimeImmutable + { + $maxDate = $this->getEntityManager()->getConnection() + ->executeQuery('SELECT MAX(date) maxDate FROM afup_presences_assemblee_generale LIMIT 1') + ->fetchOne(); + + return null !== $maxDate ? new DateTimeImmutable('@' . $maxDate) : null; + } + + public function countAttendeesAndPowers(DateTimeInterface $date): int + { + $query = $this->getEntityManager()->getConnection()->prepare(<<<'SQL' +SELECT COUNT(*) c +FROM afup_presences_assemblee_generale apag +WHERE apag.date = :date +AND (apag.presence = '1' OR apag.id_personne_avec_pouvoir > 0) +SQL + ); + $query->bindValue('date', $date->getTimestamp()); + + return (int) $query->executeQuery()->fetchOne(); + } + + public function countAttendees(DateTimeInterface $date): int + { + $query = $this->getEntityManager()->getConnection()->prepare(<<<'SQL' +SELECT COUNT(*) c +FROM afup_presences_assemblee_generale apag +WHERE apag.date = :date +AND apag.presence = '1' +SQL + ); + $query->bindValue('date', $date->getTimestamp()); + + return (int) $query->executeQuery()->fetchOne(); + } + + /** + * @return Attendee[] + */ + public function getAttendees(DateTimeInterface $date, string $order = 'nom', string $direction = 'asc', ?int $idPersonneAvecPouvoir = null): array + { + $query = $this->getEntityManager()->getConnection()->createQueryBuilder() + ->from('afup_personnes_physiques', 'app') + ->select( + 'app.id', + 'app.email', + 'app.login', + 'app.nom', + 'app.prenom', + 'app.nearest_office', + 'apag.date_consultation', + 'apag.presence', + 'app2.id AS power_id', + 'app2.nom AS power_lastname', + 'app2.prenom AS power_firstname', + ) + ->join('app', 'afup_presences_assemblee_generale', 'apag', 'app.id = apag.id_personne_physique') + ->leftJoin('app', 'afup_personnes_physiques', 'app2', 'app2.id = apag.id_personne_avec_pouvoir') + ->where('apag.date = :date') + ->orderBy($order, $direction) + ->setParameter('date', $date->getTimestamp()); + + if (null !== $idPersonneAvecPouvoir) { + $query->andWhere('id_personne_avec_pouvoir = :pouvoir') + ->setParameter('pouvoir', $idPersonneAvecPouvoir); + } + + return array_map( + static fn(array $row): Attendee => new Attendee( + (int) $row['id'], + $row['email'], + $row['login'], + $row['nom'], + $row['prenom'], + $row['nearest_office'], + $row['date_consultation'] ? new DateTimeImmutable('@' . $row['date_consultation']) : null, + (int) $row['presence'], + $row['power_id'] ? (int) $row['power_id'] : null, + $row['power_lastname'], + $row['power_firstname'], + ), + $query->executeQuery()->fetchAllAssociative(), + ); + } + + public function getAttendee(string $login, DateTimeInterface $date): ?Attendee + { + $query = $this->getEntityManager()->getConnection()->prepare(<<<'SQL' +SELECT + app.id, + app.email, + app.login, + app.nom, + app.prenom, + app.nearest_office, + apag.date_consultation, + apag.presence, + app2.id as power_id, + app2.nom as power_lastname, + app2.prenom as power_firstname +FROM afup_personnes_physiques app +JOIN afup_presences_assemblee_generale apag ON app.id = apag.id_personne_physique +LEFT JOIN afup_personnes_physiques app2 ON app2.id = apag.id_personne_avec_pouvoir +WHERE app.login = :login AND apag.date = :date +LIMIT 1 +SQL + ); + $query->bindValue('login', $login); + $query->bindValue('date', $date->getTimestamp()); + + $row = $query->executeQuery()->fetchAssociative(); + + return is_array($row) ? new Attendee( + (int) $row['id'], + $row['email'], + $row['login'], + $row['nom'], + $row['prenom'], + $row['nearest_office'], + $row['date_consultation'] ? new DateTimeImmutable('@' . $row['date_consultation']) : null, + (int) $row['presence'], + $row['power_id'] ? (int) $row['power_id'] : null, + $row['power_lastname'], + $row['power_firstname'], + ) : null; + } + + public function addAttendee(int $personId, DateTimeInterface $date, int $presence, int $powerId): bool + { + $query = $this->getEntityManager()->getConnection()->prepare(<<<'SQL' +INSERT INTO afup_presences_assemblee_generale + (id_personne_physique, `date`, presence, id_personne_avec_pouvoir, date_modification) +VALUES (:personId, :date, :presence, :powerId, :modificationDate) +SQL + ); + $query->bindValue('personId', $personId); + $query->bindValue('date', $date->getTimestamp()); + $query->bindValue('presence', $presence); + $query->bindValue('powerId', $powerId); + $query->bindValue('modificationDate', (new DateTimeImmutable())->getTimestamp()); + + return $query->executeStatement() > 0; + } + + public function editAttendee(string $login, DateTimeInterface $date, int $presence, int $powerId): bool + { + $query = $this->getEntityManager()->getConnection()->prepare(<<<'SQL' +UPDATE afup_presences_assemblee_generale apag, afup_personnes_physiques app +SET apag.presence = :presence, + apag.id_personne_avec_pouvoir = :powerId, + apag.date_modification = :modificationDate +WHERE apag.id_personne_physique = app.id + AND (app.login = :login OR app.email = :login) + AND apag.date = :date +SQL + ); + $query->bindValue('login', $login); + $query->bindValue('date', $date->getTimestamp()); + $query->bindValue('presence', $presence); + $query->bindValue('powerId', $powerId); + $query->bindValue('modificationDate', (new DateTimeImmutable())->getTimestamp()); + + return $query->executeStatement() > 0; + } + + public function obtenirEcartQuorum(DateTimeInterface $date, int $nombrePersonnesAJourDeCotisation): int + { + return $this->countAttendeesAndPowers($date) - (int) ceil($nombrePersonnesAJourDeCotisation / 4); + } + + public function getValidAttendeeIds(DateTimeInterface $date): array + { + $query = $this->getEntityManager()->getConnection()->prepare(<<<'SQL' +SELECT app.id +FROM afup_cotisations ac +INNER JOIN afup_personnes_physiques app ON app.id = ac.id_personne +WHERE date_fin >= :date +AND type_personne = 0 +AND etat = 1 +UNION SELECT app.id +FROM afup_cotisations ac +INNER JOIN afup_personnes_physiques app ON app.id = ac.id_personne_morale +WHERE date_fin >= :date +AND type_personne = 1 +AND etat = 1 +SQL + ); + $query->bindValue('date', $date->getTimestamp() - 14 * 86400); + + return array_map(static fn(array $row): int => (int) $row['id'], $query->executeQuery()->fetchAllAssociative()); + } + + public function hasUserRspvedToLastGeneralMeeting(User $user): bool + { + $latestDate = $this->getLatestAttendanceDate(); + if (null === $latestDate) { + return false; + } + + $query = $this->getEntityManager()->getConnection()->prepare(<<<'SQL' +SELECT apag.date_modification +FROM afup_presences_assemblee_generale apag +JOIN afup_personnes_physiques app ON apag.id_personne_physique = app.id +WHERE app.login = :login AND apag.date = :date +LIMIT 1 +SQL + ); + $query->bindValue('login', $user->getUsername()); + $query->bindValue('date', $latestDate->getTimestamp()); + + $row = $query->executeQuery()->fetchAssociative(); + + return is_array($row) && null !== $row['date_modification']; + } + + /** + * @return array + */ + public function getPowerSelectionList(DateTimeInterface $date, ?string $excludeLogin): array + { + $query = $this->getEntityManager()->getConnection()->createQueryBuilder() + ->from('afup_personnes_physiques', 'app') + ->join('app', 'afup_presences_assemblee_generale', 'apag', 'app.id = apag.id_personne_physique') + ->select('app.id', 'app.nom', 'app.prenom') + ->where('apag.date = :date') + ->andWhere("apag.presence = '1'") + ->groupBy('app.id') + ->orderBy('app.nom') + ->addOrderBy('app.prenom') + ->setParameter('date', $date->getTimestamp()); + + if (null !== $excludeLogin) { + $query->andWhere('app.login <> :login') + ->setParameter('login', $excludeLogin); + } + + $list = []; + foreach ($query->executeQuery()->fetchAllAssociative() as $row) { + $list[$row['id']] = $row['nom'] . ' ' . $row['prenom']; + } + + return $list; + } } diff --git a/sources/AppBundle/AssembleeGenerale/Form/GeneralMeetingQuestionFormType.php b/sources/AppBundle/AssembleeGenerale/Form/QuestionFormType.php similarity index 95% rename from sources/AppBundle/AssembleeGenerale/Form/GeneralMeetingQuestionFormType.php rename to sources/AppBundle/AssembleeGenerale/Form/QuestionFormType.php index 74d2de212..5c3a1fddd 100644 --- a/sources/AppBundle/AssembleeGenerale/Form/GeneralMeetingQuestionFormType.php +++ b/sources/AppBundle/AssembleeGenerale/Form/QuestionFormType.php @@ -16,7 +16,7 @@ /** * @extends AbstractType */ -class GeneralMeetingQuestionFormType extends AbstractType +class QuestionFormType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { diff --git a/sources/AppBundle/Command/GeneralMeetupNotificationCommand.php b/sources/AppBundle/Command/GeneralMeetupNotificationCommand.php index 3e9b4384d..9f0a34eb1 100644 --- a/sources/AppBundle/Command/GeneralMeetupNotificationCommand.php +++ b/sources/AppBundle/Command/GeneralMeetupNotificationCommand.php @@ -6,7 +6,7 @@ use AppBundle\AssembleeGenerale\Entity\Repository\AssembleeGeneraleRepository; use AppBundle\Association\Model\Repository\UserRepository; -use AppBundle\GeneralMeeting\GeneralMeetingRepository; +use AppBundle\AssembleeGenerale\Entity\Repository\PresenceRepository; use AppBundle\Notifier\SlackNotifier; use AppBundle\Slack\MessageFactory; use Symfony\Component\Console\Command\Command; @@ -19,7 +19,7 @@ class GeneralMeetupNotificationCommand extends Command public function __construct( private readonly UserRepository $userRepository, private readonly AssembleeGeneraleRepository $assembleGeneraleRepository, - private readonly GeneralMeetingRepository $generalMeetingRepository, + private readonly PresenceRepository $presenceRepository, private readonly MessageFactory $messageFactory, private readonly SlackNotifier $slackNotifier, private readonly UrlGeneratorInterface $urlGenerator, @@ -36,7 +36,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int { if ($this->assembleGeneraleRepository->hasPlanned()) { $this->slackNotifier->sendMessage($this->messageFactory->createMessageForGeneralMeeting( - $this->generalMeetingRepository, + $this->presenceRepository, $this->userRepository, $this->urlGenerator, )); diff --git a/sources/AppBundle/Controller/Admin/HomeAction.php b/sources/AppBundle/Controller/Admin/HomeAction.php index a4660d2ae..ab1fa8fb9 100644 --- a/sources/AppBundle/Controller/Admin/HomeAction.php +++ b/sources/AppBundle/Controller/Admin/HomeAction.php @@ -10,7 +10,7 @@ use AppBundle\Event\Model\Repository\EventRepository; use AppBundle\Event\Model\Repository\EventStatsRepository; use AppBundle\Event\Model\Repository\TicketEventTypeRepository; -use AppBundle\GeneralMeeting\GeneralMeetingRepository; +use AppBundle\AssembleeGenerale\Entity\Repository\PresenceRepository; use AppBundle\Security\Authentication; use AppBundle\Veille\Entity\Repository\NewsletterInscriptionRepository; use Psr\Clock\ClockInterface; @@ -26,7 +26,7 @@ public function __construct( private readonly TicketEventTypeRepository $ticketEventTypeRepository, private readonly NewsletterInscriptionRepository $newsletterInscriptionRepository, private readonly AssembleeGeneraleRepository $assembleGeneraleRepository, - private readonly GeneralMeetingRepository $generalMeetingRepository, + private readonly PresenceRepository $generalMeetingRepository, private readonly StatisticsComputer $statisticsComputer, private readonly ClockInterface $clock, private readonly Authentication $authentication, diff --git a/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListAction.php b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListAction.php index a054ad443..7c22cd211 100644 --- a/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListAction.php +++ b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListAction.php @@ -5,7 +5,7 @@ namespace AppBundle\Controller\Admin\Members\GeneralMeeting; use AppBundle\Association\Model\Repository\UserRepository; -use AppBundle\GeneralMeeting\GeneralMeetingRepository; +use AppBundle\AssembleeGenerale\Entity\Repository\PresenceRepository; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Twig\Environment; @@ -18,7 +18,7 @@ class ListAction public function __construct( private readonly UserRepository $userRepository, - private readonly GeneralMeetingRepository $generalMeetingRepository, + private readonly PresenceRepository $generalMeetingRepository, private readonly Environment $twig, ) {} diff --git a/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListingAction.php b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListingAction.php index 65353da80..0ea3a8de2 100644 --- a/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListingAction.php +++ b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListingAction.php @@ -5,7 +5,7 @@ namespace AppBundle\Controller\Admin\Members\GeneralMeeting; use Afup\Site\Utils\PDF_AG; -use AppBundle\GeneralMeeting\GeneralMeetingRepository; +use AppBundle\AssembleeGenerale\Entity\Repository\PresenceRepository; use DateTimeImmutable; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\Request; @@ -14,7 +14,7 @@ class ListingAction { - public function __construct(private readonly GeneralMeetingRepository $generalMeetingRepository) {} + public function __construct(private readonly PresenceRepository $generalMeetingRepository) {} public function __invoke(Request $request): BinaryFileResponse { diff --git a/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/PrepareAction.php b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/PrepareAction.php index 4797e69e1..42d077304 100644 --- a/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/PrepareAction.php +++ b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/PrepareAction.php @@ -6,7 +6,7 @@ use AppBundle\AssembleeGenerale\Form\PrepareFormType; use AppBundle\AuditLog\Audit; -use AppBundle\GeneralMeeting\GeneralMeetingRepository; +use AppBundle\AssembleeGenerale\Entity\Repository\AssembleeGeneraleRepository; use DateTime; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -16,7 +16,7 @@ class PrepareAction extends AbstractController { public function __construct( - private readonly GeneralMeetingRepository $generalMeetingRepository, + private readonly AssembleeGeneraleRepository $assembleGeneraleRepository, private readonly Audit $audit, ) {} @@ -26,7 +26,7 @@ public function __invoke(Request $request): Response $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $data = $form->getData(); - if ($this->generalMeetingRepository->prepare($data['date'], $data['description'])) { + if ($this->assembleGeneraleRepository->prepare($data['date'], $data['description'])) { $this->audit->log('Ajout de la préparation des personnes physiques à l\'assemblée générale'); $this->addFlash('notice', 'La préparation des personnes physiques a été ajoutée'); diff --git a/sources/AppBundle/Controller/Admin/Members/GeneralMeetingQuestion/AddAction.php b/sources/AppBundle/Controller/Admin/Members/GeneralMeetingQuestion/AddAction.php index d1cfd8106..948b831e0 100644 --- a/sources/AppBundle/Controller/Admin/Members/GeneralMeetingQuestion/AddAction.php +++ b/sources/AppBundle/Controller/Admin/Members/GeneralMeetingQuestion/AddAction.php @@ -7,7 +7,7 @@ use AppBundle\AssembleeGenerale\Entity\Question; use AppBundle\AssembleeGenerale\Entity\Repository\AssembleeGeneraleRepository; use AppBundle\AssembleeGenerale\Entity\Repository\QuestionRepository; -use AppBundle\AssembleeGenerale\Form\GeneralMeetingQuestionFormType; +use AppBundle\AssembleeGenerale\Form\QuestionFormType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -35,7 +35,7 @@ public function __invoke(Request $request, string $date): Response $question->date = \DateTime::createFromInterface($generalMeetingDate); $question->dateCreation = new \DateTime(); - $form = $this->createForm(GeneralMeetingQuestionFormType::class, $question); + $form = $this->createForm(QuestionFormType::class, $question); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->questionRepository->save($question); diff --git a/sources/AppBundle/Controller/Admin/Members/GeneralMeetingQuestion/EditAction.php b/sources/AppBundle/Controller/Admin/Members/GeneralMeetingQuestion/EditAction.php index a7f41e269..83903fb6a 100644 --- a/sources/AppBundle/Controller/Admin/Members/GeneralMeetingQuestion/EditAction.php +++ b/sources/AppBundle/Controller/Admin/Members/GeneralMeetingQuestion/EditAction.php @@ -5,7 +5,7 @@ namespace AppBundle\Controller\Admin\Members\GeneralMeetingQuestion; use AppBundle\AssembleeGenerale\Entity\Repository\QuestionRepository; -use AppBundle\AssembleeGenerale\Form\GeneralMeetingQuestionFormType; +use AppBundle\AssembleeGenerale\Form\QuestionFormType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -26,7 +26,7 @@ public function __invoke(Request $request, int $id): Response throw $this->createAccessDeniedException('Seules les questions en attente peuvent être modifiées'); } - $form = $this->createForm(GeneralMeetingQuestionFormType::class, $question); + $form = $this->createForm(QuestionFormType::class, $question); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->questionRepository->save($question); diff --git a/sources/AppBundle/Controller/Admin/Members/GeneralMeetingVote/ListAction.php b/sources/AppBundle/Controller/Admin/Members/GeneralMeetingVote/ListAction.php index 71a7e9901..0f3d97d2c 100644 --- a/sources/AppBundle/Controller/Admin/Members/GeneralMeetingVote/ListAction.php +++ b/sources/AppBundle/Controller/Admin/Members/GeneralMeetingVote/ListAction.php @@ -6,7 +6,7 @@ use AppBundle\AssembleeGenerale\Entity\Repository\QuestionRepository; use AppBundle\AssembleeGenerale\Entity\Repository\VoteRepository; -use AppBundle\GeneralMeeting\GeneralMeetingRepository; +use AppBundle\AssembleeGenerale\Entity\Repository\PresenceRepository; use DateTimeImmutable; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -15,7 +15,7 @@ class ListAction { public function __construct( - private readonly GeneralMeetingRepository $generalMeetingRepository, + private readonly PresenceRepository $generalMeetingRepository, private readonly QuestionRepository $questionRepository, private readonly VoteRepository $voteRepository, private readonly Environment $twig, diff --git a/sources/AppBundle/Controller/Website/Member/IndexAction.php b/sources/AppBundle/Controller/Website/Member/IndexAction.php index 7842ce866..5a90c7b64 100644 --- a/sources/AppBundle/Controller/Website/Member/IndexAction.php +++ b/sources/AppBundle/Controller/Website/Member/IndexAction.php @@ -9,7 +9,7 @@ use AppBundle\AssembleeGenerale\Entity\Repository\QuestionRepository; use AppBundle\Association\UserMembership\BadgesComputer; use AppBundle\Association\UserMembership\UserService; -use AppBundle\GeneralMeeting\GeneralMeetingRepository; +use AppBundle\AssembleeGenerale\Entity\Repository\PresenceRepository; use AppBundle\MembershipFee\Model\MembershipFee; use AppBundle\Security\Authentication; use AppBundle\Veille\Entity\Repository\NewsletterInscriptionRepository; @@ -24,7 +24,7 @@ final class IndexAction extends AbstractController public function __construct( private readonly ViewRenderer $view, private readonly AssembleeGeneraleRepository $assembleGeneraleRepository, - private readonly GeneralMeetingRepository $generalMeetingRepository, + private readonly PresenceRepository $generalMeetingRepository, private readonly UserService $userService, private readonly QuestionRepository $questionRepository, private readonly BadgesComputer $badgesComputer, diff --git a/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php b/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php index 027c19283..3e7f294a4 100644 --- a/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php +++ b/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php @@ -8,12 +8,12 @@ use AppBundle\AssembleeGenerale\Entity\Repository\AssembleeGeneraleRepository; use AppBundle\AssembleeGenerale\Entity\Repository\QuestionRepository; use AppBundle\AssembleeGenerale\Entity\Repository\VoteRepository; +use AppBundle\AssembleeGenerale\Enum\VoteValeur; use AppBundle\AssembleeGenerale\ReportListBuilder; -use AppBundle\Association\Model\GeneralMeetingVote; use AppBundle\Association\UserMembership\UserService; use AppBundle\AuditLog\Audit; -use AppBundle\GeneralMeeting\Attendee; -use AppBundle\GeneralMeeting\GeneralMeetingRepository; +use AppBundle\AssembleeGenerale\Dto\Attendee; +use AppBundle\AssembleeGenerale\Entity\Repository\PresenceRepository; use AppBundle\Security\Authentication; use AppBundle\Twig\ViewRenderer; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -30,7 +30,7 @@ public function __construct( private readonly ViewRenderer $view, private readonly UserService $userService, private readonly AssembleeGeneraleRepository $assembleGeneraleRepository, - private readonly GeneralMeetingRepository $generalMeetingRepository, + private readonly PresenceRepository $generalMeetingRepository, private readonly QuestionRepository $questionRepository, private readonly VoteRepository $voteRepository, private readonly ReportListBuilder $reportListBuilder, @@ -144,9 +144,9 @@ public function __invoke(Request $request): Response $questionResults[] = [ 'question' => $question, - 'count_oui' => $results[GeneralMeetingVote::VALUE_YES], - 'count_non' => $results[GeneralMeetingVote::VALUE_NO], - 'count_abstention' => $results[GeneralMeetingVote::VALUE_ABSTENTION], + 'count_oui' => $results[VoteValeur::Oui->value], + 'count_non' => $results[VoteValeur::Non->value], + 'count_abstention' => $results[VoteValeur::Abstention->value], ]; } @@ -154,7 +154,7 @@ public function __invoke(Request $request): Response 'question_results' => $questionResults, 'question' => $currentQuestion, 'vote_for_current_question' => $voteForCurrentQuestion, - 'vote_labels_by_values' => GeneralMeetingVote::getVoteLabelsByValue(), + 'vote_valeurs' => VoteValeur::cases(), 'title' => $title, 'latest_date' => $latestDate, 'form' => $form->createView(), diff --git a/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/VoteAction.php b/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/VoteAction.php index 7cb1dc276..447aa7bf3 100644 --- a/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/VoteAction.php +++ b/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/VoteAction.php @@ -7,8 +7,8 @@ use Afup\Site\Droits; use AppBundle\AssembleeGenerale\Entity\Repository\QuestionRepository; use AppBundle\AssembleeGenerale\Entity\Repository\VoteRepository; -use AppBundle\Association\Model\GeneralMeetingVote; -use AppBundle\GeneralMeeting\GeneralMeetingRepository; +use AppBundle\AssembleeGenerale\Enum\VoteValeur; +use AppBundle\AssembleeGenerale\Entity\Repository\PresenceRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; @@ -16,7 +16,7 @@ final class VoteAction extends AbstractController { public function __construct( - private readonly GeneralMeetingRepository $generalMeetingRepository, + private readonly PresenceRepository $generalMeetingRepository, private readonly QuestionRepository $questionRepository, private readonly VoteRepository $voteRepository, private readonly Droits $droits, @@ -28,7 +28,7 @@ public function __invoke(Request $request): RedirectResponse throw $this->createNotFoundException('QuestionId manquant'); } - if (false === GeneralMeetingVote::isValueAllowed($vote = $request->query->getAlpha('vote'))) { + if (null === VoteValeur::tryFrom($vote = $request->query->getAlpha('vote'))) { throw $this->createNotFoundException('Vote manquant'); } diff --git a/sources/AppBundle/GeneralMeeting/Attendee.php b/sources/AppBundle/GeneralMeeting/Attendee.php deleted file mode 100644 index 14b3a7918..000000000 --- a/sources/AppBundle/GeneralMeeting/Attendee.php +++ /dev/null @@ -1,108 +0,0 @@ -id; - } - - public function getEmail() - { - return $this->email; - } - - public function getLogin() - { - return $this->login; - } - - public function getLastname() - { - return $this->lastname; - } - - public function getFirstname() - { - return $this->firstname; - } - - public function getNearestOffice() - { - return $this->nearestOffice; - } - - public function getConsultationDate() - { - return $this->consultationDate; - } - - public function getPresence() - { - return $this->presence; - } - - public function isPresent(): bool - { - return $this->presence === GeneralMeetingResponse::STATUS_PRESENT; - } - - public function isAbsent(): bool - { - return $this->presence === GeneralMeetingResponse::STATUS_NON_PRESENT; - } - - public function getPowerId() - { - return $this->powerId; - } - - public function getPowerLastname() - { - return $this->powerLastname; - } - - public function getPowerFirstname() - { - return $this->powerFirstname; - } - - public function getHash(): string - { - return md5($this->id . '_' . $this->email . '_' . $this->login); - } -} diff --git a/sources/AppBundle/GeneralMeeting/GeneralMeeting.php b/sources/AppBundle/GeneralMeeting/GeneralMeeting.php deleted file mode 100644 index 0bbe6ee46..000000000 --- a/sources/AppBundle/GeneralMeeting/GeneralMeeting.php +++ /dev/null @@ -1,59 +0,0 @@ -id; - } - - public function getPersonnePhysiqueId() - { - return $this->personnePhysiqueId; - } - - public function getDate(): \DateTimeInterface - { - return $this->date; - } - - public function getPresence() - { - return $this->presence; - } - - public function getPersonneAvecPouvoirId() - { - return $this->personneAvecPouvoirId; - } - - public function getConsultationDate(): ?\DateTimeInterface - { - return $this->consultationDate; - } - - public function getModificationDate(): ?\DateTimeInterface - { - return $this->modificationDate; - } -} diff --git a/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php b/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php deleted file mode 100644 index 83d220173..000000000 --- a/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php +++ /dev/null @@ -1,420 +0,0 @@ -connection->executeQuery(<<<'SQL' -SELECT DISTINCT apag.date -FROM afup_presences_assemblee_generale apag -ORDER BY apag.date DESC -SQL - ); - - return array_map(static fn(array $row): \DateTimeImmutable => new DateTimeImmutable('@' . $row['date']), $query->fetchAllAssociative()); - } - - public function getLatestAttendanceDate(): ?DateTimeImmutable - { - $query = $this->connection->executeQuery('SELECT MAX(date) maxDate FROM afup_presences_assemblee_generale LIMIT 1'); - $maxDate = $query->fetchOne(); - - return null !== $maxDate ? new DateTimeImmutable('@' . $maxDate) : null; - } - - public function getLatestGeneralAssemblyDate(): ?DateTimeImmutable - { - $query = $this->connection->executeQuery('SELECT MAX(date) maxDate FROM afup_assemblee_generale LIMIT 1'); - $maxDate = $query->fetchOne(); - - return null !== $maxDate ? new DateTimeImmutable('@' . $maxDate) : null; - } - - public function hasGeneralMeetingPlanned(?DateTimeInterface $currentDate = null): bool - { - if (!$currentDate instanceof \DateTimeInterface) { - $currentDate = new DateTime(); - } - $latestDate = $this->getLatestGeneralAssemblyDate(); - - return null !== $latestDate && $latestDate->getTimestamp() > strtotime('-1 day', $currentDate->getTimestamp()); - } - - /** - * @param string $login - */ - public function findOneByLoginAndDate($login, DateTimeInterface $date): ?GeneralMeeting - { - $query = $this->connection->prepare(<<<'SQL' -SELECT apag.* -FROM afup_presences_assemblee_generale apag -JOIN afup_personnes_physiques app ON apag.id_personne_physique = app.id -WHERE app.login = :login -AND apag.date = :date -LIMIT 1 -SQL - ); - $query->bindValue('login', $login); - $query->bindValue('date', $date->getTimestamp()); - $row = $query->executeQuery()->fetchAssociative(); - - return is_array($row) ? new GeneralMeeting( - (int) $row['id'], - (int) $row['id_personne_physique'], - new DateTimeImmutable('@' . $row['date']), - (int) $row['presence'], - (int) $row['id_personne_avec_pouvoir'], - $row['date_consultation'] ? new \DateTimeImmutable('@' . $row['date_consultation']) : null, - $row['date_modification'] ? new \DateTimeImmutable('@' . $row['date_modification']) : null, - ) : null; - } - - public function findOneByDate(DateTimeInterface $date): ?array - { - $query = $this->connection->prepare(<<bindValue('date', $date->getTimestamp()); - $row = $query->executeQuery()->fetchAssociative(); - - return is_array($row) ? [ - 'date' => new \DateTimeImmutable('@' . $row['date']), - 'description' => $row['description'], - ] : null; - } - - public function countAttendeesAndPowers(DateTimeInterface $date): int - { - $query = $this->connection->prepare(<<<'SQL' -SELECT COUNT(*) c -FROM afup_presences_assemblee_generale apag -WHERE apag.date = :date -AND (apag.presence = '1' OR apag.id_personne_avec_pouvoir > 0) -SQL - ); - $query->bindValue('date', $date->getTimestamp()); - - return (int) $query->executeQuery()->fetchOne(); - } - - public function countAttendees(DateTimeInterface $date): int - { - $query = $this->connection->prepare(<<<'SQL' -SELECT COUNT(*) c -FROM afup_presences_assemblee_generale apag -WHERE apag.date = :date -AND apag.presence = '1' -SQL - ); - $query->bindValue('date', $date->getTimestamp()); - - return (int) $query->executeQuery()->fetchOne(); - } - - public function obtenirDescription(DateTimeInterface $date) - { - $query = $this->connection->prepare(<<<'SQL' -SELECT description -FROM afup_assemblee_generale aag -WHERE aag.date = :date -SQL - ); - $query->bindValue('date', $date->getTimestamp()); - - return $query->executeQuery()->fetchOne() ?: null; - } - - /** - * @param string $order - * @param string $direction - * @param int|null $idPersonneAvecPouvoir - * - * @return Attendee[] - */ - public function getAttendees(DateTimeInterface $date, $order = 'nom', $direction = 'asc', $idPersonneAvecPouvoir = null): array - { - $query = $this->connection->createQueryBuilder() - ->from('afup_personnes_physiques', 'app') - ->select( - 'app.id', - 'app.email', - 'app.login', - 'app.nom', - 'app.prenom', - 'app.nearest_office', - 'apag.date_consultation', - 'apag.presence', - 'app2.id AS power_id', - 'app2.nom AS power_lastname', - 'app2.prenom AS power_firstname', - ) - ->join('app', 'afup_presences_assemblee_generale', 'apag', 'app.id = apag.id_personne_physique') - ->leftJoin('app', 'afup_personnes_physiques', 'app2', 'app2.id = apag.id_personne_avec_pouvoir') - ->where('apag.date = :date') - ->orderBy($order, $direction) - ->setParameter('date', $date->getTimestamp()); - - if (null !== $idPersonneAvecPouvoir) { - $query->andWhere('id_personne_avec_pouvoir = :pouvoir') - ->setParameter('pouvoir', $idPersonneAvecPouvoir); - } - - return array_map(static fn(array $row): Attendee => new Attendee( - (int) $row['id'], - $row['email'], - $row['login'], - $row['nom'], - $row['prenom'], - $row['nearest_office'], - $row['date_consultation'] ? new \DateTimeImmutable('@' . $row['date_consultation']) : null, - (int) $row['presence'], - $row['power_id'] ? (int) $row['power_id'] : null, - $row['power_lastname'], - $row['power_firstname'], - ), $query->executeQuery()->fetchAllAssociative()); - } - - /** - * @param string|null $excludeLogin - * - * @return array - */ - public function getPowerSelectionList(DateTimeInterface $date, $excludeLogin): array - { - $query = $this->connection->createQueryBuilder() - ->from('afup_personnes_physiques', 'app') - ->join('app', 'afup_presences_assemblee_generale', 'apag', 'app.id = apag.id_personne_physique') - ->select('app.id', 'app.nom', 'app.prenom') - ->where('apag.date = :date') - ->andWhere('apag.presence = \'1\'') - ->groupBy('app.id') - ->orderBy('app.nom') - ->orderBy('app.prenom') - ->setParameter('date', $date->getTimestamp()); - - if (null !== $excludeLogin) { - $query->andWhere('app.login <> :login') - ->setParameter('login', $excludeLogin); - } - - $list = []; - foreach ($query->executeQuery()->fetchAllAssociative() as $row) { - $list[$row['id']] = $row['nom'] . ' ' . $row['prenom']; - } - - return $list; - } - - public function getValidAttendeeIds(DateTimeInterface $date): array - { - // On autorise un battement de 14 jours - $timestamp = $date->getTimestamp() - 14 * 86400; - $query = $this->connection->prepare(<<<'SQL' -SELECT app.id -FROM afup_cotisations ac -INNER JOIN afup_personnes_physiques app ON app.id = ac.id_personne -WHERE date_fin >= :date -AND type_personne = 0 -AND etat = 1 -UNION SELECT app.id -FROM afup_cotisations ac -INNER JOIN afup_personnes_physiques app ON app.id_personne_morale = ac.id_personne -WHERE date_fin >= :date -AND type_personne = 1 -AND etat = 1 -SQL - ); - $query->bindValue('date', $timestamp); - - return array_map(static fn(array $row): int => (int) $row['id'], $query->executeQuery()->fetchAllAssociative()); - } - - /** - * @param string $description - * - * @return bool - */ - public function prepare(DateTimeInterface $date, $description) - { - $query = $this->connection->executeQuery('SELECT id FROM afup_personnes_physiques WHERE etat = 1'); - $success = 0; - $insertQuery = $this->connection->prepare('INSERT INTO afup_presences_assemblee_generale (id_personne_physique, date) - VALUES (:id, :date)'); - $insertQuery->bindValue('date', $date->getTimestamp()); - foreach ($query->fetchAllAssociative() as $row) { - $query = $this->connection->prepare('SELECT id FROM afup_presences_assemblee_generale - WHERE id_personne_physique = :id AND date = :date'); - $query->bindValue('id', $row['id']); - $query->bindValue('date', $date->getTimestamp()); - - $preparation = $query->executeQuery()->fetchAssociative(); - if (!is_array($preparation)) { - $insertQuery->bindValue('id', $row['id']); - if ($insertQuery->executeStatement()) { - $success++; - } - } - } - if (0 === $success) { - return false; - } - - $query = $this->connection->prepare('REPLACE INTO afup_assemblee_generale (`date`, `description`) - VALUES (:date, :description)'); - $query->bindValue('date', $date->getTimestamp()); - $query->bindValue('description', $description); - - return $query->executeStatement() > 0; - } - - /** - * @param string $description - * @return bool - */ - public function save(DateTimeInterface $date, $description) - { - $query = $this->connection->prepare('UPDATE afup_assemblee_generale SET `description` = :description - WHERE `date` = :date'); - $query->bindValue('date', $date->getTimestamp()); - $query->bindValue('description', $description); - - return $query->executeStatement() > 0; - } - - /** - * @param int $personId - * @param int $presence - * @param int $powerId - * - * @return bool - */ - public function addAttendee($personId, DateTimeInterface $date, $presence, $powerId) - { - $query = $this->connection->prepare(<<<'SQL' -INSERT INTO afup_presences_assemblee_generale - (id_personne_physique, `date`, presence, id_personne_avec_pouvoir, date_modification) -VALUES (:personId, :date, :presence, :powerId, :modificationDate) -SQL - ); - $query->bindValue('personId', $personId); - $query->bindValue('date', $date->getTimestamp()); - $query->bindValue('presence', $presence); - $query->bindValue('powerId', $powerId); - $query->bindValue('modificationDate', new DateTimeImmutable()->getTimestamp()); - - return $query->executeStatement() > 0; - } - - /** - * @param string $login - * @param int $presence - * @param int $powerId - * - * @return bool - */ - public function editAttendee($login, DateTimeInterface $date, $presence, $powerId) - { - $query = $this->connection->prepare(<<<'SQL' -UPDATE afup_presences_assemblee_generale apag, afup_personnes_physiques app -SET apag.presence = :presence, - apag.id_personne_avec_pouvoir = :powerId, - apag.date_modification = :modificationDate -WHERE apag.id_personne_physique = app.id - AND (app.login = :login OR app.email = :login) - AND apag.date = :date -SQL - ); - $query->bindValue('login', $login); - $query->bindValue('date', $date->getTimestamp()); - $query->bindValue('presence', $presence); - $query->bindValue('powerId', $powerId); - $query->bindValue('modificationDate', new DateTimeImmutable()->getTimestamp()); - - return $query->executeStatement() > 0; - } - - /** - * @param string $login - */ - public function getAttendee($login, DateTimeInterface $date): ?Attendee - { - $query = $this->connection->prepare(<<<'SQL' -SELECT -app.id, -app.email, -app.login, -app.nom, -app.prenom, -app.nearest_office, -apag.date_consultation, -apag.presence, -app2.id as power_id, -app2.nom as power_lastname, -app2.prenom as power_firstname -FROM afup_personnes_physiques app -JOIN afup_presences_assemblee_generale apag ON app.id = apag.id_personne_physique -LEFT JOIN afup_personnes_physiques app2 ON app2.id = apag.id_personne_avec_pouvoir -WHERE app.login = :login AND apag.date = :date -LIMIT 1 -SQL - ); - $query->bindValue('login', $login); - $query->bindValue('date', $date->getTimestamp()); - - $row = $query->executeQuery()->fetchAssociative(); - - return is_array($row) ? new Attendee( - (int) $row['id'], - $row['email'], - $row['login'], - $row['nom'], - $row['prenom'], - $row['nearest_office'], - $row['date_consultation'] ? new \DateTimeImmutable('@' . $row['date_consultation']) : null, - (int) $row['presence'], - $row['power_id'] ? (int) $row['power_id'] : null, - $row['power_lastname'], - $row['power_firstname'], - ) : null; - } - - /** - * @param int $nombrePersonnesAJourDeCotisation - */ - public function obtenirEcartQuorum(DateTimeInterface $date, $nombrePersonnesAJourDeCotisation): int - { - $quorum = (int) ceil($nombrePersonnesAJourDeCotisation / 4); - - return $this->countAttendeesAndPowers($date) - $quorum; - } - - public function hasUserRspvedToLastGeneralMeeting(User $user): bool - { - $generalMeeting = null; - $latestDate = $this->getLatestAttendanceDate(); - if (null !== $latestDate) { - $generalMeeting = $this->findOneByLoginAndDate($user->getUsername(), $latestDate); - } - - return $generalMeeting instanceof GeneralMeeting && $generalMeeting->getModificationDate() instanceof \DateTimeInterface; - } -} diff --git a/sources/AppBundle/Slack/MessageFactory.php b/sources/AppBundle/Slack/MessageFactory.php index 34c1cdffd..781fe5ea8 100644 --- a/sources/AppBundle/Slack/MessageFactory.php +++ b/sources/AppBundle/Slack/MessageFactory.php @@ -13,7 +13,7 @@ use AppBundle\Event\Model\Repository\TicketTypeRepository; use AppBundle\Event\Model\Talk; use AppBundle\Event\Model\Vote; -use AppBundle\GeneralMeeting\GeneralMeetingRepository; +use AppBundle\AssembleeGenerale\Entity\Repository\PresenceRepository; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Contracts\Translation\TranslatorInterface; use Webmozart\Assert\Assert; @@ -149,7 +149,7 @@ public function createMessageForMemberNotification(string $membersToCheckCount): return $message; } - public function createMessageForGeneralMeeting(GeneralMeetingRepository $generalMeetingRepository, UserRepository $userRepository, UrlGeneratorInterface $urlGenerator): Message + public function createMessageForGeneralMeeting(PresenceRepository $generalMeetingRepository, UserRepository $userRepository, UrlGeneratorInterface $urlGenerator): Message { $latestDate = $generalMeetingRepository->getLatestAttendanceDate(); Assert::notNull($latestDate); diff --git a/templates/admin/association/membership/generalmeeting.html.twig b/templates/admin/association/membership/generalmeeting.html.twig index 57eb7d9ed..4bc49760e 100644 --- a/templates/admin/association/membership/generalmeeting.html.twig +++ b/templates/admin/association/membership/generalmeeting.html.twig @@ -20,9 +20,9 @@
{% if not vote_for_current_question %}
- {% for value, label in vote_labels_by_values %} + {% for voteValeur in vote_valeurs %} {% endfor %}
From 2c7d4e1485fa11a82482d2a5321ad827a87a88d8 Mon Sep 17 00:00:00 2001 From: vgreb Date: Thu, 23 Jul 2026 21:39:41 +0200 Subject: [PATCH 2/4] =?UTF-8?q?Suppression=20des=20classes=20Ting=20Genera?= =?UTF-8?q?lMeeting=20obsol=C3=A8tes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpstan-baseline.php | 432 ++++-------------- .../Model/GeneralMeetingQuestion.php | 184 -------- .../Model/GeneralMeetingResponse.php | 121 ----- .../Association/Model/GeneralMeetingVote.php | 170 ------- .../GeneralMeetingQuestionRepository.php | 154 ------- .../GeneralMeetingResponseRepository.php | 68 --- .../GeneralMeetingVoteRepository.php | 97 ---- 7 files changed, 93 insertions(+), 1133 deletions(-) delete mode 100644 sources/AppBundle/Association/Model/GeneralMeetingQuestion.php delete mode 100644 sources/AppBundle/Association/Model/GeneralMeetingResponse.php delete mode 100644 sources/AppBundle/Association/Model/GeneralMeetingVote.php delete mode 100644 sources/AppBundle/Association/Model/Repository/GeneralMeetingQuestionRepository.php delete mode 100644 sources/AppBundle/Association/Model/Repository/GeneralMeetingResponseRepository.php delete mode 100644 sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 05d397863..7dc1613a8 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -205,16 +205,10 @@ 'count' => 1, 'path' => __DIR__ . '/sources/Afup/Pagination.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Binary operation "\\." between mixed and \' \' results in an error\\.$#', - 'identifier' => 'binaryOp.invalid', - 'count' => 6, - 'path' => __DIR__ . '/sources/Afup/Utils/PDF_AG.php', -]; $ignoreErrors[] = [ 'message' => '#^Binary operation "\\." between non\\-falsy\\-string and mixed results in an error\\.$#', 'identifier' => 'binaryOp.invalid', - 'count' => 7, + 'count' => 1, 'path' => __DIR__ . '/sources/Afup/Utils/PDF_AG.php', ]; $ignoreErrors[] = [ @@ -793,6 +787,90 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Accounting/TransactionModification.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Binary operation "\\." between \'@\' and mixed results in an error\\.$#', + 'identifier' => 'binaryOp.invalid', + 'count' => 4, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Binary operation "\\." between mixed and \' \' results in an error\\.$#', + 'identifier' => 'binaryOp.invalid', + 'count' => 1, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Binary operation "\\." between non\\-falsy\\-string and mixed results in an error\\.$#', + 'identifier' => 'binaryOp.invalid', + 'count' => 1, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Cannot cast mixed to int\\.$#', + 'identifier' => 'cast.int', + 'count' => 9, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Method AppBundle\\\\AssembleeGenerale\\\\Entity\\\\Repository\\\\PresenceRepository\\:\\:getPowerSelectionList\\(\\) should return array\\ but returns array\\\\.$#', + 'identifier' => 'return.type', + 'count' => 1, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Method AppBundle\\\\AssembleeGenerale\\\\Entity\\\\Repository\\\\PresenceRepository\\:\\:getValidAttendeeIds\\(\\) return type has no value type specified in iterable type array\\.$#', + 'identifier' => 'missingType.iterableValue', + 'count' => 1, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#10 \\$powerLastname of class AppBundle\\\\AssembleeGenerale\\\\Dto\\\\Attendee constructor expects string\\|null, mixed given\\.$#', + 'identifier' => 'argument.type', + 'count' => 2, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#11 \\$powerFirstname of class AppBundle\\\\AssembleeGenerale\\\\Dto\\\\Attendee constructor expects string\\|null, mixed given\\.$#', + 'identifier' => 'argument.type', + 'count' => 2, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#2 \\$email of class AppBundle\\\\AssembleeGenerale\\\\Dto\\\\Attendee constructor expects string, mixed given\\.$#', + 'identifier' => 'argument.type', + 'count' => 2, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#3 \\$login of class AppBundle\\\\AssembleeGenerale\\\\Dto\\\\Attendee constructor expects string, mixed given\\.$#', + 'identifier' => 'argument.type', + 'count' => 2, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#4 \\$lastname of class AppBundle\\\\AssembleeGenerale\\\\Dto\\\\Attendee constructor expects string, mixed given\\.$#', + 'identifier' => 'argument.type', + 'count' => 2, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#5 \\$firstname of class AppBundle\\\\AssembleeGenerale\\\\Dto\\\\Attendee constructor expects string, mixed given\\.$#', + 'identifier' => 'argument.type', + 'count' => 2, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#6 \\$nearestOffice of class AppBundle\\\\AssembleeGenerale\\\\Dto\\\\Attendee constructor expects string, mixed given\\.$#', + 'identifier' => 'argument.type', + 'count' => 2, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Possibly invalid array key type mixed\\.$#', + 'identifier' => 'offsetAccess.invalidOffset', + 'count' => 1, + 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', +]; $ignoreErrors[] = [ 'message' => '#^Parameter \\#1 \\$email of class AppBundle\\\\Email\\\\Mailer\\\\MailUser constructor expects string, mixed given\\.$#', 'identifier' => 'argument.type', @@ -1117,36 +1195,6 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Association/Model/CompanyMember.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\GeneralMeetingVote\\:\\:getAllValues\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/GeneralMeetingVote.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\GeneralMeetingVote\\:\\:getValueLabel\\(\\) should return string\\|null but returns mixed\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/GeneralMeetingVote.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\GeneralMeetingVote\\:\\:getVoteLabelsByValue\\(\\) return type has no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/GeneralMeetingVote.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\GeneralMeetingVote\\:\\:isValueAllowed\\(\\) has parameter \\$value with no type specified\\.$#', - 'identifier' => 'missingType.parameter', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/GeneralMeetingVote.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#2 \\$haystack of function in_array expects array, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/GeneralMeetingVote.php', -]; $ignoreErrors[] = [ 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\CompanyMemberInvitationRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', 'identifier' => 'missingType.iterableValue', @@ -1369,114 +1417,6 @@ 'count' => 5, 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/CompanyMemberRepository.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingQuestionRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingQuestionRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingQuestionRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingQuestionRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingQuestionRepository\\:\\:loadNextOpenedQuestion\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingQuestionRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingQuestionRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingResponseRepository\\:\\:getByUser\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingResponseRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingResponseRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingResponseRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingResponseRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingResponseRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingResponseRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'value\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot access offset \'weight_sum\' on mixed\\.$#', - 'identifier' => 'offsetAccess.nonOffsetAccessible', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingVoteRepository\\:\\:getResultsForQuestionId\\(\\) should return array\\ but returns array\\\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingVoteRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingVoteRepository\\:\\:initMetadata\\(\\) should return M of CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata but returns CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingVoteRepository\\:\\:loadByQuestionIdAndUserId\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingVoteRepository\\:\\:loadByQuestionIdAndUserId\\(\\) has parameter \\$questionId with no type specified\\.$#', - 'identifier' => 'missingType.parameter', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Association\\\\Model\\\\Repository\\\\GeneralMeetingVoteRepository\\:\\:loadByQuestionIdAndUserId\\(\\) has parameter \\$userId with no type specified\\.$#', - 'identifier' => 'missingType.parameter', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Possibly invalid array key type mixed\\.$#', - 'identifier' => 'offsetAccess.invalidOffset', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php', -]; $ignoreErrors[] = [ 'message' => '#^Binary operation "\\*" between int and mixed results in an error\\.$#', 'identifier' => 'binaryOp.invalid', @@ -3944,19 +3884,19 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/HomeAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$date of method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:countAttendees\\(\\) expects DateTimeInterface, DateTimeImmutable\\|null given\\.$#', + 'message' => '#^Parameter \\#1 \\$date of method AppBundle\\\\AssembleeGenerale\\\\Entity\\\\Repository\\\\PresenceRepository\\:\\:countAttendees\\(\\) expects DateTimeInterface, DateTimeImmutable\\|null given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/HomeAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$date of method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:countAttendeesAndPowers\\(\\) expects DateTimeInterface, DateTimeImmutable\\|null given\\.$#', + 'message' => '#^Parameter \\#1 \\$date of method AppBundle\\\\AssembleeGenerale\\\\Entity\\\\Repository\\\\PresenceRepository\\:\\:countAttendeesAndPowers\\(\\) expects DateTimeInterface, DateTimeImmutable\\|null given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/HomeAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$date of method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:obtenirEcartQuorum\\(\\) expects DateTimeInterface, DateTimeImmutable\\|null given\\.$#', + 'message' => '#^Parameter \\#1 \\$date of method AppBundle\\\\AssembleeGenerale\\\\Entity\\\\Repository\\\\PresenceRepository\\:\\:obtenirEcartQuorum\\(\\) expects DateTimeInterface, DateTimeImmutable\\|null given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/HomeAction.php', @@ -4010,19 +3950,19 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListingAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$date of method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:getAttendees\\(\\) expects DateTimeInterface, DateTimeImmutable\\|false given\\.$#', + 'message' => '#^Parameter \\#1 \\$date of method AppBundle\\\\AssembleeGenerale\\\\Entity\\\\Repository\\\\PresenceRepository\\:\\:getAttendees\\(\\) expects DateTimeInterface, DateTimeImmutable\\|false given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListingAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$date of method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:prepare\\(\\) expects DateTimeInterface, mixed given\\.$#', + 'message' => '#^Parameter \\#1 \\$date of method AppBundle\\\\AssembleeGenerale\\\\Entity\\\\Repository\\\\AssembleeGeneraleRepository\\:\\:prepare\\(\\) expects DateTimeInterface, mixed given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/PrepareAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#2 \\$description of method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:prepare\\(\\) expects string, mixed given\\.$#', + 'message' => '#^Parameter \\#2 \\$description of method AppBundle\\\\AssembleeGenerale\\\\Entity\\\\Repository\\\\AssembleeGeneraleRepository\\:\\:prepare\\(\\) expects string, mixed given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/PrepareAction.php', @@ -5582,13 +5522,13 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#3 \\$presence of method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:addAttendee\\(\\) expects int, mixed given\\.$#', + 'message' => '#^Parameter \\#3 \\$presence of method AppBundle\\\\AssembleeGenerale\\\\Entity\\\\Repository\\\\PresenceRepository\\:\\:addAttendee\\(\\) expects int, mixed given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#3 \\$presence of method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:editAttendee\\(\\) expects int, mixed given\\.$#', + 'message' => '#^Parameter \\#3 \\$presence of method AppBundle\\\\AssembleeGenerale\\\\Entity\\\\Repository\\\\PresenceRepository\\:\\:editAttendee\\(\\) expects int, mixed given\\.$#', 'identifier' => 'argument.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php', @@ -8473,192 +8413,6 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Form/BooleanType.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\Attendee\\:\\:getConsultationDate\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/Attendee.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\Attendee\\:\\:getEmail\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/Attendee.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\Attendee\\:\\:getFirstname\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/Attendee.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\Attendee\\:\\:getId\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/Attendee.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\Attendee\\:\\:getLastname\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/Attendee.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\Attendee\\:\\:getLogin\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/Attendee.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\Attendee\\:\\:getNearestOffice\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/Attendee.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\Attendee\\:\\:getPowerFirstname\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/Attendee.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\Attendee\\:\\:getPowerId\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/Attendee.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\Attendee\\:\\:getPowerLastname\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/Attendee.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\Attendee\\:\\:getPresence\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/Attendee.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\GeneralMeeting\\:\\:getId\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeeting.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\GeneralMeeting\\:\\:getPersonneAvecPouvoirId\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeeting.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\GeneralMeeting\\:\\:getPersonnePhysiqueId\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeeting.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\GeneralMeeting\\:\\:getPresence\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeeting.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Binary operation "\\." between \'@\' and mixed results in an error\\.$#', - 'identifier' => 'binaryOp.invalid', - 'count' => 9, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Binary operation "\\." between mixed and \' \' results in an error\\.$#', - 'identifier' => 'binaryOp.invalid', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Binary operation "\\." between non\\-falsy\\-string and mixed results in an error\\.$#', - 'identifier' => 'binaryOp.invalid', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot cast mixed to int\\.$#', - 'identifier' => 'cast.int', - 'count' => 13, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:findOneByDate\\(\\) return type has no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:getPowerSelectionList\\(\\) should return array\\ but returns array\\\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:getValidAttendeeIds\\(\\) return type has no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\GeneralMeeting\\\\GeneralMeetingRepository\\:\\:obtenirDescription\\(\\) has no return type specified\\.$#', - 'identifier' => 'missingType.return', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#10 \\$powerLastname of class AppBundle\\\\GeneralMeeting\\\\Attendee constructor expects string\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#11 \\$powerFirstname of class AppBundle\\\\GeneralMeeting\\\\Attendee constructor expects string\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#2 \\$email of class AppBundle\\\\GeneralMeeting\\\\Attendee constructor expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#3 \\$login of class AppBundle\\\\GeneralMeeting\\\\Attendee constructor expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#4 \\$lastname of class AppBundle\\\\GeneralMeeting\\\\Attendee constructor expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#5 \\$firstname of class AppBundle\\\\GeneralMeeting\\\\Attendee constructor expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#6 \\$nearestOffice of class AppBundle\\\\GeneralMeeting\\\\Attendee constructor expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Possibly invalid array key type mixed\\.$#', - 'identifier' => 'offsetAccess.invalidOffset', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/GeneralMeeting/GeneralMeetingRepository.php', -]; $ignoreErrors[] = [ 'message' => '#^Method AppBundle\\\\Github\\\\Exception\\\\UnableToFindGithubUserException\\:\\:__construct\\(\\) has parameter \\$username with no type specified\\.$#', 'identifier' => 'missingType.parameter', diff --git a/sources/AppBundle/Association/Model/GeneralMeetingQuestion.php b/sources/AppBundle/Association/Model/GeneralMeetingQuestion.php deleted file mode 100644 index e80d52217..000000000 --- a/sources/AppBundle/Association/Model/GeneralMeetingQuestion.php +++ /dev/null @@ -1,184 +0,0 @@ -id; - } - - /** - * @param int $id - * - * @return $this - */ - public function setId($id): self - { - $this->propertyChanged('id', $this->id, $id); - $this->id = $id; - - return $this; - } - - public function getDate(): ?\DateTimeInterface - { - return $this->date; - } - - /** - * @return $this - */ - public function setDate(\DateTimeInterface $date): self - { - $this->propertyChanged('date', $this->date, $date); - $this->date = $date; - - return $this; - } - - /** - * @return string - */ - public function getLabel() - { - return $this->label; - } - - /** - * @param string $label - */ - public function setLabel($label): self - { - $this->propertyChanged('label', $this->label, $label); - $this->label = $label; - - return $this; - } - - /** - * @return \DateTime - */ - public function getOpenedAt(): ?\DateTime - { - return $this->openedAt; - } - - /** - * @return $this - */ - public function setOpenedAt(?\DateTime $openedAt = null): self - { - $this->propertyChanged('openedAt', $this->openedAt, $openedAt); - $this->openedAt = $openedAt; - - return $this; - } - - /** - * @return \DateTime - */ - public function getClosedAt(): ?\DateTime - { - return $this->closedAt; - } - - /** - * @return $this - */ - public function setClosedAt(?\DateTime $closedAt = null): self - { - $this->propertyChanged('closedAt', $this->closedAt, $closedAt); - $this->closedAt = $closedAt; - - return $this; - } - - /** - * @return \DateTime - */ - public function getCreatedAt(): ?\DateTime - { - return $this->createdAt; - } - - /** - * @return $this - */ - public function setCreatedAt(\DateTime $createdAt): self - { - $this->propertyChanged('createdAt', $this->createdAt, $createdAt); - $this->createdAt = $createdAt; - - return $this; - } - - public function getStatus(): string - { - if ($this->getClosedAt() instanceof \DateTime) { - return self::STATUS_CLOSED; - } - - if ($this->getOpenedAt() instanceof \DateTime) { - return self::STATUS_OPENED; - } - - return self::STATUS_WAITING; - } - - public function hasStatusWaiting(): bool - { - return self::STATUS_WAITING === $this->getStatus(); - } - - public function hasStatusOpened(): bool - { - return self::STATUS_OPENED === $this->getStatus(); - } - - public function hasStatusClosed(): bool - { - return self::STATUS_CLOSED === $this->getStatus(); - } - - /** - * @param array $results - */ - public function hasVotes(array $results): bool - { - return 0 > $results[GeneralMeetingVote::VALUE_YES] + $results[GeneralMeetingVote::VALUE_NO] + $results[GeneralMeetingVote::VALUE_ABSTENTION]; - } -} diff --git a/sources/AppBundle/Association/Model/GeneralMeetingResponse.php b/sources/AppBundle/Association/Model/GeneralMeetingResponse.php deleted file mode 100644 index b23849e71..000000000 --- a/sources/AppBundle/Association/Model/GeneralMeetingResponse.php +++ /dev/null @@ -1,121 +0,0 @@ -id; - } - - /** - * @param int $id - * - * @return $this - */ - public function setId($id): self - { - $this->propertyChanged('id', $this->id, $id); - $this->id = $id; - - return $this; - } - - /** - * @return int - */ - public function getUserid() - { - return $this->userId; - } - - /** - * @param int $userid - * - * @return $this - */ - public function setUserId($userid): self - { - $this->propertyChanged('manager', $this->userId, $userid); - $this->userId = $userid; - - return $this; - } - - /** - * @return \DateTime - */ - public function getDate(): ?\DateTime - { - return $this->date; - } - - /** - * @return $this - */ - public function setDate(\DateTime $date): self - { - $this->propertyChanged('date', $this->date, $date); - $this->date = $date; - - return $this; - } - - /** - * @return int - */ - public function getStatus() - { - return $this->status; - } - - /** - * @param int $status - * - * @return $this - */ - public function setStatus($status): self - { - $this->propertyChanged('status', $this->status, $status); - $this->status = $status; - - return $this; - } - - public function isPresent(): bool - { - return self::STATUS_PRESENT === $this->getStatus(); - } -} diff --git a/sources/AppBundle/Association/Model/GeneralMeetingVote.php b/sources/AppBundle/Association/Model/GeneralMeetingVote.php deleted file mode 100644 index 4586d87ad..000000000 --- a/sources/AppBundle/Association/Model/GeneralMeetingVote.php +++ /dev/null @@ -1,170 +0,0 @@ -questionId; - } - - /** - * @param int $questionId - * - * @return $this - */ - public function setQuestionId($questionId): self - { - $this->propertyChanged('questionId', $this->questionId, $questionId); - $this->questionId = $questionId; - - return $this; - } - - /** - * @return int - */ - public function getUserId() - { - return $this->userId; - } - - /** - * @param int $userId - * - * @return $this - */ - public function setUserId($userId): self - { - $this->propertyChanged('userId', $this->userId, $userId); - $this->userId = $userId; - - return $this; - } - - /** - * @return int - */ - public function getWeight() - { - return $this->weight; - } - - /** - * @param int $weight - * - * @return $this - */ - public function setWeight($weight): self - { - $this->propertyChanged('weight', $this->weight, $weight); - $this->weight = $weight; - - return $this; - } - - /** - * @return string - */ - public function getValue() - { - return $this->value; - } - - /** - * @return string|null - */ - public function getValueLabel() - { - $valuesLabels = self::getVoteLabelsByValue(); - $value = $this->getValue(); - - return $valuesLabels[$value] ?? null; - } - - /** - * @param string $value - */ - public function setValue($value): self - { - $this->propertyChanged('value', $this->value, $value); - $this->value = $value; - - return $this; - } - - /** - * @return \DateTime - */ - public function getCreatedAt(): ?\DateTime - { - return $this->createdAt; - } - - /** - * @return $this - */ - public function setCreatedAt(\DateTime $createdAt): self - { - $this->propertyChanged('createdAt', $this->createdAt, $createdAt); - $this->createdAt = $createdAt; - - return $this; - } - - public static function isValueAllowed($value): bool - { - return in_array($value, self::getAllValues()); - } - - private static function getAllValues() - { - return array_keys(self::getVoteLabelsByValue()); - } - - public static function getVoteLabelsByValue(): array - { - return [ - self::VALUE_YES => 'Oui', - self::VALUE_NO => 'Non', - self::VALUE_ABSTENTION => 'Abstention', - ]; - } -} diff --git a/sources/AppBundle/Association/Model/Repository/GeneralMeetingQuestionRepository.php b/sources/AppBundle/Association/Model/Repository/GeneralMeetingQuestionRepository.php deleted file mode 100644 index ebc177178..000000000 --- a/sources/AppBundle/Association/Model/Repository/GeneralMeetingQuestionRepository.php +++ /dev/null @@ -1,154 +0,0 @@ - - */ -class GeneralMeetingQuestionRepository extends Repository implements MetadataInitializer -{ - public function loadNextOpenedQuestion(\DateTimeInterface $generalMeetingDate) - { - $sql = << $generalMeetingDate->format('U'), - ]; - - $query = $this->getPreparedQuery($sql)->setParams($params); - - $collection = $query->query($this->getCollection(new HydratorSingleObject())); - - if ($collection->count() === 0) { - return null; - } - - return $collection->first(); - } - - /** - * @return iterable - */ - public function loadClosedQuestions(\DateTimeInterface $generalMeetingDate) - { - $sql = << $generalMeetingDate->format('U'), - ]; - - /** @var iterable */ - return $this->getPreparedQuery($sql)->setParams($params)->query($this->getCollection(new HydratorSingleObject())); - } - - /** - * @return iterable - */ - public function loadByDate(\DateTimeInterface $generalMeetingDate) - { - /** @var iterable */ - return $this->getBy([ - 'date' => $generalMeetingDate->format('U'), - ]); - } - - public function open(GeneralMeetingQuestion $question): void - { - $question->setOpenedAt(new \DateTime()); - $this->save($question); - } - - public function close(GeneralMeetingQuestion $question): void - { - $question->setClosedAt(new \DateTime()); - $this->save($question); - } - - /** - * @inheritDoc - */ - public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) - { - $metadata = new Metadata($serializerFactory); - - $metadata->setEntity(GeneralMeetingQuestion::class); - $metadata->setConnectionName('main'); - $metadata->setDatabase($options['database']); - $metadata->setTable('afup_assemblee_generale_question'); - - $metadata - ->addField([ - 'columnName' => 'id', - 'fieldName' => 'id', - 'primary' => true, - 'autoincrement' => true, - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'date', - 'fieldName' => 'date', - 'type' => 'datetime', - 'serializer' => DateTimeImmutable::class, - 'serializer_options' => [ - 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'], - 'serialize' => ['format' => 'U'], - ], - ]) - ->addField([ - 'columnName' => 'label', - 'fieldName' => 'label', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'opened_at', - 'fieldName' => 'openedAt', - 'type' => 'datetime', - ]) - ->addField([ - 'columnName' => 'closed_at', - 'fieldName' => 'closedAt', - 'type' => 'datetime', - ]) - ->addField([ - 'columnName' => 'created_at', - 'fieldName' => 'createdAt', - 'type' => 'datetime', - ]) - ; - - return $metadata; - } -} diff --git a/sources/AppBundle/Association/Model/Repository/GeneralMeetingResponseRepository.php b/sources/AppBundle/Association/Model/Repository/GeneralMeetingResponseRepository.php deleted file mode 100644 index 19b96829f..000000000 --- a/sources/AppBundle/Association/Model/Repository/GeneralMeetingResponseRepository.php +++ /dev/null @@ -1,68 +0,0 @@ - - */ -class GeneralMeetingResponseRepository extends Repository implements MetadataInitializer -{ - public function getByUser(User $user) - { - return $this->getBy([ - 'userId' => $user->getId(), - ]); - } - - /** - * @inheritDoc - */ - public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) - { - $metadata = new Metadata($serializerFactory); - - $metadata->setEntity(GeneralMeetingResponse::class); - $metadata->setConnectionName('main'); - $metadata->setDatabase($options['database']); - $metadata->setTable('afup_presences_assemblee_generale'); - - $metadata - ->addField([ - 'columnName' => 'id', - 'fieldName' => 'id', - 'primary' => true, - 'autoincrement' => true, - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'date', - 'fieldName' => 'date', - 'type' => 'datetime', - 'serializer_options' => [ - 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'], - ], - ]) - ->addField([ - 'columnName' => 'id_personne_physique', - 'fieldName' => 'userId', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'presence', - 'fieldName' => 'status', - 'type' => 'int', - ]) - ; - - return $metadata; - } -} diff --git a/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php b/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php deleted file mode 100644 index 2d5ccd784..000000000 --- a/sources/AppBundle/Association/Model/Repository/GeneralMeetingVoteRepository.php +++ /dev/null @@ -1,97 +0,0 @@ - - */ -class GeneralMeetingVoteRepository extends Repository implements MetadataInitializer -{ - public function loadByQuestionIdAndUserId($questionId, $userId) - { - return $this->getOneBy([ - 'questionId' => $questionId, - 'userId' => $userId, - ]); - } - - /** - * @return array - */ - public function getResultsForQuestionId(int $questionId): array - { - $results = [ - GeneralMeetingVote::VALUE_YES => 0, - GeneralMeetingVote::VALUE_NO => 0, - GeneralMeetingVote::VALUE_ABSTENTION => 0, - ]; - - $sql = <<getPreparedQuery($sql)->setParams(['question_id' => $questionId]); - foreach ($preparedQuery->query($this->getCollection(new HydratorArray())) as $row) { - $results[$row['value']] = $row['weight_sum']; - } - - return $results; - } - - - /** - * @inheritDoc - */ - public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) - { - $metadata = new Metadata($serializerFactory); - - $metadata->setEntity(GeneralMeetingVote::class); - $metadata->setConnectionName('main'); - $metadata->setDatabase($options['database']); - $metadata->setTable('afup_vote_assemblee_generale'); - - $metadata - ->addField([ - 'columnName' => 'afup_assemblee_generale_question_id', - 'fieldName' => 'questionId', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'afup_personnes_physiques_id', - 'fieldName' => 'userId', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'weight', - 'fieldName' => 'weight', - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'value', - 'fieldName' => 'value', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'created_at', - 'fieldName' => 'createdAt', - 'type' => 'datetime', - ]) - ; - - return $metadata; - } -} From d3b205fa6daeba7e348623319b992b14d398a674 Mon Sep 17 00:00:00 2001 From: vgreb Date: Thu, 23 Jul 2026 23:37:36 +0200 Subject: [PATCH 3/4] Corrections runtime de la migration AssembleeGenerale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Presence: rétablit la jointure du calcul des cotisants valides (app.id_personne_morale = ac.id_personne pour les personnes morales), la colonne ac.id_personne_morale n'existe pas - Attendee: nearestOffice accepte null (colonne nearest_office nullable) - Test Behat aligné sur le préfixe question_form du formulaire renommé --- phpstan-baseline.php | 2 +- sources/AppBundle/AssembleeGenerale/Dto/Attendee.php | 4 ++-- .../Entity/Repository/PresenceRepository.php | 2 +- .../Members/GeneralMeeting/GeneralMeetingQuestions.feature | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 7dc1613a8..c645261ef 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -860,7 +860,7 @@ 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#6 \\$nearestOffice of class AppBundle\\\\AssembleeGenerale\\\\Dto\\\\Attendee constructor expects string, mixed given\\.$#', + 'message' => '#^Parameter \\#6 \\$nearestOffice of class AppBundle\\\\AssembleeGenerale\\\\Dto\\\\Attendee constructor expects string\\|null, mixed given\\.$#', 'identifier' => 'argument.type', 'count' => 2, 'path' => __DIR__ . '/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php', diff --git a/sources/AppBundle/AssembleeGenerale/Dto/Attendee.php b/sources/AppBundle/AssembleeGenerale/Dto/Attendee.php index 08089b9d1..017f9c054 100644 --- a/sources/AppBundle/AssembleeGenerale/Dto/Attendee.php +++ b/sources/AppBundle/AssembleeGenerale/Dto/Attendee.php @@ -15,7 +15,7 @@ public function __construct( private string $login, private string $lastname, private string $firstname, - private string $nearestOffice, + private ?string $nearestOffice, private ?DateTimeImmutable $consultationDate, private int $presence, private ?int $powerId, @@ -48,7 +48,7 @@ public function getFirstname(): string return $this->firstname; } - public function getNearestOffice(): string + public function getNearestOffice(): ?string { return $this->nearestOffice; } diff --git a/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php b/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php index 14df7df35..d034c3929 100644 --- a/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php +++ b/sources/AppBundle/AssembleeGenerale/Entity/Repository/PresenceRepository.php @@ -234,7 +234,7 @@ public function getValidAttendeeIds(DateTimeInterface $date): array AND etat = 1 UNION SELECT app.id FROM afup_cotisations ac -INNER JOIN afup_personnes_physiques app ON app.id = ac.id_personne_morale +INNER JOIN afup_personnes_physiques app ON app.id_personne_morale = ac.id_personne WHERE date_fin >= :date AND type_personne = 1 AND etat = 1 diff --git a/tests/behat/features/Admin/Members/GeneralMeeting/GeneralMeetingQuestions.feature b/tests/behat/features/Admin/Members/GeneralMeeting/GeneralMeetingQuestions.feature index a415528ca..89f756b40 100644 --- a/tests/behat/features/Admin/Members/GeneralMeeting/GeneralMeetingQuestions.feature +++ b/tests/behat/features/Admin/Members/GeneralMeeting/GeneralMeetingQuestions.feature @@ -17,7 +17,7 @@ Feature: Administration - Partie Assemblée Générale Questions And I follow "afup-main-menu-item--assemblee_generale_votes" When I follow "Ajouter" Then the ".content h2" element should contain "Assemblée générale - questions" - And I fill in "general_meeting_question_form[texte]" with "Une super question" + And I fill in "question_form[texte]" with "Une super question" And I press "Ajouter cette question" Then I should see "La question a été ajoutée" @@ -26,7 +26,7 @@ Feature: Administration - Partie Assemblée Générale Questions And I follow "afup-main-menu-item--assemblee_generale_votes" When I follow "question-1-edit" Then the ".content h2" element should contain "Modifier la question" - And I fill in "general_meeting_question_form[texte]" with "Une super question modifié" + And I fill in "question_form[texte]" with "Une super question modifié" And I press "Modifier cette question" Then I should see "La question a été modifiée" And I should see "Une super question modifié" From fd726a20bcf813a4f5ab4fca25e286aa9e78e00f Mon Sep 17 00:00:00 2001 From: vgreb Date: Thu, 23 Jul 2026 23:47:13 +0200 Subject: [PATCH 4/4] =?UTF-8?q?Renomme=20la=20propri=C3=A9t=C3=A9=20genera?= =?UTF-8?q?lMeetingRepository=20en=20presenceRepository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le renommage suit le type déjà injecté (PresenceRepository) ; la migration avait laissé le nom de propriété hérité de l'ancien GeneralMeetingRepository. --- .../AppBundle/Controller/Admin/HomeAction.php | 8 ++++---- .../Admin/Members/GeneralMeeting/ListAction.php | 16 ++++++++-------- .../Members/GeneralMeeting/ListingAction.php | 6 +++--- .../Members/GeneralMeetingVote/ListAction.php | 6 +++--- .../Controller/Website/Member/IndexAction.php | 4 ++-- .../Membership/GeneralMeeting/IndexAction.php | 14 +++++++------- .../Membership/GeneralMeeting/VoteAction.php | 4 ++-- sources/AppBundle/Slack/MessageFactory.php | 10 +++++----- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/sources/AppBundle/Controller/Admin/HomeAction.php b/sources/AppBundle/Controller/Admin/HomeAction.php index ab1fa8fb9..aa49551ce 100644 --- a/sources/AppBundle/Controller/Admin/HomeAction.php +++ b/sources/AppBundle/Controller/Admin/HomeAction.php @@ -26,7 +26,7 @@ public function __construct( private readonly TicketEventTypeRepository $ticketEventTypeRepository, private readonly NewsletterInscriptionRepository $newsletterInscriptionRepository, private readonly AssembleeGeneraleRepository $assembleGeneraleRepository, - private readonly PresenceRepository $generalMeetingRepository, + private readonly PresenceRepository $presenceRepository, private readonly StatisticsComputer $statisticsComputer, private readonly ClockInterface $clock, private readonly Authentication $authentication, @@ -126,12 +126,12 @@ public function __invoke(): Response $cards[] = [ 'title' => 'Assemblée générale', 'statistics' => [ - 'Votes et pouvoirs' => $this->generalMeetingRepository->countAttendeesAndPowers($latestDate), - 'Présences' => $this->generalMeetingRepository->countAttendees($latestDate), + 'Votes et pouvoirs' => $this->presenceRepository->countAttendeesAndPowers($latestDate), + 'Présences' => $this->presenceRepository->countAttendees($latestDate), ], 'main_statistic' => [ 'label' => 'Quorum', - 'value' => $this->generalMeetingRepository->obtenirEcartQuorum($latestDate, $statistics->usersCount), + 'value' => $this->presenceRepository->obtenirEcartQuorum($latestDate, $statistics->usersCount), ], 'url' => $this->generateUrl('admin_members_general_meeting'), ]; diff --git a/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListAction.php b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListAction.php index 7c22cd211..af2bf2600 100644 --- a/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListAction.php +++ b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListAction.php @@ -18,32 +18,32 @@ class ListAction public function __construct( private readonly UserRepository $userRepository, - private readonly PresenceRepository $generalMeetingRepository, + private readonly PresenceRepository $presenceRepository, private readonly Environment $twig, ) {} public function __invoke(Request $request): Response { - $latestDate = $this->generalMeetingRepository->getLatestAttendanceDate(); + $latestDate = $this->presenceRepository->getLatestAttendanceDate(); $sort = $request->query->get('sort', 'nom'); $direction = $request->query->get('direction', 'asc'); Assert::inArray($sort, self::VALID_SORTS); Assert::inArray($direction, self::VALID_DIRECTIONS); - $dates = $this->generalMeetingRepository->getAllDates(); + $dates = $this->presenceRepository->getAllDates(); $convocations = count($this->userRepository->getActiveMembers()); $nbAttendeesAndPowers = $nbAttendees = $quorum = $validAttendeeIds = null; if (null !== $latestDate) { - $nbAttendeesAndPowers = $this->generalMeetingRepository->countAttendeesAndPowers($latestDate); - $nbAttendees = $this->generalMeetingRepository->countAttendees($latestDate); - $quorum = $this->generalMeetingRepository->obtenirEcartQuorum($latestDate, $convocations); - $validAttendeeIds = $this->generalMeetingRepository->getValidAttendeeIds($latestDate); + $nbAttendeesAndPowers = $this->presenceRepository->countAttendeesAndPowers($latestDate); + $nbAttendees = $this->presenceRepository->countAttendees($latestDate); + $quorum = $this->presenceRepository->obtenirEcartQuorum($latestDate, $convocations); + $validAttendeeIds = $this->presenceRepository->getValidAttendeeIds($latestDate); } $selectedDate = $latestDate; if ($request->query->has('date')) { $selectedDate = \DateTimeImmutable::createFromFormat('U', $request->get('date')) ?: null; } - $attendees = null !== $selectedDate ? $this->generalMeetingRepository->getAttendees($selectedDate, $sort, $direction) : []; + $attendees = null !== $selectedDate ? $this->presenceRepository->getAttendees($selectedDate, $sort, $direction) : []; return new Response($this->twig->render('admin/members/general_meeting/list.html.twig', [ 'convocations' => $convocations, diff --git a/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListingAction.php b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListingAction.php index 0ea3a8de2..f5fc20b6e 100644 --- a/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListingAction.php +++ b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ListingAction.php @@ -14,17 +14,17 @@ class ListingAction { - public function __construct(private readonly PresenceRepository $generalMeetingRepository) {} + public function __construct(private readonly PresenceRepository $presenceRepository) {} public function __invoke(Request $request): BinaryFileResponse { - $latestDate = $this->generalMeetingRepository->getLatestAttendanceDate(); + $latestDate = $this->presenceRepository->getLatestAttendanceDate(); Assert::notNull($latestDate); $selectedDate = $latestDate; if ($request->query->has('date')) { $selectedDate = DateTimeImmutable::createFromFormat('d/m/Y', (string) $request->query->get('date')); } - $attendees = $this->generalMeetingRepository->getAttendees($selectedDate); + $attendees = $this->presenceRepository->getAttendees($selectedDate); $filename = tempnam(sys_get_temp_dir(), 'assemblee_generale'); $pdf = new PDF_AG(); $pdf->setFooterTitle('Assemblée générale ' . $selectedDate->format('d/m/Y')); diff --git a/sources/AppBundle/Controller/Admin/Members/GeneralMeetingVote/ListAction.php b/sources/AppBundle/Controller/Admin/Members/GeneralMeetingVote/ListAction.php index 0f3d97d2c..19dcee8d7 100644 --- a/sources/AppBundle/Controller/Admin/Members/GeneralMeetingVote/ListAction.php +++ b/sources/AppBundle/Controller/Admin/Members/GeneralMeetingVote/ListAction.php @@ -15,7 +15,7 @@ class ListAction { public function __construct( - private readonly PresenceRepository $generalMeetingRepository, + private readonly PresenceRepository $presenceRepository, private readonly QuestionRepository $questionRepository, private readonly VoteRepository $voteRepository, private readonly Environment $twig, @@ -23,8 +23,8 @@ public function __construct( public function __invoke(Request $request): Response { - $dates = $this->generalMeetingRepository->getAllDates(); - $latestDate = $this->generalMeetingRepository->getLatestAttendanceDate(); + $dates = $this->presenceRepository->getAllDates(); + $latestDate = $this->presenceRepository->getLatestAttendanceDate(); $selectedDate = $latestDate; if ($request->query->has('date')) { diff --git a/sources/AppBundle/Controller/Website/Member/IndexAction.php b/sources/AppBundle/Controller/Website/Member/IndexAction.php index 5a90c7b64..77049cff1 100644 --- a/sources/AppBundle/Controller/Website/Member/IndexAction.php +++ b/sources/AppBundle/Controller/Website/Member/IndexAction.php @@ -24,7 +24,7 @@ final class IndexAction extends AbstractController public function __construct( private readonly ViewRenderer $view, private readonly AssembleeGeneraleRepository $assembleGeneraleRepository, - private readonly PresenceRepository $generalMeetingRepository, + private readonly PresenceRepository $presenceRepository, private readonly UserService $userService, private readonly QuestionRepository $questionRepository, private readonly BadgesComputer $badgesComputer, @@ -67,7 +67,7 @@ public function __invoke(): Response 'has_up_to_date_membership_fee' => $user->hasUpToDateMembershipFee(), 'office_label' => $user->getNearestOfficeLabel($this->antenneRepository), 'has_general_meeting_planned' => $hasGeneralMeetingPlanned, - 'has_user_rspved_to_next_general_meeting' => $this->generalMeetingRepository->hasUserRspvedToLastGeneralMeeting($user), + 'has_user_rspved_to_next_general_meeting' => $this->presenceRepository->hasUserRspvedToLastGeneralMeeting($user), 'membershipfee_end_date' => $dateFinCotisation, 'display_link_to_general_meeting_vote' => $displayLinkToGeneralMeetingVote, ]); diff --git a/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php b/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php index 3e7f294a4..4ef7ceed8 100644 --- a/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php +++ b/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/IndexAction.php @@ -30,7 +30,7 @@ public function __construct( private readonly ViewRenderer $view, private readonly UserService $userService, private readonly AssembleeGeneraleRepository $assembleGeneraleRepository, - private readonly PresenceRepository $generalMeetingRepository, + private readonly PresenceRepository $presenceRepository, private readonly QuestionRepository $questionRepository, private readonly VoteRepository $voteRepository, private readonly ReportListBuilder $reportListBuilder, @@ -43,7 +43,7 @@ public function __invoke(Request $request): Response $userService = $this->userService; $user = $this->authentication->getAfupUser(); $title = 'Présence prochaine AG'; - $latestDate = $this->generalMeetingRepository->getLatestAttendanceDate(); + $latestDate = $this->presenceRepository->getLatestAttendanceDate(); Assert::notNull($latestDate); $generalMeetingPlanned = $this->assembleGeneraleRepository->hasPlanned(); @@ -57,7 +57,7 @@ public function __invoke(Request $request): Response ]); } - $attendee = $this->generalMeetingRepository->getAttendee($user->getUsername(), $latestDate); + $attendee = $this->presenceRepository->getAttendee($user->getUsername(), $latestDate); $lastGeneralMeetingDescription = $this->assembleGeneraleRepository->findOneByDate($latestDate)?->description; $data = [ @@ -91,7 +91,7 @@ public function __invoke(Request $request): Response ], ]) ->add('id_personne_avec_pouvoir', ChoiceType::class, [ - 'choices' => array_flip($this->generalMeetingRepository->getPowerSelectionList($latestDate, $user->getUsername())), + 'choices' => array_flip($this->presenceRepository->getPowerSelectionList($latestDate, $user->getUsername())), 'label' => 'Je donne mon pouvoir à', 'required' => false, ]) @@ -105,14 +105,14 @@ public function __invoke(Request $request): Response $data = $form->getData(); if ($attendee instanceof Attendee) { - $ok = $this->generalMeetingRepository->editAttendee( + $ok = $this->presenceRepository->editAttendee( $user->getUsername(), $latestDate, $data['presence'], (int) $data['id_personne_avec_pouvoir'], ); } else { - $ok = $this->generalMeetingRepository->addAttendee( + $ok = $this->presenceRepository->addAttendee( $user->getId(), $latestDate, $data['presence'], @@ -129,7 +129,7 @@ public function __invoke(Request $request): Response $this->addFlash('error', 'Une erreur est survenue lors de la modification de la présence et du pouvoir'); } - $attendeesWithPower = $this->generalMeetingRepository->getAttendees($latestDate, 'nom', 'asc', $user->getId()); + $attendeesWithPower = $this->presenceRepository->getAttendees($latestDate, 'nom', 'asc', $user->getId()); $currentQuestion = $this->questionRepository->loadNextOpenedQuestion($latestDate); diff --git a/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/VoteAction.php b/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/VoteAction.php index 447aa7bf3..d0c1299d7 100644 --- a/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/VoteAction.php +++ b/sources/AppBundle/Controller/Website/Membership/GeneralMeeting/VoteAction.php @@ -16,7 +16,7 @@ final class VoteAction extends AbstractController { public function __construct( - private readonly PresenceRepository $generalMeetingRepository, + private readonly PresenceRepository $presenceRepository, private readonly QuestionRepository $questionRepository, private readonly VoteRepository $voteRepository, private readonly Droits $droits, @@ -55,7 +55,7 @@ public function __invoke(Request $request): RedirectResponse return $redirection; } - $weight = 1 + count($this->generalMeetingRepository->getAttendees($question->date, 'nom', 'asc', $userId)); + $weight = 1 + count($this->presenceRepository->getAttendees($question->date, 'nom', 'asc', $userId)); $generalMeetingVote = $this->voteRepository->buildVote($question->id, $userId, $weight, $vote); diff --git a/sources/AppBundle/Slack/MessageFactory.php b/sources/AppBundle/Slack/MessageFactory.php index 781fe5ea8..19cc4c821 100644 --- a/sources/AppBundle/Slack/MessageFactory.php +++ b/sources/AppBundle/Slack/MessageFactory.php @@ -149,9 +149,9 @@ public function createMessageForMemberNotification(string $membersToCheckCount): return $message; } - public function createMessageForGeneralMeeting(PresenceRepository $generalMeetingRepository, UserRepository $userRepository, UrlGeneratorInterface $urlGenerator): Message + public function createMessageForGeneralMeeting(PresenceRepository $presenceRepository, UserRepository $userRepository, UrlGeneratorInterface $urlGenerator): Message { - $latestDate = $generalMeetingRepository->getLatestAttendanceDate(); + $latestDate = $presenceRepository->getLatestAttendanceDate(); Assert::notNull($latestDate); $nombrePersonnesAJourDeCotisation = count($userRepository->getActiveMembers()); @@ -168,11 +168,11 @@ public function createMessageForGeneralMeeting(PresenceRepository $generalMeetin ->addField(new Field()->setShort(true)->setTitle('Membres à jour de cotisation') ->setValue($nombrePersonnesAJourDeCotisation)) ->addField(new Field()->setShort(true)->setTitle('Présences et pouvoirs') - ->setValue($generalMeetingRepository->countAttendeesAndPowers($latestDate))) + ->setValue($presenceRepository->countAttendeesAndPowers($latestDate))) ->addField(new Field()->setShort(true)->setTitle('Présences') - ->setValue($generalMeetingRepository->countAttendees($latestDate))) + ->setValue($presenceRepository->countAttendees($latestDate))) ->addField(new Field()->setShort(true)->setTitle('Quorum') - ->setValue($generalMeetingRepository->obtenirEcartQuorum($latestDate, $nombrePersonnesAJourDeCotisation))) + ->setValue($presenceRepository->obtenirEcartQuorum($latestDate, $nombrePersonnesAJourDeCotisation))) ; $message->addAttachment($attachment);