Skip to content

Commit

Permalink
issue#1479 Sponsor ticket transport
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Jun 19, 2024
1 parent f5cd420 commit bb6679e
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 12 deletions.
8 changes: 8 additions & 0 deletions app/Resources/translations/messages.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,11 @@ venue_speaker.expenses.intro: |
Le package speaker prend en charge le remboursement des frais de transport, sur base d'un trajet en 2nde classe ou classe économique.<br />
Envoyez-nous vos justificatifs (par exemple, une facture de billet de train ou une copie du billet), ainsi que votre RIB/IBAN.<br />
Utilisez le formulaire ci-dessous pour nous envoyer ces informations (au format PDF). Vous pouvez nous envoyer plusieurs fichiers.
certification_lead.info: |
<p>
Dans le cadre de la <a href="https://event.afup.org/forum-php-2024/certification-lead/"
target="_blank">certification LEAD</a>,
nous devons vous demander des informations à propos de votre venue,
afin d'établir notre bilan carbone.<br />
Si vous n'êtes pas sûr·e de votre mode de transport, indiquez le plus probable.
</p>
24 changes: 23 additions & 1 deletion app/Resources/views/event/ticket/sponsor.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
<th>
Email
</th>
{% if with_transport %}
<th>
Mode de transport
</th>
{% endif %}
<th>
¤
</th>
Expand All @@ -51,6 +56,12 @@
<td>
{{ ticket.email }}
</td>
{% if with_transport %}
<td>
{{ constant('AppBundle\\Event\\Model\\Ticket::TRANSPORT_MODES')[ticket.transportMode] }}<br />
{{ constant('AppBundle\\Event\\Model\\Ticket::TRANSPORT_DISTANCES')[ticket.transportDistance] }}
</td>
{% endif %}
<td>
<form method="post" class="sponsor--ticket">
<a href="{{ url('sponsor_ticket_form', {ticket: ticket.id, eventSlug: event.path}) }}" class="button">Modifier</a>
Expand All @@ -60,7 +71,7 @@
</tr>
{% else %}
<tr>
<td colspan="4"><em>Aucun ticket enregistré pour le moment.</em></td>
<td colspan="{{ with_transport ? 5 : 4 }}"><em>Aucun ticket enregistré pour le moment.</em></td>
</tr>

{% endfor %}
Expand All @@ -76,6 +87,17 @@
<p>Vous avez utilisé toutes vos invitations. Nous avons hâte de vous retrouver lors de cet évènement !</p>
{% else %}
{{ form_start(ticketForm, {attr: {class: 'sponsor--ticket-edit'}}) }}
{{ form_row(ticketForm.civility) }}
{{ form_row(ticketForm.firstname) }}
{{ form_row(ticketForm.lastname) }}
{{ form_row(ticketForm.email) }}

{% if with_transport %}
{{ 'certification_lead.info'|trans|raw }}
{{ form_row(ticketForm.transport_mode) }}
{{ form_row(ticketForm.transport_distance) }}
{% endif %}

{{ form_errors(ticketForm) }}
{{ form_widget(ticketForm) }}
<input type="submit" value="Enregistrer" />
Expand Down
8 changes: 1 addition & 7 deletions app/Resources/views/event/ticket/ticket.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,7 @@

{% if ticket.transportMode is defined %}
<div class="transport">
<p>
Dans le cadre de la <a href="https://event.afup.org/forum-php-2024/certification-lead/"
target="_blank">certification LEAD</a>,
nous devons vous demander des informations à propos de votre venue,
afin d'établir notre bilan carbone.<br />
Si vous n'êtes pas sûr·e de votre mode de transport, indiquez le plus probable.
</p>
{{ 'certification_lead.info'|trans|raw }}
{{ form_row(ticket.transportMode) }}
{{ form_row(ticket.transportDistance) }}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php


use Phinx\Migration\AbstractMigration;

class AfupForumSponsorsTicketsTransportInformation extends AbstractMigration
{
public function change()
{
$this->execute("ALTER TABLE `afup_forum_sponsors_tickets` ADD `transport_mode` TINYINT, ADD `transport_distance` SMALLINT");
}
}
3 changes: 2 additions & 1 deletion sources/AppBundle/Controller/TicketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function sponsorTicketFormAction(Request $request, $eventSlug)
} else {
$ticket = $ticketFactory->createTicketFromSponsorTicket($sponsorTicket);
}
$ticketForm = $this->createForm(SponsorTicketType::class, $ticket);
$ticketForm = $this->createForm(SponsorTicketType::class, $ticket, ['with_transport' => $event->getTransportInformationEnabled()]);
$ticketForm->handleRequest($request);

if ($ticketForm->isSubmitted() && $ticketForm->isValid() && $sponsorTicket->getPendingInvitations() > 0) {
Expand Down Expand Up @@ -148,6 +148,7 @@ public function sponsorTicketFormAction(Request $request, $eventSlug)
'event' => $event,
'sponsors_infos' => $event->getSponsorInfos($request->getLocale()),
'sponsorTicket' => $sponsorTicket,
'with_transport' => $event->getTransportInformationEnabled(),
'ticketForm' => $ticketForm->createView(),
'registeredTickets' => $sponsorTicketHelper->getRegisteredTickets($sponsorTicket),
'edit' => $edit,
Expand Down
28 changes: 25 additions & 3 deletions sources/AppBundle/Event/Form/SponsorTicketType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;

class SponsorTicketType extends AbstractType
{
Expand All @@ -30,14 +31,35 @@ public function buildForm(FormBuilderInterface $builder, array $options)
])
->add('email', EmailType::class, [
'label' => 'Email'
])
;
]);

if ($options['with_transport']) {
$transportMode = Ticket::TRANSPORT_MODES;
asort($transportMode);

$builder
->add('transport_mode', ChoiceType::class, [
'label' => 'Votre mode de transport ?',
'placeholder' => '',
'required' => true,
'constraints' => [new NotBlank()],
'choices' => array_flip($transportMode),
])
->add('transport_distance', ChoiceType::class, [
'label' => 'La distance parcourue ?',
'placeholder' => '',
'required' => true,
'constraints' => [new NotBlank()],
'choices' => array_flip(Ticket::TRANSPORT_DISTANCES)
]);
}
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Ticket::class
'data_class' => Ticket::class,
'with_transport' => false
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public static function initMetadata(SerializerFactoryInterface $serializerFactor
'type' => 'bool',
'serializer' => Boolean::class
])
->addField([
'columnName' => 'transport_mode',
'fieldName' => 'transportMode',
'type' => 'int',
])
->addField([
'columnName' => 'transport_distance',
'fieldName' => 'transportDistance',
'type' => 'int'
])
;

return $metadata;
Expand Down
54 changes: 54 additions & 0 deletions sources/AppBundle/Event/Model/SponsorTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ class SponsorTicket implements NotifyPropertyInterface
*/
private $qrCodesScannerAvailable = false;

/**
* @var null|string
*/
protected $transportMode;

/**
* @var null|int
*/
protected $transportDistance;

/**
* @return int
*/
Expand Down Expand Up @@ -289,4 +299,48 @@ public function setQrCodesScannerAvailable($qrCodesScannerAvailable)
$this->qrCodesScannerAvailable = $qrCodesScannerAvailable;
return $this;
}

/**
* @return null|string
*/
public function getTransportMode()
{
return $this->transportMode;
}

/**
* @param null|string $transportMode
*
* @return $this
*/
public function setTransportMode($transportMode)
{
$this->propertyChanged('transportMode', $this->transportMode, $transportMode);

$this->transportMode = $transportMode;

return $this;
}

/**
* @return null|int
*/
public function getTransportDistance()
{
return $this->transportDistance;
}

/**
* @param null|int $transportDistance
*
* @return $this
*/
public function setTransportDistance($transportDistance)
{
$this->propertyChanged('transportDistance', $this->transportDistance, $transportDistance);

$this->transportDistance = $transportDistance;

return $this;
}
}

0 comments on commit bb6679e

Please sign in to comment.