<?php
namespace App\Entity;
use App\Repository\ReservationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=ReservationRepository::class)
* @UniqueEntity("token")
*/
class Reservation
{
const RESERVATION_STATUS = [
'demande_first_rdv' => 'Demande de premier RDV',
'en_attente_choix_pack' => 'En attente de choix du pack',
'en_attente_paiement' => 'En attente de paiement',
'en_attente_planning' => 'En attente de planning',
'procedure_completed' => 'Procèdure Complet',
'finished' => 'Terminer',
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotNull(message="This field is required.")
*/
private $firstName;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotNull(message="This field is required.")
*/
private $lastName;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotNull(message="This field is required.")
* @Assert\Email()
*/
private $email;
/**
* @ORM\Column(type="string", length=255)
*/
private $token;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotNull(message="This field is required.")
*/
private $phone;
/**
* @ORM\ManyToOne(targetEntity=CoachingSession::class)
*/
private $formation;
/**
* @ORM\ManyToOne(targetEntity=CoursLangue::class)
*/
private $cour;
/**
* @ORM\ManyToOne(targetEntity=Coach::class, inversedBy="reservations")
* @ORM\JoinColumn(nullable=false)
*/
private $coach;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="reservations")
*/
private $utilisateur;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $status = 'demande_first_rdv';
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $firstRdvAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $firstRdvZoomLink;
/**
* @ORM\ManyToOne(targetEntity=CoachPack::class)
*/
private $pack;
/**
* @ORM\OneToMany(targetEntity=ReservationPlanning::class, mappedBy="reservation", orphanRemoval=true, cascade={"persist", "remove"})
*/
private $reservationPlannings;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $transactionId;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $payedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $remise;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $remiseAmount;
public function __construct()
{
$this->reservationPlannings = new ArrayCollection();
$this->createdAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getCour(): ?CoursLangue
{
return $this->cour;
}
public function setCour(?CoursLangue $cour): self
{
$this->cour = $cour;
return $this;
}
public function getCoach(): ?Coach
{
return $this->coach;
}
public function setCoach(?Coach $coach): self
{
$this->coach = $coach;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(string $token): self
{
$this->token = $token;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getFormation(): ?CoachingSession
{
return $this->formation;
}
public function setFormation(?CoachingSession $formation): self
{
$this->formation = $formation;
return $this;
}
public function getUtilisateur(): ?User
{
return $this->utilisateur;
}
public function setUtilisateur(?User $utilisateur): self
{
$this->utilisateur = $utilisateur;
return $this;
}
public function getStatus(): ?string
{
return $this->status ?? 'demande_first_rdv';
}
public function getFullStatus(): ?string
{
return self::RESERVATION_STATUS[$this->status ?? 'demande_first_rdv'];
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getNextStatus(): string
{
$status = $this->status;
switch ($this->status) {
case 'demande_first_rdv':
$status = 'en_attente_choix_pack';
break;
case 'en_attente_choix_pack':
$status = 'en_attente_paiement';
break;
case 'en_attente_paiement':
$status = 'en_attente_planning';
break;
case 'en_attente_planning':
$status = 'procedure_completed';
break;
case 'procedure_completed':
$status = 'finished';
break;
}
return $status;
}
public function getFirstRdvAt(): ?\DateTimeInterface
{
return $this->firstRdvAt;
}
public function setFirstRdvAt(?\DateTimeInterface $firstRdvAt): self
{
$this->firstRdvAt = $firstRdvAt;
return $this;
}
public function getFirstRdvZoomLink(): ?string
{
return $this->firstRdvZoomLink;
}
public function setFirstRdvZoomLink(?string $firstRdvZoomLink): self
{
$this->firstRdvZoomLink = $firstRdvZoomLink;
return $this;
}
public function getPack(): ?CoachPack
{
return $this->pack;
}
public function setPack(?CoachPack $pack): self
{
$this->pack = $pack;
return $this;
}
/**
* @return Collection|ReservationPlanning[]
*/
public function getReservationPlannings(): Collection
{
return $this->reservationPlannings;
}
public function addReservationPlanning(ReservationPlanning $reservationPlanning): self
{
if (!$this->reservationPlannings->contains($reservationPlanning)) {
$this->reservationPlannings[] = $reservationPlanning;
$reservationPlanning->setReservation($this);
}
return $this;
}
public function removeReservationPlanning(ReservationPlanning $reservationPlanning): self
{
if ($this->reservationPlannings->contains($reservationPlanning)) {
$this->reservationPlannings->removeElement($reservationPlanning);
// set the owning side to null (unless already changed)
if ($reservationPlanning->getReservation() === $this) {
$reservationPlanning->setReservation(null);
}
}
return $this;
}
public function getTransactionId(): ?string
{
return $this->transactionId;
}
public function setTransactionId(?string $transactionId): self
{
$this->transactionId = $transactionId;
return $this;
}
public function getPayedAt(): ?\DateTimeInterface
{
return $this->payedAt;
}
public function setPayedAt(?\DateTimeInterface $payedAt): self
{
$this->payedAt = $payedAt;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getRemise(): ?string
{
return $this->remise;
}
public function setRemise(?string $remise): self
{
$this->remise = $remise;
return $this;
}
public function getRemiseAmount(): ?float
{
return $this->remiseAmount;
}
public function setRemiseAmount(?float $remiseAmount): self
{
$this->remiseAmount = $remiseAmount;
return $this;
}
}