Validate Email + Birthday by Form

Set an default, is not set or is false - for entries in the CMS via httpPost

git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3406 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
adametz 2018-06-18 12:43:41 +00:00
parent 0534a887cf
commit bea8145faf
8 changed files with 36 additions and 11 deletions

View file

@ -42,6 +42,8 @@
{{ form_errors(form) }}
{{ form_errors(form.email) }}
<div id="message"></div>
<div class="form-box">

View file

@ -37,6 +37,7 @@
<form class="st-booking-form" method="post" data-toggle="validator">
{{ form_errors(form) }}
{{ form_errors(form.email) }}
<div id="message"></div>

View file

@ -106,7 +106,6 @@ class BookingController extends Controller
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl).'/edit';
}
$this->get('mailer')->send(\Swift_Message::newInstance()
->setSubject('Ihr Buchungsauftrag bei STERN TOURS')
->setFrom('stern@stern-tours.de', 'STERN TOURS')

View file

@ -898,11 +898,16 @@ class TravelBooking
for ($i = 0; $i < count($travelers); ++$i)
{
$traveler = $travelers[$i];
$birthdate = $traveler->getBirthDate();
if(!strtotime($birthdate)){
$birthdate = '01.01.1900';
}
$participants[''. ($i+1)] = [
'gender' => $traveler->getSex(),
'first_name' => $traveler->getFirstName(),
'last_name' => $traveler->getLastName(),
'birthday' => $traveler->getBirthDate()
'birthday' => $birthdate,
];
}
@ -930,6 +935,9 @@ class TravelBooking
$traveler->setSex(intval($participant['gender']));
$traveler->setFirstName($participant['first_name']);
$traveler->setLastName($participant['last_name']);
if(!strtotime($participant['birthday'])){
$participant['birthday'] = '01.01.1900';
}
$traveler->setBirthDate(\DateTime::createFromFormat('d.m.Y', $participant['birthday']));
$ret[] = $traveler;
}

View file

@ -88,6 +88,9 @@ class Traveler
*/
public function getBirthDate()
{
if(($this->birthDate instanceof String) && !strtotime($this->birthDate)){
return '01.01.1900';
}
return $this->birthDate;
}
@ -96,6 +99,7 @@ class Traveler
*/
public function setBirthDate($birthDate)
{
$this->birthDate = $birthDate;
}

View file

@ -31,8 +31,7 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter
$this->warn('Failed creating lead in CRM Lead', $bookingRequest, $travelDate, Logger::ERROR);
return false;
}
$bookingUrl = $this->createBooking($bookingRequest, $travelDate, $bookingPriceInfo, $lead['customer_id'],
$lead['id']);
$bookingUrl = $this->createBooking($bookingRequest, $travelDate, $bookingPriceInfo, $lead['customer_id'], $lead['id']);
if ($bookingUrl === false)
{
$this->warn('Failed creating booking in CRM Booking', $bookingRequest, $travelDate, Logger::ERROR);
@ -268,7 +267,6 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter
'participant_firstname' => $bookingRequest->getTravelers()[0]->getFirstName(),
'participant_birthdate' => $bookingRequest->getTravelers()[0]->getBirthDate(),
]]);
if (!$resp['success'])
{
return false;

View file

@ -133,17 +133,17 @@ class BookingRequestType extends AbstractType
])
->add('phone')
->add('fax')
->add('email')
/*EmailType::class, [
->add('email',
EmailType::class, [
'constraints' =>[
new Email([
'message'=>'This is not the corect email format'
'message'=>'Dies ist nicht das richtige E-Mail-Format, bitte korrigieren.'
]),
new NotBlank([
'message' => 'This field can not be blank'
'message' => 'Das Feld E-Mail darf nicht leer sein.'
])
]
])*/
])
->add('rooms', CollectionType::class, [
'entry_type' => RoomType::class,
'by_reference' => false,

View file

@ -19,12 +19,15 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\RangeType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
class FewoBookingRequestType extends AbstractType
{
@ -117,7 +120,17 @@ class FewoBookingRequestType extends AbstractType
->add('city')
->add('phone')
->add('fax')
->add('email')
->add('email',
EmailType::class, [
'constraints' =>[
new Email([
'message'=>'Dies ist nicht das richtige E-Mail-Format, bitte korrigieren.'
]),
new NotBlank([
'message' => 'Das Feld E-Mail darf nicht leer sein.'
])
]
])
->add('notes', TextareaType::class, ['required' => false])
->add('acceptTerms', CheckboxType::class, ['required' => true])
->add('acceptPrivacy', CheckboxType::class, ['required' => true])