<?php

namespace AppBundle\Entity;

use AppBundle\Utils\Traits\StatusTrait;
use AppBundle\Utils\Traits\TimestampableTrait;
use Doctrine\ORM\Mapping as ORM;

/**
 * Product
 *
 * @ORM\Table(name="product")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\ProductRepository")
 * @ORM\HasLifecycleCallbacks()
 */
class Product
{

    use TimestampableTrait;
    use StatusTrait;

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

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Company", inversedBy="products")
     * @ORM\JoinColumn(nullable=false)
     */
    private $company;

    /**
     * @var string
     *
     * @ORM\Column(name="type", type="text")
     */
    private $type;

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

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

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

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="products")
     */
    private $user;

    /***********************
     * Constructor
     ***********************/

    public function __construct($user = null, $type = null)
    {
        $this->user = $user;
        $this->company = $user->getCompany();
        $this->type = $type;
        $this->status = "AVAILABLE";
    }

    /***********************
     * Getters & Setters
     ***********************/


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

    /**
     * Set type.
     *
     * @param string $type
     *
     * @return Product
     */
    public function setType($type)
    {
        $this->type = $type;

        return $this;
    }

    /**
     * Get type.
     *
     * @return string
     */
    public function getType()
    {
        return $this->type;
    }

    /**
     * Set startDate.
     *
     * @param \DateTime $startDate
     *
     * @return Product
     */
    public function setStartDate($startDate)
    {
        $this->startDate = $startDate;

        return $this;
    }

    /**
     * Get startDate.
     *
     * @return \DateTime
     */
    public function getStartDate()
    {
        return $this->startDate;
    }

    /**
     * Set stopDate.
     *
     * @param \DateTime $stopDate
     *
     * @return Product
     */
    public function setStopDate($stopDate)
    {
        $this->stopDate = $stopDate;

        return $this;
    }

    /**
     * Get stopDate.
     *
     * @return \DateTime
     */
    public function getStopDate()
    {
        return $this->stopDate;
    }

    /**
     * Set lifetime.
     *
     * @param \DateTime $lifetime
     *
     * @return Product
     */
    public function setLifetime($lifetime)
    {
        $this->lifetime = $lifetime;

        return $this;
    }

    /**
     * Get lifetime.
     *
     * @return \DateTime
     */
    public function getLifetime()
    {
        return $this->lifetime;
    }

    /**
     * Set company.
     *
     * @param \AppBundle\Entity\Company $company
     *
     * @return Product
     */
    public function setCompany(\AppBundle\Entity\Company $company)
    {
        $this->company = $company;

        return $this;
    }

    /**
     * Get company.
     *
     * @return \AppBundle\Entity\Company
     */
    public function getCompany()
    {
        return $this->company;
    }

    /**
     * Set user.
     *
     * @param \AppBundle\Entity\User|null $user
     *
     * @return Product
     */
    public function setUser(\AppBundle\Entity\User $user = null)
    {
        $this->user = $user;

        return $this;
    }

    /**
     * Get user.
     *
     * @return \AppBundle\Entity\User|null
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     * Set productAd.
     *
     * @param \AppBundle\Entity\ProductAd|null $productAd
     *
     * @return Product
     */
    public function setProductAd(\AppBundle\Entity\ProductAd $productAd = null)
    {
        $this->productAd = $productAd;

        return $this;
    }

    /**
     * Get productAd.
     *
     * @return \AppBundle\Entity\ProductAd|null
     */
    public function getProductAd()
    {
        return $this->productAd;
    }
}
