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:
parent
0534a887cf
commit
bea8145faf
8 changed files with 36 additions and 11 deletions
|
|
@ -42,6 +42,8 @@
|
||||||
|
|
||||||
{{ form_errors(form) }}
|
{{ form_errors(form) }}
|
||||||
|
|
||||||
|
{{ form_errors(form.email) }}
|
||||||
|
|
||||||
<div id="message"></div>
|
<div id="message"></div>
|
||||||
|
|
||||||
<div class="form-box">
|
<div class="form-box">
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
<form class="st-booking-form" method="post" data-toggle="validator">
|
<form class="st-booking-form" method="post" data-toggle="validator">
|
||||||
|
|
||||||
{{ form_errors(form) }}
|
{{ form_errors(form) }}
|
||||||
|
{{ form_errors(form.email) }}
|
||||||
|
|
||||||
<div id="message"></div>
|
<div id="message"></div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,6 @@ class BookingController extends Controller
|
||||||
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl).'/edit';
|
$crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl).'/edit';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->get('mailer')->send(\Swift_Message::newInstance()
|
$this->get('mailer')->send(\Swift_Message::newInstance()
|
||||||
->setSubject('Ihr Buchungsauftrag bei STERN TOURS')
|
->setSubject('Ihr Buchungsauftrag bei STERN TOURS')
|
||||||
->setFrom('stern@stern-tours.de', 'STERN TOURS')
|
->setFrom('stern@stern-tours.de', 'STERN TOURS')
|
||||||
|
|
|
||||||
|
|
@ -898,11 +898,16 @@ class TravelBooking
|
||||||
for ($i = 0; $i < count($travelers); ++$i)
|
for ($i = 0; $i < count($travelers); ++$i)
|
||||||
{
|
{
|
||||||
$traveler = $travelers[$i];
|
$traveler = $travelers[$i];
|
||||||
|
|
||||||
|
$birthdate = $traveler->getBirthDate();
|
||||||
|
if(!strtotime($birthdate)){
|
||||||
|
$birthdate = '01.01.1900';
|
||||||
|
}
|
||||||
$participants[''. ($i+1)] = [
|
$participants[''. ($i+1)] = [
|
||||||
'gender' => $traveler->getSex(),
|
'gender' => $traveler->getSex(),
|
||||||
'first_name' => $traveler->getFirstName(),
|
'first_name' => $traveler->getFirstName(),
|
||||||
'last_name' => $traveler->getLastName(),
|
'last_name' => $traveler->getLastName(),
|
||||||
'birthday' => $traveler->getBirthDate()
|
'birthday' => $birthdate,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -930,6 +935,9 @@ class TravelBooking
|
||||||
$traveler->setSex(intval($participant['gender']));
|
$traveler->setSex(intval($participant['gender']));
|
||||||
$traveler->setFirstName($participant['first_name']);
|
$traveler->setFirstName($participant['first_name']);
|
||||||
$traveler->setLastName($participant['last_name']);
|
$traveler->setLastName($participant['last_name']);
|
||||||
|
if(!strtotime($participant['birthday'])){
|
||||||
|
$participant['birthday'] = '01.01.1900';
|
||||||
|
}
|
||||||
$traveler->setBirthDate(\DateTime::createFromFormat('d.m.Y', $participant['birthday']));
|
$traveler->setBirthDate(\DateTime::createFromFormat('d.m.Y', $participant['birthday']));
|
||||||
$ret[] = $traveler;
|
$ret[] = $traveler;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,9 @@ class Traveler
|
||||||
*/
|
*/
|
||||||
public function getBirthDate()
|
public function getBirthDate()
|
||||||
{
|
{
|
||||||
|
if(($this->birthDate instanceof String) && !strtotime($this->birthDate)){
|
||||||
|
return '01.01.1900';
|
||||||
|
}
|
||||||
return $this->birthDate;
|
return $this->birthDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,6 +99,7 @@ class Traveler
|
||||||
*/
|
*/
|
||||||
public function setBirthDate($birthDate)
|
public function setBirthDate($birthDate)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->birthDate = $birthDate;
|
$this->birthDate = $birthDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,7 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter
|
||||||
$this->warn('Failed creating lead in CRM Lead', $bookingRequest, $travelDate, Logger::ERROR);
|
$this->warn('Failed creating lead in CRM Lead', $bookingRequest, $travelDate, Logger::ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$bookingUrl = $this->createBooking($bookingRequest, $travelDate, $bookingPriceInfo, $lead['customer_id'],
|
$bookingUrl = $this->createBooking($bookingRequest, $travelDate, $bookingPriceInfo, $lead['customer_id'], $lead['id']);
|
||||||
$lead['id']);
|
|
||||||
if ($bookingUrl === false)
|
if ($bookingUrl === false)
|
||||||
{
|
{
|
||||||
$this->warn('Failed creating booking in CRM Booking', $bookingRequest, $travelDate, Logger::ERROR);
|
$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_firstname' => $bookingRequest->getTravelers()[0]->getFirstName(),
|
||||||
'participant_birthdate' => $bookingRequest->getTravelers()[0]->getBirthDate(),
|
'participant_birthdate' => $bookingRequest->getTravelers()[0]->getBirthDate(),
|
||||||
]]);
|
]]);
|
||||||
|
|
||||||
if (!$resp['success'])
|
if (!$resp['success'])
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -133,17 +133,17 @@ class BookingRequestType extends AbstractType
|
||||||
])
|
])
|
||||||
->add('phone')
|
->add('phone')
|
||||||
->add('fax')
|
->add('fax')
|
||||||
->add('email')
|
->add('email',
|
||||||
/*EmailType::class, [
|
EmailType::class, [
|
||||||
'constraints' =>[
|
'constraints' =>[
|
||||||
new Email([
|
new Email([
|
||||||
'message'=>'This is not the corect email format'
|
'message'=>'Dies ist nicht das richtige E-Mail-Format, bitte korrigieren.'
|
||||||
]),
|
]),
|
||||||
new NotBlank([
|
new NotBlank([
|
||||||
'message' => 'This field can not be blank'
|
'message' => 'Das Feld E-Mail darf nicht leer sein.'
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
])*/
|
])
|
||||||
->add('rooms', CollectionType::class, [
|
->add('rooms', CollectionType::class, [
|
||||||
'entry_type' => RoomType::class,
|
'entry_type' => RoomType::class,
|
||||||
'by_reference' => false,
|
'by_reference' => false,
|
||||||
|
|
|
||||||
|
|
@ -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\RangeType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
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\FormBuilderInterface;
|
||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
||||||
use Symfony\Component\Form\FormEvents;
|
use Symfony\Component\Form\FormEvents;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Validator\Constraints\Choice;
|
use Symfony\Component\Validator\Constraints\Choice;
|
||||||
use Symfony\Component\Validator\Constraints\NotNull;
|
use Symfony\Component\Validator\Constraints\NotNull;
|
||||||
|
use Symfony\Component\Validator\Constraints\Email;
|
||||||
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
|
||||||
class FewoBookingRequestType extends AbstractType
|
class FewoBookingRequestType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|
@ -117,7 +120,17 @@ class FewoBookingRequestType extends AbstractType
|
||||||
->add('city')
|
->add('city')
|
||||||
->add('phone')
|
->add('phone')
|
||||||
->add('fax')
|
->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('notes', TextareaType::class, ['required' => false])
|
||||||
->add('acceptTerms', CheckboxType::class, ['required' => true])
|
->add('acceptTerms', CheckboxType::class, ['required' => true])
|
||||||
->add('acceptPrivacy', CheckboxType::class, ['required' => true])
|
->add('acceptPrivacy', CheckboxType::class, ['required' => true])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue