<?php

namespace App\Entity;

use App\Repository\SectorisationVersionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Ignore;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ORM\Entity(repositoryClass=SectorisationVersionRepository::class)
 * @ORM\Table(schema="sav")
 */
class SectorisationVersion
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"map"})
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity=Site::class, inversedBy="sectorisationVersions")
     * @ORM\JoinColumn(name="idsite")
     * @Groups({"map"})
     */
    private $site;

    /**
     * @ORM\Column(type="date", nullable=true)
     * @Groups({"map"})
     */
    private $date_debut;

    /**
     * @ORM\Column(type="date", nullable=true)
     * @Groups({"map"})
     */
    private $date_fin;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     * @Groups({"map"})
     */
    private $date_modification;

    /**
     * @ORM\ManyToOne(targetEntity=Utilisateur::class, inversedBy="sectorisationVersions")
     * @ORM\JoinColumn(name="idutilisateur")
     * @Groups({"map"})
     */
    private $utilisateur;

    /**
     * @ORM\Column(type="text", nullable=true)
     * @Groups({"map"})
     */
    private $commentaire;

    /**
     * @ORM\Column(type="boolean", nullable=true)
     * @Groups({"map"})
     */
    private $en_prod = false;

    /**
     * @ORM\OneToMany(targetEntity=Secteur::class, mappedBy="sectorisation_version")
     * @Ignore()
     */
    private $secteurs;

    public function __construct()
    {
        $this->secteurs = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getSite(): ?Site
    {
        return $this->site;
    }

    public function setSite(?Site $site): self
    {
        $this->site = $site;

        return $this;
    }

    public function getDateDebut(): ?\DateTimeInterface
    {
        return $this->date_debut;
    }

    public function setDateDebut(?\DateTimeInterface $date_debut): self
    {
        $this->date_debut = $date_debut;

        return $this;
    }

    public function getDateFin(): ?\DateTimeInterface
    {
        return $this->date_fin;
    }

    public function setDateFin(?\DateTimeInterface $date_fin): self
    {
        $this->date_fin = $date_fin;

        return $this;
    }

    public function getDateModification(): ?\DateTimeInterface
    {
        return $this->date_modification;
    }

    public function setDateModification(?\DateTimeInterface $date_modification): self
    {
        $this->date_modification = $date_modification;

        return $this;
    }

    public function getUtilisateur(): ?Utilisateur
    {
        return $this->utilisateur;
    }

    public function setUtilisateur(?Utilisateur $utilisateur): self
    {
        $this->utilisateur = $utilisateur;

        return $this;
    }

    public function getCommentaire(): ?string
    {
        return $this->commentaire;
    }

    public function setCommentaire(?string $commentaire): self
    {
        $this->commentaire = $commentaire;

        return $this;
    }

    public function getEnProd(): ?bool
    {
        return $this->en_prod;
    }

    public function setEnProd(?bool $en_prod): self
    {
        $this->en_prod = $en_prod;

        return $this;
    }

    /**
     * @return Collection<int, Secteur>
     */
    public function getSecteurs(): Collection
    {
        return $this->secteurs;
    }

    public function addSecteur(Secteur $secteur): self
    {
        if (!$this->secteurs->contains($secteur)) {
            $this->secteurs[] = $secteur;
            $secteur->setSectorisationVersion($this);
        }

        return $this;
    }

    public function removeSecteur(Secteur $secteur): self
    {
        if ($this->secteurs->removeElement($secteur)) {
            // set the owning side to null (unless already changed)
            if ($secteur->getSectorisationVersion() === $this) {
                $secteur->setSectorisationVersion(null);
            }
        }

        return $this;
    }
}
