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

@ -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'];
}

View file

@ -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'