<?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="App\Repository\GoalRepository")
 */
class Goal
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=16)
     */
    private $code;

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

     /**
     * @ORM\OneToMany(targetEntity="App\Entity\Target", mappedBy="goal", orphanRemoval=true)
     */
    private $targets;

    /**
     * @ORM\Column(type="string", length=8)
     */
    private $color;

    /**
     * @ORM\Column(type="text", nullable=true)
     */
    private $description;

    /**
     * @ORM\ManyToMany(targetEntity="App\Entity\Commune")
     */
    private $communes;

    /**
     * @ORM\ManyToOne(targetEntity=Mainstay::class, inversedBy="goals")
     * @ORM\JoinColumn(nullable=true)
     */
    private $mainstay;

    /**
     * @ORM\ManyToMany(targetEntity=Costing::class, mappedBy="goals")
     */
    private $costings;

    /**
     * @ORM\OneToMany(targetEntity=ActivityPTA::class, mappedBy="goal")
     */
    private $activityPTAs;

    /**
     * @ORM\OneToMany(targetEntity=ActivityOSC::class, mappedBy="goal")
     */
    private $activityOSCs;

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

    /**
     * @var array
     * @ORM\Column(type="json", nullable=true)
     */
    private $alignement;


    public function __construct()
    {
        $this->targets = new ArrayCollection();
        $this->communes = new ArrayCollection();
        $this->alignement = array();
        //$this->costings = new ArrayCollection();
        //$this->activityPTAs = new ArrayCollection();
        //$this->activityOSCs = new ArrayCollection();
    }

    public function __toString()
    {
        return $this->getCode() . ' - ' . $this->getName();
    }

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

    public function getCode(): ?string
    {
        return $this->code;
    }

    public function setCode(string $code): self
    {
        $this->code = $code;

        return $this;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

    /**
     * @return Collection|Target[]
     */
    public function getTargets(): Collection
    {
        return $this->targets;
    }

    public function addTarget(Target $target): self
    {
        if (!$this->targets->contains($target)) {
            $this->targets[] = $target;
            $target->setGoal($this);
        }

        return $this;
    }

    public function removeTarget(Target $target): self
    {
        if ($this->targets->contains($target)) {
            $this->targets->removeElement($target);
            // set the owning side to null (unless already changed)
            if ($target->getGoal() === $this) {
                $target->setGoal(null);
            }
        }

        return $this;
    }

    public function getColor(): ?string
    {
        return $this->color;
    }

    public function setColor(string $color): self
    {
        $this->color = $color;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(?string $description): self
    {
        $this->description = $description;

        return $this;
    }

    /**
     * @return Collection|Commune[]
     */
    public function getCommunes(): Collection
    {
        return $this->communes;
    }

    public function addCommune(Commune $commune): self
    {
        if (!$this->communes->contains($commune)) {
            $this->communes[] = $commune;
        }

        return $this;
    }

    public function removeCommune(Commune $commune): self
    {
        if ($this->communes->contains($commune)) {
            $this->communes->removeElement($commune);
        }

        return $this;
    }

    public function getMainstay(): ?Mainstay
    {
        return $this->mainstay;
    }

    public function setMainstay(?Mainstay $mainstay): self
    {
        $this->mainstay = $mainstay;

        return $this;
    }

    /**
     * @return Collection|Costing[]
     */
    /*public function getCostings(): Collection
    {
        return $this->costings;
    }

    public function addCosting(Costing $costing): self
    {
        if (!$this->costings->contains($costing)) {
            $this->costings[] = $costing;
            $costing->addGoal($this);
        }

        return $this;
    }

    public function removeCosting(Costing $costing): self
    {
        if ($this->costings->contains($costing)) {
            $this->costings->removeElement($costing);
            $costing->removeGoal($this);
        }

        return $this;
    }*/

    /**
     * @return Collection|ActivityPTA[]
     */
    /*public function getActivityPTAs(): Collection
    {
        return $this->activityPTAs;
    }

    public function addActivityPTA(ActivityPTA $activityPTA): self
    {
        if (!$this->activityPTAs->contains($activityPTA)) {
            $this->activityPTAs[] = $activityPTA;
            $activityPTA->setGoal($this);
        }

        return $this;
    }

    public function removeActivityPTA(ActivityPTA $activityPTA): self
    {
        if ($this->activityPTAs->contains($activityPTA)) {
            $this->activityPTAs->removeElement($activityPTA);
            // set the owning side to null (unless already changed)
            if ($activityPTA->getGoal() === $this) {
                $activityPTA->setGoal(null);
            }
        }

        return $this;
    }*/

    /**
     * @return Collection|ActivityOSC[]
     */
    /*public function getActivityOSCs(): Collection
    {
        return $this->activityOSCs;
    }

    public function addActivityOSC(ActivityOSC $activityOSC): self
    {
        if (!$this->activityOSCs->contains($activityOSC)) {
            $this->activityOSCs[] = $activityOSC;
            $activityOSC->setGoal($this);
        }

        return $this;
    }

    public function removeActivityOSC(ActivityOSC $activityOSC): self
    {
        if ($this->activityOSCs->contains($activityOSC)) {
            $this->activityOSCs->removeElement($activityOSC);
            // set the owning side to null (unless already changed)
            if ($activityOSC->getGoal() === $this) {
                $activityOSC->setGoal(null);
            }
        }

        return $this;
    }*/

    public function getAgenda(): ?int
    {
        return $this->agenda;
    }

    public function setAgenda(?int $agenda): self
    {
        $this->agenda = $agenda;

        return $this;
    }

    public function getAlignement() : ?array
    {
        return $this->alignement;
    }

    public function setAlignement($alignement): self
    {
        $this->alignement = $alignement;

        return $this;
    }

}
