From 353b758bcdd7e9a6686beeacd4999b0a0c620f69 Mon Sep 17 00:00:00 2001 From: uli Date: Tue, 21 Feb 2017 16:54:37 +0000 Subject: [PATCH] * Behoben: Falsche CRM-URL in Buchungs-Service-E-Mail * Kontaktformular git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3300 f459cee4-fb09-11de-96c3-f9c5f16c3c76 --- .../email/contactServiceEmail.txt.twig | 27 ++ .../pages/bookingConfirmation.html.twig | 4 + .../views/default/pages/contact.html.twig | 73 ++++ .../pages/contactConfirmation.html.twig | 11 + trunk/app/config/services.yml | 7 +- .../Controller/BookingController.php | 3 +- .../Controller/DefaultController.php | 58 +++ trunk/src/AppBundle/Entity/ContactRequest.php | 361 ++++++++++++++++++ ...r.php => BookingSternToursCrmExporter.php} | 34 +- .../Export/ContactSternToursCrmExporter.php | 61 +++ .../Export/SternToursCrmExporter.php | 51 +++ .../src/AppBundle/Form/ContactRequestType.php | 85 +++++ 12 files changed, 741 insertions(+), 34 deletions(-) create mode 100644 trunk/app/Resources/views/default/email/contactServiceEmail.txt.twig create mode 100644 trunk/app/Resources/views/default/pages/contact.html.twig create mode 100644 trunk/app/Resources/views/default/pages/contactConfirmation.html.twig create mode 100644 trunk/src/AppBundle/Entity/ContactRequest.php rename trunk/src/AppBundle/Export/{SternToursCrmBookingExporter.php => BookingSternToursCrmExporter.php} (89%) create mode 100644 trunk/src/AppBundle/Export/ContactSternToursCrmExporter.php create mode 100644 trunk/src/AppBundle/Export/SternToursCrmExporter.php create mode 100644 trunk/src/AppBundle/Form/ContactRequestType.php diff --git a/trunk/app/Resources/views/default/email/contactServiceEmail.txt.twig b/trunk/app/Resources/views/default/email/contactServiceEmail.txt.twig new file mode 100644 index 00000000..bce67876 --- /dev/null +++ b/trunk/app/Resources/views/default/email/contactServiceEmail.txt.twig @@ -0,0 +1,27 @@ +{# @var contact_request \AppBundle\Entity\ContactRequest +#}Neue Kontaktanfrage: + +CRM: {{ crm_url }} + +Anrede: {{ contact_request.salutation == 1 ? 'Herr' : 'Frau' }} +Vorname: {{ contact_request.firstName|default('-') }} +Nachname: {{ contact_request.lastName|default('-') }} +Adresse: {{ contact_request.streetAddress|default('-') }} +PLZ: {{ contact_request.zipCode|default('-') }} +Ort: {{ contact_request.city|default('-') }} +Telefonnummer: {{ contact_request.phone|default('-') }} +Fax: {{ contact_request.mobilePhone|default('-') }} +E-Mail: {{ contact_request.email|default('-') }} + +Abflugort 1: {{ contact_request.departure0|default('-') }} +Abflugort 2: {{ contact_request.departure1|default('-') }} +Abflugort 3: {{ contact_request.departure2|default('-') }} + +Reisebeginn: {{ contact_request.start is not empty ? contact_request.start|date }} +Reiseende: {{ contact_request.end is not empty ? contact_request.end|date }} +Dauer: {{ contact_request.duration|default('-') }} Tage +Anzahl d. Reisenden: {{ contact_request.travelerCount|default('-') }} + +Kommentar: + +{{ contact_request.notes }} diff --git a/trunk/app/Resources/views/default/pages/bookingConfirmation.html.twig b/trunk/app/Resources/views/default/pages/bookingConfirmation.html.twig index a22f3638..351692a8 100644 --- a/trunk/app/Resources/views/default/pages/bookingConfirmation.html.twig +++ b/trunk/app/Resources/views/default/pages/bookingConfirmation.html.twig @@ -4,4 +4,8 @@ {% block body %}

Vielen Dank für Ihren Buchungsauftrag!

+ +

+ Zurück zur Startseite +

{% endblock %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/pages/contact.html.twig b/trunk/app/Resources/views/default/pages/contact.html.twig new file mode 100644 index 00000000..f6c00efa --- /dev/null +++ b/trunk/app/Resources/views/default/pages/contact.html.twig @@ -0,0 +1,73 @@ +{% extends get_base_template() %} +{% form_theme contact_form 'default/form/theme.html.twig' %} + +{% block body %} +
+ +

Individuelle Reiseplanung

+ +

+ Sie haben noch nicht die richtige Reise gefunden? Oder planen Sie einen ganz besonderen Urlaub, den Sie im + Katalog nicht finden? Dann teilen Sie uns doch alle relevanten Informationen für Ihre Wunsch-Reise mit. Wir + werden uns dann umgehend bei Ihnen melden. Ihre Daten (Name, Telefonnummer etc.) werden ausschließlich zur + Bearbeitung Ihrer Anfrage verwendet und nicht an Dritte weitergegeben. +

+ +
+ +
+ +
+
+

Reisedaten

+
+ +
+

Abflughafen

+
+ +
{{ form_field_pho(contact_form.departure0, 'Abflughafen 1. Wahl') }}
+
{{ form_field_pho(contact_form.departure1, 'Abflughafen 2. Wahl') }}
+
{{ form_field_pho(contact_form.departure2, 'Abflughafen 3. Wahl') }}
+ +
+

Reisetermin

+
+ +
{{ form_field_pho(contact_form.start, 'Anreise') }}
+
{{ form_field_pho(contact_form.end, 'Abreise') }}
+
{{ form_field_pho(contact_form.duration, 'Reisedauer in Tagen') }}
+
+ +
+
+

Persönliche Daten

+
+ +
{{ form_field_pho(contact_form.salutation) }}
+
{{ form_field_pho(contact_form.firstName, 'Vorname') }}
+
{{ form_field_pho(contact_form.lastName, 'Nachname') }}
+
{{ form_field_pho(contact_form.streetAddress, 'Straße, Hausnummer') }}
+
{{ form_field_pho(contact_form.zipCode, 'Postleitzahl') }}
+
{{ form_field_pho(contact_form.city, 'Ort') }}
+
{{ form_field_pho(contact_form.nation) }}
+
{{ form_field_pho(contact_form.phone, 'Telefon tagsüber') }}
+
{{ form_field_pho(contact_form.mobilePhone, 'Telefon mobil') }}
+
{{ form_field_pho(contact_form.email, 'E-Mail-Adresse') }}
+
{{ form_field_pho(contact_form.travelerCount) }}
+ +
+ {{ form_field_pho(contact_form.notes, 'Bitte Reiseland und Programmwunsch angeben', {attr: {rows: 8}}) }} + + +
+
+ + {{ form_rest(contact_form) }} +
+ +
+ + +
+{% endblock body %} \ No newline at end of file diff --git a/trunk/app/Resources/views/default/pages/contactConfirmation.html.twig b/trunk/app/Resources/views/default/pages/contactConfirmation.html.twig new file mode 100644 index 00000000..7b7dfd02 --- /dev/null +++ b/trunk/app/Resources/views/default/pages/contactConfirmation.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block canonical_tag %}{% endblock %} + +{% block body %} +

Vielen Dank, wir haben Ihre Anfrage erhalten!

+ +

+ Zurück zur Startseite +

+{% endblock %} \ No newline at end of file diff --git a/trunk/app/config/services.yml b/trunk/app/config/services.yml index defd92d4..b28fda83 100644 --- a/trunk/app/config/services.yml +++ b/trunk/app/config/services.yml @@ -32,7 +32,12 @@ services: - { name: form.type, alias: datalist } app.booking_exporter: - class: AppBundle\Export\SternToursCrmBookingExporter + class: AppBundle\Export\BookingSternToursCrmExporter + arguments: + - '@monolog.logger' + + app.contact_exporter: + class: AppBundle\Export\ContactSternToursCrmExporter arguments: - '@monolog.logger' diff --git a/trunk/src/AppBundle/Controller/BookingController.php b/trunk/src/AppBundle/Controller/BookingController.php index 4b9d19a6..68736f18 100644 --- a/trunk/src/AppBundle/Controller/BookingController.php +++ b/trunk/src/AppBundle/Controller/BookingController.php @@ -94,6 +94,7 @@ class BookingController extends Controller $em->flush(); $crmBookingUrl = $this->get('app.booking_exporter')->process($bookingRequest, $travelDate, $bookingPriceInfo); + $crmBookingUrl = preg_replace('/\\/api/', '', $crmBookingUrl) .'/edit'; $this->get('mailer')->send(\Swift_Message::newInstance() ->setSubject('Ihr Buchungsauftrag bei STERN TOURS') @@ -118,7 +119,7 @@ class BookingController extends Controller ->setBody( $this->renderView('default/email/bookingServiceEmail.txt.twig', [ 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR, - 'crm_url' => $crmBookingUrl .'/edit', + 'crm_url' => $crmBookingUrl, 'travel_program_url' => Util::getBaseUrl() . $travelProgramPage->getUrlPath(), 'booking_request' => $bookingRequest, 'booking_price_info' => $bookingPriceInfo, diff --git a/trunk/src/AppBundle/Controller/DefaultController.php b/trunk/src/AppBundle/Controller/DefaultController.php index 37f4027e..3bcce590 100644 --- a/trunk/src/AppBundle/Controller/DefaultController.php +++ b/trunk/src/AppBundle/Controller/DefaultController.php @@ -3,8 +3,10 @@ namespace AppBundle\Controller; use AppBundle\Entity\BreadcrumbEntry; +use AppBundle\Entity\ContactRequest; use AppBundle\Entity\Page; use AppBundle\Entity\TravelProgram; +use AppBundle\Form\ContactRequestType; use AppBundle\Form\SearchRequestType; use AppBundle\Form\TtSearchRequestType; use AppBundle\Util; @@ -224,6 +226,62 @@ class DefaultController extends Controller ]); } + /** + * @Route("/kontakt") + */ + public function contactAction(Request $request) + { + $form = $this->createForm(ContactRequestType::class); + $breadcrumbEntries = [new BreadcrumbEntry('Kontaktformular')]; + + if ($request->getMethod() == 'POST') + { + $form->handleRequest($request); + + if ($form->isValid()) + { + /** @var ContactRequest $contactRequest */ + $contactRequest = $form->getData(); + + $crmLeadUrl = $this->get('app.contact_exporter')->process($contactRequest); + if ($crmLeadUrl) + { + $crmLeadUrl = preg_replace('/\\/api\\/lead/', '/leads', $crmLeadUrl) .'/edit'; + } + else + { + $crmLeadUrl = '[Übertragung zum CRM fehlgeschlagung]'; + } + + $this->get('mailer')->send(\Swift_Message::newInstance() + ->setSubject('Kontaktformular (stern-tours.de)') + ->setFrom('stern@stern-tours.de', 'STERN TOURS') + ->setTo('ulrich.hecht@hecht-software.de') + ->setBody( + $this->renderView('default/email/contactServiceEmail.txt.twig', [ + 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR, + 'crm_url' => $crmLeadUrl, + 'contact_request' => $contactRequest, + ]), + 'text/plain', 'utf-8' + ) + ); + + // #TODO This will lead to multiple submissions. Redirect instead! + return $this->render('default/pages/contactConfirmation.html.twig', [ + 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR, + 'breadcrumb_entries' => $breadcrumbEntries, + ]); + } + } + + return $this->render('default/pages/contact.html.twig', [ + 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR, + 'breadcrumb_entries' => $breadcrumbEntries, + 'contact_form' => $form->createView(), + ]); + } + public function headerAction() { $qb = $this->getEntityManager()->createQueryBuilder(); diff --git a/trunk/src/AppBundle/Entity/ContactRequest.php b/trunk/src/AppBundle/Entity/ContactRequest.php new file mode 100644 index 00000000..100d3b51 --- /dev/null +++ b/trunk/src/AppBundle/Entity/ContactRequest.php @@ -0,0 +1,361 @@ + + * @date 02/21/2017 + */ + +namespace AppBundle\Entity; + +use Symfony\Component\Validator\Constraints as Assert; + +class ContactRequest +{ + const MR = 1; + const MRS = 2; + + /** @var int|null $salutation */ + private $salutation; + + /** @var string|null $firstName */ + private $firstName; + + /** @var string|null $lastName */ + private $lastName; + + /** @var string|null $streetAddress */ + private $streetAddress; + + /** @var string|null $zipCode */ + private $zipCode; + + /** @var string|null $city */ + private $city; + + /** @var int|null $nation */ + private $nation; + + /** @var string|null $phone */ + private $phone; + + /** @var string|null $mobilePhone */ + private $mobilePhone; + + /** @var string|null $email */ + private $email; + + /** + * @var string|null $travelerCount */ + private $travelerCount; + + /** @var string|null $notes */ + private $notes; + + /** @var string|null $departure0 */ + private $departure0; + + /** @var string|null $departure1 */ + private $departure1; + + /** @var string|null $departure2 */ + private $departure2; + + /** @var \DateTime|null $start */ + private $start; + + /** @var \DateTime|null $end */ + private $end; + + /** + * @var int|null $duration + * @Assert\Type(type="integer", message="Bitte geben Sie eine gültige Ganzzahl für die Dauer in Tagen ein") + */ + private $duration; + + /** + * @return int|null + */ + public function getSalutation() + { + return $this->salutation; + } + + /** + * @param int|null $salutation + */ + public function setSalutation($salutation) + { + $this->salutation = $salutation; + } + + /** + * @return null|string + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * @param null|string $firstName + */ + public function setFirstName($firstName) + { + $this->firstName = $firstName; + } + + /** + * @return null|string + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * @param null|string $lastName + */ + public function setLastName($lastName) + { + $this->lastName = $lastName; + } + + /** + * @return null|string + */ + public function getStreetAddress() + { + return $this->streetAddress; + } + + /** + * @param null|string $streetAddress + */ + public function setStreetAddress($streetAddress) + { + $this->streetAddress = $streetAddress; + } + + /** + * @return null|string + */ + public function getZipCode() + { + return $this->zipCode; + } + + /** + * @param null|string $zipCode + */ + public function setZipCode($zipCode) + { + $this->zipCode = $zipCode; + } + + /** + * @return null|string + */ + public function getCity() + { + return $this->city; + } + + /** + * @param null|string $city + */ + public function setCity($city) + { + $this->city = $city; + } + + /** + * @return int|null + */ + public function getNation() + { + return $this->nation; + } + + /** + * @param int|null $nation + */ + public function setNation($nation) + { + $this->nation = $nation; + } + + /** + * @return null|string + */ + public function getPhone() + { + return $this->phone; + } + + /** + * @param null|string $phone + */ + public function setPhone($phone) + { + $this->phone = $phone; + } + + /** + * @return null|string + */ + public function getMobilePhone() + { + return $this->mobilePhone; + } + + /** + * @param null|string $mobilePhone + */ + public function setMobilePhone($mobilePhone) + { + $this->mobilePhone = $mobilePhone; + } + + /** + * @return null|string + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param null|string $email + */ + public function setEmail($email) + { + $this->email = $email; + } + + /** + * @return null|string + */ + public function getTravelerCount() + { + return $this->travelerCount; + } + + /** + * @param null|string $travelerCount + */ + public function setTravelerCount($travelerCount) + { + $this->travelerCount = $travelerCount; + } + + /** + * @return null|string + */ + public function getNotes() + { + return $this->notes; + } + + /** + * @param null|string $notes + */ + public function setNotes($notes) + { + $this->notes = $notes; + } + + /** + * @return null|string + */ + public function getDeparture0() + { + return $this->departure0; + } + + /** + * @param null|string $departure0 + */ + public function setDeparture0($departure0) + { + $this->departure0 = $departure0; + } + + /** + * @return null|string + */ + public function getDeparture1() + { + return $this->departure1; + } + + /** + * @param null|string $departure1 + */ + public function setDeparture1($departure1) + { + $this->departure1 = $departure1; + } + + /** + * @return null|string + */ + public function getDeparture2() + { + return $this->departure2; + } + + /** + * @param null|string $departure2 + */ + public function setDeparture2($departure2) + { + $this->departure2 = $departure2; + } + + /** + * @return \DateTime|null + */ + public function getStart() + { + return $this->start; + } + + /** + * @param \DateTime|null $start + */ + public function setStart($start) + { + $this->start = $start; + } + + /** + * @return \DateTime|null + */ + public function getEnd() + { + return $this->end; + } + + /** + * @param \DateTime|null $end + */ + public function setEnd($end) + { + $this->end = $end; + } + + /** + * @return int|null + */ + public function getDuration() + { + return $this->duration; + } + + /** + * @param int|null $duration + */ + public function setDuration($duration) + { + $this->duration = $duration; + } +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Export/SternToursCrmBookingExporter.php b/trunk/src/AppBundle/Export/BookingSternToursCrmExporter.php similarity index 89% rename from trunk/src/AppBundle/Export/SternToursCrmBookingExporter.php rename to trunk/src/AppBundle/Export/BookingSternToursCrmExporter.php index 3a63d3f4..97e52e93 100644 --- a/trunk/src/AppBundle/Export/SternToursCrmBookingExporter.php +++ b/trunk/src/AppBundle/Export/BookingSternToursCrmExporter.php @@ -13,18 +13,12 @@ use AppBundle\Entity\Traveler; use AppBundle\Util; use Monolog\Logger; -class SternToursCrmBookingExporter +class BookingSternToursCrmExporter extends SternToursCrmExporter { - const API_URL = 'http://www.cms.stern-tours.net/api'; - const API_KEY = 'f6077389c9ce710e554763a5de02c8ec'; - const API_USER_ID = 15; // 'apiuser' - const WEBSITE_ID = 1; // 'sterntours.de' - - private $logger; public function __construct(Logger $logger) { - $this->logger = $logger; + parent::__construct($logger); } public function process(BookingRequest $bookingRequest, TravelDate $travelDate, $bookingPriceInfo) @@ -322,30 +316,6 @@ class SternToursCrmBookingExporter return $resp['success']; } - private function httpGet($url) - { - $resp = Util::httpGet($url, ['X-ApiKey: '. self::API_KEY]); - $ret = json_decode($resp['content'], true); - if ($ret === null) - { - $this->warn('Invalid server response: '. $resp['content']); - } - return $ret; - } - - private function httpPost($context, $postData = [], $isContextFullUrl = false) - { - $url = $isContextFullUrl ? $context : self::API_URL.'/'. $context .'.json'; - $resp = Util::httpPost($url, $postData, ['X-ApiKey: '. self::API_KEY], true); - return [ - 'content' => json_decode($resp['content']), - 'location' => isset($resp['response_headers']['location']) - ? $resp['response_headers']['location'] - : null, - 'success' => $resp['success'] && ($resp['status_code'] == 201) - ]; - } - private function warn($msg, BookingRequest $bookingRequest = null, TravelDate $travelDate = null, $level = Logger::WARNING) { diff --git a/trunk/src/AppBundle/Export/ContactSternToursCrmExporter.php b/trunk/src/AppBundle/Export/ContactSternToursCrmExporter.php new file mode 100644 index 00000000..4e30c493 --- /dev/null +++ b/trunk/src/AppBundle/Export/ContactSternToursCrmExporter.php @@ -0,0 +1,61 @@ + + * @date 02/21/2017 + */ + +namespace AppBundle\Export; + + +use AppBundle\Entity\ContactRequest; +use Monolog\Logger; + +class ContactSternToursCrmExporter extends SternToursCrmExporter +{ + + public function __construct(Logger $logger) + { + parent::__construct($logger); + } + + public function process(ContactRequest $contactRequest) + { + $data = ['lead' => [ + 'customerForm' => [ + 'salutation_id' => $contactRequest->getSalutation(), + 'name' => $contactRequest->getLastName(), + 'firstname' => $contactRequest->getFirstName(), + 'street' => $contactRequest->getStreetAddress(), + 'zip' => $contactRequest->getZipCode(), + 'city' => $contactRequest->getCity(), + 'country_id' => $contactRequest->getNation(), + 'phone' => $contactRequest->getPhone(), + 'phonemobile' => $contactRequest->getMobilePhone(), + 'email' => $contactRequest->getEmail() + ], + 'request_date' => (new \DateTime())->format('Y-m-d'), + 'sf_guard_user_id' => self::API_USER_ID, + 'status_id' => 10, // 'Angebot erstellen' + 'travelperiod_start' => $contactRequest->getStart(), + 'travelperiod_end' => $contactRequest->getEnd(), + //'travelcategory_id' + 'is_closed' => 0, + 'website_id' => self::WEBSITE_ID, + 'initialcontacttype_id' => 1, + 'travelperiod_length' => $contactRequest->getDuration(), + 'remarks' => $contactRequest->getNotes(), + 'pax' => $contactRequest->getTravelerCount(), + ]]; + + $resp = $this->httpPost('lead', $data); + + if (!$resp['success']) + { + $this->logger->error(get_class($this). ': Failed submitting contact request to CRM'); + $this->logger->error('*** Submitted data: '. json_encode($data)); + $this->logger->error('*** Server response: '. $resp['content']); + } + + return $resp['location'] ?? null; + } +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Export/SternToursCrmExporter.php b/trunk/src/AppBundle/Export/SternToursCrmExporter.php new file mode 100644 index 00000000..e2498629 --- /dev/null +++ b/trunk/src/AppBundle/Export/SternToursCrmExporter.php @@ -0,0 +1,51 @@ + + * @date 02/21/2017 + */ + +namespace AppBundle\Export; + + +use AppBundle\Util; +use Monolog\Logger; + +abstract class SternToursCrmExporter +{ + const API_URL = 'http://www.cms.stern-tours.net/api'; + const API_KEY = 'f6077389c9ce710e554763a5de02c8ec'; + const API_USER_ID = 15; // 'apiuser' + const WEBSITE_ID = 1; // 'sterntours.de' + + protected $logger; + + public function __construct(Logger $logger) + { + $this->logger = $logger; + } + + protected final function httpGet($url) + { + $resp = Util::httpGet($url, ['X-ApiKey: '. self::API_KEY]); + $ret = json_decode($resp['content'], true); + if ($ret === null) + { + $this->logger->warn(get_class($this) .': Invalid server response: '. $resp['content']); + $this->logger->warn('*** Date: '. (new \DateTime())->format('d.m.Y')); + } + return $ret; + } + + protected final function httpPost($context, $postData = [], $isContextFullUrl = false) + { + $url = $isContextFullUrl ? $context : self::API_URL.'/'. $context .'.json'; + $resp = Util::httpPost($url, $postData, ['X-ApiKey: '. self::API_KEY], true); + return [ + 'content' => json_decode($resp['content']), + 'location' => isset($resp['response_headers']['location']) + ? $resp['response_headers']['location'] + : null, + 'success' => $resp['success'] && ($resp['status_code'] == 201) + ]; + } +} \ No newline at end of file diff --git a/trunk/src/AppBundle/Form/ContactRequestType.php b/trunk/src/AppBundle/Form/ContactRequestType.php new file mode 100644 index 00000000..ead6d280 --- /dev/null +++ b/trunk/src/AppBundle/Form/ContactRequestType.php @@ -0,0 +1,85 @@ + + * @date 02/21/2017 + */ + +namespace AppBundle\Form; + + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Form\Extension\Core\Type\EmailType; +use Symfony\Component\Form\Extension\Core\Type\TextareaType; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraints\Choice; +use Symfony\Component\Validator\Constraints\NotNull; + +class ContactRequestType extends AbstractType +{ + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => 'AppBundle\Entity\ContactRequest', + ]); + } + + /** + * @param FormBuilderInterface $builder + * @param array $options + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $travelerCountChoices = []; + for ($i = 1; $i <= 20; ++$i) + { + $travelerCountChoices[$i] = $i; + } + + $builder + ->add('salutation', ChoiceType::class, [ + 'placeholder' => 'Anrede (Bitte wählen) *', + 'choices' => BookingRequestType::$SALUTATION_CHOICES, + 'constraints' => [ + new NotNull(), + new Choice(['choices' => BookingRequestType::$SALUTATION_CHOICES]) + ] + ]) + ->add('firstName', TextType::class, ['required' => true]) + ->add('lastName', TextType::class, ['required' => true]) + ->add('streetAddress') + ->add('zipCode') + ->add('city') + ->add('nation', ChoiceType::class, [ + 'placeholder' => 'Land (Bitte wählen)', + 'choices' => BookingRequestType::$NATION_CHOICES, + 'constraints' => [ + new NotNull(), + new Choice(['choices' => BookingRequestType::$NATION_CHOICES]) + ], + 'data' => BookingRequestType::$NATION_CHOICES['Deutschland'], + ]) + ->add('phone', TextType::class, ['required' => true]) + ->add('mobilePhone') + ->add('email', EmailType::class, ['required' => true]) + ->add('travelerCount', ChoiceType::class, [ + 'placeholder' => 'Anzahl der Reisenden (Bitte wählen)', + 'choices' => $travelerCountChoices, + 'constraints' => [ + new Choice(['choices' => $travelerCountChoices])] + ]) + ->add('notes', TextareaType::class, ['required' => false]) + ->add('departure0') + ->add('departure1') + ->add('departure2') + ->add('start', StDateType::class, ['required' => false]) + ->add('end', StDateType::class, ['required' => false]) + ->add('duration') + ; + } +} \ No newline at end of file