1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| #Date de départ type calendrier
->add('dateStart', DateType::class, [
'label'=>'date de départ',
'required'=>true,
// prevents rendering it as type="date", to avoid HTML5 date pickers
'html5' => false,
'widget'=>'single_text',
'format' => 'dd-MM-yyyy',
// adds a class that can be selected in JavaScript
'attr' => ['class' => 'js-datepicker'],
])
# Date de retour type calendrier
->add('dateEnd', DateType::class, [
'label'=>'date de retour',
'widget'=>'single_text',
'required'=>true,
'format' => 'dd-MM-yyyy',
// prevents rendering it as type="date", to avoid HTML5 date pickers
'html5' => false,
'attr' => ['class' => 'js-datepicker'],
])
->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
# CALCUL DES TARIFS
$price = 0;
$dateStart = DateTime::createFromFormat('m-d-Y', $dateStart)->getTimestamp();
$dateEnd = DateTime::createFromFormat('m-d-Y', $dateEnd)->getTimestamp();
echo ($dateStart- $dateEnd) / (24*60*60); // 86400 might save some math
#registration.accommodation sont les données recueillies apres validation du formulaire, c'est ce que je veux mais ça ne se présente pas comme ça
// if (registration.accommodation_type = 'economique'){
// $price = $nbJours * 5000,
// elseif (registration.accommodation_type = 'standard') {
// $price =$nbJours * 8000;
// }
// else {
// $price=$nbJours * 15000;
// }
$registration->setPrice($price); |
Partager