profitMargin = $profitMargin; return $this; } /** * Get profitMargin * * @return float */ public function getProfitMargin() { return $this->profitMargin; } /** * Set programCode * * @param string $programCode * * @return TravelProgram */ public function setProgramCode($programCode) { $this->programCode = $programCode; return $this; } /** * Get programCode * * @return string */ public function getProgramCode() { return $this->programCode; } /** * Set programDuration * * @param integer $programDuration * * @return TravelProgram */ public function setProgramDuration($programDuration) { $this->programDuration = $programDuration; return $this; } /** * Get programDuration * * @return integer */ public function getProgramDuration() { return $this->programDuration; } /** * Set isSeasonal * * @param boolean $isSeasonal * * @return TravelProgram */ public function setIsSeasonal($isSeasonal) { $this->isSeasonal = $isSeasonal; return $this; } /** * Get isSeasonal * * @return boolean */ public function getIsSeasonal() { return $this->isSeasonal; } /** * Set youth * * @param boolean $youth * * @return TravelProgram */ public function setYouth($youth) { $this->youth = $youth; return $this; } /** * Get youth * * @return boolean */ public function getYouth() { return $this->youth; } /** * Set title * * @param string $title * * @return TravelProgram */ public function setTitle($title) { $this->title = $title; return $this; } /** * Get title * * @return string */ public function getTitle() { return $this->title; } /** * Set subtitle * * @param string $subtitle * * @return TravelProgram */ public function setSubtitle($subtitle) { $this->subtitle = $subtitle; return $this; } /** * Get subtitle * * @return string */ public function getSubtitle() { return $this->subtitle; } /** * Set programType * * @param integer $programType * * @return TravelProgram */ public function setProgramType($programType) { $this->programType = $programType; return $this; } /** * Get programType * * @return integer */ public function getProgramType() { return $this->programType; } /** * Set status * * @param boolean $status * * @return TravelProgram */ public function setStatus($status) { $this->status = $status; return $this; } /** * Get status * * @return boolean */ public function getStatus() { return $this->status; } /** * Set included * * @param string $included * * @return TravelProgram */ public function setIncluded($included) { $this->included = $included; return $this; } /** * Get included * * @return string */ public function getIncluded() { return $this->included; } /** * Set classDescription * * @param string $classDescription * * @return TravelProgram */ public function setClassDescription($classDescription) { $this->classDescription = $classDescription; return $this; } /** * Get classDescription * * @return string */ public function getClassDescription() { return $this->classDescription; } /** * Set excluded * * @param string $excluded * * @return TravelProgram */ public function setExcluded($excluded) { $this->excluded = $excluded; return $this; } /** * Get excluded * * @return string */ public function getExcluded() { return $this->excluded; } /** * Set advices * * @param string $advices * * @return TravelProgram */ public function setAdvices($advices) { $this->advices = $advices; return $this; } /** * Get advices * * @return string */ public function getAdvices() { return $this->advices; } /** * Set notes * * @param string $notes * * @return TravelProgram */ public function setNotes($notes) { $this->notes = $notes; return $this; } /** * Get notes * * @return string */ public function getNotes() { return $this->notes; } /** * Set url * * @param string $url * * @return TravelProgram */ public function setUrl($url) { $this->url = $url; return $this; } /** * Get url * * @return string */ public function getUrl() { return $this->url; } /** * Set maxAgeForChildren * * @param integer $maxAgeForChildren * * @return TravelProgram */ public function setMaxAgeForChildren($maxAgeForChildren) { $this->maxAgeForChildren = $maxAgeForChildren; return $this; } /** * Get maxAgeForChildren * * @return integer */ public function getMaxAgeForChildren() { return $this->maxAgeForChildren; } /** * Set htmlDescription * * @param string $htmlDescription * * @return TravelProgram */ public function setHtmlDescription($htmlDescription) { $this->htmlDescription = $htmlDescription; return $this; } /** * Get htmlDescription * * @return string */ public function getHtmlDescription() { return $this->htmlDescription; } /** * @param \DateTime $startDate * @return array */ // '

X Tag / Anreise ... : Programm

'; public function getTravelProgramDates(\DateTime $startDate) { $lines = array(); $count = 0; if($this->htmlDescription){ $text = $this->htmlDescription; $regex = '#

(.*?)

#'; preg_match_all($regex, $text, $matches); foreach ($matches[1] as $val){ if(strpos($val, ':')){ $v = explode(':', $val); $int = (int) filter_var($v[0], FILTER_SANITIZE_NUMBER_INT); if($int) { $lines[$int] = array('count'=> $count, 'day' => trim($v[1]), 'date' => $startDate->format('d.m.Y')); $startDate->modify('+1 day'); $count++; } } } } if($this->classDescription){ $text = $this->classDescription; //standard //komfort $regex = "''si"; preg_match_all($regex, $text, $matches); if(isset($matches[1][0]) && strpos($matches[1][0], '')){ $text = $matches[1][0]; $regex = '#
  • (.*?)
  • #'; preg_match_all($regex, $text, $matches); foreach ($matches[1] as $val){ if(strpos($val, ':')){ $v = explode(':', $val); $int = (int) filter_var($v[0], FILTER_SANITIZE_NUMBER_INT); if($int && isset($lines[$int])) { $lines[$int]['night'] = trim($v[1]); } } } } } return $lines; } /** * Set inSlider * * @param boolean $inSlider * * @return TravelProgram */ public function setInSlider($inSlider) { $this->inSlider = $inSlider; return $this; } /** * Get inSlider * * @return boolean */ public function getInSlider() { return $this->inSlider; } /** * Set showMap * * @param boolean $showMap * * @return TravelProgram */ public function setShowMap($showMap) { $this->showMap = $showMap; return $this; } /** * Get showMap * * @return int 1 for mapHtml, 2 for mapImage */ public function getShowMap() { return $this->showMap; } /** * Set mapHtml * * @param string $mapHtml * * @return TravelProgram */ public function setMapHtml($mapHtml) { $this->mapHtml = $mapHtml; return $this; } /** * Get mapHtml * * @return string */ public function getMapHtml() { return $this->mapHtml; } /** * Set mapImage * * @param string $mapImage * * @return TravelProgram */ public function setMapImage($mapImage) { $this->mapImage = $mapImage; return $this; } /** * Get mapImage * * @return string */ public function getMapImage() { return $this->mapImage; } /** * Set mapImageExt * * @param string $mapImageExt * * @return TravelProgram */ public function setMapImageExt($mapImageExt) { $this->mapImageExt = $mapImageExt; return $this; } /** * Get mapImageExt * * @return string */ public function getMapImageExt() { return $this->mapImageExt; } /** * Set travelCountry * * @param integer $travelCountry * * @return TravelProgram */ public function setTravelCountry($travelCountry) { $this->travelCountry = $travelCountry; return $this; } /** * Get travelCountry * * @return integer */ public function getTravelCountry() { return $this->travelCountry; } /** * Set travelCategory * * @param integer $travelCategory * * @return TravelProgram */ public function setTravelCategory($travelCategory) { $this->travelCategory = $travelCategory; return $this; } /** * Get travelCategory * * @return integer */ public function getTravelCategory() { return $this->travelCategory; } /** * Set travelAgenda * * @param integer $travelAgenda * * @return TravelProgram */ public function setTravelAgenda($travelAgenda) { $this->travelAgenda = $travelAgenda; return $this; } /** * Get travelAgenda * * @return integer */ public function getTravelAgenda() { return $this->travelAgenda; } /** * Set nettoPricesInEuro * * @param boolean $nettoPricesInEuro * * @return TravelProgram */ public function setNettoPricesInEuro($nettoPricesInEuro) { $this->nettoPricesInEuro = $nettoPricesInEuro; return $this; } /** * Get nettoPricesInEuro * * @return boolean */ public function getNettoPricesInEuro() { return $this->nettoPricesInEuro; } /** * Set textRight * * @param string $textRight * * @return TravelProgram */ public function setTextRight($textRight) { $this->textRight = $textRight; return $this; } /** * Get textRight * * @return string */ public function getTextRight() { return $this->textRight; } /** * Set defaultFlightPrice * * @param float $defaultFlightPrice * * @return TravelProgram */ public function setDefaultFlightPrice($defaultFlightPrice) { $this->defaultFlightPrice = $defaultFlightPrice; return $this; } /** * Get defaultFlightPrice * * @return float */ public function getDefaultFlightPrice() { return $this->defaultFlightPrice; } /** * Set weekdays * * @param string $weekdays * * @return TravelProgram */ public function setWeekdays($weekdays) { $this->weekdays = $weekdays; return $this; } /** * Get days * * @return array|int[] */ public function getWeekdays() { return $this->weekdays == null ? null : explode(',', $this->weekdays); } /** * @param int $weekday Weekday as returned by date format 'w' * * @return bool */ public function getIsAvailWeekday($weekday) { if ($this->weekdays == null) { return false; } return in_array($weekday, explode(',', $this->weekdays)); } /** * Set position * * @param integer $position * * @return TravelProgram */ public function setPosition($position) { $this->position = $position; return $this; } /** * Get position * * @return integer */ public function getPosition() { return $this->position; } /** * Set discount * * @param float $discount * * @return TravelProgram */ public function setDiscount($discount) { $this->discount = $discount; return $this; } /** * Get discount * * @return float */ public function getDiscount() { return $this->discount; } /** * Set discountIsPercentValue * * @param boolean $discountIsPercentValue * * @return TravelProgram */ public function setDiscountIsPercentValue($discountIsPercentValue) { $this->discountIsPercentValue = $discountIsPercentValue; return $this; } /** * Get discountIsPercentValue * * @return boolean */ public function getDiscountIsPercentValue() { return $this->discountIsPercentValue; } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set travelArrivalPoint * * @param \AppBundle\Entity\TravelArrivalPoint $travelArrivalPoint * * @return TravelProgram */ public function setTravelArrivalPoint(\AppBundle\Entity\TravelArrivalPoint $travelArrivalPoint = null) { $this->travelArrivalPoint = $travelArrivalPoint; return $this; } /** * Get travelArrivalPoint * * @return \AppBundle\Entity\TravelArrivalPoint */ public function getTravelArrivalPoint() { return $this->travelArrivalPoint; } /** * Set organizer * * @param \AppBundle\Entity\TravelOrganizer $organizer * * @return TravelProgram */ public function setOrganizer(\AppBundle\Entity\TravelOrganizer $organizer = null) { $this->organizer = $organizer; return $this; } /** * Get organizer * * @return \AppBundle\Entity\TravelOrganizer */ public function getOrganizer() { return $this->organizer; } /** * Set insurance1 * * @param \AppBundle\Entity\TravelInsurance $insurance1 * * @return TravelProgram */ public function setInsurance1(\AppBundle\Entity\TravelInsurance $insurance1 = null) { $this->insurance1 = $insurance1; return $this; } /** * Get insurance1 * * @return \AppBundle\Entity\TravelInsurance */ public function getInsurance1() { return $this->insurance1; } /** * Set insurance2 * * @param \AppBundle\Entity\TravelInsurance $insurance2 * * @return TravelProgram */ public function setInsurance2(\AppBundle\Entity\TravelInsurance $insurance2 = null) { $this->insurance2 = $insurance2; return $this; } /** * Get insurance2 * * @return \AppBundle\Entity\TravelInsurance */ public function getInsurance2() { return $this->insurance2; } /** * Set category * * @param \AppBundle\Entity\TravelCategory $category * * @return TravelProgram */ public function setCategory(\AppBundle\Entity\TravelCategory $category = null) { $this->category = $category; return $this; } /** * Get category * * @return \AppBundle\Entity\TravelCategory */ public function getCategory() { return $this->category; } /** * Constructor */ public function __construct() { $this->periods = new \Doctrine\Common\Collections\ArrayCollection(); $this->countries = new \Doctrine\Common\Collections\ArrayCollection(); $this->departures = new \Doctrine\Common\Collections\ArrayCollection(); $this->travelDateByKey = []; } /** * Set generalnote * * @param \AppBundle\Entity\TravelGeneralNote $generalnote * * @return TravelGeneralNote */ public function setGeneralnote(\AppBundle\Entity\TravelGeneralNote $generalnote = null) { $this->generalnote = $generalnote; return $this; } /** * Get generalnote * * @return \AppBundle\Entity\TravelGeneralNote */ public function getGeneralnote() { return $this->generalnote; } /** * Add period * * @param \AppBundle\Entity\TravelPeriod $period * * @return TravelProgram */ public function addPeriod(\AppBundle\Entity\TravelPeriod $period) { $this->periods[] = $period; return $this; } /** * Remove period * * @param \AppBundle\Entity\TravelPeriod $period */ public function removePeriod(\AppBundle\Entity\TravelPeriod $period) { $this->periods->removeElement($period); } /** * Get periods * * @return \Doctrine\Common\Collections\Collection|TravelPeriod[] */ public function getPeriods() { return $this->periods; } public function getIsMediated() { return $this->programType == TravelProgram::MEDIATED_PROGRAM_TYPE; } /** * Add departure * * @param \AppBundle\Entity\TravelDeparturePoint $departure * * @return TravelProgram */ public function addDeparture(\AppBundle\Entity\TravelDeparturePoint $departure) { $this->departures[] = $departure; return $this; } /** * Remove departure * * @param \AppBundle\Entity\TravelDeparturePoint $departure */ public function removeDeparture(\AppBundle\Entity\TravelDeparturePoint $departure) { $this->departures->removeElement($departure); } /** * Get departures * * @return \Doctrine\Common\Collections\Collection */ public function getDepartures() { return $this->departures; } /** * Add country * * @param \AppBundle\Entity\TravelCountry $country * * @return TravelProgram */ public function addCountry(\AppBundle\Entity\TravelCountry $country) { $this->countries[] = $country; return $this; } /** * Remove country * * @param \AppBundle\Entity\TravelCountry $country */ public function removeCountry(\AppBundle\Entity\TravelCountry $country) { $this->countries->removeElement($country); } /** * Get countries * * @return \AppBundle\Entity\TravelCountry[]|\Doctrine\Common\Collections\Collection */ public function getCountries() { return $this->countries; } /** * Add image * * @param \AppBundle\Entity\TravelProgramImage $image * * @return TravelProgram */ public function addImage(\AppBundle\Entity\TravelProgramImage $image) { $this->images[] = $image; return $this; } /** * Remove image * * @param \AppBundle\Entity\TravelProgramImage $image */ public function removeImage(\AppBundle\Entity\TravelProgramImage $image) { $this->images->removeElement($image); } /** * Get images * * @return \Doctrine\Common\Collections\Collection|TravelProgramImage[] */ public function getImages() { return $this->images; } private function assertTravelDateNotDefinedYet($key) { if (isset($this->travelDateByKey[$key])) { throw new \Exception('Travel period with key '. $key .' already exists'); } } public function addTravelDateFromNonSeasonTravelPeriod($key, TravelPeriod $travelPeriod, FlightPeriod $flightPeriod = null, $currencyFactor) { $this->assertTravelDateNotDefinedYet($key); $this->travelDateByKey[$key] = TravelDate::createForNonSeasonTravelPeriod($key, $travelPeriod, $flightPeriod, $currencyFactor); } public function addTravelDateFromSeasonTravelPeriod($key, TravelPeriod $travelPeriod, $index, \DateTime $start, \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); } public function addTravelDate($key, TravelPeriod $travelPeriod, FlightPeriod $flightPeriod = null, $currencyFactor, \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); } public function hasTravelDate($key) { return isset($this->travelDateByKey[$key]); } public function getTravelDate($key) { return $this->travelDateByKey[$key] ?? null; } /** * @return TravelDate[]|array */ public function getTravelDates() { if ($this->isTravelDateMapTainted) { ksort($this->travelDateByKey); $this->isTravelDateMapTainted = false; } return $this->travelDateByKey; } public function hasTravelDates() { return !empty($this->travelDateByKey); } public function getIsPossibleStartDate(\DateTime $startDate) { return $this->getIsAvailWeekday(intval($startDate->format('w'))); } public function getLowestPrice() { $lowestPrice = -1; foreach ($this->getTravelDates() as $travelDate) { $curLowestPrice = $travelDate->getLowestPrice(); if ($lowestPrice < 0 || $curLowestPrice < $lowestPrice) { $lowestPrice = $curLowestPrice; } } return $lowestPrice; } /** * Add option * * @param \AppBundle\Entity\TravelOption $option * * @return TravelProgram */ public function addOption(\AppBundle\Entity\TravelOption $option) { $this->options[] = $option; return $this; } /** * Remove option * * @param \AppBundle\Entity\TravelOption $option */ public function removeOption(\AppBundle\Entity\TravelOption $option) { $this->options->removeElement($option); } /** * Get options * * @return TravelOption[]|\Doctrine\Common\Collections\Collection */ public function getOptions() { return $this->options; } public function getPreviewImage() { foreach ($this->getImages() as $image) { if ($image->getType() == 2) { return $image; } } return $this->getImages()[0]; } /** * Set page * * @param \AppBundle\Entity\Page $page * * @return TravelProgram */ public function setPage(\AppBundle\Entity\Page $page = null) { $this->page = $page; return $this; } /** * Get page * * @return \AppBundle\Entity\Page */ public function getPage() { return $this->page; } public function getHasMap() { return ($this->showMap ?? 0) > 0 && ($this->mapHtml or $this->mapImage); } /** * Add destination * * @param \AppBundle\Entity\TravelDestination $destination * * @return TravelProgram */ public function addDestination(\AppBundle\Entity\TravelDestination $destination) { $this->destinations[] = $destination; return $this; } /** * Remove destination * * @param \AppBundle\Entity\TravelDestination $destination */ public function removeDestination(\AppBundle\Entity\TravelDestination $destination) { $this->destinations->removeElement($destination); } /** * Get destinations * * @return \Doctrine\Common\Collections\Collection */ public function getDestinations() { return $this->destinations; } }