<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * TravelProgram
 *
 * @ORM\Table(name="travel_program", indexes={@ORM\Index(name="FK_travel_program_travel_organizer", columns={"organizer"}), @ORM\Index(name="FK_travel_program_travel_insurance", columns={"insurance_1"}), @ORM\Index(name="FK_travel_program_travel_insurance_2", columns={"insurance_2"}), @ORM\Index(name="FK_travel_program_travel_category", columns={"category_id"}), @ORM\Index(name="FK_travel_program_travel_arrival_point", columns={"travel_arrival_point_id"})})
 * @ORM\Entity(repositoryClass="AppBundle\Entity\TravelProgramRepository")
 */
class TravelProgram
{
    const ORGANIZED_PROGRAM_TYPE = 0;
    const MEDIATED_PROGRAM_TYPE = 1;

    /**
     * @var float
     *
     * @ORM\Column(name="profit_margin", type="float", precision=10, scale=2, nullable=true)
     */
    private $profitMargin = '20.00';

    /**
     * @var string
     *
     * @ORM\Column(name="program_code", type="string", length=255, nullable=true)
     */
    private $programCode;

    /**
     * @var integer
     *
     * @ORM\Column(name="program_duration", type="integer", nullable=true)
     */
    private $programDuration;

    /**
     * @var boolean
     *
     * @ORM\Column(name="is_seasonal", type="boolean", nullable=true)
     */
    private $isSeasonal;

    /**
     * @var boolean
     *
     * @ORM\Column(name="youth", type="boolean", nullable=true)
     */
    private $youth = '0';

    /**
     * @var string
     *
     * @ORM\Column(name="title", type="string", length=255, nullable=true)
     */
    private $title;

    /**
     * @var string
     *
     * @ORM\Column(name="subtitle", type="string", length=255, nullable=true)
     */
    private $subtitle;

    /**
     * @var integer
     *
     * @ORM\Column(name="program_type", type="integer", nullable=true)
     */
    private $programType;

    /**
     * @var boolean
     *
     * @ORM\Column(name="status", type="boolean", nullable=true)
     */
    private $status;

    /**
     * @var string
     *
     * @ORM\Column(name="included", type="text", length=65535, nullable=true)
     */
    private $included;

    /**
     * @var string
     *
     * @ORM\Column(name="class_description", type="text", length=65535, nullable=true)
     */
    private $classDescription;

    /**
     * @var string
     *
     * @ORM\Column(name="excluded", type="text", length=65535, nullable=true)
     */
    private $excluded;

    /**
     * @var string
     *
     * @ORM\Column(name="advices", type="text", length=65535, nullable=true)
     */
    private $advices;

    /**
     * @var string
     *
     * @ORM\Column(name="notes", type="text", length=65535, nullable=true)
     */
    private $notes;

    /**
     * @var string
     *
     * @ORM\Column(name="url", type="string", length=255, nullable=true)
     */
    private $url;

    /**
     * @var integer
     *
     * @ORM\Column(name="max_age_for_children", type="integer", nullable=true)
     */
    private $maxAgeForChildren;

    /**
     * @var string
     *
     * @ORM\Column(name="html_description", type="text", length=65535, nullable=true)
     */
    private $htmlDescription;

    /**
     * @var boolean
     *
     * @ORM\Column(name="in_slider", type="boolean", nullable=false)
     */
    private $inSlider = '0';

    /**
     * @var boolean
     *
     * @ORM\Column(name="show_map", type="boolean", nullable=false)
     */
    private $showMap = '1';

    /**
     * @var string
     *
     * @ORM\Column(name="map_html", type="text", length=65535, nullable=true)
     */
    private $mapHtml;

    /**
     * @var string
     *
     * @ORM\Column(name="map_image", type="string", length=255, nullable=false)
     */
    private $mapImage = '';

    /**
     * @var string
     *
     * @ORM\Column(name="map_image_ext", type="string", length=255, nullable=false)
     */
    private $mapImageExt = '';

    /**
     * @var integer
     *
     * @ORM\Column(name="travel_country", type="integer", nullable=true)
     */
    private $travelCountry;

    /**
     * @var integer
     *
     * @ORM\Column(name="travel_category", type="integer", nullable=true)
     */
    private $travelCategory;

    /**
     * @var integer
     *
     * @ORM\Column(name="travel_agenda", type="integer", nullable=true)
     */
    private $travelAgenda;

    /**
     * @var boolean
     *
     * @ORM\Column(name="netto_prices_in_euro", type="boolean", nullable=true)
     */
    private $nettoPricesInEuro = '0';

    /**
     * @var string
     *
     * @ORM\Column(name="text_right", type="text", length=65535, nullable=true)
     */
    private $textRight;

    /**
     * @var float
     *
     * @ORM\Column(name="default_flight_price", type="float", precision=10, scale=2, nullable=true)
     */
    private $defaultFlightPrice;

    /**
     * @var string
     *
     * @ORM\Column(name="weekdays", type="string", length=255, nullable=true)
     */
    private $weekdays;

    /**
     * @var integer
     *
     * @ORM\Column(name="position", type="smallint", nullable=true)
     */
    private $position;

    /**
     * @var float
     *
     * @ORM\Column(name="discount", type="float", precision=10, scale=0, nullable=true)
     */
    private $discount;

    /**
     * @var boolean
     *
     * @ORM\Column(name="discount_is_percent_value", type="boolean", nullable=true)
     */
    private $discountIsPercentValue;

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var \AppBundle\Entity\TravelArrivalPoint
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelArrivalPoint")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="travel_arrival_point_id", referencedColumnName="id")
     * })
     */
    private $travelArrivalPoint;

    /**
     * @var \AppBundle\Entity\TravelOrganizer
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelOrganizer")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="organizer", referencedColumnName="id")
     * })
     */
    private $organizer;

    /**
     * @var \AppBundle\Entity\TravelInsurance
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelInsurance")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="insurance_1", referencedColumnName="id")
     * })
     */
    private $insurance1;

    /**
     * @var \AppBundle\Entity\TravelInsurance
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelInsurance")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="insurance_2", referencedColumnName="id")
     * })
     */
    private $insurance2;

    /**
     * @var \AppBundle\Entity\TravelCategory
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelCategory")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="category_id", referencedColumnName="id")
     * })
     */
    private $category;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelPeriod", mappedBy="program")
     */
    private $periods;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelDeparturePoint", mappedBy="program")
     */
    private $departures;

    /**
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\TravelCountry", inversedBy="programs")
     * @ORM\JoinTable(name="travel_program_country",
     *     joinColumns={@ORM\JoinColumn(name="program_id", referencedColumnName="id")},
     *     inverseJoinColumns={@ORM\JoinColumn(name="country_id", referencedColumnName="id")}
     * )
     */
    private $countries;

    /**
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\TravelDestination")
     * @ORM\JoinTable(name="travel_program_destination",
     *     joinColumns={@ORM\JoinColumn(name="program_id", referencedColumnName="id")},
     *     inverseJoinColumns={@ORM\JoinColumn(name="destination_id", referencedColumnName="id")}
     * )
     */
    private $destinations;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelProgramImage", mappedBy="program")
     */
    private $images;

    /**
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\TravelOption")
     * @ORM\JoinTable(name="travel_program_option",
     *     joinColumns={@ORM\JoinColumn(name="program_id", referencedColumnName="id")},
     *     inverseJoinColumns={@ORM\JoinColumn(name="option_id", referencedColumnName="id")}
     * )
     */
    private $options;

    /**
     * @ORM\OneToOne(targetEntity="AppBundle\Entity\Page", mappedBy="travelProgram")
     */
    private $page;

    /**
     * @var array|TravelDate[]
     */
    private $travelDateByKey = [];

    private $isTravelDateMapTainted = true;

    /**
     * Set profitMargin
     *
     * @param float $profitMargin
     *
     * @return TravelProgram
     */
    public function setProfitMargin($profitMargin)
    {
        $this->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;
    }

    /**
     * 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 = [];
    }

    /**
     * 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;
    }
}
