diff --git a/trunk/app/Resources/views/default/admin/lodgingsEdit.html.twig b/trunk/app/Resources/views/default/admin/lodgingsEdit.html.twig index 9b456c41..ea9a673f 100644 --- a/trunk/app/Resources/views/default/admin/lodgingsEdit.html.twig +++ b/trunk/app/Resources/views/default/admin/lodgingsEdit.html.twig @@ -233,6 +233,14 @@ background: linear-gradient(145deg, #f0bcbc 49%,#f2f2f2 50%,#f0bcbc 51%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f0bcbc', endColorstr='#f0bcbc',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */ } + .table > tbody > tr > td.calendar-day-disabled-half-booked { + /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#f0bcbc+49,f2f2f2+50,f0bcbc+51 */ + background: #f0bcbc; /* Old browsers */ + background: -moz-linear-gradient(-35deg, #f0bcbc 49%, #f2f2f2 50%, #C5DCC6 51%); /* FF3.6-15 */ + background: -webkit-linear-gradient(-35deg, #f0bcbc 49%,#f2f2f2 50%,#C5DCC6 51%); /* Chrome10-25,Safari5.1-6 */ + background: linear-gradient(145deg, #f0bcbc 49%,#f2f2f2 50%,#C5DCC6 51%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f0bcbc', endColorstr='#C5DCC6',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */ + } .table > tbody > tr > td.active { background-color: rgba(88, 155, 92, 0.35); padding: 0; @@ -256,6 +264,13 @@ display: block; height: 100%; } + .table > tbody > tr > td a { + font-weight: 700; + width: 100%; + display: block; + height: 100%; + padding: 8px; + } diff --git a/trunk/app/Resources/views/default/components/booking/summary.html.twig b/trunk/app/Resources/views/default/components/booking/summary.html.twig index 69741465..d573b06b 100644 --- a/trunk/app/Resources/views/default/components/booking/summary.html.twig +++ b/trunk/app/Resources/views/default/components/booking/summary.html.twig @@ -2,7 +2,7 @@ {% for summary_entry in summary %} - + {{ summary_entry.value|number_format(2) }} € @@ -13,20 +13,20 @@ - + = {{ total_price|number_format(2) }} € Gesamtpreis der Reise - + {{ booking_price_info.deposit_total|number_format(2) }} € Anzahlung (ist sofort fällig) - + {{ booking_price_info.final_payment|number_format(2) }} € Restzahlung ({{ booking_price_info.final_payment_date_str}}) diff --git a/trunk/app/Resources/views/default/email/components/bookingSummary.txt.twig b/trunk/app/Resources/views/default/email/components/bookingSummary.txt.twig index 9011b1f5..f7258f34 100644 --- a/trunk/app/Resources/views/default/email/components/bookingSummary.txt.twig +++ b/trunk/app/Resources/views/default/email/components/bookingSummary.txt.twig @@ -8,25 +8,33 @@ Reisezeitraum: {{ travel_date.start|date }} - {{ travel_date.end|date } Abfahrts-/Abflugort: {{ booking_request.departure.name }} {{ booking_request.departure.extraCharge|number_format(2) }} € p.P. {% for room in booking_price_info['rooms'] %} -1x {{ room['name'] }} [Personen: {{ room.adults }} x {{ room['price']|number_format(2) }} €] +1x {{ room['name'] }} [Personen: {{ room.adults }} x {{ room['price']|number_format(2) }} € {% if room['children'] > 0 %} + Kind: {{ room['price_children']|number_format(2) }} € {% endif %}] {% endfor %} + {{ booking_request.departure.extraCharge < 0 ? 'Aufschlag' : 'Abzug' }} Abfahrts-/Abflugort {{ booking_request.departure.name }}{# -#} {{ booking_request.travelerCount }} x {{ booking_request.departure.extraCharge|number_format(2) }} €: {{ +#} {{ (booking_request.travelerCount + booking_request.childrenCount) }} x {{ booking_request.departure.extraCharge|number_format(2) }} €: {{ (booking_request.travelerCount * booking_request.departure.extraCharge)|number_format(2) }} € -{% for insuranceInfo in booking_price_info['insurances'] %} -{{ insuranceInfo['count'] }}x RV {{ insuranceInfo['insurance'].name }} ({{ insuranceInfo['insurancePrice'].code -}} -) {{ insuranceInfo['insurancePriceValue']|number_format(2) }} €: {{ (insuranceInfo['count'] * - insuranceInfo['insurancePriceValue'])|number_format(2) }} € + +{% for insuranceInfo in booking_price_info['insurancesOut'] %} +{{ insuranceInfo['count'] }}x {{ insuranceInfo['label_first'] }} [ {{ insuranceInfo['label_last'] }} ] {{ insuranceInfo['value']|number_format(2) }} € {% endfor %} + {% for option in booking_request.travelOptions %} -{{ booking_request.travelerCount }}x zugebuchte Leistung (Erwachsener): {{ option.name }} {{ option.price|number_format(2) -}} -€: {{ (booking_request.travelerCount * option.price)|number_format(2) }} € +{{ (booking_request.travelerCount + booking_request.childrenCount) }}x zugebuchte Leistung: {{ option.name }} [Erwachsener: {{ option.price|number_format(2) -}}€ ] +{% if option.priceChildren > 0 %}[Kind: {{ option.priceChildren|number_format(2) -}} €] {% endif %} + {{ ((booking_request.travelerCount * option.price) + (booking_request.childrenCount * option.priceChildren))|number_format(2) }} € {% endfor %} + {% for classOption in booking_price_info['classOptions'] %} {{ classOption['count'] }}x {{ classOption['name'] }} {{ classOption['price']|number_format(2) }} €: {{ (classOption['count'] * classOption['price'])|number_format(2) }} € {% endfor %} +{% for discount in booking_price_info['discount'] %} +{{ discount['count'] }}x {{ discount['label_first'] }} [ {{ discount['label_last'] }} ] {{ discount['value']|number_format(2) }} € +{% endfor %} + + Gesamtpreis: {{ booking_price_info['total']|number_format(2) }} € Anzahlung: {{ booking_price_info.deposit_total|number_format(2) }} € (ist sofort fällig) @@ -65,20 +73,32 @@ Reiseteilnehmer: Zimmernummer, Zimmertyp, Geschlecht, Vorname, Nachname, Geburtsdatum ===================================================================================== {% set travelerIndex = 0 %} -{% set travelerCollection = booking_request.travelers|slice(0, booking_request.travelerCount) %} +{% set travelerCollection = booking_request.travelers|slice(0, (booking_request.travelerCount + booking_request.childrenCount)) %} {% for room in booking_request.occupiedRooms %} {% if(room.type == 1) %} -{{ loop.index }}. Einzelzimmer, {{ travelerCollection[travelerIndex].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex].firstName }}, {{ travelerCollection[travelerIndex].lastName -}}, {{ travelerCollection[travelerIndex].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} +{{ loop.index }}. Einzelzimmer Erwachsener, {{ travelerCollection[travelerIndex].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex].firstName }}, {{ travelerCollection[travelerIndex].lastName -}}, {{ travelerCollection[travelerIndex].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} {% set travelerIndex = travelerIndex + 1 %} +{% if(room.child == 1) %} +{{ loop.index }}. Einzelzimmer Kind, {{ travelerCollection[travelerIndex].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex].firstName }}, {{ travelerCollection[travelerIndex].lastName -}}, {{ travelerCollection[travelerIndex].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} +{% set travelerIndex = travelerIndex + 1 %} +{% endif %} {% elseif (room.type == 2) %} -{{ loop.index }}. Doppelzimmer, {{ travelerCollection[travelerIndex].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex].firstName }}, {{ travelerCollection[travelerIndex].lastName -}}, {{ travelerCollection[travelerIndex].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} -{{ loop.index }}. Doppelzimmer, {{ travelerCollection[travelerIndex+1].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex+1].firstName }}, {{ travelerCollection[travelerIndex+1].lastName -}}, {{ travelerCollection[travelerIndex+1].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} +{{ loop.index }}. Doppelzimmer Erwachsener, {{ travelerCollection[travelerIndex].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex].firstName }}, {{ travelerCollection[travelerIndex].lastName -}}, {{ travelerCollection[travelerIndex].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} +{{ loop.index }}. Doppelzimmer Erwachsener, {{ travelerCollection[travelerIndex+1].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex+1].firstName }}, {{ travelerCollection[travelerIndex+1].lastName -}}, {{ travelerCollection[travelerIndex+1].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} {% set travelerIndex = travelerIndex + 2 %} +{% if(room.child == 1) %} +{{ loop.index }}. Doppelzimmer Kind, {{ travelerCollection[travelerIndex].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex].firstName }}, {{ travelerCollection[travelerIndex].lastName -}}, {{ travelerCollection[travelerIndex].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} +{% set travelerIndex = travelerIndex + 1 %} +{% endif %} {% elseif (room.type == 3) %} -{{ loop.index }}. Dreibettzimmer, {{ travelerCollection[travelerIndex].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex].firstName }}, {{ travelerCollection[travelerIndex].lastName -}}, {{ travelerCollection[travelerIndex].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} -{{ loop.index }}. Dreibettzimmer, {{ travelerCollection[travelerIndex+1].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex+1].firstName }}, {{ travelerCollection[travelerIndex+1].lastName -}}, {{ travelerCollection[travelerIndex+1].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} -{{ loop.index }}. Dreibettzimmer, {{ travelerCollection[travelerIndex+2].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex+2].firstName }}, {{ travelerCollection[travelerIndex+2].lastName -}}, {{ travelerCollection[travelerIndex+2].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} +{{ loop.index }}. Dreibettzimmer Erwachsener, {{ travelerCollection[travelerIndex].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex].firstName }}, {{ travelerCollection[travelerIndex].lastName -}}, {{ travelerCollection[travelerIndex].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} +{{ loop.index }}. Dreibettzimmer Erwachsener, {{ travelerCollection[travelerIndex+1].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex+1].firstName }}, {{ travelerCollection[travelerIndex+1].lastName -}}, {{ travelerCollection[travelerIndex+1].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} +{{ loop.index }}. Dreibettzimmer Erwachsener, {{ travelerCollection[travelerIndex+2].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex+2].firstName }}, {{ travelerCollection[travelerIndex+2].lastName -}}, {{ travelerCollection[travelerIndex+2].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} {% set travelerIndex = travelerIndex + 3 %} +{% if(room.child == 1) %} +{{ loop.index }}. Dreibettzimmer Kind, {{ travelerCollection[travelerIndex].sex == 1 ? 'männlich' : 'weiblich' }}, {{ travelerCollection[travelerIndex].firstName }}, {{ travelerCollection[travelerIndex].lastName -}}, {{ travelerCollection[travelerIndex].birthDate }}, {{ travelerCollection[travelerIndex].nationalityName }} +{% set travelerIndex = travelerIndex + 1 %} +{% endif %} {% endif %} {% endfor %} diff --git a/trunk/app/Resources/views/default/pages/booking.html.twig b/trunk/app/Resources/views/default/pages/booking.html.twig index 58f67b0b..064292a9 100644 --- a/trunk/app/Resources/views/default/pages/booking.html.twig +++ b/trunk/app/Resources/views/default/pages/booking.html.twig @@ -41,6 +41,22 @@
{{ form_errors(form) }} + {% spaceless %} + {% if not form.vars.valid %} + + + + + {% endif %} + {% endspaceless %} + + + + {{ form_errors(form.email) }} @@ -77,9 +93,13 @@ {# TODO folgendes evtl noch weiter verallgemeinern #} {% set priceTypeIds = [] %} + {% set priceTypeChildIds = [] %} {% for price in travel_date.prices %} {% if(price.available == "1") %} {% set priceTypeIds = priceTypeIds|merge([price.priceTypeId]) %} + {% if(price.priceChildren > 0) %} + {% set priceTypeChildIds = priceTypeChildIds|merge([price.priceTypeId]) %} + {% endif %} {% endif %} {% endfor %} @@ -94,6 +114,20 @@ {{ form_errors(form.singleRoomCount) }} + + {% if "1" in priceTypeChildIds %} + + {% else %} + + {% endif %} + {{ form_label(form.singleRoomChildCount, 'Einzelzimmer mit Kind') }} + + {{ form_widget(form.singleRoomChildCount) }} + {{ form_errors(form.singleRoomChildCount) }} + + + + {% if "3" in priceTypeIds %} {% else %} @@ -105,18 +139,41 @@ {{ form_errors(form.doubleRoomCount) }} - - {% if "5" in priceTypeIds %} + {% if "3" in priceTypeChildIds %} {% else %} - {% endif %} + {% endif %} + {{ form_label(form.doubleRoomChildCount, 'Doppelzimmer mit Kind') }} + + {{ form_widget(form.doubleRoomChildCount) }} + {{ form_errors(form.doubleRoomChildCount) }} + + + + + {% if "5" in priceTypeIds %} + + {% else %} + + {% endif %} {{ form_label(form.tripleRoomCount, 'Dreibettzimmer') }} {{ form_widget(form.tripleRoomCount) }} {{ form_errors(form.tripleRoomCount) }} + {% if "5" in priceTypeChildIds %} + + {% else %} + + {% endif %} + {{ form_label(form.tripleRoomChildCount, 'Dreibettzimmer mit Kind') }} + + {{ form_widget(form.tripleRoomChildCount) }} + {{ form_errors(form.tripleRoomChildCount) }} + + Zubuchbare Leistungen @@ -494,7 +551,7 @@ data-st-traveler-index="{{ currentIndex }}" data-room-index="{{ loop.parent.loop.index }}" data-room-type="{{ room.vars.value.type }}" - style="display: none; border-bottom:2px solid #ffc926; margin-bottom: 20px; padding-bottom: 10px;"> + style="display: ; border-bottom:2px solid #ffc926; margin-bottom: 20px; padding-bottom: 10px;">
-
+ Reiseteilnehmer | {{ roomType }} + + {% if traveler.vars.value.child %} +
bis einschließlich 11 Jahre + {% endif %} +
-
+
{{ form_field_pho(traveler.sex, 'Geschlecht', { required: false }) }} @@ -526,7 +586,7 @@
-
+
{{ form_field_pho(traveler.firstName, 'Vorname') }}
@@ -535,7 +595,7 @@
-
+
{{ form_field_pho(traveler.lastName, 'Nachname') }}
@@ -544,7 +604,7 @@
-
+
{{ form_field_pho(traveler.nationality, 'Nationalität') }}
@@ -554,7 +614,7 @@
-
+
{{ form_field_pho(traveler.birthDate, 'Geburtsdatum') }}
@@ -723,11 +783,6 @@
- - - - - {{ form_rest(form) }} diff --git a/trunk/app/Resources/views/default/pages/cms/fewoTravelProgram.html.twig b/trunk/app/Resources/views/default/pages/cms/fewoTravelProgram.html.twig index cedff618..4a99d752 100644 --- a/trunk/app/Resources/views/default/pages/cms/fewoTravelProgram.html.twig +++ b/trunk/app/Resources/views/default/pages/cms/fewoTravelProgram.html.twig @@ -220,7 +220,7 @@ diff --git a/trunk/app/Resources/views/default/pages/fewoBooking.html.twig b/trunk/app/Resources/views/default/pages/fewoBooking.html.twig index 79198753..8c0f45dd 100644 --- a/trunk/app/Resources/views/default/pages/fewoBooking.html.twig +++ b/trunk/app/Resources/views/default/pages/fewoBooking.html.twig @@ -37,7 +37,7 @@ - + {# + #}
diff --git a/trunk/src/AppBundle/Controller/BookingController.php b/trunk/src/AppBundle/Controller/BookingController.php index ab8b25ab..094b00bc 100644 --- a/trunk/src/AppBundle/Controller/BookingController.php +++ b/trunk/src/AppBundle/Controller/BookingController.php @@ -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() .'" ['. $this->calcNumTravelerLabel($travelerCount) .' x '. - Util::formatPrice($departure->getExtraCharge()) .' pro Person]' - ]; + $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() .' ['. $this->calcNumTravelerLabel($travelerCount) .' x '. - Util::formatPrice($travelOption->getPrice()) .' pro Person]' - ]; + $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 ['. $this->calcNumTravelerLabel($travelerCount) .' x '. - Util::formatPrice($room['price']->getEffectiveComfortPrice()) .' pro Person]' - ]; + $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() .' ['. $this->calcNumTravelerLabel($adultCount) .' x '. - Util::formatPrice($singleFullPrice) .' pro Person]'; - if ($room['persons']['children'] != 0) - { - $label .= ', Kinder: '. $this->calcNumTravelerLabel($room['persons']['children']) .' x '. - Util::formatPrice($room['price']->getEffectiveChildPrice()) .''; - $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 ['. $this->calcNumTravelerLabel($adultCount) .'x '. - Util::formatPrice($singleFullPrice - $singleDiscountPrice) .' pro Person]' - ]; + $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'].'['.$item['count'].' x '.$item['label_last'].' ]', + 'label' => ''.$item['count'].' x '.$item['label_first'].' ['.$item['label_last'].' ]', ]; } } + //Comfort + if(count($tempComfortHTML) > 0){ + foreach ($tempComfortHTML as $item) { + $outHtmlSummary[] =[ + 'value' => $item['value'], + 'label' => ''.$item['count'].' x '.$item['label_first'].' ['.$item['label_last'].' ]', + ]; + } + } + //ROOMS + if(count($tempRoomHTML) > 0){ + foreach ($tempRoomHTML as $item) { + $label = ''.$item['count'].' x '.$item['label_first'].' ['.$item['label_last'].']'; + if($item['childCount'] > 0){ + $label .= ' [ + Kind: '.$item['price_child']; + } + $label .= ']'; + $outHtmlSummary[] =[ + 'value' => $item['value'], + 'label' => $label, + ]; + } + } + //DISCOUNT + if(count($tempDiscountHTML) > 0){ + foreach ($tempDiscountHTML as $item) { + $insuranceHtmlSummary[] =[ + 'value' => $item['value'], + 'label' => ''.$item['count'].' x '.$item['label_first'].' ['.$item['label_last'].' ]', + ]; + } + } + //options + if(count($tempOptionHTML) > 0){ + foreach ($tempOptionHTML as $item) { + $label = ''.$item['count'].' x '.$item['label_first'].' ['.$item['label_last'].']'; + if($item['childCount'] > 0){ + $label .= ' ['.$item['price_child'].']'; + } + $outHtmlSummary[] =[ + 'value' => $item['value'], + 'label' => $label, + ]; + } + } + + + //Versicherungen + if(count($tempInsuranceHTML) > 0 ){ + foreach ($tempInsuranceHTML as $item) { + $insuranceHtmlSummary[] =[ + 'value' => $item['value'], + 'label' => ''.$item['count'].' x '.$item['label_first'].' ['.$item['label_last'].' ]', + ]; + } + } + + + 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; diff --git a/trunk/src/AppBundle/Entity/BookingRequest.php b/trunk/src/AppBundle/Entity/BookingRequest.php index 4ae2ba61..36efe3c3 100644 --- a/trunk/src/AppBundle/Entity/BookingRequest.php +++ b/trunk/src/AppBundle/Entity/BookingRequest.php @@ -32,6 +32,12 @@ class BookingRequest private $tripleRoomCount; + private $singleRoomChildCount; + + private $doubleRoomChildCount; + + private $tripleRoomChildCount; + private $roomCount; /** @@ -90,6 +96,10 @@ class BookingRequest private $doubleRooms = []; private $tripleRooms = []; + private $singleChildRooms = []; + private $doubleChildRooms = []; + private $tripleChildRooms = []; + private $notes; /** @@ -106,12 +116,30 @@ class BookingRequest */ public function __construct() { - for($i = 0; $i < 5; ++$i) + for($i = 0; $i < 4; ++$i) { $this->singleRooms[] = new Room(1); + } + for($i = 0; $i < 4; ++$i) + { + $this->singleChildRooms[] = new Room(4); + } + for($i = 0; $i < 3; ++$i) + { $this->doubleRooms[] = new Room(2); + } + for($i = 0; $i < 3; ++$i) + { + $this->doubleChildRooms[] = new Room(5); + } + for($i = 0; $i < 2; ++$i) + { $this->tripleRooms[] = new Room(3); } + for($i = 0; $i < 2; ++$i) + { + $this->tripleChildRooms[] = new Room(6); + } } /** @@ -140,20 +168,62 @@ class BookingRequest { $allUsedTravelersCount += $this->singleRooms[$i]->getTravelerCount(); } + for($i = 0; $i < $this->singleRoomChildCount; ++$i) + { + $allUsedTravelersCount += $this->singleChildRooms[$i]->getTravelerCount(); + } for($i = 0; $i < $this->doubleRoomCount; ++$i) { $allUsedTravelersCount += $this->doubleRooms[$i]->getTravelerCount(); } - + for($i = 0; $i < $this->doubleRoomChildCount; ++$i) + { + $allUsedTravelersCount += $this->doubleChildRooms[$i]->getTravelerCount(); + } for($i = 0; $i < $this->tripleRoomCount; ++$i) { $allUsedTravelersCount += $this->tripleRooms[$i]->getTravelerCount(); } + for($i = 0; $i < $this->tripleRoomChildCount; ++$i) + { + $allUsedTravelersCount += $this->tripleChildRooms[$i]->getTravelerCount(); + } return $allUsedTravelersCount; } + public function getChildrenCount() + { + $allUsedChildrenCount = 0; + for($i = 0; $i < $this->singleRoomCount; ++$i) + { + $allUsedChildrenCount += 0;//$this->singleRooms[$i]->getTravelerCount(); + } + for($i = 0; $i < $this->singleRoomChildCount; ++$i) + { + $allUsedChildrenCount += 1;//$this->singleRooms[$i]->getTravelerCount(); + } + for($i = 0; $i < $this->doubleRoomCount; ++$i) + { + $allUsedChildrenCount += 0;//$this->singleRooms[$i]->getTravelerCount(); + } + for($i = 0; $i < $this->doubleRoomChildCount; ++$i) + { + $allUsedChildrenCount += 1;//$this->singleRooms[$i]->getTravelerCount(); + } + for($i = 0; $i < $this->tripleRoomCount; ++$i) + { + $allUsedChildrenCount += 0;//$this->singleRooms[$i]->getTravelerCount(); + } + for($i = 0; $i < $this->tripleRoomChildCount; ++$i) + { + $allUsedChildrenCount += 1;//$this->singleRooms[$i]->getTravelerCount(); + } + + return $allUsedChildrenCount; + } + /** * @param mixed $travelerCount */ @@ -245,6 +315,55 @@ class BookingRequest } + /** + * @return mixed + */ + public function getSingleRoomChildCount() + { + return $this->singleRoomChildCount; + } + + /** + * @param mixed $singleRoomChildCount + */ + public function setSingleRoomChildCount($singleRoomChildCount) + { + $this->singleRoomChildCount = $singleRoomChildCount; + } + + /** + * @return mixed + */ + public function getDoubleRoomChildCount() + { + return $this->doubleRoomChildCount; + } + + /** + * @param mixed $doubleRoomChildCount + */ + public function setDoubleRoomChildCount($doubleRoomChildCount) + { + $this->doubleRoomChildCount = $doubleRoomChildCount; + } + + /** + * @return mixed + */ + public function getTripleRoomChildCount() + { + return $this->tripleRoomChildCount; + } + + /** + * @param mixed $tripleRoomChildCount + */ + public function setTripleRoomChildCount($tripleRoomChildCount) + { + $this->tripleRoomChildCount = $tripleRoomChildCount; + } + + /** * @return TravelInsurance */ @@ -467,16 +586,27 @@ class BookingRequest { $allUsedTravelers = array_merge($allUsedTravelers, $this->singleRooms[$i]->getTravelers()); } + for ($i = 0; $i < $this->singleRoomChildCount; ++$i) + { + $allUsedTravelers = array_merge($allUsedTravelers, $this->singleChildRooms[$i]->getTravelers()); + } for ($i = 0; $i < $this->doubleRoomCount; ++$i) { $allUsedTravelers = array_merge($allUsedTravelers, $this->doubleRooms[$i]->getTravelers()); } - + for ($i = 0; $i < $this->doubleRoomChildCount; ++$i) + { + $allUsedTravelers = array_merge($allUsedTravelers, $this->doubleChildRooms[$i]->getTravelers()); + } for ($i = 0; $i < $this->tripleRoomCount; ++$i) { $allUsedTravelers = array_merge($allUsedTravelers, $this->tripleRooms[$i]->getTravelers()); } + for ($i = 0; $i < $this->tripleRoomChildCount; ++$i) + { + $allUsedTravelers = array_merge($allUsedTravelers, $this->tripleChildRooms[$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 @@ -539,6 +669,54 @@ class BookingRequest $this->tripleRooms = $tripleRooms; } + /** + * @return Room[] + */ + public function getSingleChildRooms() + { + return $this->singleChildRooms; + } + + /** + * @param Room[] $singleChildRooms + */ + public function setSingleChildRooms($singleChildRooms) + { + $this->singleChildRooms = $singleChildRooms; + } + + /** + * @return Room[] + */ + public function getDoubleChildRooms() + { + return $this->doubleChildRooms; + } + + /** + * @param Room[] $doubleChildRooms + */ + public function setDoubleChildRooms($doubleChildRooms) + { + $this->doubleChildRooms = $doubleChildRooms; + } + + /** + * @return Room[] + */ + public function getTripleChildRooms() + { + return $this->tripleChildRooms; + } + + /** + * @param Room[] $tripleChildRooms + */ + public function setTripleChildRooms($tripleChildRooms) + { + $this->tripleChildRooms = $tripleChildRooms; + } + /** * @return Room[] */ @@ -546,8 +724,11 @@ class BookingRequest { $allRooms = []; $allRooms = array_merge($allRooms, $this->singleRooms); + $allRooms = array_merge($allRooms, $this->singleChildRooms); $allRooms = array_merge($allRooms, $this->doubleRooms); + $allRooms = array_merge($allRooms, $this->doubleChildRooms); $allRooms = array_merge($allRooms, $this->tripleRooms); + $allRooms = array_merge($allRooms, $this->tripleChildRooms); return $allRooms; } @@ -568,20 +749,34 @@ class BookingRequest $allRooms[] = $this->singleRooms[$i]; //$allRooms = array_push($allRooms, $this->singleRooms[$i]); } + for($i = 0; $i < $this->singleRoomChildCount; $i++) + { + $allRooms[] = $this->singleChildRooms[$i]; + //$allChildRooms = array_push($allChildRooms, $this->singleChildRooms[$i]); + } for($i = 0; $i < $this->doubleRoomCount; $i++) { $allRooms[] = $this->doubleRooms[$i]; //$allRooms = array_push($allRooms, $this->doubleRooms[$i]); } + for($i = 0; $i < $this->doubleRoomChildCount; $i++) + { + $allRooms[] = $this->doubleChildRooms[$i]; + //$allChildRooms = array_push($allChildRooms, $this->doubleChildRooms[$i]); + } for($i = 0; $i < $this->tripleRoomCount; $i++) { $allRooms[] = $this->tripleRooms[$i]; //$allRooms = array_push($allRooms, $this->tripleRooms[$i]); } + for($i = 0; $i < $this->tripleRoomChildCount; $i++) + { + $allRooms[] = $this->tripleChildRooms[$i]; + //$allChildRooms = array_push($allChildRooms, $this->tripleChildRooms[$i]); + } return $allRooms; } - /* public function addTraveler(Traveler $traveler) { diff --git a/trunk/src/AppBundle/Entity/Room.php b/trunk/src/AppBundle/Entity/Room.php index 6e9d6f1f..7eee05f4 100644 --- a/trunk/src/AppBundle/Entity/Room.php +++ b/trunk/src/AppBundle/Entity/Room.php @@ -11,27 +11,59 @@ class Room const DOUBLE = 2; const TRIPLE = 3; + const SINGLECHILD = 4; + const DOUBLECHILD = 5; + const TRIPLECHILD = 6; + /** * @Assert\NotNull * @Assert\Choice(choices={1,2,3}) */ private $type; + private $child = false; + /** * @Assert\Valid */ private $travelers = []; private $travelerCount; + private $childrenCount; public function __construct($type) { + $child = 0; + if($type == 4){ + $type = 1; + $child = 1; + $this->child = true; + } + if($type == 5){ + $type = 2; + $child = 1; + $this->child = true; + } + if($type == 6){ + $type = 3; + $child = 1; + $this->child = true; + } $this->type = $type; + for($i = 0; $i < $this->type; $i++) { $this->travelers[] = new Traveler(); } + for($i = 0; $i < $child; $i++) + { + $temp = new Traveler(); + $temp->setChild(true); + $this->travelers[] = $temp; + $this->childrenCount++; + } + $this->travelerCount = $type; } @@ -51,6 +83,22 @@ class Room $this->type = $type; } + /** + * @return int + */ + public function getChild() + { + return $this->child; + } + + /** + * @param int $child + */ + public function setChild($child) + { + $this->child = $child; + } + /** * @return Traveler[] */ @@ -83,5 +131,21 @@ class Room $this->travelerCount = $travelerCount; } + /** + * @return mixed + */ + public function getChildrenCount() + { + return $this->childrenCount; + } + + /** + * @param mixed $childrenCount + */ + public function setChildrenCount($childrenCount) + { + $this->childrenCount = $childrenCount; + } + } \ No newline at end of file diff --git a/trunk/src/AppBundle/Entity/TravelPeriodPrice.php b/trunk/src/AppBundle/Entity/TravelPeriodPrice.php index cdf918a5..1a9dfd2e 100644 --- a/trunk/src/AppBundle/Entity/TravelPeriodPrice.php +++ b/trunk/src/AppBundle/Entity/TravelPeriodPrice.php @@ -283,6 +283,16 @@ class TravelPeriodPrice return $this->calculateDiscountPrice($this->price); } + + /** + * Probably getEffectiveDiscountPrice() is the method you are actually looking for. + * @return float|null + */ + public function getChildDiscountPrice() + { + return $this->calculateDiscountPrice($this->priceChildren); + } + /** * @return float * @throws \Exception @@ -296,6 +306,19 @@ class TravelPeriodPrice return $this->calculateDiscountPrice($this->effectivePrice); } + /** + * @return float + * @throws \Exception + */ + public function getEffectiveChildDiscountPrice() + { + if ($this->effectiveChildPrice === null) + { + throw new \Exception('Effective price must be set from outside before reading effective discount price.'); + } + return $this->calculateDiscountPrice($this->effectiveChildPrice); + } + /** * @return float * @throws \Exception diff --git a/trunk/src/AppBundle/Entity/Traveler.php b/trunk/src/AppBundle/Entity/Traveler.php index 8e3c18ec..10cbdae7 100644 --- a/trunk/src/AppBundle/Entity/Traveler.php +++ b/trunk/src/AppBundle/Entity/Traveler.php @@ -50,6 +50,11 @@ class Traveler */ private $acceptEntryRequirements = false; + /** + * @Assert\IsTrue() + */ + private $child = false; + /** * @return int */ @@ -167,4 +172,23 @@ class Traveler } + /** + * @return mixed + */ + public function isChild() + { + return $this->child; + } + + + /** + * @param mixed $child + */ + + public function setChild($child) + { + $this->child = $child; + } + + } \ No newline at end of file diff --git a/trunk/src/AppBundle/Export/BookingSternToursCrmExporter.php b/trunk/src/AppBundle/Export/BookingSternToursCrmExporter.php index 9c9256b1..bf3a1096 100644 --- a/trunk/src/AppBundle/Export/BookingSternToursCrmExporter.php +++ b/trunk/src/AppBundle/Export/BookingSternToursCrmExporter.php @@ -25,7 +25,9 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter { $tp = $travelDate->getTravelProgram(); $startDateStr = $travelDate->getStart()->format('Y-m-d'); + $lead = $this->createLead($bookingRequest, $travelDate); + if ($lead === null) { $this->warn('Failed creating lead in CRM Lead', $bookingRequest, $travelDate, Logger::ERROR); @@ -38,7 +40,7 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter return false; } - for ($i = 1; $i < $bookingRequest->getTravelerCount(); ++$i) + for ($i = 1; $i < ($bookingRequest->getTravelerCount() + $bookingRequest->getChildrenCount()); ++$i) { if (!$this->createTraveler($bookingUrl, $bookingRequest->getTravelers()[$i])) { @@ -46,6 +48,7 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter } } + if ($tp->getIsMediated()) { $serviceItemDefaults = [ @@ -86,57 +89,68 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter } else { + $viewPosition = 100; $viewPositionPrice = 50; $endDateStr = $travelDate->getEnd()->format('Y-m-d'); - $arrangementDefaults = [ - 'state' => (new \DateTime())->format('Y-m-d'), - 'in_pdf' => 1 - ]; + $arrangementDefaults = [ + 'state' => (new \DateTime())->format('Y-m-d'), + 'in_pdf' => 1 + ]; - $this->createArrangement($bookingUrl, $arrangementDefaults + [ - 'type_id' => 4, // Flug - 'type_s' => 'Flug', - 'begin' => $startDateStr, - 'view_position' => --$viewPosition, - 'data_s' => ['Hinflug' => 'von '. $bookingPriceInfo['departure']->getName()], - ]); + $this->createArrangement($bookingUrl, $arrangementDefaults + [ + 'type_id' => 4, // Flug + 'type_s' => 'Flug', + 'begin' => $startDateStr, + 'view_position' => --$viewPosition, + 'data_s' => ['Hinflug' => 'von '. $bookingPriceInfo['departure']->getName()], + ]); - $this->createArrangement($bookingUrl, $arrangementDefaults + [ - 'type_id' => 26, // Preisinformation - 'type_s' => 'Preisinformation', - 'view_position' => --$viewPositionPrice, - 'data_s' => [ - 'Name' => 'Abfahrts-/Abflugort '. $bookingPriceInfo['departure']->getName(), - 'Preis' => $bookingPriceInfo['departure']->getExtraCharge(), - 'Teilnehmer' => $bookingRequest->getTravelerCount(), - ], - ]); + $this->createArrangement($bookingUrl, $arrangementDefaults + [ + 'type_id' => 26, // Preisinformation + 'type_s' => 'Preisinformation', + 'view_position' => --$viewPositionPrice, + 'data_s' => [ + 'Name' => 'Abfahrts-/Abflugort '. $bookingPriceInfo['departure']->getName(), + 'Preis' => $bookingPriceInfo['departure']->getExtraCharge(), + 'Teilnehmer' => ($bookingRequest->getTravelerCount() + $bookingRequest->getChildrenCount()), + ], + ]); + + $this->createArrangement($bookingUrl, $arrangementDefaults + [ + 'type_id' => 24, // Rundreise + 'type_s' => 'Rundreise', // Rundreise + 'begin' => $startDateStr, + 'end' => $endDateStr, + 'view_position' => --$viewPosition, + 'data_s' => ['Name' => $tp->getTitle() .' ('. $travelDate->getName() .')'], + ]); - $this->createArrangement($bookingUrl, $arrangementDefaults + [ - 'type_id' => 24, // Rundreise - 'type_s' => 'Rundreise', // Rundreise - 'begin' => $startDateStr, - 'end' => $endDateStr, - 'view_position' => --$viewPosition, - 'data_s' => ['Name' => $tp->getTitle() .' ('. $travelDate->getName() .')'], - ]); $roomStrs = []; foreach ($bookingPriceInfo['rooms'] as $room) { $roomStrs[] = '1x '. $room['name']; + $child = array(); + if($room['children'] > 0){ + $child = [ + 'Kind' => $room['children'], + 'KindPreis' => $room['price_children'], + ]; + } + $data = [ + 'Name' => 'pro Person im \''. $room['name'] .'\'', + 'Preis' => $room['price'], + 'Teilnehmer' => $room['adults'], + ]; + $data = array_merge($data, $child); $this->createArrangement($bookingUrl, $arrangementDefaults + [ 'type_id' => 26, // Preisinformation 'type_s' => 'Preisinformation', 'view_position' => --$viewPositionPrice, - 'data_s' => [ - 'Name' => 'pro Person im \''. $room['name'] .'\'', - 'Preis' => $room['price'], - 'Teilnehmer' => $room['adults'], - ], + 'data_s' => $data, ]); } $this->createArrangement($bookingUrl, $arrangementDefaults + [ @@ -159,6 +173,7 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter 'Name' => $classOption['name'], 'Preis' => $classOption['price'], 'Teilnehmer' => $classOption['count'], + ], ]); } @@ -171,31 +186,51 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter 'data_s' => ['Rückflug' => $bookingRequest->getDeparture()->getName()], ]); + foreach ($bookingRequest->getTravelOptions() as $option) { + $child = array(); + if($option->getPriceChildren() > 0){ + $child = [ + 'Kind' => $bookingRequest->getChildrenCount(), + 'KindPreis' => $option->getPriceChildren(), + ]; + } + $data = [ + 'Name' => $option->getName(), + 'Preis' => $option->getPrice(), + 'Teilnehmer' => $bookingRequest->getTravelerCount(), + ]; + $data = array_merge($data, $child); $this->createArrangement($bookingUrl, $arrangementDefaults + [ 'type_id' => 26, // Preisinformation 'type_s' => 'Preisinformation', 'view_position' => --$viewPositionPrice, - 'data_s' => [ - 'Name' => $option->getName(), - 'Preis' => $option->getPrice(), - 'Teilnehmer' => $bookingRequest->getTravelerCount(), - ], + 'data_s' => $data ]); } } - foreach ($bookingPriceInfo['insurances'] as $insuranceInfo) - { + foreach ($bookingPriceInfo['insurances'] as $insuranceInfo) { $this->createServiceItem($bookingUrl, [ 'travel_company_id' => 30, 'service_price' => $insuranceInfo['count'] * $insuranceInfo['insurancePriceValue'], - 'name' => $insuranceInfo['count'] . 'x ' . $insuranceInfo['insurance']->getName() . ' ('. + 'name' => $insuranceInfo['count'] . 'x ' . $insuranceInfo['insurance']->getName() . ' (' . $insuranceInfo['insurancePrice']->getCode() . ')', 'commission' => round(($insuranceInfo['count'] * $insuranceInfo['insurancePriceValue']) * 20 / 100, 2), 'travel_date' => $startDateStr, ]); + //child + if ($insuranceInfo['countChild'] > 0){ + $this->createServiceItem($bookingUrl, [ + 'travel_company_id' => 30, + 'service_price' => $insuranceInfo['countChild'] * $insuranceInfo['insuranceChildPriceValue'], + 'name' => $insuranceInfo['countChild'] . 'x ' . $insuranceInfo['insurance']->getName() . ' (' . + $insuranceInfo['insuranceChildPrice']->getCode() . ')', + 'commission' => round(($insuranceInfo['countChild'] * $insuranceInfo['insuranceChildPriceValue']) * 20 / 100, 2), + 'travel_date' => $startDateStr, + ]); + } } return $bookingUrl; @@ -228,7 +263,6 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter // 'travelperiod_length 'remarks' => $bookingRequest->getNotes() ]]); - if ($resp['success']) { $ret = $this->httpGet($resp['location']); @@ -284,6 +318,7 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter 'participant_name' => $traveler->getLastName(), 'participant_firstname' => $traveler->getFirstName(), 'participant_birthdate' => $traveler->getBirthDate(), + 'participant_child' => $traveler->isChild(), ]], true); return $resp['success']; } diff --git a/trunk/src/AppBundle/Export/SternToursCrmExporter.php b/trunk/src/AppBundle/Export/SternToursCrmExporter.php index 012d5605..ff9df1fb 100644 --- a/trunk/src/AppBundle/Export/SternToursCrmExporter.php +++ b/trunk/src/AppBundle/Export/SternToursCrmExporter.php @@ -13,7 +13,7 @@ use Monolog\Logger; abstract class SternToursCrmExporter { const API_URL = 'http://www.cms.stern-tours.net/api'; - //const API_URL = 'http://cms-stern-torus.local//api'; + //const API_URL = 'http://cms-stern-tours.local/api'; const API_KEY = 'f6077389c9ce710e554763a5de02c8ec'; const API_USER_ID = 15; // 'apiuser' const WEBSITE_ID = 1; // 'sterntours.de' diff --git a/trunk/src/AppBundle/Form/BookingRequestType.php b/trunk/src/AppBundle/Form/BookingRequestType.php index 6ad4cf6a..a0a02671 100644 --- a/trunk/src/AppBundle/Form/BookingRequestType.php +++ b/trunk/src/AppBundle/Form/BookingRequestType.php @@ -39,7 +39,14 @@ class BookingRequestType extends AbstractType '2 Einzelzimmer' => 2, '3 Einzelzimmer' => 3, '4 Einzelzimmer' => 4, - '5 Einzelzimmer' => 5, + ]; + + public static $SINGLE_ROOM_CHILD_COUNT_CHOICES = [ + '0 Einzelzimmer [1 Erwachsener + 1 Kind (bis einschl. 11 Jahren)]' => 0, + '1 Einzelzimmer [1 Erwachsener + 1 Kind (bis einschl. 11 Jahren)]' => 1, + '2 Einzelzimmer [1 Erwachsener + 1 Kind (bis einschl. 11 Jahren)]' => 2, + '3 Einzelzimmer [1 Erwachsener + 1 Kind (bis einschl. 11 Jahren)]' => 3, + '4 Einzelzimmer [1 Erwachsener + 1 Kind (bis einschl. 11 Jahren)]' => 4, ]; public static $DOUBLE_ROOM_COUNT_CHOICES = [ @@ -47,17 +54,25 @@ class BookingRequestType extends AbstractType '1 Doppelzimmer' => 1, '2 Doppelzimmer' => 2, '3 Doppelzimmer' => 3, - '4 Doppelzimmer' => 4, - '5 Doppelzimmer' => 5, + ]; + + public static $DOUBLE_ROOM_CHILD_COUNT_CHOICES = [ + '0 Doppelzimmer [2 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 0, + '1 Doppelzimmer [2 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 1, + '2 Doppelzimmer [2 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 2, + '3 Doppelzimmer [2 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 3, ]; 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 $TRIPLE_ROOM_CHILD_COUNT_CHOICES = [ + '0 Dreibettzimmer [3 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 0, + '1 Dreibettzimmer [3 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 1, + '2 Dreibettzimmer [3 Erwachsene + 1 Kind (bis einschl. 11 Jahren)]' => 2, ]; public static $NATION_CHOICES = [ @@ -172,6 +187,12 @@ class BookingRequestType extends AbstractType new Choice(['choices' => self::$SINGLE_ROOM_COUNT_CHOICES] )] ]); + $builder->add('singleRoomChildCount', ChoiceType::class, [ + 'choices' => self::$SINGLE_ROOM_CHILD_COUNT_CHOICES, + 'constraints' => [ + new Choice(['choices' => self::$SINGLE_ROOM_CHILD_COUNT_CHOICES] + )] + ]); $builder->add('doubleRoomCount', ChoiceType::class, [ 'choices' => self::$DOUBLE_ROOM_COUNT_CHOICES, @@ -179,6 +200,12 @@ class BookingRequestType extends AbstractType new Choice(['choices' => self::$DOUBLE_ROOM_COUNT_CHOICES] )] ]); + $builder->add('doubleRoomChildCount', ChoiceType::class, [ + 'choices' => self::$DOUBLE_ROOM_CHILD_COUNT_CHOICES, + 'constraints' => [ + new Choice(['choices' => self::$DOUBLE_ROOM_CHILD_COUNT_CHOICES] + )] + ]); $builder->add('tripleRoomCount', ChoiceType::class, [ 'choices' => self::$TRIPLE_ROOM_COUNT_CHOICES, @@ -186,6 +213,12 @@ class BookingRequestType extends AbstractType new Choice(['choices' => self::$TRIPLE_ROOM_COUNT_CHOICES] )] ]); + $builder->add('tripleRoomChildCount', ChoiceType::class, [ + 'choices' => self::$TRIPLE_ROOM_CHILD_COUNT_CHOICES, + 'constraints' => [ + new Choice(['choices' => self::$TRIPLE_ROOM_CHILD_COUNT_CHOICES] + )] + ]); $insuranceChoices = []; diff --git a/trunk/src/AppBundle/Resources/public/js/booking.js b/trunk/src/AppBundle/Resources/public/js/booking.js index 71b2f368..74a00fb9 100644 --- a/trunk/src/AppBundle/Resources/public/js/booking.js +++ b/trunk/src/AppBundle/Resources/public/js/booking.js @@ -6,10 +6,16 @@ $(document).ready(function() { var roomCountSR$ = $('#booking_request_singleRoomCount'); var roomCountDR$ = $('#booking_request_doubleRoomCount'); var roomCountTR$ = $('#booking_request_tripleRoomCount'); + + var roomChildCountSR$ = $('#booking_request_singleRoomChildCount'); + var roomChildCountDR$ = $('#booking_request_doubleRoomChildCount'); + var roomChildCountTR$ = $('#booking_request_tripleRoomChildCount'); + + //var travelersIndices = $('.st-traveller-index'); var travelers$ = $('.st-traveler'); - var travelerFields$ = travelers$.find('input,select'); + var travelerFields$ = travelers$.find('input,select,checkbox'); frm$.find('input, select').change(function() { var tmp = location.href.split('?'); @@ -92,28 +98,29 @@ $(document).ready(function() { $i.toggleClass('icon-minus icon-plus'); } + $('.acc_nationality_panel').on('hidden.bs.collapse', toggleUpdateChevron); $('.acc_nationality_panel').on('shown.bs.collapse', toggleUpdateChevron); - function toggleChevronIn(e) { - console.log(e); - var $i = $(e.target) - .parent('.panel-group') - .find("i.indicator"); + function toggleChevronIn(e) { + console.log(e); + var $i = $(e.target) + .parent('.panel-group') + .find("i.indicator"); - $i.toggleClass('icon-minus icon-plus'); + $i.toggleClass('icon-minus icon-plus'); - if($i.hasClass('icon-minus')){ - $i.parent('h5').find('span').html('Leistungen ausblenden'); - } - if($i.hasClass('icon-plus')){ - $i.parent('h5').find('span').html('Leistungen einblenden'); - } + if($i.hasClass('icon-minus')){ + $i.parent('h5').find('span').html('Leistungen ausblenden'); } + if($i.hasClass('icon-plus')){ + $i.parent('h5').find('span').html('Leistungen einblenden'); + } + } - $('.booking_insurance_toogle').on('hidden.bs.collapse', toggleChevronIn); - $('.booking_insurance_toogle').on('shown.bs.collapse', toggleChevronIn); + $('.booking_insurance_toogle').on('hidden.bs.collapse', toggleChevronIn); + $('.booking_insurance_toogle').on('shown.bs.collapse', toggleChevronIn); @@ -125,58 +132,163 @@ $(document).ready(function() { var doubleTravelerCount = parseInt(roomCountDR$.val()) * 2; var tripleTravelerCount = parseInt(roomCountTR$.val()) * 3; - var allTravelersCount = singleTravelerCount + doubleTravelerCount + tripleTravelerCount; + var singleTravelerChildCount = parseInt(roomChildCountSR$.val()) * 2; + var doubleTravelerChildCount = parseInt(roomChildCountDR$.val()) * 3; + var tripleTravelerChildCount = parseInt(roomChildCountTR$.val()) * 4; + + var allTravelersCount = singleTravelerCount + doubleTravelerCount + tripleTravelerCount + singleTravelerChildCount + doubleTravelerChildCount + tripleTravelerChildCount; travelers$.hide(); travelerFields$.prop('required', false); + var counter = 1; + var $offset = 1; + + //single if(singleTravelerCount > 0) { - for(var i = 1; i <= singleTravelerCount; i++) + for(var i = $offset; i <= singleTravelerCount; i++) { var travelerSelector = '.st-traveler-' + i; var roomIndexSelector = travelerSelector+' .st-traveller-index'; - var currentRoomIndex = $(travelerSelector).attr("data-room-index"); + //var currentRoomIndex = $(travelerSelector).attr("data-room-index"); $(travelerSelector).show().find('input,select').prop('required', true); - //$(roomIndexSelector).text(currentRoomIndex); - $(roomIndexSelector).text(counter + ".) Reiseteilnehmer | Einzelzimmer"); + $(roomIndexSelector).text(counter + ".) Reiseteilnehmer | Einzelzimmer | 1. Erwachsender"); counter ++; } } + //single + child + $offset = $offset + parseInt(roomCountSR$.find('option').length) -1; + //4 next 5 + if(singleTravelerChildCount > 0) + { + for(var i = $offset; i < singleTravelerChildCount + $offset; 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(counter + ".) Reiseteilnehmer | Einzelzimmer | 1. Erwachsender"); + counter ++; + + //child + 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(counter + ".) Reiseteilnehmer | Einzelzimmer | Kind"); + counter ++; + } + } + //double + $offset = $offset + (parseInt(roomChildCountSR$.find('option').length) -1) * 2; + //4 + 4*2 next 13 if(doubleTravelerCount > 0) { - var offset = 5 - singleTravelerCount; - for(var j = 6; j <= doubleTravelerCount + 5; j++) + $m = 1; + + for(var i = $offset; i < doubleTravelerCount + $offset; i++) { - var travelerSelector = '.st-traveler-'+j; + var travelerSelector = '.st-traveler-'+i; var roomIndexSelector = travelerSelector+' .st-traveller-index'; - var currentRoomIndex = $(travelerSelector).attr("data-room-index"); + // var currentRoomIndex = $(travelerSelector).attr("data-room-index"); $(travelerSelector).show().find('input,select').prop('required', true); - //$(roomIndexSelector).text(currentRoomIndex - offset); - $(roomIndexSelector).text(counter + ".) Reiseteilnehmer | Doppelzimmer"); + $(roomIndexSelector).text(counter + ".) Reiseteilnehmer | Doppelzimmer | " + $m + ". Erwachsender"); counter ++; + $m++; + if($m == 3){ + $m = 1; + } + } + } + //double + child + $offset = $offset + (parseInt(roomCountDR$.find('option').length) -1) * 2; + //12 + 3*2 next 19 + if(doubleTravelerChildCount > 0) + { + $m = 1; + for(var i = $offset; i < doubleTravelerChildCount + $offset; 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(counter + ".) Reiseteilnehmer | Doppelzimmer | " + $m + ". Erwachsender"); + counter ++; + $m++; + if($m == 3){ + $m = 1; + //child + 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(counter + ".) Reiseteilnehmer | Doppelzimmer | Kind"); + counter ++; + } } } + //triple + $offset = $offset + (parseInt(roomChildCountDR$.find('option').length) -1) * 3; + //18 + 3*3 next 28 if(tripleTravelerCount > 0) { - var offset = 10 - (singleTravelerCount + (doubleTravelerCount / 2)); - for(var k = 16; k <= tripleTravelerCount + 15; k++) + $m = 1; + for(var i = $offset; i < tripleTravelerCount + $offset; i++) { - var travelerSelector = '.st-traveler-'+k; + var travelerSelector = '.st-traveler-'+i; var roomIndexSelector = travelerSelector+' .st-traveller-index'; - var currentRoomIndex = $(travelerSelector).attr("data-room-index"); + //var currentRoomIndex = $(travelerSelector).attr("data-room-index"); $(travelerSelector).show().find('input,select').prop('required', true); - //$(roomIndexSelector).text(currentRoomIndex - offset); - $(roomIndexSelector).text(counter + ".) Reiseteilnehmer | Dreibettzimmer"); + $(roomIndexSelector).text(counter + ".) Reiseteilnehmer | Dreibettzimmer | " + $m + ". Erwachsender"); counter ++; + $m++; + if($m == 4){ + $m = 1; + } + } + } + + //triple + child + $offset = $offset + (parseInt(roomCountTR$.find('option').length) -1) * 3; + //27 + 2*3 next 34 + if(tripleTravelerChildCount > 0) + { + $m = 1; + for(var i = $offset; i < tripleTravelerChildCount + $offset; 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(counter + ".) Reiseteilnehmer | Dreibettzimmer | " + $m + ". Erwachsender"); + counter ++; + $m++; + if($m == 4){ + $m = 1; + //child + 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(counter + ".) Reiseteilnehmer | Dreibettzimmer | Kind"); + counter ++; + } } } } + roomCountSR$.change(updateTravelers); roomCountDR$.change(updateTravelers); roomCountTR$.change(updateTravelers); + roomChildCountSR$.change(updateTravelers); + roomChildCountDR$.change(updateTravelers); + roomChildCountTR$.change(updateTravelers); updateTravelers(); }); \ No newline at end of file diff --git a/trunk/src/AppBundle/Service/LodgingCalendarService.php b/trunk/src/AppBundle/Service/LodgingCalendarService.php index e83f55a3..de9c6c57 100644 --- a/trunk/src/AppBundle/Service/LodgingCalendarService.php +++ b/trunk/src/AppBundle/Service/LodgingCalendarService.php @@ -786,8 +786,6 @@ class LodgingCalendarService if($minDays > $checkDay->getPrice()->getSeason()->getMinimumStay()){ $last = $counter+$checkDay->getPrice()->getSeason()->getMinimumStay(); - - $setMinStayTo->modify('-'.($last).' days'); } if($minDays < $checkDay->getPrice()->getSeason()->getMinimumStay()){ @@ -799,7 +797,6 @@ class LodgingCalendarService } } $counter++; - if($counter <= $last) { $checkDay->setIsBookable(false); } @@ -832,18 +829,17 @@ class LodgingCalendarService $prices = $lodging->getPrices(); - foreach ($prices as $price) - { - $season = $price->getSeason(); - $pricesCalendar = $this->markCalendarDays($pricesCalendar, $season->getFromDate(), $season->getToDate(), + foreach ($prices as $price) { + if (!empty($price->getSeason())){ + $season = $price->getSeason(); + $pricesCalendar = $this->markCalendarDays($pricesCalendar, $season->getFromDate(), $season->getToDate(), false, $price); + } } - foreach($reservations as $reservation) { $fromDate = $reservation->getFromDate(); $toDate = $reservation->getToDate(); - $reservationsCalendar = $this->markCalendarDays($reservationsCalendar, $fromDate, $toDate, true, null, $reservation); //TODO fast fertig } diff --git a/trunk/src/AppBundle/Util/CalendarDayState.php b/trunk/src/AppBundle/Util/CalendarDayState.php index a7c987a2..d89cf762 100644 --- a/trunk/src/AppBundle/Util/CalendarDayState.php +++ b/trunk/src/AppBundle/Util/CalendarDayState.php @@ -267,7 +267,11 @@ class CalendarDayState $ret .= 'calendar-day-reservation-begin '; return $ret; } + if($this->getIsReservationEnd() && $this->getIsBookable()){ + $ret .= ' calendar-day-disabled-half-booked'; + return $ret; + } if($this->getIsReservationEnd()){ $ret .= 'calendar-day-reservation-end '; return $ret; diff --git a/trunk/src/AppBundle/Validator/Constraints/BookingRequestValidator.php b/trunk/src/AppBundle/Validator/Constraints/BookingRequestValidator.php index 935d4fcf..d247c6ca 100644 --- a/trunk/src/AppBundle/Validator/Constraints/BookingRequestValidator.php +++ b/trunk/src/AppBundle/Validator/Constraints/BookingRequestValidator.php @@ -39,27 +39,48 @@ class BookingRequestValidator extends ConstraintValidator public function validate($bookingRequest, Constraint $constraint) { - for($i = 0; $i < $bookingRequest->getSingleRoomCount(); ++$i) + for($i = 1; $i < $bookingRequest->getSingleRoomCount(); ++$i) { $this->context->getValidator()->inContext($this->context) ->atPath('rooms['.$i.']') ->validate($bookingRequest->getSingleRooms()[$i]) ; } - - for($j = 0; $j < $bookingRequest->getDoubleRoomCount(); ++$j) + for($i = 1; $i < $bookingRequest->getSingleRoomChildCount(); ++$i) { $this->context->getValidator()->inContext($this->context) - ->atPath('rooms['.($j+5).']') - ->validate($bookingRequest->getDoubleRooms()[$j]) + ->atPath('rooms['.($i+3).']') + ->validate($bookingRequest->getSingleChildRooms()[$i]) + ; + } + for($i = 1; $i < $bookingRequest->getDoubleRoomCount(); ++$i) + { + $this->context->getValidator()->inContext($this->context) + ->atPath('rooms['.($i+7).']') + ->validate($bookingRequest->getDoubleRooms()[$i]) ; } - for($k = 0; $k < $bookingRequest->getTripleRoomCount(); ++$k) + for($i = 1; $i < $bookingRequest->getDoubleRoomChildCount(); ++$i) { $this->context->getValidator()->inContext($this->context) - ->atPath('rooms['.($k + 10).']') - ->validate($bookingRequest->getTripleRooms()[$k]) + ->atPath('rooms['.($i+10).']') + ->validate($bookingRequest->getDoubleChildRooms()[$i]) + ; + } + + for($i = 1; $i < $bookingRequest->getTripleRoomCount(); ++$i) + { + $this->context->getValidator()->inContext($this->context) + ->atPath('rooms['.($i + 13).']') + ->validate($bookingRequest->getTripleRooms()[$i]) + ; + } + for($i = 1; $i < $bookingRequest->getTripleRoomChildCount(); ++$i) + { + $this->context->getValidator()->inContext($this->context) + ->atPath('rooms['.($i + 15).']') + ->validate($bookingRequest->getTripleChildRooms()[$i]) ; } }