<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * TravelDeparturePoint
 *
 * @ORM\Table(name="travel_departure_point", uniqueConstraints={@ORM\UniqueConstraint(name="UK_flight_period_id_name", columns={"flight_period_id", "name"}), @ORM\UniqueConstraint(name="UK_travel_arrival_point_id_name", columns={"travel_arrival_point_id", "name"}), @ORM\UniqueConstraint(name="UK_program_id_name", columns={"program_id", "name"}), @ORM\UniqueConstraint(name="UK_period_id_name", columns={"period_id", "name"})}, indexes={@ORM\Index(name="FK_travel_departure_point_travel_program", columns={"program_id"}), @ORM\Index(name="FK_travel_departure_point_flight_period", columns={"flight_period_id"}), @ORM\Index(name="FK_travel_departure_point_travel_arrival_point", columns={"travel_arrival_point_id"})})
 * @ORM\Entity(repositoryClass="AppBundle\Entity\TravelDeparturePointRepository")
 */
class TravelDeparturePoint
{
    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=255, nullable=true)
     */
    private $name;

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

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

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

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

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

    /**
     * @var \AppBundle\Entity\FlightPeriod
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\FlightPeriod", inversedBy="departures")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="flight_period_id", referencedColumnName="id")
     * })
     */
    private $flightPeriod;

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

    /**
     * @var \AppBundle\Entity\TravelProgram
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelProgram", inversedBy="departures")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="program_id", referencedColumnName="id")
     * })
     */
    private $program;

    /**
     * @var TravelPeriod
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\TravelPeriod", inversedBy="departures")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="period_id", referencedColumnName="id")
     * })
     */
    private $travelPeriod;

    private $isVirtual = null;

    /**
     * Set name
     *
     * @param string $name
     *
     * @return TravelDeparturePoint
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set extraCharge
     *
     * @param string $extraCharge
     *
     * @return TravelDeparturePoint
     */
    public function setExtraCharge($extraCharge)
    {
        $this->extraCharge = $extraCharge;

        return $this;
    }

    /**
     * Get extraCharge
     *
     * @return float
     */
    public function getExtraCharge()
    {
        return ($this->extraCharge === null || $this->extraCharge === '') ? null : floatval($this->extraCharge);
    }

    /**
     * Set days
     *
     * @param string $days
     *
     * @return TravelDeparturePoint
     */
    public function setDays($days)
    {
        $this->days = $days;

        return $this;
    }

    /**
     * Get days
     *
     * @return array|int[]
     */
    public function getDays()
    {
        return $this->days == null ? null : json_decode($this->days);
    }

    /**
     * Set departureType
     *
     * @param string $departureType
     *
     * @return TravelDeparturePoint
     */
    public function setDepartureType($departureType)
    {
        $this->departureType = $departureType;

        return $this;
    }

    /**
     * Get departureType
     *
     * @return string
     */
    public function getDepartureType()
    {
        return $this->departureType;
    }

    /**
     * Set threeLetter
     *
     * @param string $threeLetter
     *
     * @return TravelDeparturePoint
     */
    public function setThreeLetter($threeLetter)
    {
        $this->three_letter = $threeLetter;

        return $this;
    }

    /**
     * Get threeLetter
     *
     * @return string
     */
    public function getThreeLetter()
    {
        return $this->three_letter;
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set flightPeriod
     *
     * @param \AppBundle\Entity\FlightPeriod $flightPeriod
     *
     * @return TravelDeparturePoint
     */
    public function setFlightPeriod(\AppBundle\Entity\FlightPeriod $flightPeriod = null)
    {
        $this->flightPeriod = $flightPeriod;

        return $this;
    }

    /**
     * Get flightPeriod
     *
     * @return \AppBundle\Entity\FlightPeriod
     */
    public function getFlightPeriod()
    {
        return $this->flightPeriod;
    }

    /**
     * Set travelArrivalPoint
     *
     * @param \AppBundle\Entity\TravelArrivalPoint $travelArrivalPoint
     *
     * @return TravelDeparturePoint
     */
    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 program
     *
     * @param \AppBundle\Entity\TravelProgram $program
     *
     * @return TravelDeparturePoint
     */
    public function setProgram(\AppBundle\Entity\TravelProgram $program = null)
    {
        $this->program = $program;

        return $this;
    }

    /**
     * Get program
     *
     * @return \AppBundle\Entity\TravelProgram
     */
    public function getProgram()
    {
        return $this->program;
    }

    /**
     * Set travelPeriod
     *
     * @param \AppBundle\Entity\TravelPeriod $travelPeriod
     *
     * @return TravelDeparturePoint
     */
    public function setTravelPeriod(\AppBundle\Entity\TravelPeriod $travelPeriod = null)
    {
        $this->travelPeriod = $travelPeriod;

        return $this;
    }

    /**
     * Get travelPeriod
     *
     * @return \AppBundle\Entity\TravelPeriod
     */
    public function getTravelPeriod()
    {
        return $this->travelPeriod;
    }

    public function getIsEmpty()
    {
        return !isset($this->extraCharge) || $this->extraCharge == '';
    }

    /**
     * @return boolean
     */
    public function getIsVirtual()
    {
        return $this->isVirtual;
    }

    /**
     * @param boolean $isVirtual
     */
    public function setIsVirtual($isVirtual)
    {
        $this->isVirtual = $isVirtual;
    }

    public function __toString()
    {
        return $this->getName() .' ('. number_format($this->getExtraCharge(), 2, ',', '.') .' €)';
    }
}
