Child in Booking Form, calculate, show, validate, mail, success

git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3447 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
adametz 2018-08-20 11:40:10 +00:00
parent 48131f72e2
commit 22af43b07a
18 changed files with 1147 additions and 209 deletions

View file

@ -35,6 +35,27 @@ class BookingController extends Controller
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
* @throws \Exception
*/
private function getErrorMessages(\Symfony\Component\Form\Form $form) {
$errors = array();
foreach ($form->getErrors() as $key => $error) {
if ($form->isRoot()) {
$errors['#'][] = $error->getMessage();
} else {
$errors[] = $error->getMessage();
}
}
foreach ($form->all() as $child) {
if (!$child->isValid()) {
$errors[$child->getName()] = $this->getErrorMessages($child);
}
}
return $errors;
}
public function indexAction(Page $travelProgramPage, $action, Request $request)
{
$travelProgram = $travelProgramPage->getTravelProgram();
@ -78,6 +99,7 @@ class BookingController extends Controller
$htmlSummary = [];
$bookingPriceInfo = [];
$totalPrice = $this->calculatePrice($travelDate, $bookingRequest, $travelProgram->getCategory()->getId(), $htmlSummary, $bookingPriceInfo);
if ($action == '/buchen')
{
$breadcrumbEntries = Util::createBreadcrumb($travelProgramPage);
@ -86,8 +108,17 @@ class BookingController extends Controller
if ($request->getMethod() == 'POST' && $form->isValid())
{
$errors = array();
foreach ($form as $fieldName => $formField) {
foreach ($formField->getErrors(true) as $error) {
$errors[$fieldName] = $error->getMessage();
}
}
$booking = $this->getDoctrine()->getRepository('AppBundle:TravelBooking')->createFromBookingRequest(
$bookingRequest, $travelDate, $bookingPriceInfo);
$em = $this->getDoctrine()->getManager();
$em->persist($booking);
$em->flush();
@ -104,10 +135,12 @@ 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')
->setTo($bookingRequest->getEmail())
->setTo($bookingRequest->getEmail()) //
->setBody(
$this->renderView('default/email/bookingConfirmationEmail.txt.twig', [
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
@ -120,11 +153,10 @@ class BookingController extends Controller
)
);
$this->get('mailer')->send(\Swift_Message::newInstance()
->setSubject('BUCHUNG: '. $travelProgram->getTitle() .'('. $travelDate->getName() .')')
->setFrom('stern@stern-tours.de', 'STERN TOURS')
->setTo('stern@stern-tours.de')
->setTo("kevin.adametz@me.com") //'stern@stern-tours.de'
->setBody(
$this->renderView('default/email/bookingServiceEmail.txt.twig', [
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
@ -159,7 +191,13 @@ class BookingController extends Controller
]);
}
/* $string = (string) $form->getErrors(true, true);
var_dump($string);
var_dump( $form->isValid());
var_dump($this->getErrorMessages($form));
die();
*/
return $this->render('default/pages/booking.html.twig', [
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
'page' => $travelProgramPage,
@ -183,6 +221,7 @@ class BookingController extends Controller
: null
]);
}
elseif ($action == '/berechne-gesamtpreis')
{
return $this->render('default/components/booking/summary.html.twig', [
@ -210,11 +249,20 @@ class BookingController extends Controller
{
$ret = 0;
$insuranceAssessmentBasis = 0;
$insuranceAssessmentChildBasis = 0;
$travelerCount = $bookingRequest->getTravelerCount();
$singleRoomCount = $bookingRequest->getSingleRoomCount();
$doubleRoomCount = $bookingRequest->getDoubleRoomCount();
$tripleRoomCount = $bookingRequest->getTripleRoomCount();
$singleRoomChildCount = $bookingRequest->getSingleRoomChildCount();
$doubleRoomChildCount = $bookingRequest->getDoubleRoomChildCount();
$tripleRoomChildCount = $bookingRequest->getTripleRoomChildCount();
$childrenCount = $bookingRequest->getChildrenCount();
if (isset($outHtmlSummary))
{
$insuranceHtmlSummary = [];
@ -223,6 +271,7 @@ class BookingController extends Controller
{
$outPriceInfo['rooms'] = [];
$outPriceInfo['insurances'] = [];
$outPriceInfo['insurancesOut'] = [];
$outPriceInfo['options'] = [];
$outPriceInfo['classOptions'] = [];
$outPriceInfo['departure'] = 0;
@ -230,8 +279,11 @@ class BookingController extends Controller
$outPriceInfo['flight_price'] = 0;
$outPriceInfo['final_payment_date'] = $travelDate->getFinalPaymentDate();
$outPriceInfo['final_payment_date_str'] = $travelDate->getFinalPaymentDateStr();
$outPriceInfo['discount'] = [];
}
$tempDepartureHTML = array();
//ABFLUG
if($bookingRequest->getDeparture() != null)
{
$departure = Util\DepartureUtil::limitIndividualArrivalPrice($bookingRequest->getDeparture(),
@ -244,34 +296,55 @@ class BookingController extends Controller
if ($departure->getExtraCharge() != 0)
{
$insuranceAssessmentBasis += $departure->getExtraCharge();
$a = $travelerCount * $departure->getExtraCharge();
$insuranceAssessmentChildBasis += $departure->getExtraCharge();
$a = ($travelerCount + $childrenCount) * $departure->getExtraCharge();
$ret += $a;
$outPriceInfo['departure_extra'] += $a;
if (isset($outHtmlSummary))
{
$outHtmlSummary[] = [
'value' => $a,
'label' => ($departure->getExtraCharge() > 0 ? 'Aufschlag' : 'Abzug') .
' für Abfahrts-/Abflugort "'. $departure->getName() .'" <strong>['. $this->calcNumTravelerLabel($travelerCount) .' x '.
Util::formatPrice($departure->getExtraCharge()) .' pro Person]</strong>'
];
$key = $departure->getExtraCharge();
if(!empty($tempDepartureHTML[$key])) {
$tempDepartureHTML[$key]['count'] = $tempDepartureHTML[$key]['count'] + ($travelerCount + $childrenCount);
$tempDepartureHTML[$key]['value'] = $tempDepartureHTML[$key]['value'] + $a;
}else{
$tempDepartureHTML[$key] = array(
'value' => $a,
'label_first' => ($departure->getExtraCharge() > 0 ? 'Aufschlag' : 'Abzug') . ' für Abfahrts-/Abflugort "'. $departure->getName(),
'label_last' => Util::formatPrice($departure->getExtraCharge()) . ' pro Person',
'count' => ($travelerCount + $childrenCount),
);
}
}
}
}
//OPTIONEN
$tempOptionHTML = array();
foreach ($bookingRequest->getTravelOptions() as $travelOption)
{
$insuranceAssessmentBasis += $travelOption->getPrice();
$insuranceAssessmentChildBasis += $travelOption->getPriceChildren();
$a = $travelerCount * $travelOption->getPrice();
$a += $childrenCount * $travelOption->getPriceChildren();
$ret += $a;
//OPTIONS
if (isset($outHtmlSummary))
{
$outHtmlSummary[] = [
'value' => $a,
'label' => $travelOption->getName() .' <strong>['. $this->calcNumTravelerLabel($travelerCount) .' x '.
Util::formatPrice($travelOption->getPrice()) .' pro Person]</strong>'
];
$key = $travelOption->getId();
if(!empty($tempOptionHTML[$key])) {
// $tempOptionHTML[$key]['count'] = $tempOptionHTML[$key]['count'] + $travelerCount;
$tempOptionHTML[$key]['value'] = $tempOptionHTML[$key]['value'] + $a;
}else{
$tempOptionHTML[$key] = array(
'value' => $a,
'label_first' => $travelOption->getName(),
'label_last' => Util::formatPrice($travelOption->getPrice()) . ' pro Person',
'count' => $travelerCount + $childrenCount,
'childCount' => $childrenCount,
'price_child' => Util::formatPrice($travelOption->getPriceChildren()) . ' pro Kind',
);
}
}
if (isset($outPriceInfo))
{
@ -283,28 +356,39 @@ class BookingController extends Controller
'total' => $travelerCount,
'adults' => $travelerCount,
'singleRoomPersons' => $singleRoomCount,
'singleRoomChildPersons' => $singleRoomChildCount,
'doubleRoomPersons' => $doubleRoomCount * 2,
'doubleRoomChildPersons' => $doubleRoomChildCount * 2,
'tripleRoomPersons' => $tripleRoomCount * 3,
'tripleRoomChildPersons' => $tripleRoomChildCount * 3,
'children' => 0 //TODO
];
//Komfort
$possibleRooms = $this->getRooms($travelDate->getPrices(), $persons);
$tempComfortHTML = array();
if ($bookingRequest->getComfort())
{
foreach ($possibleRooms as $room)
{
$insuranceAssessmentBasis += $room['price']->getEffectiveComfortPrice();
$insuranceAssessmentChildBasis += $room['price']->getEffectiveComfortPrice();
$a = $room['persons']['total'] * $room['price']->getEffectiveComfortPrice();
$ret += $a;
if (isset($outHtmlSummary))
{
$outHtmlSummary[] = [
'value' => $a,
'label' => 'Komfort-Kategorie <strong>['. $this->calcNumTravelerLabel($travelerCount) .' x '.
Util::formatPrice($room['price']->getEffectiveComfortPrice()) .' pro Person]</strong>'
];
$key = intval($room['price']->getEffectiveComfortPrice());
if(!empty($tempComfortHTML[$key])) {
$tempComfortHTML[$key]['count'] = $tempComfortHTML[$key]['count'] + 1;
$tempComfortHTML[$key]['value'] = $tempComfortHTML[$key]['value'] + $a;
}else{
$tempComfortHTML[$key] = array(
'value' => $a,
'label_first' => 'Komfort-Kategorie',
'label_last' => Util::formatPrice($room['price']->getEffectiveComfortPrice()) . ' pro Person',
'count' => 1,
);
}
}
if (isset($outPriceInfo))
{
@ -319,75 +403,149 @@ class BookingController extends Controller
$insuranceTotal = 0;
$tempInsuranceHTML = array();
$tempRoomHTML = array();
$tempDiscountHTML = array();
//ROOMS DISCOUNT Versicherungen
foreach ($possibleRooms as $room)
{
$adultCount = $room['persons']['adults'];
$childrenCount = $room['persons']['children'];
$singleFullPrice = $room['price']->getEffectivePrice();
$roomPrice = $singleFullPrice * $adultCount + $singleFullPrice * $room['persons']['children'];
$childPrice = $room['price']->getEffectiveChildPrice();
$roomPrice = ($singleFullPrice * $adultCount) + ($childPrice * $room['persons']['children']);
$singleDiscountPrice = $room['price']->getEffectiveDiscountPrice();
$discount = ($singleDiscountPrice === null) ? 0
: ($adultCount * ($singleDiscountPrice - $singleFullPrice));
$ret += $roomPrice + $discount;
$singleChildDiscountPrice = $room['price']->getEffectiveChildDiscountPrice();
$discount = ($singleDiscountPrice === null) ? 0 : ($adultCount * ($singleDiscountPrice - $singleFullPrice));
$childDiscount = ($singleChildDiscountPrice === null) ? 0 : ($childrenCount * ($singleChildDiscountPrice - $childPrice));
$ret += $roomPrice + $discount + $childDiscount;
$singel_flight_price = $travelDate->getFlightCalcPrice();
$outPriceInfo['flight_price'] += (($singel_flight_price * $adultCount) + ($singel_flight_price * $room['persons']['children']));
//Room price
if (isset($outPriceInfo))
{
$price = $singleDiscountPrice ?? $singleFullPrice;
$price += $singleChildDiscountPrice ?? $childPrice;
$outPriceInfo['rooms'][] = [
'name' => $room['priceType']->getName(),
'adults' => $room['persons']['adults'],
'children' => $room['persons']['children'],
'adults' => $adultCount,
'children' => $childrenCount,
'price' => $singleDiscountPrice ?? $singleFullPrice,
'price_children' => $room['price']->getEffectiveChildPrice(),
'price_total' => $roomPrice + $discount,
'price_children' => $singleChildDiscountPrice ?? $childPrice,
'price_total' => $roomPrice + $discount + $childDiscount,
];
}
//Room html
if (isset($outHtmlSummary))
{
$label = $room['priceType']->getName() .' <strong>['. $this->calcNumTravelerLabel($adultCount) .' x '.
Util::formatPrice($singleFullPrice) .' pro Person]</strong>';
if ($room['persons']['children'] != 0)
{
$label .= ', Kinder: '. $this->calcNumTravelerLabel($room['persons']['children']) .' x <strong>'.
Util::formatPrice($room['price']->getEffectiveChildPrice()) .'</strong>';
$label .= ']';
//ROOMS
$key = $room['priceType']->getId();
if(!empty($tempRoomHTML[$key])) {
$tempRoomHTML[$key]['count'] = $tempRoomHTML[$key]['count'] + 1;
$tempRoomHTML[$key]['value'] = $tempRoomHTML[$key]['value'] + $roomPrice;
}else{
$tempRoomHTML[$key] = array(
'value' => $roomPrice,
'label_first' => $room['priceType']->getName(),
'label_last' => Util::formatPrice($singleFullPrice) . ' pro Person',
'count' => 1,
'childCount' => $room['persons']['children'],
'price_child' => Util::formatPrice($room['price']->getEffectiveChildPrice()),
);
}
$outHtmlSummary[] = [
'value' => $roomPrice,
'label' => $label
];
//DISCOUNT
if ($singleDiscountPrice !== null)
{
$outHtmlSummary[] = [
'value' => $discount,
'label' => 'Rabatt <strong>['. $this->calcNumTravelerLabel($adultCount) .'x '.
Util::formatPrice($singleFullPrice - $singleDiscountPrice) .' pro Person]</strong>'
];
$key = ($singleFullPrice - $singleDiscountPrice);
if(!empty($tempDiscountHTML[$key])) {
$tempDiscountHTML[$key]['count'] = $tempDiscountHTML[$key]['count'] + $adultCount;
$tempDiscountHTML[$key]['value'] = $tempDiscountHTML[$key]['value'] + $discount;
}else{
$tempDiscountHTML[$key] = array(
'value' => $discount,
'label_first' => 'Rabatt',
'label_last' => Util::formatPrice($singleFullPrice - $singleDiscountPrice) . ' pro Person',
'count' => $adultCount,
);
}
if($childDiscount > 0){
$key = ($childPrice - $singleChildDiscountPrice);
if(!empty($tempDiscountHTML[$key])) {
$tempDiscountHTML[$key]['count'] = $tempDiscountHTML[$key]['count'] + $childrenCount;
$tempDiscountHTML[$key]['value'] = $tempDiscountHTML[$key]['value'] + $childDiscount;
}else{
$tempDiscountHTML[$key] = array(
'value' => $childDiscount,
'label_first' => 'Rabatt',
'label_last' => Util::formatPrice($childPrice - $singleChildDiscountPrice) . ' pro Person',
'count' => $childrenCount,
);
}
}
if (isset($outPriceInfo))
{
$key = ($singleFullPrice - $singleDiscountPrice);
if(!empty($outPriceInfo['discount'][$key])) {
$outPriceInfo['discount'][$key]['count'] = $outPriceInfo['discount'][$key]['count'] + $adultCount;
$outPriceInfo['discount'][$key]['value'] = $outPriceInfo['discount'][$key]['value'] + $discount;
}else{
$outPriceInfo['discount'][$key] = array(
'value' => $discount,
'label_first' => 'Rabatt',
'label_last' => Util::formatPrice($singleFullPrice - $singleDiscountPrice) . ' pro Person',
'count' => $adultCount,
);
}
if($childDiscount > 0){
$key = ($childPrice - $singleChildDiscountPrice);
if(!empty($outPriceInfo['discount'][$key])) {
$outPriceInfo['discount'][$key]['count'] = $outPriceInfo['discount'][$key]['count'] + $childrenCount;
$outPriceInfo['discount'][$key]['value'] = $outPriceInfo['discount'][$key]['value'] + $childDiscount;
}else{
$outPriceInfo['discount'][$key] = array(
'value' => $childDiscount,
'label_first' => 'Rabatt',
'label_last' => Util::formatPrice($childPrice - $singleChildDiscountPrice) . ' pro Person',
'count' => $childrenCount,
);
}
}
}
}
//Versicherung price + html
if ($bookingRequest->getInsurance() && $adultCount > 0)
{
$curAssessmentBasis = $insuranceAssessmentBasis + ($singleDiscountPrice ?? $singleFullPrice);
$curAssessmentChildBasis = $insuranceAssessmentChildBasis + ($singleChildDiscountPrice ?? $childPrice);
$insurancePrice = $this->getDoctrine()->getRepository('AppBundle:TravelInsurancePrice')
->findOneByInsuranceIdAndAssessmentBasis($bookingRequest->getInsurance()->getId(),
$curAssessmentBasis);
$insurancePriceValue = $insurancePrice->getPrice() > 0 ? $insurancePrice->getPrice()
: round($insurancePrice->getPercent() * $curAssessmentBasis / 100, 2);
->findOneByInsuranceIdAndAssessmentBasis($bookingRequest->getInsurance()->getId(), $curAssessmentBasis);
$insuranceChildPrice = $this->getDoctrine()->getRepository('AppBundle:TravelInsurancePrice')
->findOneByInsuranceIdAndAssessmentBasis($bookingRequest->getInsurance()->getId(), $curAssessmentChildBasis);
$insurancePriceValue = $insurancePrice->getPrice() > 0 ? $insurancePrice->getPrice() : round($insurancePrice->getPercent() * $curAssessmentBasis / 100, 2);
$insuranceChildPriceValue = $insuranceChildPrice->getPrice() > 0 ? $insuranceChildPrice->getPrice() : round($insuranceChildPrice->getPercent() * $curAssessmentChildBasis / 100, 2);
$a = $adultCount * $insurancePriceValue;
$insuranceTotal += $a;
$ret += $a;
$b = $childrenCount * $insuranceChildPriceValue;
$insuranceTotal += $a + $b;
$ret += $a + $b;
if (isset($insuranceHtmlSummary))
{
if(!empty($tempInsuranceHTML[$a])){
$tempInsuranceHTML[$a]['count'] = intval($tempInsuranceHTML[$a]['count']) + $adultCount;
$tempInsuranceHTML[$a]['value'] = $tempInsuranceHTML[$a]['value'] + $insurancePriceValue;
if(!empty($tempInsuranceHTML[$insurancePriceValue])){
$tempInsuranceHTML[$insurancePriceValue]['count'] = intval($tempInsuranceHTML[$insurancePriceValue]['count']) + $adultCount;
$tempInsuranceHTML[$insurancePriceValue]['value'] = $tempInsuranceHTML[$insurancePriceValue]['value'] + $a;
}else{
$tempInsuranceHTML[$a] = array(
$tempInsuranceHTML[$insurancePriceValue] = array(
'value' => $a,
'label_first' => 'RV '. $bookingRequest->getInsurance()->getName() .' ('. $insurancePrice->getCode() .') ',
'label_last' => Util::formatPrice($insurancePriceValue) . ' pro Person',
@ -395,29 +553,131 @@ class BookingController extends Controller
);
}
if($b > 0){
if(!empty($tempInsuranceHTML[$insuranceChildPriceValue])){
$tempInsuranceHTML[$insuranceChildPriceValue]['count'] = intval($tempInsuranceHTML[$insuranceChildPriceValue]['count']) + $childrenCount;
$tempInsuranceHTML[$insuranceChildPriceValue]['value'] = $tempInsuranceHTML[$insuranceChildPriceValue]['value'] + $b;
}else{
$tempInsuranceHTML[$insuranceChildPriceValue] = array(
'value' => $b,
'label_first' => 'RV '. $bookingRequest->getInsurance()->getName() .' ('. $insuranceChildPrice->getCode() .') ',
'label_last' => Util::formatPrice($insuranceChildPriceValue) . ' pro Kind',
'count' => $childrenCount,
);
}
}
}
if (isset($outPriceInfo))
{
if(!empty($outPriceInfo['insurancesOut'][$insurancePriceValue])){
$outPriceInfo['insurancesOut'][$insurancePriceValue]['count'] = intval($outPriceInfo['insurancesOut'][$insurancePriceValue]['count']) + $childrenCount;
$outPriceInfo['insurancesOut'][$insurancePriceValue]['value'] = $outPriceInfo['insurancesOut'][$insurancePriceValue]['value'] + $b;
}else{
$outPriceInfo['insurancesOut'][$insurancePriceValue] = [
'value' => $a,
'label_first' => 'RV '. $bookingRequest->getInsurance()->getName() .' ('. $insurancePrice->getCode() .') ',
'label_last' => Util::formatPrice($insurancePriceValue) . ' pro Person',
'count' => $adultCount,
];
}
if($b > 0){
if(!empty($outPriceInfo['insurancesOut'][$insuranceChildPriceValue])){
$outPriceInfo['insurancesOut'][$insuranceChildPriceValue]['count'] = intval($outPriceInfo['insurancesOut'][$insuranceChildPriceValue]['count']) + $childrenCount;
$outPriceInfo['insurancesOut'][$insuranceChildPriceValue]['value'] = $outPriceInfo['insurancesOut'][$insuranceChildPriceValue]['value'] + $b;
}else{
$outPriceInfo['insurancesOut'][$insuranceChildPriceValue] = [
'value' => $b,
'label_first' => 'RV '. $bookingRequest->getInsurance()->getName() .' ('. $insuranceChildPrice->getCode() .') ',
'label_last' => Util::formatPrice($insuranceChildPriceValue) . ' pro Kind',
'count' => $childrenCount,
];
}
}
$outPriceInfo['insurances'][] = [
'insurance' => $bookingRequest->getInsurance(),
'insurancePriceValue' => $insurancePriceValue,
'insurancePrice' => $insurancePrice,
'count' => $adultCount,
'insuranceChildPriceValue' => $insuranceChildPriceValue,
'insuranceChildPrice' => $insuranceChildPrice,
'countChild' => $childrenCount,
];
}
}
}
}
if(count($tempInsuranceHTML) > 0 ){
foreach ($tempInsuranceHTML as $item) {
$insuranceHtmlSummary[] =[
//Departure
if(count($tempDepartureHTML) > 0){
foreach ($tempDepartureHTML as $item) {
$outHtmlSummary[] =[
'value' => $item['value'],
'label' => $item['label_first'].'<strong>['.$item['count'].' x '.$item['label_last'].' ]</strong>',
'label' => '<strong>'.$item['count'].'</strong> x '.$item['label_first'].'<strong> ['.$item['label_last'].' ]</strong>',
];
}
}
//Comfort
if(count($tempComfortHTML) > 0){
foreach ($tempComfortHTML as $item) {
$outHtmlSummary[] =[
'value' => $item['value'],
'label' => '<strong>'.$item['count'].'</strong> x '.$item['label_first'].'<strong> ['.$item['label_last'].' ]</strong>',
];
}
}
//ROOMS
if(count($tempRoomHTML) > 0){
foreach ($tempRoomHTML as $item) {
$label = '<strong>'.$item['count'].'</strong> x '.$item['label_first'].'<strong> ['.$item['label_last'].']</strong>';
if($item['childCount'] > 0){
$label .= ' <strong>[ + Kind: '.$item['price_child'];
}
$label .= ']</strong>';
$outHtmlSummary[] =[
'value' => $item['value'],
'label' => $label,
];
}
}
//DISCOUNT
if(count($tempDiscountHTML) > 0){
foreach ($tempDiscountHTML as $item) {
$insuranceHtmlSummary[] =[
'value' => $item['value'],
'label' => '<strong>'.$item['count'].'</strong> x '.$item['label_first'].'<strong> ['.$item['label_last'].' ]</strong>',
];
}
}
//options
if(count($tempOptionHTML) > 0){
foreach ($tempOptionHTML as $item) {
$label = '<strong>'.$item['count'].'</strong> x '.$item['label_first'].'<strong> ['.$item['label_last'].']</strong>';
if($item['childCount'] > 0){
$label .= ' <strong>['.$item['price_child'].']</strong>';
}
$outHtmlSummary[] =[
'value' => $item['value'],
'label' => $label,
];
}
}
//Versicherungen
if(count($tempInsuranceHTML) > 0 ){
foreach ($tempInsuranceHTML as $item) {
$insuranceHtmlSummary[] =[
'value' => $item['value'],
'label' => '<strong>'.$item['count'].'</strong> x '.$item['label_first'].'<strong> ['.$item['label_last'].' ]</strong>',
];
}
}
if (isset($insuranceHtmlSummary))
{
@ -463,6 +723,7 @@ class BookingController extends Controller
foreach($prices as $price)
{
$priceTypeId = $price->getPriceTypeId();
//with children
$priceType = $this->priceTypeById[$priceTypeId];
if($priceTypeId == 1 && $persons['singleRoomPersons'] > 0)
@ -483,6 +744,27 @@ class BookingController extends Controller
}
}
if($priceTypeId == 1 && $persons['singleRoomChildPersons'] > 0)
{
$priceTypeId = 2;
$priceType = $this->priceTypeById[$priceTypeId];
for($i = 0; $i < $persons['singleRoomChildPersons']; $i++)
{
$currentPersons = [
'total' => 1,
'adults' => 1,
'children' => 1
];
$ret[] = [
'priceType' => $priceType,
'persons' => $currentPersons,
'price' => $price
];
}
}
if($priceTypeId == 3 && $persons['doubleRoomPersons'] > 0)
{
for($j = 0; $j < ($persons['doubleRoomPersons'] / 2); $j++)
@ -501,6 +783,27 @@ class BookingController extends Controller
}
}
if($priceTypeId == 3 && $persons['doubleRoomChildPersons'] > 0)
{
$priceTypeId = 4;
$priceType = $this->priceTypeById[$priceTypeId];
for($j = 0; $j < ($persons['doubleRoomChildPersons'] / 2); $j++)
{
$currentPersons = [
'total' => 2,
'adults' => 2,
'children' => 1
];
$ret[] = [
'priceType' => $priceType,
'persons' => $currentPersons,
'price' => $price
];
}
}
if($priceTypeId == 5 && $persons['tripleRoomPersons'] > 0)
{
for($k = 0; $k < ($persons['tripleRoomPersons'] / 3); $k++)
@ -518,6 +821,27 @@ class BookingController extends Controller
];
}
}
if($priceTypeId == 5 && $persons['tripleRoomChildPersons'] > 0)
{
$priceTypeId = 7;
$priceType = $this->priceTypeById[$priceTypeId];
for($k = 0; $k < ($persons['tripleRoomChildPersons'] / 3); $k++)
{
$currentPersons = [
'total' => 3,
'adults' => 3,
'children' => 1
];
$ret[] = [
'priceType' => $priceType,
'persons' => $currentPersons,
'price' => $price
];
}
}
}
return $ret;