diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index ba4337205..604b570c2 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -23,6 +23,7 @@ use Chill\MainBundle\Entity\HasScopeInterface; use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; +use Chill\ThirdPartyBundle\Entity\ThirdParty; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; @@ -48,20 +49,28 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter #[ORM\ManyToOne(targetEntity: Scope::class)] private ?Scope $circle = null; - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)] + #[ORM\Column(type: Types::DATETIME_MUTABLE)] private ?\DateTime $date = null; #[ORM\Id] - #[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)] + #[ORM\Column(name: 'id', type: Types::INTEGER)] #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; #[ORM\ManyToOne(targetEntity: User::class)] private ?User $moderator = null; + /** + * @var Collection + */ + #[ORM\ManyToMany(targetEntity: ThirdParty::class)] + #[Serializer\Groups(['read'])] + #[ORM\JoinTable('chill_event_thirdparty')] + private Collection $animators; + #[Assert\NotBlank] #[Serializer\Groups(['read'])] - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 150)] + #[ORM\Column(type: Types::STRING, length: 150)] private ?string $name = null; /** @@ -99,9 +108,6 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter #[ORM\JoinTable('chill_event_event_documents')] private Collection $documents; - #[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 4, nullable: true, options: ['default' => '0.0'])] - private string $organizationCost = '0.0'; - /** * @var Collection */ @@ -119,6 +125,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter $this->comment = new CommentEmbeddable(); $this->themes = new ArrayCollection(); $this->budgetElements = new ArrayCollection(); + $this->animators = new ArrayCollection(); } public function addBudgetElement(EventBudgetElement $budgetElement) @@ -176,17 +183,28 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter $this->themes->removeElement($theme); } - /** - * @return Center - */ + public function getAnimators(): Collection + { + return $this->animators; + } + + public function addAnimator(ThirdParty $tp): self + { + $this->animators->add($tp); + + return $this; + } + + public function removeAnimator(ThirdParty $tp): void + { + $this->animators->removeElement($tp); + } + public function getCenter(): ?Center { return $this->center; } - /** - * @return Scope - */ public function getCircle(): ?Scope { return $this->circle; @@ -194,8 +212,6 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter /** * Get date. - * - * @return \DateTime */ public function getDate(): ?\DateTime { @@ -204,8 +220,6 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter /** * Get id. - * - * @return int */ public function getId(): ?int { @@ -219,8 +233,6 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter /** * Get label. - * - * @return string */ public function getName(): ?string { @@ -257,17 +269,12 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter /** * @deprecated - * - * @return Scope */ public function getScope(): ?Scope { return $this->getCircle(); } - /** - * @return EventType - */ public function getType(): ?EventType { return $this->type; @@ -376,14 +383,4 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter { $this->documents = $documents; } - - public function getOrganizationCost(): string - { - return $this->organizationCost; - } - - public function setOrganizationCost(string $organizationCost): void - { - $this->organizationCost = $organizationCost; - } } diff --git a/src/Bundle/ChillEventBundle/Form/EventType.php b/src/Bundle/ChillEventBundle/Form/EventType.php index 23d83c6f0..ef35ce04b 100644 --- a/src/Bundle/ChillEventBundle/Form/EventType.php +++ b/src/Bundle/ChillEventBundle/Form/EventType.php @@ -15,7 +15,6 @@ use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Form\StoredObjectType; use Chill\EventBundle\Entity\BudgetTypeEnum; use Chill\EventBundle\Entity\Event; -use Chill\EventBundle\Form\Type\PickEventBudgetKindType; use Chill\EventBundle\Form\Type\PickEventThemeType; use Chill\EventBundle\Form\Type\PickEventTypeType; use Chill\EventBundle\Repository\EventBudgetKindRepository; @@ -26,10 +25,9 @@ use Chill\MainBundle\Form\Type\ChillDateTimeType; use Chill\MainBundle\Form\Type\CommentType; use Chill\MainBundle\Form\Type\PickUserDynamicType; use Chill\MainBundle\Form\Type\ScopePickerType; -use Chill\MainBundle\Templating\TranslatableStringHelperInterface; +use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\Extension\Core\Type\MoneyType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -39,10 +37,9 @@ class EventType extends AbstractType public function __construct( private readonly IdToLocationDataTransformer $idToLocationDataTransformer, private readonly EventBudgetKindRepository $eventBudgetKindRepository, - private readonly TranslatableStringHelperInterface $translatableStringHelper, ) {} - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $chargeKinds = $this->eventBudgetKindRepository->findByType(BudgetTypeEnum::CHARGE->value); $resourceKinds = $this->eventBudgetKindRepository->findByType(BudgetTypeEnum::RESOURCE->value); @@ -70,6 +67,9 @@ class EventType extends AbstractType ->add('moderator', PickUserDynamicType::class, [ 'label' => 'Pick a moderator', ]) + ->add('animators', PickThirdpartyDynamicType::class, [ + 'multiple' => true, + ]) ->add('budgetElements', ChillCollectionType::class, [ 'entry_type' => AddEventBudgetElementType::class, 'entry_options' => ['label' => false], @@ -91,10 +91,6 @@ class EventType extends AbstractType 'delete_empty' => fn (StoredObject $storedObject): bool => '' === $storedObject->getFilename(), 'button_remove_label' => 'event.form.remove_document', 'button_add_label' => 'event.form.add_document', - ]) - ->add('organizationCost', MoneyType::class, [ - 'label' => 'event.fields.organizationCost', - 'help' => 'event.form.organisationCost_help', ]); $builder->add('location', HiddenType::class) @@ -116,7 +112,7 @@ class EventType extends AbstractType /** * @return string */ - public function getBlockPrefix() + public function getBlockPrefix(): string { // as the js shares some hardcoded items from the activity bundle, we have to rewrite block prefix return 'chill_activitybundle_activity'; diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig index 2f879de26..f54867f21 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig @@ -19,10 +19,9 @@ {{ 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.location) }} {{ form_row(edit_form.budgetElements) }} - {{ form_row(edit_form.organizationCost) }} - {{ form_row(edit_form.comment) }} {{ form_row(edit_form.documents) }} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig index 1f7b58baf..20bc9254a 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig @@ -20,9 +20,9 @@ {{ form_row(form.type, { label: "Event type" }) }} {{ form_row(form.themes) }} {{ form_row(form.moderator) }} + {{ form_row(form.animators) }} {{ form_row(form.location) }}
- {{ form_row(form.organizationCost) }} {{ form_row(form.budgetElements) }} {{ form_row(form.comment) }} {{ form_row(form.documents) }} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig index f4a6f2f3c..ccabf769f 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig @@ -16,6 +16,16 @@ {{ encore_entry_link_tags('mod_document_action_buttons_group') }} {% endblock %} +{% macro insert_onthefly(type, entity, parent = null) %} + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: type, id: entity.id }, + buttonText: entity|chill_entity_render_string, + isDead: entity.deathdate is defined and entity.deathdate is not null, + parent: parent + } %} +{% endmacro %} + {% block event_content -%}

{{ 'Details of an event'|trans }}

@@ -48,7 +58,15 @@ {{ 'Moderator'|trans }} - {{ event.moderator|trans|default('-') }} + {{ event.moderator|chill_entity_render_string }} + + + {{ 'Animators'|trans }} + + {% for a in event.animators %} + {{ _self.insert_onthefly('thirdparty', a) }} + {% endfor %} + {{ 'event.fields.location'|trans }} diff --git a/src/Bundle/ChillEventBundle/migrations/Version20250507073301.php b/src/Bundle/ChillEventBundle/migrations/Version20250507073301.php new file mode 100644 index 000000000..e2c985a5f --- /dev/null +++ b/src/Bundle/ChillEventBundle/migrations/Version20250507073301.php @@ -0,0 +1,57 @@ +addSql(<<<'SQL' + CREATE TABLE chill_event_thirdparty (event_id INT NOT NULL, thirdparty_id INT NOT NULL, PRIMARY KEY(event_id, thirdparty_id)) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_9946573E71F7E88B ON chill_event_thirdparty (event_id) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_9946573EC7D3A8E6 ON chill_event_thirdparty (thirdparty_id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_thirdparty ADD CONSTRAINT FK_9946573E71F7E88B FOREIGN KEY (event_id) REFERENCES chill_event_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_thirdparty ADD CONSTRAINT FK_9946573EC7D3A8E6 FOREIGN KEY (thirdparty_id) REFERENCES chill_3party.third_party (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_event DROP organizationcost + SQL); + } + + public function down(Schema $schema): void + { + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_thirdparty DROP CONSTRAINT FK_9946573E71F7E88B + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_thirdparty DROP CONSTRAINT FK_9946573EC7D3A8E6 + SQL); + $this->addSql(<<<'SQL' + DROP TABLE chill_event_thirdparty + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_event_event ADD organizationcost NUMERIC(10, 4) DEFAULT '0.0' + SQL); + } +} diff --git a/src/Bundle/ChillEventBundle/translations/messages.fr.yml b/src/Bundle/ChillEventBundle/translations/messages.fr.yml index ac55f93bf..d4078f80d 100644 --- a/src/Bundle/ChillEventBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillEventBundle/translations/messages.fr.yml @@ -7,7 +7,7 @@ Participation: Participation Participations: Participations Status: Statut Last update: Dernière mise à jour -Moderator: Animateur +Moderator: Responsable #CRUD event Details of an event: Détails d'un événement @@ -74,7 +74,7 @@ Show the event: Voir l'événement Subscribe an event: Ajouter un événement Pick an event: Choisir un événement Pick a type of event: Choisir un type d'événement -Pick a moderator: Choisir un animateur +Pick a moderator: Choisir un responsable # exports Select a format: Choisir un format