<?php

declare(strict_types=1);

namespace App\Entity\Organization;

use ApiPlatform\Metadata\ApiResource;
use App\Entity\Core\File;
// use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * Configuration de l'IEL pour une organization.
 */
// #[Auditable]
#[ApiResource(operations: [])]
#[ORM\Entity]
class OnlineRegistrationSettings
{
    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    /** @var Collection<int, OnlineRegistrationOpeningPeriod> */
    #[ORM\OneToMany(targetEntity: OnlineRegistrationOpeningPeriod::class, mappedBy: 'onlineRegistrationSettings', cascade: ['persist'], orphanRemoval: true)]
    private Collection $openingPeriods;

    /** @var Collection<int, OnlineRegistrationDocument> */
    #[ORM\OneToMany(targetEntity: OnlineRegistrationDocument::class, mappedBy: 'onlineRegistrationSettings', cascade: ['persist'], orphanRemoval: true)]
    private Collection $documents;

    /** @var Collection<int, OnlineRegistrationDocument> */
    #[ORM\OneToMany(targetEntity: OnlineRegistrationDocument::class, mappedBy: 'guardiansOnlineRegistrationSettings', cascade: ['persist'], orphanRemoval: true)]
    private Collection $guardiansDocuments;

    /** @var Collection<int, File> */
    #[ORM\OneToMany(targetEntity: File::class, mappedBy: 'onlineRegistrationSetting', orphanRemoval: true)]
    private Collection $introductionFiles;

    /** @var Collection<int, File> */
    #[ORM\OneToMany(targetEntity: File::class, mappedBy: 'onlineRegistrationSettingNewEnrolments', orphanRemoval: true)]
    private Collection $introductionFilesNewEnrolments;

    /** @var Collection<int, OnlineRegistrationOpeningPeriod> */
    #[ORM\OneToMany(targetEntity: OnlineRegistrationOpeningPeriod::class, mappedBy: 'onlineRegistrationSettingsNewEnrolments', cascade: ['persist'], orphanRemoval: true)]
    private Collection $openingPeriodsNewEnrolments;

    #[ORM\OneToOne(targetEntity: Organization::class, inversedBy: 'onlineRegistrationSettings', cascade: [])]
    protected ?Organization $organization;

    #[ORM\Column]
    private bool $addNewStudents = false;

    #[ORM\Column]
    private bool $addNewEducations = false;

    /** @var Collection<int, OnlineRegistrationDocument> */
    #[ORM\OneToMany(
        targetEntity: OnlineRegistrationDocument::class,
        mappedBy: 'adultStudentOnlineRegistrationSettings',
        cascade: ['persist'],
        orphanRemoval: true,
    )]
    protected Collection $adultStudentDocuments;

    public function __construct()
    {
        $this->openingPeriods = new ArrayCollection();
        $this->documents = new ArrayCollection();
        $this->guardiansDocuments = new ArrayCollection();
        $this->introductionFiles = new ArrayCollection();
        $this->introductionFilesNewEnrolments = new ArrayCollection();
        $this->openingPeriodsNewEnrolments = new ArrayCollection();
        $this->adultStudentDocuments = new ArrayCollection();
    }

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

    public function setId(?int $id): self
    {
        $this->id = $id;

        return $this;
    }

    /**
     * @return Collection<int, OnlineRegistrationOpeningPeriod>
     */
    public function getOpeningPeriods(): Collection
    {
        return $this->openingPeriods;
    }

    public function addOpeningPeriod(OnlineRegistrationOpeningPeriod $openingPeriod): self
    {
        if (!$this->openingPeriods->contains($openingPeriod)) {
            $this->openingPeriods[] = $openingPeriod;
            $openingPeriod->setOnlineRegistrationSettings($this);
        }

        return $this;
    }

    public function removeOpeningPeriod(OnlineRegistrationOpeningPeriod $openingPeriod): self
    {
        if ($this->openingPeriods->removeElement($openingPeriod)) {
            // set the owning side to null (unless already changed)
            if ($openingPeriod->getOnlineRegistrationSettings() === $this) {
                $openingPeriod->setOnlineRegistrationSettings(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, OnlineRegistrationDocument>
     */
    public function getDocuments(): Collection
    {
        return $this->documents;
    }

    public function addDocument(OnlineRegistrationDocument $document): self
    {
        if (!$this->documents->contains($document)) {
            $this->documents[] = $document;
            $document->setOnlineRegistrationSettings($this);
        }

        return $this;
    }

    public function removeDocument(OnlineRegistrationDocument $document): self
    {
        if ($this->documents->removeElement($document)) {
            // set the owning side to null (unless already changed)
            if ($document->getOnlineRegistrationSettings() === $this) {
                $document->setOnlineRegistrationSettings(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, OnlineRegistrationDocument>
     */
    public function getGuardiansDocuments(): Collection
    {
        return $this->guardiansDocuments;
    }

    public function addGuardiansDocument(OnlineRegistrationDocument $guardiansDocument): self
    {
        if (!$this->guardiansDocuments->contains($guardiansDocument)) {
            $this->guardiansDocuments[] = $guardiansDocument;
            $guardiansDocument->setGuardiansOnlineRegistrationSettings($this);
        }

        return $this;
    }

    public function removeGuardiansDocument(OnlineRegistrationDocument $guardiansDocument): self
    {
        if ($this->guardiansDocuments->removeElement($guardiansDocument)) {
            // set the owning side to null (unless already changed)
            if ($guardiansDocument->getGuardiansOnlineRegistrationSettings() === $this) {
                $guardiansDocument->setGuardiansOnlineRegistrationSettings(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, File>
     */
    public function getIntroductionFiles(): Collection
    {
        return $this->introductionFiles;
    }

    public function addIntroductionFile(File $introductionFile): self
    {
        if (!$this->introductionFiles->contains($introductionFile)) {
            $this->introductionFiles[] = $introductionFile;
            $introductionFile->setOnlineRegistrationSetting($this);
        }

        return $this;
    }

    public function removeIntroductionFile(File $introductionFile): self
    {
        if ($this->introductionFiles->removeElement($introductionFile)) {
            // set the owning side to null (unless already changed)
            if ($introductionFile->getOnlineRegistrationSetting() === $this) {
                $introductionFile->setOnlineRegistrationSetting(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, File>
     */
    public function getIntroductionFilesNewEnrolments(): Collection
    {
        return $this->introductionFilesNewEnrolments;
    }

    public function addIntroductionFilesNewEnrolment(File $introductionFilesNewEnrolment): self
    {
        if (!$this->introductionFilesNewEnrolments->contains($introductionFilesNewEnrolment)) {
            $this->introductionFilesNewEnrolments[] = $introductionFilesNewEnrolment;
            $introductionFilesNewEnrolment->setOnlineRegistrationSettingNewEnrolments($this);
        }

        return $this;
    }

    public function removeIntroductionFilesNewEnrolment(File $introductionFilesNewEnrolment): self
    {
        if ($this->introductionFilesNewEnrolments->removeElement($introductionFilesNewEnrolment)) {
            // set the owning side to null (unless already changed)
            if ($introductionFilesNewEnrolment->getOnlineRegistrationSettingNewEnrolments() === $this) {
                $introductionFilesNewEnrolment->setOnlineRegistrationSettingNewEnrolments(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, OnlineRegistrationOpeningPeriod>
     */
    public function getOpeningPeriodsNewEnrolments(): Collection
    {
        return $this->openingPeriodsNewEnrolments;
    }

    public function addOpeningPeriodsNewEnrolment(OnlineRegistrationOpeningPeriod $openingPeriodsNewEnrolment): self
    {
        if (!$this->openingPeriodsNewEnrolments->contains($openingPeriodsNewEnrolment)) {
            $this->openingPeriodsNewEnrolments[] = $openingPeriodsNewEnrolment;
            $openingPeriodsNewEnrolment->setOnlineRegistrationSettingsNewEnrolments($this);
        }

        return $this;
    }

    public function removeOpeningPeriodsNewEnrolment(OnlineRegistrationOpeningPeriod $openingPeriodsNewEnrolment): self
    {
        if ($this->openingPeriodsNewEnrolments->removeElement($openingPeriodsNewEnrolment)) {
            // set the owning side to null (unless already changed)
            if ($openingPeriodsNewEnrolment->getOnlineRegistrationSettingsNewEnrolments() === $this) {
                $openingPeriodsNewEnrolment->setOnlineRegistrationSettingsNewEnrolments(null);
            }
        }

        return $this;
    }

    public function getOrganization(): ?Organization
    {
        return $this->organization;
    }

    public function setOrganization(?Organization $organization): self
    {
        $this->organization = $organization;

        return $this;
    }

    public function isAddNewStudents(): bool
    {
        return $this->addNewStudents;
    }

    public function setAddNewStudents(bool $addNewStudents): self
    {
        $this->addNewStudents = $addNewStudents;

        return $this;
    }

    public function isAddNewEducations(): bool
    {
        return $this->addNewEducations;
    }

    public function setAddNewEducations(bool $addNewEducations): self
    {
        $this->addNewEducations = $addNewEducations;

        return $this;
    }

    public function getAdultStudentDocuments(): Collection
    {
        return $this->adultStudentDocuments;
    }

    public function addAdultStudentDocument(OnlineRegistrationDocument $adultStudentDocument): self
    {
        if (!$this->adultStudentDocuments->contains($adultStudentDocument)) {
            $this->adultStudentDocuments[] = $adultStudentDocument;
        }

        return $this;
    }

    public function removeAdultStudentDocument(OnlineRegistrationDocument $adultStudentDocument): self
    {
        $this->adultStudentDocuments->removeElement($adultStudentDocument);

        return $this;
    }
}
