Skip to content

Commit

Permalink
afup#1477 Ticket mode de transport
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Apr 23, 2024
1 parent 8bdc216 commit 221f4ef
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 54 deletions.
27 changes: 19 additions & 8 deletions app/Resources/views/event/ticket/ticket.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,25 @@

<p class="tickets--type-stock-limit"><em>{{ 'Dans la limite des stocks disponibles.'|trans }}</em></p>

<p>
Dans le cadre de la <a href="">certification LEAD</a> ,
nous devons vous demandez des informations à propos de votre venue,
et-ce 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>
{{ form_row(ticket.transportMode) }}
{{ form_row(ticket.transportDistance) }}
{% if ticket.transportMode is defined %}
<div class="transport">
<p>
Dans le cadre de la <a href="">certification LEAD</a> ,
nous devons vous demandez des informations à propos de votre venue,
et-ce 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>
{{ form_row(ticket.transportMode) }}
{{ form_row(ticket.transportDistance) }}

{% if key == 0 %}
<button id="clone_transport" class="btn-link">
Recopier les informations de transport pour toutes les personnes
</button>
{% endif %}

</div>
{% endif %}

<p>{{ 'Merci de renseigner 3 tags (et/ou votre id Twitter) vous caractérisant, ces tags seront imprimés sur votre badge afin de faciliter le networking pendant l\'évènement'|trans }}</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class AfupForumTransportInformation extends AbstractMigration
public function change()
{
$this->execute("ALTER TABLE `afup_forum` ADD `transport_information_enabled` TINYINT DEFAULT 0");
$this->execute("ALTER TABLE `afup_inscription_forum` ADD `transport_mode` VARCHAR(255), ADD `transport_distance` TINYINT");
$this->execute("ALTER TABLE `afup_inscription_forum` ADD `transport_mode` TINYINT, ADD `transport_distance` TINYINT");
}
}
30 changes: 23 additions & 7 deletions htdocs/css/tickets.css
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,34 @@ div.sponsor--become-form label {
div.tickets--errors{
border-color: #B0413E;
}

fieldset div.fieldset--inner > div.transport {
padding: 1em;
border: 1px #50a0dd solid;
background-color: #FEFEFE;
}
fieldset div.fieldset--inner > div.transport p {
padding-top: 0;
}
fieldset div.fieldset--inner > div.transport button {
color: rgb(76, 110, 175);
text-decoration: underline;
background-color: transparent;
border: 0;
}
fieldset div.fieldset--inner > div.transport button:hover {
text-decoration: none;
}

@media(min-width: 460px) {

ul.tickets--type-list{
margin-left:150px;
}

ul.tickets--type-list li {
width: 600px;
}

ul.tickets--type-list hr{
width:600px;
}
Expand All @@ -236,11 +252,11 @@ div.tickets--errors{
top: 12px;
left: -7px;
}

p.tickets--type-stock-limit{
margin-left:200px;
}

ul.tickets--errors, #fieldset--optin div{
margin-left:200px;
}
Expand All @@ -256,5 +272,5 @@ div.tickets--errors{
form {
font-size:16px;
}

}
31 changes: 31 additions & 0 deletions htdocs/js/inscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,35 @@ $(document).ready(function(){
$('#purchase_tickets_0_firstname').on('change', function(){copyValBetweenFields('purchase_tickets_0_firstname', 'purchase_firstname')});
$('#purchase_tickets_0_email').on('change', function(){copyValBetweenFields('purchase_tickets_0_email', 'purchase_email')});


// Mode de transport
var cloneTransport = function () {
let $button = $('#clone_transport');

if (nbInscriptions <= 1) {
$button.hide();
}
$("#purchase_nbPersonnes").change(function () {
$button.show();
var nb = parseInt($("#purchase_nbPersonnes").val(), 10);
if (nb <= 1) {
$button.hide();
}
});

$button.on('click', function (e) {
e.preventDefault();
let mode = $('#purchase_tickets_0_transportMode').val();
let distance = $('#purchase_tickets_0_transportDistance').val();
for (let i = 1; i < nbInscriptions; i++) {
$('#purchase_tickets_'+i+'_transportMode').val(mode).change();
$('#purchase_tickets_'+i+'_transportDistance').val(distance).change();
}

return false;
});
}

var init = function(){
if (storageAvailable('localStorage') && localStorage.getItem('tickets')) {
try {
Expand Down Expand Up @@ -400,6 +429,8 @@ $(document).ready(function(){
manageFieldSet(nbInscriptions);

updateSummary();

cloneTransport();
};
init();

Expand Down
12 changes: 10 additions & 2 deletions htdocs/pages/administration/forum_inscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,11 @@ function updateGlobalsForTarif(
$groupe[] = $formulaire->createElement('radio', 'mail_partenaire', null, 'non', 0);
$formulaire->addGroup($groupe, 'groupe_mail_partenaire', null, '&nbsp;', false);

$formulaire->addElement('header', 'boutons' , '');
$formulaire->addElement('header', null, 'Transport');
$formulaire->addElement('select', 'transport_mode', 'Quel est votre mode de transport ?', Ticket::TRANSPORT_MODES);
$formulaire->addElement('select', 'transport_distance', 'Quelle sera la distance parcourue ?', Ticket::TRANSPORT_DISTANCES);

$formulaire->addElement('header', 'boutons' , '');
$formulaire->addElement('submit', 'soumettre', 'Soumettre');

// On ajoute les règles
Expand Down Expand Up @@ -370,6 +374,8 @@ function updateGlobalsForTarif(
$ticket->setComments($valeurs['commentaires']);
$ticket->setStatus($valeurs['etat']);
$ticket->setInvoiceStatus($valeurs['facturation']);
$ticket->setTransportMode($valeurs['transport_mode']);
$ticket->setTransportDistance($valeurs['transport_distance']);
try {
$ticketRepository->save($ticket);
$ok = true;
Expand All @@ -392,7 +398,9 @@ function updateGlobalsForTarif(
$valeurs['mail_partenaire'],
$valeurs['commentaires'],
$valeurs['etat'],
$valeurs['facturation']);
$valeurs['facturation'],
$valeurs['transport_mode'],
$valeurs['transport_distance']);

/** @var \AppBundle\Event\Model\Ticket $ticket */
$ticket = $ticketRepository->get($_GET['id']);
Expand Down
15 changes: 14 additions & 1 deletion sources/Afup/Bootstrap/commonStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,27 @@
define('AFUP_SIRET', '500 869 011 00022');
define('AFUP_NUMERO_TVA', 'FR27 500 869 011');

// Ticket transport mode
// Ticket transport distance
define('AFUP_TRANSPORT_DISTANCE_0', 0);
define('AFUP_TRANSPORT_DISTANCE_25_50', 25);
define('AFUP_TRANSPORT_DISTANCE_50_100', 50);
define('AFUP_TRANSPORT_DISTANCE_100_500', 100);
define('AFUP_TRANSPORT_DISTANCE_500_1000', 500);
define('AFUP_TRANSPORT_DISTANCE_1000', 1000);

// Ticket transport mode
define('AFUP_TRANSPORT_MODE_SEUL_THERMIQUE', 10);
define('AFUP_TRANSPORT_MODE_SEUL_ELECTRIQUE', 20);
define('AFUP_TRANSPORT_MODE_SEUL_HYBRIDE', 30);
define('AFUP_TRANSPORT_MODE_PASSAGERS_THERMIQUE', 40);
define('AFUP_TRANSPORT_MODE_PASSAGERS_ELECTRIQUE', 50);
define('AFUP_TRANSPORT_MODE_PASSAGERS_HYBRIDE', 60);
define('AFUP_TRANSPORT_MODE_BUS', 70);
define('AFUP_TRANSPORT_MODE_TRAIN', 80);
define('AFUP_TRANSPORT_MODE_AVION_ECO', 90);
define('AFUP_TRANSPORT_MODE_AVION_BUSINESS', 100);
define('AFUP_TRANSPORT_MODE_COMMUN', 110);

$AFUP_Tarifs_Forum = array(
AFUP_FORUM_INVITATION => 0,
AFUP_FORUM_ORGANISATION => 0,
Expand Down
7 changes: 5 additions & 2 deletions sources/Afup/Forum/Inscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ function obtenirListe($id_forum = null,

function modifierInscription($id, $reference, $type_inscription, $civilite, $nom, $prenom,
$email, $telephone, $coupon, $citer_societe, $newsletter_afup,
$newsletter_nexen, $mail_partenaire, $commentaires, $etat, $facturation)
$newsletter_nexen, $mail_partenaire, $commentaires, $etat, $facturation,
$transportMode, $transportDistance)
{
$requete = 'UPDATE ';
$requete .= ' afup_inscription_forum ';
Expand All @@ -281,7 +282,9 @@ function modifierInscription($id, $reference, $type_inscription, $civilite, $nom
$requete .= ' mail_partenaire=' . $this->_bdd->echapper($mail_partenaire) . ',';
$requete .= ' commentaires=' . $this->_bdd->echapper($commentaires) . ',';
$requete .= ' etat=' . $this->_bdd->echapper($etat) . ',';
$requete .= ' facturation=' . $this->_bdd->echapper($facturation);
$requete .= ' facturation=' . $this->_bdd->echapper($facturation) . ',';
$requete .= ' transport_mode=' . $this->_bdd->echapper($transportMode) . ',';
$requete .= ' transport_distance=' . $this->_bdd->echapper($transportDistance);
$requete .= 'WHERE';
$requete .= ' id=' . $id;

Expand Down
46 changes: 14 additions & 32 deletions sources/AppBundle/Event/Form/TicketType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace AppBundle\Event\Form;

use Afup\Site\Forum\Forum;
use AppBundle\Event\Model\Repository\EventRepository;
use AppBundle\Event\Model\Repository\TicketEventTypeRepository;
use AppBundle\Event\Model\Repository\TicketSpecialPriceRepository;
Expand Down Expand Up @@ -173,38 +174,19 @@ public function buildForm(FormBuilderInterface $builder, array $options)
;
});

$builder->add('transportMode', ChoiceType::class, [
'label' => 'Quel est votre mode de transport ?',
'required' => true,
'choices' => [
'' => '',
'Voiture seul·e' => 'Voiture seul·e',
'Voiture seul·e électrique' => 'Voiture seul·e électrique',
'Voiture seul·e hybride' => 'Voiture seul·e hybride',
'Voiture avec passagers·ères' => 'Voiture avec passagers·ères',
'Voiture avec passagers·ères électrique' => 'Voiture avec passagers·ères électrique',
'Voiture avec passagers·ères hybride' => 'Voiture avec passagers·ères hybride',
'Bus' => 'Bus',
'Train' => 'Train',
'Avion classe économique' => 'Avion classe économique',
'Avion classe business' => 'Avion classe business',
'Transports en commun' => 'Transports en commun'
],
]);

$builder->add('transportDistance', ChoiceType::class, [
'label' => 'Quelle sera la distance parcourue ?',
'required' => true,
'choices' => [
'' => '',
'< 25 km' => AFUP_TRANSPORT_DISTANCE_0,
'entre 25 et 50 km' => AFUP_TRANSPORT_DISTANCE_25_50,
'entre 50 et 100 km' => AFUP_TRANSPORT_DISTANCE_50_100,
'entre 100 et 500 km' => AFUP_TRANSPORT_DISTANCE_100_500,
'entre 500 et 1000 km' => AFUP_TRANSPORT_DISTANCE_500_1000,
'> 1000 km' => AFUP_TRANSPORT_DISTANCE_1000,
],
]);
if ($event->getTransportInformationEnabled()) {
$builder->add('transportMode', ChoiceType::class, [
'label' => 'Quel est votre mode de transport ?',
'required' => true,
'choices' => array_flip(Ticket::TRANSPORT_MODES),
]);

$builder->add('transportDistance', ChoiceType::class, [
'label' => 'Quelle sera la distance parcourue ?',
'required' => true,
'choices' => array_flip(Ticket::TRANSPORT_DISTANCES),
]);
}


$builder
Expand Down
25 changes: 25 additions & 0 deletions sources/AppBundle/Event/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class Event implements NotifyPropertyInterface

private $accomodationEnabled;

private $transportInformationEnabled;

/**
* @var string
*/
Expand Down Expand Up @@ -712,6 +714,29 @@ public function setWaitingListUrl($waitingListUrl)
return $this;
}

/**
* @return bool
*/
public function getTransportInformationEnabled()
{
return $this->transportInformationEnabled;
}

/**
* @param bool $transportInformationEnabled
*
* @return $this
*/
public function setTransportInformationEnabled($transportInformationEnabled)
{
$transportInformationEnabled = (bool) $transportInformationEnabled;

$this->propertyChanged('transportInformationEnabled', $this->transportInformationEnabled, $transportInformationEnabled);
$this->transportInformationEnabled = $transportInformationEnabled;

return $this;
}

public function isOnline()
{
return false !== strpos($this->getPath(), 'enligne');
Expand Down
5 changes: 5 additions & 0 deletions sources/AppBundle/Event/Model/Repository/EventRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ public static function initMetadata(SerializerFactoryInterface $serializerFactor
'fieldName' => 'waitingListUrl',
'type' => 'string',
])
->addField([
'columnName' => 'transport_information_enabled',
'fieldName' => 'transportInformationEnabled',
'type' => 'boolean',
])
;

return $metadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public static function initMetadata(SerializerFactoryInterface $serializerFactor
->addField([
'columnName' => 'transport_mode',
'fieldName' => 'transportMode',
'type' => 'string',
'type' => 'int',
])
->addField([
'columnName' => 'transport_distance',
Expand Down
25 changes: 25 additions & 0 deletions sources/AppBundle/Event/Model/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@ class Ticket implements NotifyPropertyInterface
{
use NotifyProperty;

const TRANSPORT_MODES = [
'' => '',
AFUP_TRANSPORT_MODE_SEUL_THERMIQUE => 'Voiture seul·e',
AFUP_TRANSPORT_MODE_SEUL_ELECTRIQUE => 'Voiture seul·e électrique',
AFUP_TRANSPORT_MODE_SEUL_HYBRIDE => 'Voiture seul·e hybride',
AFUP_TRANSPORT_MODE_PASSAGERS_THERMIQUE=> 'Voiture avec passagers·ères',
AFUP_TRANSPORT_MODE_PASSAGERS_ELECTRIQUE => 'Voiture avec passagers·ères électrique',
AFUP_TRANSPORT_MODE_PASSAGERS_HYBRIDE => 'Voiture avec passagers·ères hybride',
AFUP_TRANSPORT_MODE_BUS => 'Bus',
AFUP_TRANSPORT_MODE_TRAIN => 'Train',
AFUP_TRANSPORT_MODE_AVION_ECO => 'Avion classe économique',
AFUP_TRANSPORT_MODE_AVION_BUSINESS => 'Avion classe business',
AFUP_TRANSPORT_MODE_COMMUN => 'Transports en commun'
];

const TRANSPORT_DISTANCES = [
'' => '',
AFUP_TRANSPORT_DISTANCE_0 => '< 25 km',
AFUP_TRANSPORT_DISTANCE_25_50 => 'entre 25 et 50 km',
AFUP_TRANSPORT_DISTANCE_50_100 => 'entre 50 et 100 km',
AFUP_TRANSPORT_DISTANCE_100_500 => 'entre 100 et 500 km',
AFUP_TRANSPORT_DISTANCE_500_1000 => 'entre 500 et 1000 km',
AFUP_TRANSPORT_DISTANCE_1000 => '> 1000 km',
];

const STATUS_CREATED = AFUP_FORUM_ETAT_CREE;
const STATUS_CANCELLED = AFUP_FORUM_ETAT_ANNULE;
const STATUS_ERROR = AFUP_FORUM_ETAT_ERREUR;
Expand Down

0 comments on commit 221f4ef

Please sign in to comment.