<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * TravelBooking
 *
 * @ORM\Table(name="travel_booking", indexes={@ORM\Index(name="FK_travel_booking_travel_period", columns={"period_id"}), @ORM\Index(name="FK_travel_booking_travel_program", columns={"program_id"})})
 * @ORM\Entity(repositoryClass="AppBundle\Entity\TravelBookingRepository")
 */
class TravelBooking
{
    /**
     * @var string
     *
     * @ORM\Column(name="ip", type="string", length=255, nullable=true)
     */
    private $ip;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="created", type="datetime", nullable=true)
     */
    private $created;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="selected_start_date", type="date", nullable=true)
     */
    private $selectedStartDate;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="selected_end_date", type="date", nullable=true)
     */
    private $selectedEndDate;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



    /**
     * Set ip
     *
     * @param string $ip
     *
     * @return TravelBooking
     */
    public function setIp($ip)
    {
        $this->ip = $ip;

        return $this;
    }

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

    /**
     * Set created
     *
     * @param \DateTime $created
     *
     * @return TravelBooking
     */
    public function setCreated($created)
    {
        $this->created = $created;

        return $this;
    }

    /**
     * Get created
     *
     * @return \DateTime
     */
    public function getCreated()
    {
        return $this->created;
    }

    /**
     * Set programName
     *
     * @param string $programName
     *
     * @return TravelBooking
     */
    public function setProgramName($programName)
    {
        $this->programName = $programName;

        return $this;
    }

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

    /**
     * Set programId
     *
     * @param integer $programId
     *
     * @return TravelBooking
     */
    public function setProgramId($programId)
    {
        $this->programId = $programId;

        return $this;
    }

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

    /**
     * Set periodId
     *
     * @param integer $periodId
     *
     * @return TravelBooking
     */
    public function setPeriodId($periodId)
    {
        $this->periodId = $periodId;

        return $this;
    }

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

    /**
     * Set class
     *
     * @param string $class
     *
     * @return TravelBooking
     */
    public function setClass($class)
    {
        $this->class = $class;

        return $this;
    }

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

    /**
     * Set salutation
     *
     * @param integer $salutation
     *
     * @return TravelBooking
     */
    public function setSalutation($salutation)
    {
        $this->salutation = $salutation;

        return $this;
    }

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

    /**
     * Set firstName
     *
     * @param string $firstName
     *
     * @return TravelBooking
     */
    public function setFirstName($firstName)
    {
        $this->firstName = $firstName;

        return $this;
    }

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

    /**
     * Set lastName
     *
     * @param string $lastName
     *
     * @return TravelBooking
     */
    public function setLastName($lastName)
    {
        $this->lastName = $lastName;

        return $this;
    }

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

    /**
     * Set street
     *
     * @param string $street
     *
     * @return TravelBooking
     */
    public function setStreet($street)
    {
        $this->street = $street;

        return $this;
    }

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

    /**
     * Set houseNr
     *
     * @param string $houseNr
     *
     * @return TravelBooking
     */
    public function setHouseNr($houseNr)
    {
        $this->houseNr = $houseNr;

        return $this;
    }

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

    /**
     * Set zipcode
     *
     * @param string $zipcode
     *
     * @return TravelBooking
     */
    public function setZipcode($zipcode)
    {
        $this->zipcode = $zipcode;

        return $this;
    }

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

    /**
     * Set city
     *
     * @param string $city
     *
     * @return TravelBooking
     */
    public function setCity($city)
    {
        $this->city = $city;

        return $this;
    }

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

    /**
     * Set country
     *
     * @param integer $country
     *
     * @return TravelBooking
     */
    public function setCountry($country)
    {
        $this->country = $country;

        return $this;
    }

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

    /**
     * Set mail
     *
     * @param string $mail
     *
     * @return TravelBooking
     */
    public function setMail($mail)
    {
        $this->mail = $mail;

        return $this;
    }

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

    /**
     * Set phone
     *
     * @param string $phone
     *
     * @return TravelBooking
     */
    public function setPhone($phone)
    {
        $this->phone = $phone;

        return $this;
    }

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

    /**
     * Set fax
     *
     * @param string $fax
     *
     * @return TravelBooking
     */
    public function setFax($fax)
    {
        $this->fax = $fax;

        return $this;
    }

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

    /**
     * Set selectedDeparture
     *
     * @param string $selectedDeparture
     *
     * @return TravelBooking
     */
    public function setSelectedDeparture($selectedDeparture)
    {
        $this->selectedDeparture = is_array($selectedDeparture) ? json_encode($selectedDeparture) : $selectedDeparture;

        return $this;
    }

    /**
     * Get selectedDeparture
     *
     * @return string
     */
    public function getSelectedDeparture()
    {
        $ret = json_decode($this->selectedDeparture, true);
        if (empty($ret) || !is_array($ret))
        {
            return $this->selectedDeparture;
        }
        return $ret;
    }

    /**
     * Set selectedStartDate
     *
     * @param \DateTime $selectedStartDate
     *
     * @return TravelBooking
     */
    public function setSelectedStartDate($selectedStartDate)
    {
        $this->selectedStartDate = $selectedStartDate;

        return $this;
    }

    /**
     * Get selectedStartDate
     *
     * @return \DateTime
     */
    public function getSelectedStartDate()
    {
        return $this->selectedStartDate;
    }

    /**
     * Set selectedEndDate
     *
     * @param \DateTime $selectedEndDate
     *
     * @return TravelBooking
     */
    public function setSelectedEndDate($selectedEndDate)
    {
        $this->selectedEndDate = $selectedEndDate;

        return $this;
    }

    /**
     * Get selectedEndDate
     *
     * @return \DateTime
     */
    public function getSelectedEndDate()
    {
        return $this->selectedEndDate;
    }

    /**
     * Set selectedAdults
     *
     * @param integer $selectedAdults
     *
     * @return TravelBooking
     */
    public function setSelectedAdults($selectedAdults)
    {
        $this->selectedAdults = $selectedAdults;

        return $this;
    }

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

    /**
     * Set selectedChild1
     *
     * @param integer $selectedChild1
     *
     * @return TravelBooking
     */
    public function setSelectedChild1($selectedChild1)
    {
        $this->selectedChild1 = $selectedChild1;

        return $this;
    }

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

    /**
     * Set selectedChild2
     *
     * @param integer $selectedChild2
     *
     * @return TravelBooking
     */
    public function setSelectedChild2($selectedChild2)
    {
        $this->selectedChild2 = $selectedChild2;

        return $this;
    }

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

    /**
     * Set selectedChild3
     *
     * @param integer $selectedChild3
     *
     * @return TravelBooking
     */
    public function setSelectedChild3($selectedChild3)
    {
        $this->selectedChild3 = $selectedChild3;

        return $this;
    }

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

    /**
     * Set rooms
     *
     * @param string $rooms
     *
     * @return TravelBooking
     */
    public function setRooms($rooms)
    {
        $this->options = is_array($rooms) ? json_encode($rooms) : $rooms;

        return $this;
    }

    /**
     * Get rooms
     *
     * @return string
     */
    public function getRooms()
    {
        $ret = json_decode($this->rooms, true);
        if (empty($ret) || !is_array($ret))
        {
            return $this->rooms;
        }
        return $ret;
    }

    /**
     * Set participants
     *
     * @param Traveler[] $travelers
     *
     * @return TravelBooking
     */
    public function setParticipants($travelers)
    {
        if (!is_array($travelers))
        {
            $this->participants = $travelers;
            return $this;
        }

        $participants = [];

        for ($i = 0; $i < count($travelers); ++$i)
        {
            $traveler = $travelers[$i];

            $birthdate = $traveler->getBirthDate();
            if(!strtotime($birthdate)){
                $birthdate = '01.01.1900';
            }
            $participants[''. ($i+1)] = [
                'gender' => $traveler->getSex(),
                'first_name' => $traveler->getFirstName(),
                'last_name' => $traveler->getLastName(),
                'birthday' => $birthdate,
            ];
        }

        $this->participants = json_encode($participants);

        return $this;
    }

    /**
     * Get participants
     *
     * @return string
     */
    public function getParticipants()
    {
        $participants = json_decode($this->participants, true);
        if (empty($participants) || !is_array($participants))
        {
            return $this->participants;
        }
        $ret = [];
        foreach ($participants as $participant)
        {
            $traveler = new Traveler();
            $traveler->setSex(intval($participant['gender']));
            $traveler->setFirstName($participant['first_name']);
            $traveler->setLastName($participant['last_name']);
            if(!strtotime($participant['birthday'])){
                $participant['birthday'] = '01.01.1900';
            }
            $traveler->setBirthDate(\DateTime::createFromFormat('d.m.Y', $participant['birthday']));
            $ret[] = $traveler;
        }
        return $ret;
    }

    /**
     * Set participantsTotal
     *
     * @param integer $participantsTotal
     *
     * @return TravelBooking
     */
    public function setParticipantsTotal($participantsTotal)
    {
        $this->participantsTotal = $participantsTotal;

        return $this;
    }

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

    /**
     * Set priceTotal
     *
     * @param float $priceTotal
     *
     * @return TravelBooking
     */
    public function setPriceTotal($priceTotal)
    {
        $this->priceTotal = $priceTotal;

        return $this;
    }

    /**
     * Get priceTotal
     *
     * @return float
     */
    public function getPriceTotal()
    {
        return $this->priceTotal;
    }

    /**
     * Set comments
     *
     * @param string $comments
     *
     * @return TravelBooking
     */
    public function setComments($comments)
    {
        $this->comments = $comments;

        return $this;
    }

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

    /**
     * Set insuranceName
     *
     * @param string $insuranceName
     *
     * @return TravelBooking
     */
    public function setInsuranceName($insuranceName)
    {
        $this->insuranceName = $insuranceName;

        return $this;
    }

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

    /**
     * Set insurances
     *
     * @param string $insurances
     *
     * @return TravelBooking
     */
    public function setInsurances($insurances)
    {
        $this->insurances = is_array($insurances) ? json_encode($insurances) : $insurances;

        return $this;
    }

    /**
     * Get insurances
     *
     * @return string
     */
    public function getInsurances()
    {
        $ret = json_decode($this->insurances, true);
        if (empty($ret) || !is_array($ret))
        {
            return $this->insurances;
        }
        return $ret;
    }

     /**
     * Set travelCancellation
     *
     * @param string $travelCancellation
     *
     * @return TravelBooking
     */
    public function setTravelCancellation($travelCancellation)
    {
        $this->travelCancellation = $travelCancellation;

        return $this;
    }

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


    /**
     * Set options
     *
     * @param string $options
     *
     * @return TravelBooking
     */
    public function setOptions($options)
    {
        $this->options = is_array($options) ? json_encode($options) : $options;

        return $this;
    }

    /**
     * Get options
     *
     * @return string
     */
    public function getOptions()
    {
        $ret = json_decode($this->options, true);
        if (empty($ret) || !is_array($ret))
        {
            return $this->options;
        }
        return $ret;
    }

    /**
     * Set classOptions
     *
     * @param string $classOptions
     *
     * @return TravelBooking
     */
    public function setClassOptions($classOptions)
    {
        $this->classOptions = is_array($classOptions) ? json_encode($classOptions) : $classOptions;

        return $this;
    }

    /**
     * Get classOptions
     *
     * @return string
     */
    public function getClassOptions()
    {
        $ret = json_decode($this->classOptions, true);
        if (empty($ret) || !is_array($ret))
        {
            return $this->classOptions;
        }
        return $ret;
    }

    /**
     * Set extraCategory
     *
     * @param string $extraCategory
     *
     * @return TravelBooking
     */
    public function setExtraCategory($extraCategory)
    {
        $this->extraCategory = is_array($extraCategory) ? json_encode($extraCategory) : $extraCategory;

        return $this;
    }

    /**
     * Get extraCategory
     *
     * @return string
     */
    public function getExtraCategory()
    {
        $ret = json_decode($this->extraCategory, true);
        if (empty($ret) || !is_array($ret))
        {
            return $this->extraCategory;
        }
        return $ret;
    }

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