Skip to content

Commit

Permalink
[NationalEvent] add qualities checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed May 17, 2024
1 parent 4a15463 commit a2f8284
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 16 deletions.
1 change: 1 addition & 0 deletions config/packages/twig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ twig:
article_preview_admin_key: "%env(ARTICLE_PREVIEW_ADMIN_KEY)%"
besoindeurope_host: "%env(BESOINDEUROPE_HOST)%"
user_besoindeurope_host: "%env(USER_BESOINDEUROPE_HOST)%"
ticket_besoindeurope_host: "%env(GCLOUD_NATIONAL_EVENT_BUCKET)%"

form_themes:
- 'form_theme.html.twig'
Expand Down
19 changes: 19 additions & 0 deletions migrations/Version20240517142406.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20240517142406 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE national_event_inscription ADD qualities JSON DEFAULT NULL');
}

public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE national_event_inscription DROP qualities');
}
}
2 changes: 2 additions & 0 deletions src/Admin/NationalEvent/NationalEventInscriptionsAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use App\Entity\MyTeam\DelegatedAccess;
use App\Entity\NationalEvent\EventInscription;
use App\Form\CivilityType;
use App\Form\NationalEvent\QualityChoiceType;
use App\NationalEvent\InscriptionStatusEnum;
use App\Query\Utils\MultiColumnsSearchHelper;
use App\Utils\PhoneNumberUtils;
Expand Down Expand Up @@ -108,6 +109,7 @@ protected function configureFormFields(FormMapper $form): void
->add('lastName', null, ['label' => 'Nom'])
->add('postalCode', null, ['label' => 'Code postal'])
->add('birthdate', null, ['label' => 'Date de naissance', 'widget' => 'single_text'])
->add('qualities', QualityChoiceType::class, ['label' => 'Qualités'])
->add('phone', PhoneNumberType::class, [
'label' => 'Téléphone',
'widget' => PhoneNumberType::WIDGET_COUNTRY_CHOICE,
Expand Down
4 changes: 3 additions & 1 deletion src/Controller/Admin/AdminNationalEventCRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function inscriptionsAction(Request $request, NationalEvent $event, Event
$request->query->get('q'),
$statuses = [InscriptionStatusEnum::ACCEPTED, InscriptionStatusEnum::INCONCLUSIVE],
$request->query->getInt('page', 1),
2
100
),
'count_without_qrcodes' => $eventInscriptionRepository->countWithoutTicketQRCodes($event),
'count_without_ticket' => $eventInscriptionRepository->countTickets($event, true, $statuses),
Expand All @@ -41,6 +41,8 @@ public function sendTicketsAction(Request $request, NationalEvent $event, EventI
$inscriptions = $eventInscriptionRepository->findAllPartialForEvent($event, [InscriptionStatusEnum::ACCEPTED, InscriptionStatusEnum::INCONCLUSIVE]);
} elseif ($request->query->has('only_missing')) {
$inscriptions = $eventInscriptionRepository->findAllPartialForEvent($event, [InscriptionStatusEnum::ACCEPTED, InscriptionStatusEnum::INCONCLUSIVE], true);
} elseif (($uuid = $request->query->get('uuid')) && $inscription = $eventInscriptionRepository->findOneByUuid($uuid)) {
$inscriptions = [$inscription];
}

if ($inscriptions) {
Expand Down
4 changes: 4 additions & 0 deletions src/DataFixtures/ORM/LoadNationalEventData.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public function load(ObjectManager $manager): void
$event->textConfirmation = '<p>Lorem ipsum dolor sit amet consectetur. Nunc cras porta sed nullam eget at.</p>';
$event->textTicketEmail = '<p>Lorem ipsum dolor sit amet consectetur. Nunc cras porta sed nullam eget at.</p>';
$event->intoImagePath = '/donation-bg.jpg';
$event->imageTicketEmail = '/donation-bg.jpg';
$event->subjectTicketEmail = 'Meeting arrive bientôt !';
$event->source = '123xyz';

$this->setReference('event-national-1', $event);
Expand All @@ -42,6 +44,8 @@ public function load(ObjectManager $manager): void
$event->textConfirmation = '<p>Lorem ipsum dolor sit amet consectetur. Nunc cras porta sed nullam eget at.</p>';
$event->textTicketEmail = '<p>Lorem ipsum dolor sit amet consectetur. Nunc cras porta sed nullam eget at.</p>';
$event->intoImagePath = '/donation-bg.jpg';
$event->imageTicketEmail = '/donation-bg.jpg';
$event->subjectTicketEmail = 'Meeting arrive bientôt !';
$event->source = '123xyz';

$this->setReference('event-national-2', $event);
Expand Down
2 changes: 2 additions & 0 deletions src/DataFixtures/ORM/LoadNationalEventInscriptionData.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function load(ObjectManager $manager): void
$eventInscription->firstName = $this->faker->firstName();
$eventInscription->lastName = $this->faker->lastName();
$eventInscription->gender = 0 === $i % 2 ? Genders::FEMALE : Genders::MALE;
$eventInscription->ticketQRCodeFile = 0 === $i % 2 ? $eventInscription->getUuid()->toString().'.png' : null;
$eventInscription->ticketSentAt = 0 === $i % 2 ? new \DateTime() : null;
$eventInscription->addressEmail = $this->faker->email();
$eventInscription->postalCode = $this->faker->postcode();
$eventInscription->birthdate = $this->faker->dateTimeBetween('-100 years', '-15 years');
Expand Down
6 changes: 6 additions & 0 deletions src/Entity/NationalEvent/EventInscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ class EventInscription
*/
public ?string $postalCode = null;

/**
* @ORM\Column(nullable=true)
*/
public ?array $qualities = null;

/**
* @Groups({"national_event_inscription:webhook"})
*
Expand Down Expand Up @@ -172,6 +177,7 @@ public function updateFromRequest(EventInscriptionRequest $inscriptionRequest):
$this->gender = $inscriptionRequest->civility;
$this->phone = $inscriptionRequest->phone;
$this->postalCode = $inscriptionRequest->postalCode;
$this->qualities = $inscriptionRequest->qualities;
$this->birthdate = $inscriptionRequest->birthdate;
$this->utmSource = $inscriptionRequest->utmSource;
$this->utmCampaign = $inscriptionRequest->utmCampaign;
Expand Down
2 changes: 2 additions & 0 deletions src/Event/Request/EventInscriptionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class EventInscriptionRequest implements RecaptchaChallengeInterface
public ?string $utmSource = null;
public ?string $utmCampaign = null;

public array $qualities = [];

public function __construct(
public readonly string $sessionId,
public readonly string $clientIp,
Expand Down
1 change: 1 addition & 0 deletions src/Form/NationalEvent/EventInscriptionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('acceptCgu', AcceptPersonalDataCollectType::class)
->add('acceptMedia', AcceptPersonalDataCollectType::class)
->add('allowNotifications', CheckboxType::class, ['required' => false])
->add('qualities', QualityChoiceType::class)
->add('utmSource', HiddenType::class)
->add('utmCampaign', HiddenType::class)
;
Expand Down
29 changes: 29 additions & 0 deletions src/Form/NationalEvent/QualityChoiceType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Form\NationalEvent;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;

class QualityChoiceType extends AbstractType
{
public function getParent(): string
{
return ChoiceType::class;
}

public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'required' => false,
'choices' => [
'Colistier(e) Besoin d\'Europe' => 'colistier',
'Parlementaire' => 'parlementaire',
'Élu(e) local(e)' => 'elu_local',
],
'expanded' => true,
'multiple' => true,
]);
}
}
38 changes: 23 additions & 15 deletions templates/admin/national_event/inscriptions.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,11 @@
<thead>
<tr role="row">
<th class="sorting">Uuid</th>
<th class="sorting">Billet reçu</th>
<th class="sorting">Civilité</th>
<th class="sorting">Prénom</th>
<th class="sorting">Nom</th>
<th class="sorting">Email</th>
<th class="sorting">Civilité/Prénom/Nom/Email</th>
<th class="sorting">Code postal</th>
<th class="sorting">Statut</th>
<th class="sorting">Labels</th>
<th class="sorting">Statut</th>
<th class="sorting">Billet reçu</th>
<th class="sorting">Action</th>
</tr>
</thead>
Expand All @@ -120,19 +117,30 @@
{% for row in event_inscriptions %}
<tr>
<td>
<img height="40" src="https://billets.besoindeurope.fr/{{ national_event.slug }}/{{ row.uuid }}.png" />
{{ row.uuid }}
{% set image_url = 'https://' ~ ticket_besoindeurope_host ~ '/' ~ row.ticketQRCodeFile %}
<a href="{{ image_url }}" target="_blank">
<img height="40" src="{{ image_url }}" /> {{ row.uuid }}
</a>
</td>
<td>
{{ row.gender == 'male' ? 'M' : 'Mme' }} {{ row.firstName }} {{ row.lastName }}
<br/><strong>{{ row.addressEmail }}</strong>
</td>
<td>{{ row.ticketSentAt|format_datetime('none', 'none', "d MMM yyyy à HH:mm") }}</td>
<td>{{ row.gender }}</td>
<td>{{ row.firstName }}</td>
<td>{{ row.lastName }}</td>
<td>{{ row.addressEmail }}</td>
<td>{{ row.postalCode }}</td>
<td>{{ row.status|trans }}</td>
<td>{% include 'admin/adherent/_tags.html.twig' with { tags: row.adherent ? row.adherent.tags : [] } %}</td>
<td>{{ row.status|trans }}</td>
<td>{{ row.ticketSentAt|format_datetime('none', 'none', "d MMM yyyy à HH:mm") }}</td>
<td>
<a href="{{ path('admin_app_nationalevent_nationalevent_sendTickets', {id: national_event.id, uuid: row.uuid}) }}" class="btn btn-primary">Envoyer billet</a>
<div class="btn-group" style="display: flex;">
<a href="{{ path('admin_app_nationalevent_eventinscription_edit', {id: row.id}) }}" class="btn btn-sm btn-default">
<i class="fas fa-pencil-alt" aria-hidden="true"></i>
Éditer
</a>
<a href="{{ path('admin_app_nationalevent_nationalevent_sendTickets', {id: national_event.id, uuid: row.uuid}) }}" class="btn btn-sm btn-success">
<i class="fas fa-envelope" aria-hidden="true"></i>
Envoyer billet
</a>
</div>
</td>
</tr>
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
{{ form_errors(form.birthdate) }}
</fieldset>

<fieldset>
{{ form_row(form.qualities, {label: 'Je suis (optionnel)' }) }}
</fieldset>

<fieldset>
{{ form_row(form.phone, {label: 'Numéro de téléphone (optionnel)', help: 'En nous communiquant votre téléphone, vous recevrez votre billet par SMS.' }) }}
</fieldset>
Expand Down

0 comments on commit a2f8284

Please sign in to comment.