#1342
#1343
#1345
#1346
#1349

git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3340 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
valentin.wacker 2017-07-20 09:59:11 +00:00
parent 27d2713283
commit 652eeb16cb
27 changed files with 994 additions and 204 deletions

View file

@ -64,7 +64,8 @@ class BookingController extends Controller
$bookingRequest = new BookingRequest();
if ($request->getMethod() != 'POST')
{
$bookingRequest->setTravelerCount(2);
$bookingRequest->setDoubleRoomCount(1);
$bookingRequest->setRoomCount(2);
$bookingRequest->setDeparture($travelDate->getDepartures()[0]);
}
$form = $this->createForm(BookingRequestType::class, $bookingRequest, [
@ -85,6 +86,8 @@ class BookingController extends Controller
$breadcrumbEntries = Util::createBreadcrumb($travelProgramPage);
$breadcrumbEntries[] = new BreadcrumbEntry('Buchen');
if ($request->getMethod() == 'POST' && $form->isValid())
{
$booking = $this->getDoctrine()->getRepository('AppBundle:TravelBooking')->createFromBookingRequest(
@ -187,7 +190,11 @@ class BookingController extends Controller
{
$ret = 0;
$insuranceAssessmentBasis = 0;
$travelerCount = $bookingRequest->getTravelerCount();
$singleRoomCount = $bookingRequest->getSingleRoomCount();
$doubleRoomCount = $bookingRequest->getDoubleRoomCount();
$tripleRoomCount = $bookingRequest->getTripleRoomCount();
if (isset($outHtmlSummary))
{
$insuranceHtmlSummary = [];
@ -242,24 +249,19 @@ class BookingController extends Controller
}
}
$persons = [
'total' => $travelerCount,
'adults' => $travelerCount,
'children' => 0
'singleRoomPersons' => $singleRoomCount,
'doubleRoomPersons' => $doubleRoomCount * 2,
'tripleRoomPersons' => $tripleRoomCount * 3,
'children' => 0 //TODO
];
$possibleRooms = $this->searchRooms($travelDate->getPrices(), $persons);
if (empty($possibleRooms))
{
if ($travelerCount % 2 == 0)
{
$possibleRooms = $this->splitIntoTwoGroups($travelDate->getPrices(), $persons, 'equal');
}
elseif ($travelerCount >= 3)
{
$possibleRooms = $this->splitIntoTwoGroups($travelDate->getPrices(), $persons, 'move_without_children');
}
}
$possibleRooms = $this->getRooms($travelDate->getPrices(), $persons);
if ($bookingRequest->getComfort())
{
@ -385,52 +387,61 @@ class BookingController extends Controller
*
* @return array
*/
private function searchRooms($prices, $persons)
private function getRooms($prices, $persons)
{
$ret = [];
foreach ($prices as $price)
foreach($prices as $price)
{
$priceType = $this->priceTypeById[$price->getPriceTypeId()];
if ($priceType->getMax() == $persons['total'] &&
$priceType->getMaxAdults() >= $persons['adults'] &&
$priceType->getMinAdults() <= $persons['adults'] &&
$priceType->getMaxChildren() >= $persons['children'])
$priceTypeId = $price->getPriceTypeId();
$priceType = $this->priceTypeById[$priceTypeId];
if($priceTypeId == 1 && $persons['singleRoomPersons'] > 0)
{
$currentPersons = [
'total' => $persons['singleRoomPersons'],
'adults' => $persons['singleRoomPersons'],
'children' => 0 //TODO
];
$ret[] = [
'priceType' => $priceType,
'persons' => $persons,
'persons' => $currentPersons,
'price' => $price
];
}
if($priceTypeId == 3 && $persons['doubleRoomPersons'] > 0)
{
$currentPersons = [
'total' => $persons['doubleRoomPersons'],
'adults' => $persons['doubleRoomPersons'],
'children' => 0
];
$ret[] = [
'priceType' => $priceType,
'persons' => $currentPersons,
'price' => $price
];
}
if($priceTypeId == 5 && $persons['tripleRoomPersons'] > 0)
{
$currentPersons = [
'total' => $persons['tripleRoomPersons'],
'adults' => $persons['tripleRoomPersons'],
'children' => 0
];
$ret[] = [
'priceType' => $priceType,
'persons' => $currentPersons,
'price' => $price
];
}
}
return $ret;
}
private function splitIntoTwoGroups($prices, $persons, $mode)
{
$group1 = [];
$group2 = [];
if($mode == 'equal')
{
$group1['adults'] = $group2['adults'] = $persons['adults'] / 2;
$group1['children'] = $group2['children'] = $persons['children'] / 2;
$group1['total'] = $group2['total'] = $group1['adults'] + $group2['children'];
}
elseif($mode = 'move_without_children')
{
$group1['adults'] = $persons['adults'] - 1;
$group1['children'] = 0;
$group1['total'] = $group1['adults'] + $group1['children'];
$group2['adults'] = 1;
$group2['children'] = 0;
$group2['total'] = $group2['adults'] + $group2['children'];
}
$possibleRoomsGroup1 = $this->searchRooms($prices, $group1);
$possibleRoomsGroup2 = $this->searchRooms($prices, $group2);
return array_merge($possibleRoomsGroup1, $possibleRoomsGroup2);
}
}

View file

@ -13,6 +13,8 @@ use AppBundle\Form\TtSearchRequestType;
use AppBundle\Listener\KernelControllerListener;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use AppBundle\Util;
use Symfony\Component\HttpFoundation\Response;
/**
* Controller for CMS pages. CMS pages are represented by Page instances (i.e. entries of the page database table).
@ -121,6 +123,53 @@ class CmsController extends Controller
]);
}
public function pdfAction(Page $page)
{
$travelProgram = $page->getTravelProgram();
$program_id = $travelProgram->getId();
if($program_id != NULL)
{
$url = Util::getBaseUrl().$page->getUrlPath();
// Initialisierung
$pdfObj = $this->container->get('app.pdf');
$pdfObj->SetMargins(PDF_MARGIN_LEFT, 40, PDF_MARGIN_RIGHT);
$pdfObj->SetAutoPageBreak(true, 65);
$pdfObj->AddPage();
// Erzeugen des HTML über das Twig-Template
$pageHTML = $this->render('default/pages/cms/travelProgramPDF.html.twig', [
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
'page' => $page,
'show_offers_sidebar_widget' => false,
'travel_program' => $page->getTravelProgram()
]);
// Filtern von Hyper-Links
$filteredContent = preg_replace('#<p><a(.*)>(.*)</a></p>#Uis', '', $pageHTML->getContent());
$filteredContent = preg_replace('#<a(.*)>#Uis', '', $filteredContent);
$filteredContent = preg_replace('#</a>#Uis', '', $filteredContent);
$filteredContent = str_replace('*', '<img src="https://www.stern-tours.de/images/icons/star-mini.png" />', $filteredContent);
// Schreiben des HTML
$pdfObj->writeHTML('<strong>Reiseangebot zu finden unter:</strong><br /><a href="'.$url.'"style="text-decoration: none!; font-size: 10px; color: black;">'.$url.'</a><br />');
$pdfObj->writeHTML($filteredContent);
// Ersetzen der Umlaute
$germanLetters = array("/ä/","/ö/","/ü/","/Ä/","/Ö/","/Ü/","/ß/");
$replace = array("ae","oe","ue","Ae","Oe","Ue","ss");
$filename = preg_replace($germanLetters, $replace, $travelProgram->getTitle());
header('Link: <'.$travelProgram->getUrl().'>; rel="canonical"');
$pdfObj->Output($filename.'.pdf', 'D');
}
}
/**
* @param Page $page
*

View file

@ -26,7 +26,13 @@ class BookingRequest
*/
private $departure;
private $travelerCount;
private $singleRoomCount;
private $doubleRoomCount;
private $tripleRoomCount;
private $roomCount;
/**
* @var TravelInsurance $insurance
@ -80,6 +86,10 @@ class BookingRequest
private $travelers = [];
private $singleRooms = [];
private $doubleRooms = [];
private $tripleRooms = [];
private $notes;
/**
@ -92,9 +102,11 @@ class BookingRequest
*/
public function __construct()
{
for ($i = 0; $i < 4; ++$i)
for($i = 0; $i < 5; ++$i)
{
$this->travelers[] = new Traveler();
$this->singleRooms[] = new Room(1);
$this->doubleRooms[] = new Room(2);
$this->tripleRooms[] = new Room(3);
}
}
@ -119,7 +131,23 @@ class BookingRequest
*/
public function getTravelerCount()
{
return $this->travelerCount;
$allUsedTravelersCount = 0;
for($i = 0; $i < $this->singleRoomCount; ++$i)
{
$allUsedTravelersCount += $this->singleRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->doubleRoomCount; ++$i)
{
$allUsedTravelersCount += $this->doubleRooms[$i]->getTravelerCount();
}
for($i = 0; $i < $this->tripleRoomCount; ++$i)
{
$allUsedTravelersCount += $this->tripleRooms[$i]->getTravelerCount();
}
return $allUsedTravelersCount;
}
/**
@ -130,6 +158,89 @@ class BookingRequest
$this->travelerCount = $travelerCount;
}
/**
* @return mixed
*/
public function getRoomCount()
{
return $this->roomCount;
}
/**
* @param mixed $travelers
*/
public function setRoomCount($travelers)
{
// nicht so kompliziert
// übliche Anzahl der Reisenden war 2 -> Standardraum: 1 Doppelzimmer
$this->travelerCount = $travelers;
if($travelers % 2 != 0)
{
$times = ($travelers - 1) / 2;
$this->singleRoomCount = 1;
$this->doubleRoomCount = $times;
$this->tripleRoomCount = 0;
$this->roomCount = $times + 1;
}
else
{
$times = $travelers / 2;
$this->singleRoomCount = 0;
$this->doubleRoomCount = $times;
$this->tripleRoomCount = 0;
$this->roomCount = $times;
}
}
/**
* @return mixed
*/
public function getSingleRoomCount()
{
return $this->singleRoomCount;
}
/**
* @param mixed $singleRoomCount
*/
public function setSingleRoomCount($singleRoomCount)
{
$this->singleRoomCount = $singleRoomCount;
}
/**
* @return mixed
*/
public function getDoubleRoomCount()
{
return $this->doubleRoomCount;
}
/**
* @param mixed $doubleRoomCount
*/
public function setDoubleRoomCount($doubleRoomCount)
{
$this->doubleRoomCount = $doubleRoomCount;
}
/**
* @return mixed
*/
public function getTripleRoomCount()
{
return $this->tripleRoomCount;
}
/**
* @param mixed $tripleRoomCount
*/
public function setTripleRoomCount($tripleRoomCount)
{
$this->tripleRoomCount = $tripleRoomCount;
}
/**
* @return TravelInsurance
*/
@ -338,12 +449,33 @@ class BookingRequest
$this->email = $email;
}
// get und set der Travelers liegt jetzt in Room; sollte so nicht mehr verwendet werden!
/**
* @return Traveler[]
*/
public function getTravelers()
{
return $this->travelers;
$allUsedTravelers = [];
// könnte man eventuell in eine for-Schleife packen, wenn man garantiert, dass es immer gleich viele Räume von jedem Typ gibt
for ($i = 0; $i < $this->singleRoomCount; ++$i)
{
$allUsedTravelers = array_merge($allUsedTravelers, $this->singleRooms[$i]->getTravelers());
}
for ($i = 0; $i < $this->doubleRoomCount; ++$i)
{
$allUsedTravelers = array_merge($allUsedTravelers, $this->doubleRooms[$i]->getTravelers());
}
for ($i = 0; $i < $this->tripleRoomCount; ++$i)
{
$allUsedTravelers = array_merge($allUsedTravelers, $this->tripleRooms[$i]->getTravelers());
}
// $this->travelers = $allUsedTravelers; // schlecht, getter sollte kein setter sein
// return $this->travelers; // aber wenn man es so verwenden würde, dann sollte man auch das verwenden
return $allUsedTravelers;
}
/**
@ -354,6 +486,76 @@ class BookingRequest
$this->travelers = $travelers;
}
/**
* @return Room[]
*/
public function getSingleRooms()
{
return $this->singleRooms;
}
/**
* @param Room[] $singleRooms
*/
public function setSingleRooms($singleRooms)
{
$this->singleRooms = $singleRooms;
}
/**
* @return Room[]
*/
public function getDoubleRooms()
{
return $this->doubleRooms;
}
/**
* @param Room[] $doubleRooms
*/
public function setDoubleRooms($doubleRooms)
{
$this->doubleRooms = $doubleRooms;
}
/**
* @return Room[]
*/
public function getTripleRooms()
{
return $this->tripleRooms;
}
/**
* @param Room[] $tripleRooms
*/
public function setTripleRooms($tripleRooms)
{
$this->tripleRooms = $tripleRooms;
}
/**
* @return Room[]
*/
public function getRooms()
{
$allRooms = [];
$allRooms = array_merge($allRooms, $this->singleRooms);
$allRooms = array_merge($allRooms, $this->doubleRooms);
$allRooms = array_merge($allRooms, $this->tripleRooms);
return $allRooms;
}
/**
* @param Room[] $tripleRooms
*/
public function setRooms($rooms)
{
// falls man es braucht, nachziehen und oder umstrukturieren (booking.html.twig)
}
/*
public function addTraveler(Traveler $traveler)
{

View file

@ -0,0 +1,87 @@
<?php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
class Room
{
// von BookingRequest abgeguckt, brauch ich das überhaupt, wenn ich bei $type ein Assert habe?
const SINGLE = 1;
const DOUBLE = 2;
const TRIPLE = 3;
/**
* @Assert\NotNull
* @Assert\Choice(choices={1,2,3})
*/
private $type;
/**
* @Assert\Valid
*/
private $travelers = [];
private $travelerCount;
public function __construct($type)
{
$this->type = $type;
for($i = 0; $i < $this->type; $i++)
{
$this->travelers[] = new Traveler();
}
$this->travelerCount = $type;
}
/**
* @return int
*/
public function getType()
{
return $this->type;
}
/**
* @param int $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return Traveler[]
*/
public function getTravelers()
{
return $this->travelers;
}
/**
* @param Traveler[] $travelers
*/
public function setTravelers($travelers)
{
$this->travelers = $travelers;
}
/**
* @return mixed
*/
public function getTravelerCount()
{
return $this->travelerCount;
}
/**
* @param mixed $travelerCount
*/
public function setTravelerCount($travelerCount)
{
$this->travelerCount = $travelerCount;
}
}

View file

@ -59,7 +59,8 @@ class TravelBookingRepository extends \Doctrine\ORM\EntityRepository
}
$ret->setInsurances($insurances);
}
$ret->setParticipants(array_slice($bookingRequest->getTravelers(), 0, $bookingRequest->getTravelerCount()));
$ret->setParticipants($bookingRequest->getTravelers());
$ret->setParticipantsTotal($bookingRequest->getTravelerCount());
$ret->setRooms($bookingPriceInfo['rooms']);
$ret->setPriceTotal($bookingPriceInfo['total']);

View file

@ -29,11 +29,31 @@ use Symfony\Component\Validator\Constraints\NotNull;
class BookingRequestType extends AbstractType
{
public static $TRAVELER_COUNT_CHOICES = [
'1 Person' => 1,
'2 Personen' => 2,
'3 Personen' => 3,
'4 Personen' => 4,
public static $SINGLE_ROOM_COUNT_CHOICES = [
'0 Einzelzimmer' => 0,
'1 Einzelzimmer' => 1,
'2 Einzelzimmer' => 2,
'3 Einzelzimmer' => 3,
'4 Einzelzimmer' => 4,
'5 Einzelzimmer' => 5,
];
public static $DOUBLE_ROOM_COUNT_CHOICES = [
'0 Doppelzimmer' => 0,
'1 Doppelzimmer' => 1,
'2 Doppelzimmer' => 2,
'3 Doppelzimmer' => 3,
'4 Doppelzimmer' => 4,
'5 Doppelzimmer' => 5,
];
public static $TRIPLE_ROOM_COUNT_CHOICES = [
'0 Dreibettzimmer' => 0,
'1 Dreibettzimmer' => 1,
'2 Dreibettzimmer' => 2,
'3 Dreibettzimmer' => 3,
'4 Dreibettzimmer' => 4,
'5 Dreibettzimmer' => 5,
];
public static $NATION_CHOICES = [
@ -110,8 +130,8 @@ class BookingRequestType extends AbstractType
->add('phone')
->add('fax')
->add('email')
->add('travelers', CollectionType::class, [
'entry_type' => TravelerType::class,
->add('rooms', CollectionType::class, [
'entry_type' => RoomType::class,
'by_reference' => false,
])
->add('notes', TextareaType::class, ['required' => false])
@ -130,11 +150,25 @@ class BookingRequestType extends AbstractType
)]
]);
$builder->add('travelerCount', ChoiceType::class, [
'choices' => self::$TRAVELER_COUNT_CHOICES,
$builder->add('singleRoomCount', ChoiceType::class, [
'choices' => self::$SINGLE_ROOM_COUNT_CHOICES,
'constraints' => [
new Choice(['choices' => self::$TRAVELER_COUNT_CHOICES]
)]
new Choice(['choices' => self::$SINGLE_ROOM_COUNT_CHOICES]
)]
]);
$builder->add('doubleRoomCount', ChoiceType::class, [
'choices' => self::$DOUBLE_ROOM_COUNT_CHOICES,
'constraints' => [
new Choice(['choices' => self::$DOUBLE_ROOM_COUNT_CHOICES]
)]
]);
$builder->add('tripleRoomCount', ChoiceType::class, [
'choices' => self::$TRIPLE_ROOM_COUNT_CHOICES,
'constraints' => [
new Choice(['choices' => self::$TRIPLE_ROOM_COUNT_CHOICES]
)]
]);
$insuranceChoices = [];
@ -159,6 +193,8 @@ class BookingRequestType extends AbstractType
]);
}
//$travelDate->getPrices()[0]->getPriceType()
if ($travelDate->hasComfortCategory())
{
$builder->add('comfort', CheckboxType::class, ['required' => false]);

View file

@ -0,0 +1,47 @@
<?php
namespace AppBundle\Form;
//use AppBundle\Entity\Traveler;
use AppBundle\Entity\Room;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
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 RoomType extends AbstractType
{
public static $TYPE_CHOICES = [
'Einzelzimmer' => Room::SINGLE,
'Doppelzimmer' => Room::DOUBLE,
'Dreibettzimmer' => Room::TRIPLE
];
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\Room'
));
}
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('travelers', CollectionType::class, [
'entry_type' => TravelerType::class,
]);
}
}

View file

@ -0,0 +1,25 @@
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\DateType;
class StPlainDateType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'placeholder' => 'TT.MM.JJJJ',
'widget' => 'single_text',
'format' => 'dd.MM.yyyy'
]);
}
public function getParent()
{
return DateType::class;
}
}

View file

@ -50,7 +50,7 @@ class TravelerType extends AbstractType
])
->add('firstName')
->add('lastName')
->add('birthDate', DateType::class, [
->add('birthDate', StPlainDateType::class, [
'widget' => 'single_text',
'format' => 'dd.MM.yyyy',
'required' => true,

View file

@ -132,6 +132,11 @@ class KernelControllerListener
$request->attributes->set('action', $restOfPath);
$request->attributes->set('_controller', 'AppBundle:Booking:index');
}
elseif($restOfPath && $node->getTravelProgram() != null && (
$restOfPath == '/pdf'))
{
$request->attributes->set('_controller', 'AppBundle:Cms:pdf');
}
elseif ($node->getTravelProgram() != null)
{
if ($node->getTravelProgram()->getStatus() == 0)

View file

@ -0,0 +1,53 @@
<?php
namespace AppBundle;
use TCPDF;
class Pdf extends TCPDF
{
private $webDir;
private $assetManager;
function __construct($rootDir, $assetManager)
{
parent::__construct('P', 'mm', 'A4', true, 'UTF-8', false, false);//($orientation, $unit, $format, $unicode, $encoding, $diskcache, $pdfa);//('P', 'mm', 'A4', true, 'UTF-8', false, false);
$this->webDir = realpath($rootDir . '/../web');
$this->assetManager = $assetManager;
}
private function getFileName($file)
{
$assetPath = $this->assetManager->get($file)->getTargetPath();
$fileNameParts = explode('/', $assetPath);
$lastPartIndex = count($fileNameParts) - 1;
$fileName = $fileNameParts[$lastPartIndex];
return $fileName;
}
public function Header()
{
$backgroundDir = $this->webDir.'\bundles\app\images\header-bg.png';
$logoDir = $this->webDir.'\assetic\\'.$this->getFileName('headerLogo');
$this->Image($backgroundDir, 0, 0, 210, 0, '', '', '', false, 300, 'C');
$this->Image($logoDir, 0, 15, 90, 0, '', '', '', false, 300, 'C');
}
public function Footer()
{
$footerDir = $this->webDir.'\assetic\\'.$this->getFileName('footerText');
$this->ImageSVG($footerDir, 0, 228, 210, '');
$this->SetY(-58);
$this->SetX(-30);
$this->SetFont('helvetica', '', 10);
$this->Cell(0, 14, 'Seite '.$this->getAliasNumPage().' von '.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
/* End of file Pdf.php */
/* Location: ./application/libraries/Pdf.php */

View file

@ -0,0 +1,10 @@
@import url(https://fonts.googleapis.com/css?family=Raleway:400,100,200,300,500,600,700,800,900);
@import url(https://fonts.googleapis.com/css?family=Oswald:400,700);
@import url(https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css);
@import url(../../app/css/font-awesome-4.7.0.css);
@import url(../../app/css/bootstrap-select-1.12.0.css);
@import url(../../app/css/owl-carousel.css);
@import url(../../app/css/prettyPhoto.css);
/* ==================================================================
FONTS
================================================================== */

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="595.358px" height="191.533px" viewBox="0 0 595.358 191.533" enable-background="new 0 0 595.358 191.533"
xml:space="preserve">
<rect x="30.424" y="97.229" fill="none" width="95.653" height="79.521"/>
<text transform="matrix(1 0 0 1 30.4243 103.3096)"><tspan x="0" y="0" fill="#7e7e7e" font-family="'Tahoma-Bold'" font-size="8">STERN TOURS GmbH</tspan><tspan x="0" y="9.5" fill="#1E181A" font-family="'Tahoma-Bold'" font-size="8">Uhlandstraße 137</tspan><tspan x="0" y="19" fill="#1E181A" font-family="'Tahoma'" font-size="8">10717 Berlin </tspan></text>
<rect x="144.078" y="97.229" fill="none" width="126.32" height="79.521"/>
<text transform="matrix(1 0 0 1 144.0776 103.3096)"><tspan x="0" y="0" fill="#7e7e7e" font-family="'Tahoma-Bold'" font-size="8">e-Mail</tspan><tspan x="24.961" y="0" fill="#1E181A" font-family="'Tahoma'" font-size="8" letter-spacing="1"> </tspan><tspan x="28.667" y="0" fill="#1E181A" font-family="'Tahoma'" font-size="8"> stern@stern-tours.de</tspan><tspan x="0" y="9.5" fill="#7e7e7e" font-family="'Tahoma-Bold'" font-size="8">Web</tspan><tspan x="18.027" y="9.5" fill="#1E181A" font-family="'Tahoma'" font-size="8" letter-spacing="8"> </tspan><tspan x="28.667" y="9.5" fill="#1E181A" font-family="'Tahoma'" font-size="8"> www.stern-tours.de</tspan><tspan x="0" y="28.5" fill="#7e7e7e" font-family="'Tahoma-Bold'" font-size="8">Fon</tspan><tspan x="14.707" y="28.5" fill="#1E181A" font-family="'Tahoma'" font-size="8" letter-spacing="11"> </tspan><tspan x="28.667" y="28.5" fill="#1E181A" font-family="'Tahoma'" font-size="8"> 030 | 700 94 100</tspan><tspan x="0" y="38" fill="#7e7e7e" font-family="'Tahoma-Bold'" font-size="8">Fax</tspan><tspan x="14.273" y="38" fill="#1E181A" font-family="'Tahoma'" font-size="8" letter-spacing="11"> </tspan><tspan x="28.667" y="38" fill="#1E181A" font-family="'Tahoma'" font-size="8"> 030 | 700 94 1044</tspan></text>
<rect x="287.48" y="97.229" fill="none" width="135.597" height="79.521"/>
<text transform="matrix(1 0 0 1 287.4805 103.3086)"><tspan x="0" y="0" fill="#7e7e7e" font-family="'Tahoma-Bold'" font-size="8">Bankverbindung</tspan><tspan x="0" y="9.5" fill="#1E181A" font-family="'Tahoma'" font-size="8">STERN TOURS GmbH</tspan><tspan x="0" y="19" fill="#1E181A" font-family="'Tahoma'" font-size="8">Hypo Vereinsbank</tspan><tspan x="0" y="28.5" fill="#1E181A" font-family="'Tahoma'" font-size="8">BLZ: 10020890</tspan><tspan x="0" y="38" fill="#1E181A" font-family="'Tahoma'" font-size="8">Kto.: 18857111</tspan><tspan x="0" y="57" fill="#1E181A" font-family="'Tahoma'" font-size="8">IBAN: DE83100208900018857111</tspan><tspan x="0" y="66.5" fill="#1E181A" font-family="'Tahoma'" font-size="8">BIC-/SWIFT-Code: HYVEDEMM488</tspan></text>
<rect x="447.182" y="97.229" fill="none" width="129.12" height="88.521"/>
<text transform="matrix(1 0 0 1 447.1821 103.3086)"><tspan x="0" y="0" fill="#7e7e7e" font-family="'Tahoma-Bold'" font-size="8">Telefonische Öffnungszeiten</tspan><tspan x="0" y="9.5" fill="#1E181A" font-family="'Tahoma'" font-size="8">Mo - Do:</tspan><tspan x="31.012" y="9.5" fill="#1E181A" font-family="'Tahoma'" font-size="8" letter-spacing="10"> </tspan><tspan x="43.75" y="9.5" fill="#1E181A" font-family="'Tahoma'" font-size="8">09:00 - 23:00 Uhr</tspan><tspan x="0" y="19" fill="#1E181A" font-family="'Tahoma'" font-size="8">Fr:</tspan><tspan x="9.883" y="19" fill="#1E181A" font-family="'Tahoma'" font-size="8" letter-spacing="13"> </tspan><tspan x="26" y="19" fill="#1E181A" font-family="'Tahoma'" font-size="8" letter-spacing="15"> </tspan><tspan x="43.75" y="19" fill="#1E181A" font-family="'Tahoma'" font-size="8">10:00 - 23:00 Uhr</tspan><tspan x="0" y="28.5" fill="#1E181A" font-family="'Tahoma'" font-size="8">Sa: </tspan><tspan x="13.984" y="28.5" fill="#1E181A" font-family="'Tahoma'" font-size="8" letter-spacing="9"> </tspan><tspan x="26" y="28.5" fill="#1E181A" font-family="'Tahoma'" font-size="8" letter-spacing="15"> </tspan><tspan x="43.75" y="28.5" fill="#1E181A" font-family="'Tahoma'" font-size="8">11:00 - 23.00 Uhr</tspan><tspan x="0" y="47.5" fill="#1E181A" font-family="'Tahoma'" font-size="8">UStID:</tspan><tspan x="23.617" y="47.5" fill="#1E181A" font-family="'Tahoma'" font-size="8"> </tspan><tspan x="26" y="47.5" fill="#1E181A" font-family="'Tahoma'" font-size="8"> DE192609253</tspan><tspan x="0" y="57" fill="#1E181A" font-family="'Tahoma'" font-size="8">Registernummer: HRB 67111</tspan><tspan x="0" y="66.5" fill="#1E181A" font-family="'Tahoma'" font-size="8">Amtsgericht Charlottenburg</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -2,7 +2,12 @@ $(document).ready(function() {
var frm$ = $('.st-booking-form');
var summary$ = $('.st-booking-summary');
var travelerCountDd$ = $('#booking_request_travelerCount');
var roomCountSR$ = $('#booking_request_singleRoomCount');
var roomCountDR$ = $('#booking_request_doubleRoomCount');
var roomCountTR$ = $('#booking_request_tripleRoomCount');
//var travelersIndices = $('.st-traveller-index');
var travelers$ = $('.st-traveler');
var travelerFields$ = travelers$.find('input,select');
@ -31,15 +36,58 @@ $(document).ready(function() {
function updateTravelers()
{
var travelerCount = parseInt(travelerCountDd$.val());
var travelersIndex = 1;
var singleTravelerCount = parseInt(roomCountSR$.val());
var doubleTravelerCount = parseInt(roomCountDR$.val()) * 2;
var tripleTravelerCount = parseInt(roomCountTR$.val()) * 3;
var allTravelersCount = singleTravelerCount + doubleTravelerCount + tripleTravelerCount;
travelers$.hide();
travelerFields$.prop('required', false);
for (var i = 1; i <= travelerCount; ++i)
{
$('.st-traveler-'+ i).show().find('input,select').prop('required', true);
}
}
travelerCountDd$.change(updateTravelers);
updateTravelers();
if(singleTravelerCount > 0)
{
for(var i = 1; i <= singleTravelerCount; i++)
{
var travelerSelector = '.st-traveler-' + i;
var roomIndexSelector = travelerSelector+' .st-traveller-index';
var currentRoomIndex = $(travelerSelector).attr("data-room-index");
$(travelerSelector).show().find('input,select').prop('required', true);
$(roomIndexSelector).text(currentRoomIndex);
}
}
if(doubleTravelerCount > 0)
{
var offset = 5 - singleTravelerCount;
for(var j = 6; j <= doubleTravelerCount + 5; j++)
{
var travelerSelector = '.st-traveler-'+j;
var roomIndexSelector = travelerSelector+' .st-traveller-index';
var currentRoomIndex = $(travelerSelector).attr("data-room-index");
$(travelerSelector).show().find('input,select').prop('required', true);
$(roomIndexSelector).text(currentRoomIndex - offset);
}
}
if(tripleTravelerCount > 0)
{
var offset = 10 - (singleTravelerCount + (doubleTravelerCount / 2));
for(var k = 16; k <= tripleTravelerCount + 15; k++)
{
var travelerSelector = '.st-traveler-'+k;
var roomIndexSelector = travelerSelector+' .st-traveller-index';
var currentRoomIndex = $(travelerSelector).attr("data-room-index");
$(travelerSelector).show().find('input,select').prop('required', true);
$(roomIndexSelector).text(currentRoomIndex - offset);
}
}
}
roomCountSR$.change(updateTravelers);
roomCountDR$.change(updateTravelers);
roomCountTR$.change(updateTravelers);
updateTravelers();
});

View file

@ -38,17 +38,29 @@ class BookingRequestValidator extends ConstraintValidator
*/
public function validate($bookingRequest, Constraint $constraint)
{
//die($bookingRequest->get);
for ($i = 0; $i < $bookingRequest->getTravelerCount(); ++$i)
for($i = 0; $i < $bookingRequest->getSingleRoomCount(); ++$i)
{
//$this->context->atPa
$this->context->getValidator()->inContext($this->context)
->atPath('travelers['. $i .']')
->validate($bookingRequest->getTravelers()[$i])
->atPath('rooms['.$i.']')
->validate($bookingRequest->getSingleRooms()[$i])
;
//$this->context->getValidator()->validate($bookingRequest->getTravelers()[$i]);
}
//$this->context->getValidator()->startContext()
//->atPath('travelers')->
for($j = 0; $j < $bookingRequest->getDoubleRoomCount(); ++$j)
{
$this->context->getValidator()->inContext($this->context)
->atPath('rooms['.($j+5).']')
->validate($bookingRequest->getDoubleRooms()[$j])
;
}
for($k = 0; $k < $bookingRequest->getTripleRoomCount(); ++$k)
{
$this->context->getValidator()->inContext($this->context)
->atPath('rooms['.($k + 10).']')
->validate($bookingRequest->getTripleRooms()[$k])
;
}
}
}