* Fertigstellung Buchungsformular (#1321) (SternTours-CRM-API-Anbindung, Mailversand, Validierung, Dynamische Preisberechnung, Persistierung von Buchungsinformationen)

* Fehler bei der Preisberechnung behoben
* Farbschema geändert (Kevin Adametz)

git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3289 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
uli 2017-02-14 11:26:49 +00:00
parent dde3b91724
commit 3a28866cd2
36 changed files with 2200 additions and 268 deletions

View file

@ -129,32 +129,9 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository
$usedArrivalPointIds = array_keys($isUsedArrivalPointById);
// Find flight periods and related departures
$flightPeriods = [];
if (!empty($isUsedArrivalPointById))
{
$qb = $this->getEntityManager()->createQueryBuilder();
$unindexedFlightPeriods = $qb
->from('AppBundle:FlightPeriod', 'fp')
->addSelect('fp')
->leftJoin('fp.departures', 'fp_dep')
->addSelect('fp_dep')
->where('fp.startDate >= :startDate')
->andWhere('fp.endDate <= :endDate')
->andWhere($qb->expr()->in('IDENTITY(fp.travelArrivalPoint)', $usedArrivalPointIds))
->setParameter('startDate', $startDate)
->setParameter('endDate', $endDate)
->getQuery()->getResult();
// Index by CONCAT(start date, end date, arrival point id):
/** @var FlightPeriod $flightPeriod */
foreach ($unindexedFlightPeriods as $flightPeriod)
{
$flightPeriods[$flightPeriod->getStartDate()->format('Y-m-d') .
$flightPeriod->getEndDate()->format('Y-m-d') .
$flightPeriod->getTravelArrivalPoint()->getId()] = $flightPeriod;
}
}
$flightPeriods = empty($isUsedArrivalPointById) ? []
: $this->getEntityManager()->getRepository('AppBundle:FlightPeriod')
->getIndexedFlightPeriodsForTimePeriod($startDate, $endDate, $usedArrivalPointIds);
// Find default departures and classify by-program or by-arrival-point
// We could've simply left joined them to get an equal result. But we're reducing the number of rows returned
@ -253,8 +230,9 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository
// Only mediated travel programs define departures in travelPeriods
$qb->leftJoin('p.departures', 'p_dep')->addSelect('p_dep');
}
else
elseif (!($flags & self::TD_QUERY_VIRTUAL))
{
// Retrieving all flight periods by join is only possible, if virtual entries are excluded
$qb->leftJoin('AppBundle:FlightPeriod', 'fp', Expr\Join::WITH, 'IDENTITY(fp.travelArrivalPoint) = '.
':travelArrivalPointId AND d.startDate = fp.startDate AND d.endDate = fp.endDate');
$qb->setParameter('travelArrivalPointId', $program->getTravelArrivalPoint()->getId());
@ -299,11 +277,19 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository
->addOrderBy('p.name', 'ASC')
;
// #TODO Try to optimize this later
$entities = $qb->getQuery()->execute();
$flightPeriodByKey = [];
$flightPeriodByKey = null;
if (!$program->getIsMediated())
{
if ($flags & self::TD_QUERY_VIRTUAL)
{
// If virtual entries are included, we have to fetch all flight periods, because we don't know
// the actual dates yet
$flightPeriodByKey = $this->getEntityManager()->getRepository('AppBundle:FlightPeriod')
->getIndexedFlightPeriodsForTimePeriod($startDate, null, $program->getTravelArrivalPoint()->getId());
}
foreach ($entities as $key => $entity)
{
if ($entity == null)
@ -334,6 +320,8 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository
}
}
}
//$x = array_keys($flightPeriodByKey);
//var_dump($x); die();
$this->addTravelDatesToProgram($program, $entities, $flightPeriodByKey, $startDate, null);
return $program->getTravelDates();
@ -415,6 +403,15 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository
{
$flightPeriodKey = $travelDateKey .
$travelProgram->getTravelArrivalPoint()->getId();
// #DEBUG
/*
if ($travelPeriodDate->getId() . $travelPeriod->getName() . $i == '18888D8')
{
$x = array_keys($flightPeriods);
var_dump($x);
die (isset($flightPeriods[$flightPeriodKey]) ? 'ok' : 'nok');
}
*/
$flightPeriod = $flightPeriods[$flightPeriodKey] ?? null;
}
$travelProgram->addTravelDateFromSeasonTravelPeriod(
@ -443,8 +440,13 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository
$flightPeriod = null;
if (!$travelProgram->getIsMediated())
{
//$x = array_keys($flightPeriods);
//var_dump($x);
//die($travelDateKey . $travelProgram->getTravelArrivalPoint()->getId());
$flightPeriod = $flightPeriods[$travelDateKey . $travelProgram->getTravelArrivalPoint()->getId()]
?? null;
//if ($travelPeriod->getName() == 'ISRA-HOE18888D8');
//die($travelPeriod->getName() .';'. $flightPeriod->getPrice());
}
// #TODO There is an error in the old backend which causes duplicates