<?php

namespace App\Entity;

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

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

    /**
     * @ORM\ManyToOne(targetEntity=PlanningInitiativeType::class, inversedBy="planningInitiativeDetails")
     * @ORM\JoinColumn(nullable=false, name="idplanning_initiative_type")
     * @Groups({"site_list"})
     */
    private $planning_initiative_type;

    /**
     * @ORM\Column(type="string", length=50)
     * @Groups({"site_list"})
     */
    private $nom;

    /**
     * @ORM\Column(type="string", length=50)
     * @Groups({"site_list"})
     */
    private $prenom;

    /**
     * @ORM\Column(type="string", length=50)
     * @Groups({"site_list"})
     */
    private $societe;

    /**
     * @ORM\Column(type="boolean")
     * @Groups({"site_list"})
     */
    private $actif;

    /**
     * @ORM\OneToMany(targetEntity=Planning::class, mappedBy="planning_initiative_detail")
     */
    private $plannings;

    /**
     * @ORM\OneToMany(targetEntity=PlanningHistoriqueModification::class, mappedBy="planning_initiative_detail")
     */
    private $planningHistoriqueModifications;

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

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

    public function getPlanningInitiativeType(): ?PlanningInitiativeType
    {
        return $this->planning_initiative_type;
    }

    public function setPlanningInitiativeType(?PlanningInitiativeType $planning_initiative_type): self
    {
        $this->planning_initiative_type = $planning_initiative_type;

        return $this;
    }

    /** @SerializedName("initiative_type_name")
     * @Groups({"site_list"})
     */
    public function getInitiativeTypeName() {
        return $this->getPlanningInitiativeType()->getLibelle();
    }

    public function getNom(): ?string
    {
        return $this->nom;
    }

    public function setNom(?string $nom): self
    {
        $this->nom = $nom;

        return $this;
    }

    public function getPrenom(): ?string
    {
        return $this->prenom;
    }

    public function setPrenom(string $prenom): self
    {
        $this->prenom = $prenom;

        return $this;
    }

    public function getSociete(): ?string
    {
        return $this->societe;
    }

    public function setSociete(string $societe): self
    {
        $this->societe = $societe;

        return $this;
    }

    public function getActif(): ?bool
    {
        return $this->actif;
    }

    public function setActif(bool $actif): self
    {
        $this->actif = $actif;

        return $this;
    }

    /**
     * @return Collection<int, Planning>
     */
    public function getPlannings(): Collection
    {
        return $this->plannings;
    }

    public function addPlanning(Planning $planning): self
    {
        if (!$this->plannings->contains($planning)) {
            $this->plannings[] = $planning;
            $planning->setPlanningInitiativeDetail($this);
        }

        return $this;
    }

    public function removePlanning(Planning $planning): self
    {
        if ($this->plannings->removeElement($planning)) {
            // set the owning side to null (unless already changed)
            if ($planning->getPlanningInitiativeDetail() === $this) {
                $planning->setPlanningInitiativeDetail(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, PlanningHistoriqueModification>
     */
    public function getPlanningHistoriqueModifications(): Collection
    {
        return $this->planningHistoriqueModifications;
    }

    public function addPlanningHistoriqueModification(PlanningHistoriqueModification $planningHistoriqueModification): self
    {
        if (!$this->planningHistoriqueModifications->contains($planningHistoriqueModification)) {
            $this->planningHistoriqueModifications[] = $planningHistoriqueModification;
            $planningHistoriqueModification->setPlanningInitiativeDetail($this);
        }

        return $this;
    }

    public function removePlanningHistoriqueModification(PlanningHistoriqueModification $planningHistoriqueModification): self
    {
        if ($this->planningHistoriqueModifications->removeElement($planningHistoriqueModification)) {
            // set the owning side to null (unless already changed)
            if ($planningHistoriqueModification->getPlanningInitiativeDetail() === $this) {
                $planningHistoriqueModification->setPlanningInitiativeDetail(null);
            }
        }

        return $this;
    }
}
