diff --git a/src/Bundle/ChillEventBundle/Controller/EventController.php b/src/Bundle/ChillEventBundle/Controller/EventController.php index 38fcc357f..d10349cf1 100644 --- a/src/Bundle/ChillEventBundle/Controller/EventController.php +++ b/src/Bundle/ChillEventBundle/Controller/EventController.php @@ -204,7 +204,7 @@ final class EventController extends AbstractController $this->addFlash('success', $this->translator ->trans('The event was created')); - return $this->redirectToRoute('chill_event__event_show', ['event_id' => $entity->getId()]); + return $this->redirectToRoute('chill_event__event_show', ['id' => $entity->getId()]); } $entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); @@ -310,7 +310,7 @@ final class EventController extends AbstractController $this->addFlash('success', $this->translator->trans('The event was updated')); - return $this->redirectToRoute('chill_event__event_show', ['event_id' => $event_id]); + return $this->redirectToRoute('chill_event__event_show', ['id' => $event_id]); } return $this->render('@ChillEvent/Event/edit.html.twig', [ diff --git a/src/Bundle/ChillEventBundle/Entity/Animator.php b/src/Bundle/ChillEventBundle/Entity/Animator.php deleted file mode 100644 index 1f9557fe6..000000000 --- a/src/Bundle/ChillEventBundle/Entity/Animator.php +++ /dev/null @@ -1,127 +0,0 @@ -id; - } - - public function getThirdparty(): ?ThirdParty - { - return $this->thirdparty; - } - - public function setThirdparty(?ThirdParty $thirdparty): self - { - $this->thirdparty = $thirdparty; - - if (null !== $thirdparty) { - $this->user = null; - } - - return $this; - } - - public function getUser(): ?User - { - return $this->user; - } - - public function setUser(?User $user): self - { - $this->user = $user; - - if (null !== $user) { - $this->thirdparty = null; - } - - return $this; - } - - public function getEvent(): ?Event - { - return $this->event; - } - - public function setEvent(?Event $event): self - { - $this->event = $event; - return $this; - } - - public function getAnimator(): User|ThirdParty|null - { - return $this->user ?? $this->thirdparty; - } - - public function setAnimator(User|ThirdParty|null $animator): self - { - if ($animator instanceof User) { - $this->setUser($animator); - } elseif ($animator instanceof ThirdParty) { - $this->setThirdparty($animator); - } else { - $this->user = null; - $this->thirdparty = null; - } - - return $this; - } - - public function isUser(): bool - { - return null !== $this->user; - } - - public function isThirdParty(): bool - { - return null !== $this->thirdparty; - } -} diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index b66581e02..cbb2b1154 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -63,13 +63,17 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter /** * @var Collection */ - #[ORM\OneToMany(mappedBy: 'event', targetEntity: User::class)] + #[ORM\ManyToMany(targetEntity: User::class)] + #[Serializer\Groups(['read'])] + #[ORM\JoinTable('chill_event_animatorsintern')] private Collection $animatorsIntern; /** * @var Collection */ - #[ORM\OneToMany(mappedBy: 'event', targetEntity: ThirdParty::class)] + #[ORM\ManyToMany(targetEntity: ThirdParty::class)] + #[Serializer\Groups(['read'])] + #[ORM\JoinTable('chill_event_animatorsextern')] private Collection $animatorsExtern; #[Assert\NotBlank] @@ -204,26 +208,26 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter return $this->animatorsExtern; } - public function addAnimatorIntern(User $ai): self + public function addAnimatorsIntern(User $ai): self { $this->animatorsIntern->add($ai); return $this; } - public function removeAnimatorIntern(User $ai): void + public function removeAnimatorsIntern(User $ai): void { $this->animatorsIntern->removeElement($ai); } - public function addAnimatorExtern(User $ae): self + public function addAnimatorsExtern(ThirdParty $ae): self { $this->animatorsExtern->add($ae); return $this; } - public function removeAnimatorExtern(User $ae): void + public function removeAnimatorsExtern(ThirdParty $ae): void { $this->animatorsExtern->removeElement($ae); } diff --git a/src/Bundle/ChillEventBundle/Form/EventType.php b/src/Bundle/ChillEventBundle/Form/EventType.php index 42eec286f..00d456d26 100644 --- a/src/Bundle/ChillEventBundle/Form/EventType.php +++ b/src/Bundle/ChillEventBundle/Form/EventType.php @@ -32,12 +32,14 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Contracts\Translation\TranslatorInterface; class EventType extends AbstractType { public function __construct( private readonly IdToLocationDataTransformer $idToLocationDataTransformer, private readonly EventBudgetKindRepository $eventBudgetKindRepository, + private readonly TranslatorInterface $translator, ) {} public function buildForm(FormBuilderInterface $builder, array $options): void @@ -70,12 +72,12 @@ class EventType extends AbstractType ]) ->add('animatorsIntern', PickUserDynamicType::class, [ 'multiple' => true, - 'label' => 'Pick an internal animator', + 'label' => $this->translator->trans('event.fields.internal animators'), 'required' => false, ]) ->add('animatorsExtern', PickThirdpartyDynamicType::class, [ 'multiple' => true, - 'label' => 'Pick an external animator', + 'label' => $this->translator->trans('event.fields.external animators'), 'required' => false, ]) ->add('budgetElements', ChillCollectionType::class, [ diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickAnimatorType.php b/src/Bundle/ChillEventBundle/Form/Type/PickAnimatorType.php deleted file mode 100644 index 5b3d4ce20..000000000 --- a/src/Bundle/ChillEventBundle/Form/Type/PickAnimatorType.php +++ /dev/null @@ -1,56 +0,0 @@ -add('thirdparty', PickThirdpartyDynamicType::class, [ - 'required' => false, - ]) - ->add('user', PickUserDynamicType::class, [ - 'required' => false, - ]); - - // Add the data transformer -// $builder->addModelTransformer(new AnimatorCollectionTransformer($this->entityManager)); - } - - public function configureOptions(OptionsResolver $resolver): void - { - $resolver->setDefaults([ - 'data_class' => null, - 'multiple' => false, - 'placeholder' => 'Select an animator...', - 'required' => false, - 'by_reference' => false, - ]); - - $resolver->setAllowedTypes('multiple', 'bool'); - $resolver->setAllowedTypes('placeholder', ['string', 'null']); - } -} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig index f54867f21..55c2fc21f 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig @@ -19,7 +19,8 @@ {{ form_row(edit_form.type, { label: "Event type" }) }} {{ form_row(edit_form.themes) }} {{ form_row(edit_form.moderator) }} - {{ form_row(edit_form.animators) }} + {{ form_row(edit_form.animatorsIntern) }} + {{ form_row(edit_form.animatorsExtern) }} {{ form_row(edit_form.location) }} {{ form_row(edit_form.budgetElements) }} {{ form_row(edit_form.comment) }} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/page_list.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/page_list.html.twig index 27aaeecb4..7d74268a5 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/page_list.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/page_list.html.twig @@ -11,7 +11,7 @@ block js %} {{ filter | chill_render_filter_order_helper }} - {# {% if is_granted('CHILL_EVENT_CREATE') %} #} + {% if is_granted('CHILL_EVENT_CREATE') %} - {# {% endif %} #} {% if events|length > 0 %} + {% endif %} + + {% if events|length > 0 %}
{% for e in events %}
@@ -41,6 +43,7 @@ block js %} {{ e.moderator | chill_entity_render_box }}

{% endif %} +
{% for t in e.themes %} {{ t|chill_entity_render_box }} @@ -53,6 +56,7 @@ block js %}

{{ 'count participations to this event'|trans({'count': e.participations|length}) }}

+

{{ "center"|trans }}: {{ e.center.name }}

diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig index 7a8c5bdcc..1f6f2d4b9 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig @@ -65,9 +65,17 @@ {{ event.moderator|chill_entity_render_string }} - {{ 'Animators'|trans }} + {{ 'event.animators.intern'|trans }} - {% for a in event.animators %} + {% for a in event.animatorsIntern %} + {{ _self.insert_onthefly('user', a) }} + {% endfor %} + + + + {{ 'event.animators.extern'|trans }} + + {% for a in event.animatorsExtern %} {{ _self.insert_onthefly('thirdparty', a) }} {% endfor %} @@ -153,7 +161,7 @@ {% else %} -

{{ 'event.budget.no elements' }}

+

{{ 'event.budget.no elements'|trans }}

{% endif %} @@ -180,7 +188,7 @@

{{ 'Participations'|trans }}

{% set count = event.participations|length %} -

{{ 'count participations to this event'|trans({'count': count}) }}

+

{{ 'count participations to this event'|trans({'count': count}) }}

{% if count > 0 %} diff --git a/src/Bundle/ChillEventBundle/migrations/Version20250702144312.php b/src/Bundle/ChillEventBundle/migrations/Version20250702144312.php new file mode 100644 index 000000000..2f0f4a897 --- /dev/null +++ b/src/Bundle/ChillEventBundle/migrations/Version20250702144312.php @@ -0,0 +1,72 @@ +addSql(<<<'SQL' + CREATE TABLE chill_event_animatorsintern (event_id INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY(event_id, user_id)) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_E699558771F7E88B ON chill_event_animatorsintern (event_id) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_E6995587A76ED395 ON chill_event_animatorsintern (user_id) + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE chill_event_animatorsextern (event_id INT NOT NULL, thirdparty_id INT NOT NULL, PRIMARY KEY(event_id, thirdparty_id)) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_7EFBF7DE71F7E88B ON chill_event_animatorsextern (event_id) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_7EFBF7DEC7D3A8E6 ON chill_event_animatorsextern (thirdparty_id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_animatorsintern ADD CONSTRAINT FK_E699558771F7E88B FOREIGN KEY (event_id) REFERENCES chill_event_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_animatorsintern ADD CONSTRAINT FK_E6995587A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_animatorsextern ADD CONSTRAINT FK_7EFBF7DE71F7E88B FOREIGN KEY (event_id) REFERENCES chill_event_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_animatorsextern ADD CONSTRAINT FK_7EFBF7DEC7D3A8E6 FOREIGN KEY (thirdparty_id) REFERENCES chill_3party.third_party (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + } + + public function down(Schema $schema): void + { + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_animatorsintern DROP CONSTRAINT FK_E699558771F7E88B + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_animatorsintern DROP CONSTRAINT FK_E6995587A76ED395 + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_animatorsextern DROP CONSTRAINT FK_7EFBF7DE71F7E88B + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_animatorsextern DROP CONSTRAINT FK_7EFBF7DEC7D3A8E6 + SQL); + $this->addSql(<<<'SQL' + DROP TABLE chill_event_animatorsintern + SQL); + $this->addSql(<<<'SQL' + DROP TABLE chill_event_animatorsextern + SQL); + } +} diff --git a/src/Bundle/ChillEventBundle/translations/messages.fr.yml b/src/Bundle/ChillEventBundle/translations/messages.fr.yml index 9ba712b78..0ea69463c 100644 --- a/src/Bundle/ChillEventBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillEventBundle/translations/messages.fr.yml @@ -141,6 +141,8 @@ event: organizationCost: Coût d'organisation location: Localisation documents: Documents + internal animators: Animateurs internes + external animators: Animateurs externes form: organisationCost_help: Coût d'organisation pour la structure. Utile pour les statistiques. add_document: Ajouter un document @@ -159,6 +161,9 @@ event: charge type: Charge amount: Montant comment: Commentaire + animators: + intern: Animateurs internes + extern: Animateurs externes crud: event_theme: