<?php

namespace App\Entity;

use App\Repository\PartenaireRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: PartenaireRepository::class)]
class Partenaire
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\ManyToOne(inversedBy: 'partenaires')]
    #[ORM\JoinColumn(nullable: false)]
    private ?User $partenaire = null;

    #[ORM\ManyToOne(inversedBy: 'partenaires')]
    #[ORM\JoinColumn(nullable: false)]
    private ?Societe $societe = null;

    #[ORM\Column(type: Types::DATETIME_MUTABLE)]
    private ?\DateTimeInterface $date_add = null;

    #[ORM\Column]
    private ?bool $active = null;

    #[ORM\ManyToOne]
    private ?User $admin = null;

    #[ORM\Column(type: Types::SMALLINT)]
    private ?int $role = null;

    #[ORM\Column]
    private ?bool $notifier = null;

    #[ORM\Column(nullable: true)]
    private ?array $access = null;

    #[ORM\OneToMany(mappedBy: 'partenaire', targetEntity: ReservationArticleValidation::class)]
    private Collection $reservationArticleValidations;

    #[ORM\Column]
    private ?bool $selected = null;

    #[ORM\OneToMany(mappedBy: 'partenaire', targetEntity: ReservationServiceValidation::class)]
    private Collection $reservationServiceValidations;

    public function __construct()
    {
        $this->active = false;
        $this->notifier = false;
        $this->selected = false;
        $this->role = 1;  // 1 ROLE_PARTNER_ADVANCED   | 2 ROLE_PARTNER
        $this->date_add = new \DateTime();
        $this->reservationArticleValidations = new ArrayCollection();
        $this->reservationServiceValidations = new ArrayCollection();
        
    }

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

    public function getPartenaire(): ?User
    {
        return $this->partenaire;
    }

    public function setPartenaire(?User $partenaire): static
    {
        $this->partenaire = $partenaire;

        return $this;
    }

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

    public function setSociete(?Societe $societe): static
    {
        $this->societe = $societe;

        return $this;
    }

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

    public function setDateAdd(\DateTimeInterface $date_add): static
    {
        $this->date_add = $date_add;

        return $this;
    }

    public function isActive(): ?bool
    {
        return $this->active;
    }

    public function setActive(bool $active): static
    {
        $this->active = $active;

        return $this;
    }

    public function getAdmin(): ?User
    {
        return $this->admin;
    }

    public function setAdmin(?User $admin): static
    {
        $this->admin = $admin;

        return $this;
    }

    public function getRole(): ?int
    {
        return $this->role;
    }

    public function setRole(int $role): static
    {
        $this->role = $role;

        return $this;
    }

    public function isNotifier(): ?bool
    {
        return $this->notifier;
    }

    public function setNotifier(bool $notifier): static
    {
        $this->notifier = $notifier;

        return $this;
    }

    public function getAccess(): ?array
    {
        return $this->access;
    }

    public function setAccess(?array $access): static
    {
        $this->access = $access;

        return $this;
    }

    /**
     * @return Collection<int, ReservationArticleValidation>
     */
    public function getReservationArticleValidations(): Collection
    {
        return $this->reservationArticleValidations;
    }

    public function addReservationArticleValidation(ReservationArticleValidation $reservationArticleValidation): static
    {
        if (!$this->reservationArticleValidations->contains($reservationArticleValidation)) {
            $this->reservationArticleValidations->add($reservationArticleValidation);
            $reservationArticleValidation->setPartenaire($this);
        }

        return $this;
    }

    public function removeReservationArticleValidation(ReservationArticleValidation $reservationArticleValidation): static
    {
        if ($this->reservationArticleValidations->removeElement($reservationArticleValidation)) {
            // set the owning side to null (unless already changed)
            if ($reservationArticleValidation->getPartenaire() === $this) {
                $reservationArticleValidation->setPartenaire(null);
            }
        }

        return $this;
    }

    public function isSelected(): ?bool
    {
        return $this->selected;
    }

    public function setSelected(bool $selected): static
    {
        $this->selected = $selected;

        return $this;
    }

    /**
     * @return Collection<int, ReservationServiceValidation>
     */
    public function getReservationServiceValidations(): Collection
    {
        return $this->reservationServiceValidations;
    }

    public function addReservationServiceValidation(ReservationServiceValidation $reservationServiceValidation): static
    {
        if (!$this->reservationServiceValidations->contains($reservationServiceValidation)) {
            $this->reservationServiceValidations->add($reservationServiceValidation);
            $reservationServiceValidation->setPartenaire($this);
        }

        return $this;
    }

    public function removeReservationServiceValidation(ReservationServiceValidation $reservationServiceValidation): static
    {
        if ($this->reservationServiceValidations->removeElement($reservationServiceValidation)) {
            // set the owning side to null (unless already changed)
            if ($reservationServiceValidation->getPartenaire() === $this) {
                $reservationServiceValidation->setPartenaire(null);
            }
        }

        return $this;
    }

}
