diff --git a/.gitignore b/.gitignore index 95850d695..f90ba46d4 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,4 @@ js_dist drivers chromedriver.log /htdocs/dist +app/config/reference.php diff --git a/db/migrations/20260430000000_add_mic_type_to_speakers.php b/db/migrations/20260430000000_add_mic_type_to_speakers.php new file mode 100644 index 000000000..9f2aa4dbc --- /dev/null +++ b/db/migrations/20260430000000_add_mic_type_to_speakers.php @@ -0,0 +1,13 @@ +query("ALTER TABLE afup_conferenciers ADD mic_type ENUM('handheld', 'headset') DEFAULT NULL AFTER bluesky"); + } +} diff --git a/db/migrations/20260501000000_add_mic_type_enabled_to_forum.php b/db/migrations/20260501000000_add_mic_type_enabled_to_forum.php new file mode 100644 index 000000000..6172ed159 --- /dev/null +++ b/db/migrations/20260501000000_add_mic_type_enabled_to_forum.php @@ -0,0 +1,13 @@ +query("ALTER TABLE afup_forum ADD mic_type_enabled TINYINT DEFAULT 0"); + } +} diff --git a/db/seeds/Event.php b/db/seeds/Event.php index 25cd9fe45..84483512d 100644 --- a/db/seeds/Event.php +++ b/db/seeds/Event.php @@ -50,6 +50,7 @@ public function run(): void 'date_annonce_planning' => $now - $oneMonthInSeconds, 'transport_information_enabled' => 1, 'has_prices_defined_with_vat' => 1, + 'mic_type_enabled' => 1, ], [ 'id' => 2, diff --git a/sources/AppBundle/Event/Form/EventType.php b/sources/AppBundle/Event/Form/EventType.php index cd998b51f..be7773a3f 100644 --- a/sources/AppBundle/Event/Form/EventType.php +++ b/sources/AppBundle/Event/Form/EventType.php @@ -132,6 +132,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'Activer les nuits d\'hôtel', 'required' => false, ]) + ->add('micTypeEnabled', CheckboxType::class, [ + 'label' => 'Activer le choix du type de microphone', + 'required' => false, + ]) ->add('coupons', TextareaType::class, [ 'mapped' => false, 'label' => 'Liste des coupons', diff --git a/sources/AppBundle/Event/Model/Event.php b/sources/AppBundle/Event/Model/Event.php index a18e4debd..000d9e885 100644 --- a/sources/AppBundle/Event/Model/Event.php +++ b/sources/AppBundle/Event/Model/Event.php @@ -86,6 +86,8 @@ class Event implements NotifyPropertyInterface private ?bool $accomodationEnabled = null; + private ?bool $micTypeEnabled = null; + private ?bool $transportInformationEnabled = null; /** @@ -625,6 +627,21 @@ public function setAccomodationEnabled($accomodationEnabled): self return $this; } + public function getMicTypeEnabled(): ?bool + { + return $this->micTypeEnabled; + } + + public function setMicTypeEnabled($micTypeEnabled): self + { + $micTypeEnabled = (bool) $micTypeEnabled; + + $this->propertyChanged('micTypeEnabled', $this->micTypeEnabled, $micTypeEnabled); + $this->micTypeEnabled = $micTypeEnabled; + + return $this; + } + public function isAfupDay(): bool { return str_starts_with((string) $this->getTitle(), 'AFUP Day'); diff --git a/sources/AppBundle/Event/Model/Repository/EventRepository.php b/sources/AppBundle/Event/Model/Repository/EventRepository.php index 6fd13e137..00e0343c2 100644 --- a/sources/AppBundle/Event/Model/Repository/EventRepository.php +++ b/sources/AppBundle/Event/Model/Repository/EventRepository.php @@ -475,6 +475,12 @@ public static function initMetadata(SerializerFactoryInterface $serializerFactor 'type' => 'bool', 'serializer' => Boolean::class, ]) + ->addField([ + 'columnName' => 'mic_type_enabled', + 'fieldName' => 'micTypeEnabled', + 'type' => 'bool', + 'serializer' => Boolean::class, + ]) ->addField([ 'columnName' => 'waiting_list_url', 'fieldName' => 'waitingListUrl', diff --git a/sources/AppBundle/Event/Model/Repository/SpeakerRepository.php b/sources/AppBundle/Event/Model/Repository/SpeakerRepository.php index 61027bce9..a84f833b9 100644 --- a/sources/AppBundle/Event/Model/Repository/SpeakerRepository.php +++ b/sources/AppBundle/Event/Model/Repository/SpeakerRepository.php @@ -7,6 +7,7 @@ use AppBundle\Event\Model\Event; use AppBundle\Event\Model\Speaker; use AppBundle\Event\Model\Talk; +use AppBundle\Event\Speaker\MicrophoneType; use AppBundle\Ting\JoinHydrator; use CCMBenchmark\Ting\Driver\Mysqli\Serializer\Boolean; use CCMBenchmark\Ting\Repository\CollectionInterface; @@ -14,6 +15,7 @@ use CCMBenchmark\Ting\Repository\Metadata; use CCMBenchmark\Ting\Repository\MetadataInitializer; use CCMBenchmark\Ting\Repository\Repository; +use CCMBenchmark\Ting\Serializer\BackedEnum; use CCMBenchmark\Ting\Serializer\SerializerFactoryInterface; use Webmozart\Assert\Assert; @@ -63,7 +65,8 @@ public function getScheduledSpeakersByEvent(Event $event, $returnTalksThatWillBe speaker.phone_number, speaker.has_hosting_sponsor, speaker.travel_refund_needed, - speaker.travel_refund_sponsored + speaker.travel_refund_sponsored, + speaker.mic_type FROM afup_conferenciers speaker INNER JOIN afup_conferenciers_sessions cs ON cs.conferencier_id = speaker.conferencier_id INNER JOIN afup_sessions talk ON talk.session_id = cs.session_id @@ -320,6 +323,15 @@ public static function initMetadata(SerializerFactoryInterface $serializerFactor 'type' => 'bool', 'serializer' => Boolean::class, ]) + ->addField([ + 'columnName' => 'mic_type', + 'fieldName' => 'micType', + 'type' => 'enum', + 'serializer' => BackedEnum::class, + 'serializer_options' => [ + 'unserialize' => ['enum' => MicrophoneType::class], + ], + ]) ; return $metadata; diff --git a/sources/AppBundle/Event/Model/Speaker.php b/sources/AppBundle/Event/Model/Speaker.php index 64059a75f..d686aefbf 100644 --- a/sources/AppBundle/Event/Model/Speaker.php +++ b/sources/AppBundle/Event/Model/Speaker.php @@ -4,6 +4,7 @@ namespace AppBundle\Event\Model; +use AppBundle\Event\Speaker\MicrophoneType; use CCMBenchmark\Ting\Entity\NotifyProperty; use CCMBenchmark\Ting\Entity\NotifyPropertyInterface; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -135,6 +136,8 @@ class Speaker implements NotifyPropertyInterface private bool $travelRefundNeeded = true; private bool $travelRefundSponsored = false; + private ?MicrophoneType $micType = null; + public function getId(): ?int { return $this->id; @@ -708,6 +711,17 @@ public function setTravelRefundSponsored(bool $travelRefundSponsored): self return $this; } + public function getMicType(): ?MicrophoneType + { + return $this->micType; + } + + public function setMicType(?MicrophoneType $micType): void + { + $this->propertyChanged('micType', $this->micType, $micType); + $this->micType = $micType; + } + public function hasHotelNightBefore(): ?bool { if (null === ($hotelNights = $this->getHotelNightsArray())) { diff --git a/sources/AppBundle/Event/Speaker/MicrophoneType.php b/sources/AppBundle/Event/Speaker/MicrophoneType.php new file mode 100644 index 000000000..3ec38cfd1 --- /dev/null +++ b/sources/AppBundle/Event/Speaker/MicrophoneType.php @@ -0,0 +1,11 @@ +redirectFromRequest($request); } + $shouldDisplayMicrophoneForm = (bool) $event->getMicTypeEnabled(); + + $speakersMicrophoneType = $this->createForm(SpeakersMicrophoneType::class, ['type' => $speaker->getMicType()]); + $speakersMicrophoneType->handleRequest($request); + if ($shouldDisplayMicrophoneForm && $speakersMicrophoneType->isSubmitted() && $speakersMicrophoneType->isValid()) { + $speaker->setMicType($speakersMicrophoneType->getData()['type']); + $this->speakerRepository->save($speaker); + $this->addFlash('notice', 'Préférence de microphone enregistrée'); + + return $this->redirectFromRequest($request); + } + $speakersDinerDefaults = [ 'will_attend' => $speaker->getWillAttendSpeakersDiner(), 'has_special_diet' => $speaker->getHasSpecialDiet(), @@ -169,6 +182,7 @@ public function handleRequest(Request $request, Event $event, Speaker $speaker) 'description' => $description, 'talks_infos' => $this->addTalkInfos($event, $talks), 'speaker' => $speaker, + 'should_display_microphone_form' => $shouldDisplayMicrophoneForm, 'should_display_speakers_diner_form' => $shouldDisplaySpeakersDinerForm, 'should_display_hotel_reservation_form' => $shouldDisplayHotelReservationForm, 'speakers_expenses_form' => $speakersExpensesType->createView(), @@ -177,6 +191,7 @@ public function handleRequest(Request $request, Event $event, Speaker $speaker) 'speakers_diner_form' => $speakersDinerType->createView(), 'hotel_reservation_form' => $hotelReservationType->createView(), 'speakers_contact_form' => $speakersContactType->createView(), + 'speakers_microphone_form' => $speakersMicrophoneType->createView(), 'day_before_event' => DateTimeImmutable::createFromMutable($event->getDateStart())->modify('- 1 day'), ]); } diff --git a/sources/AppBundle/SpeakerInfos/Form/SpeakersMicrophoneType.php b/sources/AppBundle/SpeakerInfos/Form/SpeakersMicrophoneType.php new file mode 100644 index 000000000..49d6a5e7c --- /dev/null +++ b/sources/AppBundle/SpeakerInfos/Form/SpeakersMicrophoneType.php @@ -0,0 +1,38 @@ +add('type', EnumType::class, [ + 'class' => MicrophoneType::class, + 'label' => 'speaker_infos.microphone.label', + 'expanded' => true, + 'placeholder' => 'speaker_infos.microphone.placeholder', + 'choice_label' => fn(MicrophoneType $type) => match ($type) { + MicrophoneType::Headset => 'speaker_infos.microphone.choice.headset', + MicrophoneType::Handheld => 'speaker_infos.microphone.choice.handheld', + }, + 'choice_translation_domain' => true, + 'required' => false, + ]) + ->add('submit', SubmitType::class, ['label' => 'Enregistrer']); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults(['csrf_protection' => false]); + } +} diff --git a/templates/admin/event/form.html.twig b/templates/admin/event/form.html.twig index d168b87c8..8b59c4b61 100644 --- a/templates/admin/event/form.html.twig +++ b/templates/admin/event/form.html.twig @@ -92,6 +92,7 @@ {{ _self.wysiwyg(form.CFP.speaker_management_en) }} {{ form_row(form.speakersDinerEnabled) }} {{ form_row(form.accomodationEnabled) }} + {{ form_row(form.micTypeEnabled) }} {{ form_row(form.dateEndSpeakersDinerInfosCollection) }} {{ form_row(form.dateEndHotelInfosCollection) }} diff --git a/templates/admin/event/speakers_management.html.twig b/templates/admin/event/speakers_management.html.twig index 5bbf73262..510b1cbfc 100644 --- a/templates/admin/event/speakers_management.html.twig +++ b/templates/admin/event/speakers_management.html.twig @@ -19,6 +19,7 @@
{% trans %}speaker_infos.microphone.intro{% endtrans %}
+ + {{ form_start(speakers_microphone_form, { attr: { class: "speakers-infos-form" }, action: '#microphone'}) }} + +