diff --git a/trunk/src/AppBundle/Entity/TravelPeriodRepository.php b/trunk/src/AppBundle/Entity/TravelPeriodRepository.php index e4e6176a..d4e8c8c6 100644 --- a/trunk/src/AppBundle/Entity/TravelPeriodRepository.php +++ b/trunk/src/AppBundle/Entity/TravelPeriodRepository.php @@ -202,6 +202,14 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository const TD_QUERY_ACP = self::TD_QUERY_INACTIVE | self::TD_QUERY_OUTDATED; const TD_QUERY_VIRTUAL_AND_NON_VIRTUAL = self::TD_QUERY_VIRTUAL | self::TD_QUERY_NON_VIRTUAL; + /** + * @param TravelProgram $program + * @param bool $class + * @param int $flags + * + * @return TravelDate[]|array + * @todo Find a more appropriate name for this method + */ public function getTrueTravelPeriods(TravelProgram $program, $class = false, $flags = self::TD_QUERY_VIRTUAL_AND_NON_VIRTUAL) { @@ -320,8 +328,6 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository } } } - //$x = array_keys($flightPeriodByKey); - //var_dump($x); die(); $this->addTravelDatesToProgram($program, $entities, $flightPeriodByKey, $startDate, null); return $program->getTravelDates(); @@ -375,10 +381,12 @@ class TravelPeriodRepository extends \Doctrine\ORM\EntityRepository $seasonEndDate = clone $endDate; } // Subtract temporarily added days which were added above. (Also subtract if date was limited!) - $seasonEndDate->modify('-'.$travelProgram->getProgramDuration().' day'); + // Add one day to include season end date in $dates array below (would be excluded otherwise) + $seasonEndDate->modify('-'. ($travelProgram->getProgramDuration() - 1) .' day'); $dates = new \DatePeriod($travelPeriodDate->getStartDate(), \DateInterval::createFromDateString('1 day'), $seasonEndDate); + $doTestStartDate = $startDate != null; /** @var \DateTime $date */ foreach ($dates as $date) @@ -403,15 +411,6 @@ 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( @@ -440,13 +439,8 @@ 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 diff --git a/trunk/src/AppBundle/Entity/TravelProgram.php b/trunk/src/AppBundle/Entity/TravelProgram.php index 336fce5d..11fa2c33 100644 --- a/trunk/src/AppBundle/Entity/TravelProgram.php +++ b/trunk/src/AppBundle/Entity/TravelProgram.php @@ -341,6 +341,8 @@ class TravelProgram */ private $travelDateByKey = []; + private $isTravelDateMapTainted = true; + /** * Set profitMargin * @@ -1424,6 +1426,7 @@ class TravelProgram \DateTime $end = null, FlightPeriod $flightPeriod = null, $currencyFactor) { $this->assertTravelDateNotDefinedYet($key); + $this->isTravelDateMapTainted = true; $this->travelDateByKey[$key] = TravelDate::createForSeasonTravelPeriod($key, $travelPeriod, $index, $start, $end, $flightPeriod, $currencyFactor); } @@ -1432,6 +1435,7 @@ class TravelProgram \DateTime $start = null, \DateTime $end = null, $index = null) { $this->assertTravelDateNotDefinedYet($key); + $this->isTravelDateMapTainted = true; $this->travelDateByKey[$key] = new TravelDate($key, $travelPeriod, $flightPeriod, $currencyFactor, $start, $end, $index); } @@ -1451,6 +1455,11 @@ class TravelProgram */ public function getTravelDates() { + if ($this->isTravelDateMapTainted) + { + ksort($this->travelDateByKey); + $this->isTravelDateMapTainted = false; + } return $this->travelDateByKey; }