<?php
namespace App\Entity;
use App\Repository\EnterpriseOptionSejourSessionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=EnterpriseOptionSejourSessionRepository::class)
*/
class EnterpriseOptionSejourSession
{
const OPEN = "open";
const VALIDATED = "validated";
const REFUSED = "refused";
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Enterprise::class, inversedBy="enterpriseOptionSejourSessions")
* @ORM\JoinColumn(nullable=false)
*/
private $enterprise;
/**
* @ORM\ManyToOne(targetEntity=EnterpriseRequest::class, inversedBy="enterpriseOptionSejourSessions")
* @ORM\JoinColumn(nullable=true)
*/
private $enterpriseRequest;
/**
* @ORM\ManyToOne(targetEntity=SejourSession::class, inversedBy="enterpriseOptionSejourSessions")
*/
private $sejourSession;
/**
* @ORM\Column(type="integer")
*/
private $nbreSouhaite;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $nbreBooke;
/**
* @ORM\Column(type="datetime")
*/
private $creationDate;
/**
* @ORM\Column(type="datetime")
*/
private $endDate;
/**
* @ORM\OneToMany(targetEntity=Inscription::class, mappedBy="enterpriseOptionSejourSession")
*/
private $inscriptions;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $statut;
/**
* @ORM\OneToMany(targetEntity=Commande::class, mappedBy="enterpriseOptionSejourSession")
*/
private $commandes;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isIndividuel;
public function __construct()
{
$this->inscriptions = new ArrayCollection();
$this->creationDate = new \Datetime();
$this->nbreBooke = 0;
$this->statut = self::OPEN;
$this->commandes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEnterprise(): ?Enterprise
{
return $this->enterprise;
}
public function setEnterprise(?Enterprise $enterprise): self
{
$this->enterprise = $enterprise;
return $this;
}
public function getEnterpriseRequest()
{
return $this->enterpriseRequest;
}
public function setEnterpriseRequest(?EnterpriseRequest $enterpriseRequest): self
{
$this->enterpriseRequest = $enterpriseRequest;
return $this;
}
public function getSejourSession(): ?SejourSession
{
return $this->sejourSession;
}
public function setSejourSession(?SejourSession $sejourSession): self
{
$this->sejourSession = $sejourSession;
return $this;
}
public function getNbreSouhaite(): ?int
{
return $this->nbreSouhaite;
}
public function setNbreSouhaite(int $nbre_souhaite): self
{
$this->nbreSouhaite = $nbre_souhaite;
return $this;
}
public function getNbreBooke(): ?int
{
return $this->nbreBooke;
}
public function getNbreBooke2(): ?int
{
$count = 0;
foreach($this->inscriptions as $inscription){
if($inscription->getStatut() !== Inscription::CANCELLED)
$count ++;
}
}
public function setNbreBooke(?int $nbre_booke): self
{
$this->nbreBooke = $nbre_booke;
return $this;
}
public function getCreationDate(): ?\DateTimeInterface
{
return $this->creationDate;
}
public function setCreationDate(\DateTimeInterface $creationDate): self
{
$this->creationDate = $creationDate;
return $this;
}
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
public function setEndDate(\DateTimeInterface $endDate): self
{
$this->endDate = $endDate;
return $this;
}
/**
* @return Collection|Inscription[]
*/
public function getInscriptions(): Collection
{
return $this->inscriptions;
}
/**
* @return Collection|Inscription[]
*/
public function getInscriptionsValides(): array
{
$output = [];
foreach( $this->inscriptions as $inscription)
if($inscription->getStatut()!== Inscription::CANCELLED) $output[]=$inscription;
return $output;
}
public function addInscription(Inscription $inscription): self
{
if (!$this->inscriptions->contains($inscription)) {
$this->inscriptions[] = $inscription;
$inscription->setEnterpriseOptionSejourSession($this);
}
return $this;
}
public function removeInscription(Inscription $inscription): self
{
if ($this->inscriptions->removeElement($inscription)) {
// set the owning side to null (unless already changed)
if ($inscription->getEnterpriseOptionSejourSession() === $this) {
$inscription->setEnterpriseOptionSejourSession(null);
}
}
return $this;
}
public function getStatut(): ?string
{
return $this->statut;
}
public function setStatut(?string $statut): self
{
$this->statut = $statut;
return $this;
}
/**
* @return Collection<int, Commande>
*/
public function getCommandes(): Collection
{
return $this->commandes;
}
public function addCommande(Commande $commande): self
{
if (!$this->commandes->contains($commande)) {
$this->commandes[] = $commande;
$commande->setEnterpriseOptionSejourSession($this);
}
return $this;
}
public function removeCommande(Commande $commande): self
{
if ($this->commandes->removeElement($commande)) {
// set the owning side to null (unless already changed)
if ($commande->getEnterpriseOptionSejourSession() === $this) {
$commande->setEnterpriseOptionSejourSession(null);
}
}
return $this;
}
public function isIsIndividuel(): ?bool
{
return $this->isIndividuel;
}
public function setIsIndividuel(?bool $isIndividuel): self
{
$this->isIndividuel = $isIndividuel;
return $this;
}
}