<?php
namespace App\Entity;
use App\Repository\InscriptionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=InscriptionRepository::class)
*/
class Inscription
{
const OPEN = "open";
const PART = "part";
const PAID = "complete";
const CANCELLED = "cancelled";
const OPTION = "option";
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Contact::class, inversedBy="inscriptions",cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private $enfant;
/**
* @ORM\ManyToOne(targetEntity=Contact::class, inversedBy="inscriptionParents",cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private $parent;
/**
* @ORM\ManyToOne(targetEntity=Contact::class, inversedBy="inscriptionParents",cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private $responsable;
/**
* @ORM\ManyToOne(targetEntity=SejourSession::class, inversedBy="inscriptions", fetch="EAGER")
* @ORM\JoinColumn(nullable=false)
*/
private $sejourSession;
/**
* @ORM\OneToMany(targetEntity=Compta::class, mappedBy="inscription", cascade={"remove"})
*/
private $comptas;
/**
* @ORM\OneToMany(targetEntity=TiersDeConfiance::class, mappedBy="inscription", cascade={"remove"})
*/
private $tiersDeConfiance;
/**
* @ORM\ManyToOne(targetEntity=MajorationTransport::class, inversedBy="inscriptions")
*/
private $majorationTransportAller;
/**
* @ORM\ManyToOne(targetEntity=MajorationTransport::class, inversedBy="inscriptionsRetour")
*/
private $majorationTransportRetour;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isGOA;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $origin;
/**
* @ORM\ManyToOne(targetEntity=Commande::class, inversedBy="inscription",cascade={"persist"})
*/
private $commande;
/**
* @ORM\OneToMany(targetEntity=Media::class, mappedBy="inscription", cascade={"remove"})
*/
private $medias;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $legacyId;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $statut;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $trancheAge;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $code;
/**
* @ORM\ManyToOne(targetEntity=EnterpriseOptionSejourSession::class, inversedBy="inscriptions")
*/
private $enterpriseOptionSejourSession;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $createdDate;
/**
* @ORM\Column(type="datetime", nullable= true)
*/
private $updatedDate;
/**
* @ORM\OneToMany(targetEntity=ContactForFamilleAccueil::class, mappedBy="inscription",cascade={"persist"})
*/
private $contactForFamilleAccueils;
public function getContactForFamilleAccueils(): Collection
{
return $this->contactForFamilleAccueils;
}
public function addContactForFamilleAccueil(ContactForFamilleAccueil $contact): self
{
if (!$this->contactForFamilleAccueils->contains($contact)) {
$this->contactForFamilleAccueils[] = $contact;
$contact->setInscription($this);
}
return $this;
}
public function __construct()
{
$this->comptas = new ArrayCollection();
$this->medias = new ArrayCollection();
$this->contactForFamilleAccueils = new ArrayCollection();
$this->createdDate = new \DateTimeImmutable();
$this->updatedDate = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getEnfant(): ?Contact
{
return $this->enfant;
}
public function setEnfant(?Contact $enfant): self
{
$this->enfant = $enfant;
return $this;
}
public function getParent(): ?Contact
{
return $this->parent;
}
public function setParent(?Contact $parent): self
{
$this->parent = $parent;
return $this;
}
public function getResponsable(): ?Contact
{
return $this->responsable;
}
public function setResponsable(?Contact $responsable): self
{
$this->responsable = $responsable;
return $this;
}
public function getSejourSession(): ?SejourSession
{
return $this->sejourSession;
}
public function setSejourSession(?SejourSession $sejourSession): self
{
$this->sejourSession = $sejourSession;
return $this;
}
/**
* @return Collection|TiersDeConfiance[]
*/
public function getTiersDeConfiance(): Collection
{
return $this->tiersDeConfiance;
}
public function addTiersDeConfiance(TiersDeConfiance $compta): self
{
if (!$this->tiersDeConfiance->contains($compta)) {
$this->tiersDeConfiance[] = $compta;
$compta->setInscription($this);
}
return $this;
}
public function removeTiersDeConfiance(TiersDeConfiance $compta): self
{
if ($this->tiersDeConfiance->removeElement($compta)) {
// set the owning side to null (unless already changed)
if ($compta->getInscription() === $this) {
$compta->setInscription(null);
}
}
return $this;
}
/**
* @return Collection|Compta[]
*/
public function getComptas(): Collection
{
return $this->comptas;
}
public function addCompta(Compta $compta): self
{
if (!$this->comptas->contains($compta)) {
$this->comptas[] = $compta;
$compta->setInscription($this);
}
return $this;
}
public function removeCompta(Compta $compta): self
{
if ($this->comptas->removeElement($compta)) {
// set the owning side to null (unless already changed)
if ($compta->getInscription() === $this) {
$compta->setInscription(null);
}
}
return $this;
}
public function getMajorationTransportAller(): ?MajorationTransport
{
return $this->majorationTransportAller;
}
public function setMajorationTransportAller(?MajorationTransport $majorationTransportAller): self
{
$this->majorationTransportAller = $majorationTransportAller;
return $this;
}
public function getMajorationTransportRetour(): ?MajorationTransport
{
return $this->majorationTransportRetour;
}
public function setMajorationTransportRetour(?MajorationTransport $majorationTransportRetour): self
{
$this->majorationTransportRetour = $majorationTransportRetour;
return $this;
}
public function getIsGOA(): ?bool
{
return $this->isGOA;
}
public function setIsGOA(?bool $isGOA): self
{
$this->isGOA = $isGOA;
return $this;
}
public function getOrigin(): ?string
{
return $this->origin;
}
public function setOrigin(?string $origin): self
{
$this->origin = $origin;
return $this;
}
public function getCommande(): ?Commande
{
return $this->commande;
}
public function setCommande(?Commande $commande): self
{
$this->commande = $commande;
return $this;
}
/**
* @return Collection|Media[]
*/
public function getMedias(): Collection
{
return $this->medias;
}
public function addMedia(Media $media): self
{
if (!$this->medias->contains($media)) {
$this->medias[] = $media;
$media->setInscription($this);
}
return $this;
}
public function removeMedia(Media $media): self
{
if ($this->medias->removeElement($media)) {
// set the owning side to null (unless already changed)
if ($media->getInscription() === $this) {
$media->setInscription(null);
}
}
return $this;
}
public function getLegacyId(): ?int
{
return $this->legacyId;
}
public function setLegacyId(?int $legacyId): self
{
$this->legacyId = $legacyId;
return $this;
}
public function getStatut(): ?string
{
return $this->statut;
}
public function setStatut(?string $statut): self
{
$this->statut = $statut;
return $this;
}
public function getTrancheAge(): ?string
{
return $this->trancheAge;
}
public function setTrancheAge(?string $statut): self
{
$this->trancheAge = $statut;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
public function getEnterpriseOptionSejourSession(): ?EnterpriseOptionSejourSession
{
return $this->enterpriseOptionSejourSession;
}
public function setEnterpriseOptionSejourSession(?EnterpriseOptionSejourSession $enterpriseOptionSejourSession): self
{
$this->enterpriseOptionSejourSession = $enterpriseOptionSejourSession;
return $this;
}
public function getCreatedDate(): ?\DateTimeImmutable
{
return $this->createdDate;
}
public function setCreatedDate(\DateTimeImmutable $createdDate): self
{
$this->createdDate = $createdDate;
return $this;
}
public function getUpdatedDate(): ?\DateTime
{
return $this->updatedDate;
}
public function setUpdatedDate(\DateTime $createdDate): self
{
$this->updatedDate = $createdDate;
return $this;
}
public function getPaiementOverview(): array
{
$output = [];
foreach ($this->comptas as $compta) {
$output[$compta->getStatut()] = array_key_exists($compta->getStatut(), $output) ? $output[$compta->getStatut()] + $compta->getValeur() : $compta->getValeur();
}
return $output;
}
}