<?php
namespace App\Entity;
use App\Repository\InscriptionSessionFormationRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: InscriptionSessionFormationRepository::class)]
class InscriptionSessionFormation
{
public const STATUS_ARRAY = [
'WAITING' => 'en cours',
'VALIDATED' => 'validée',
'REFUSED' => 'proposition',
];
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $fonction = null;
#[ORM\ManyToOne(inversedBy: 'inscriptionSessionFormations')]
private ?User $user = null;
#[ORM\Column(length: 255)]
private ?string $tel = null;
#[ORM\Column(length: 255)]
private ?string $mail = null;
#[ORM\ManyToOne(inversedBy: 'inscriptionSessionFormations', cascade: ['persist'])]
private ?Sessionsformation $sessionFormation = null;
#[ORM\Column(type: 'string', nullable:false, options:[ 'default' => self::STATUS_ARRAY['WAITING'] ])]
private $status = self::STATUS_ARRAY['WAITING'] ;
#[ORM\Column(type: Types::TEXT, nullable:true)]
private ?string $motif = null;
public function getId(): ?int
{
return $this->id;
}
public function getFonction(): ?string
{
return $this->fonction;
}
public function setFonction(string $fonction): self
{
$this->fonction = $fonction;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getTel(): ?string
{
return $this->tel;
}
public function setTel(string $tel): self
{
$this->tel = $tel;
return $this;
}
public function getStatus()
{
return $this->status;
}
public function setStatus($status): self
{
$current_status = strtolower(array_search($this->status, self::STATUS_ARRAY));
if ($status) {
$this->status = self::STATUS_ARRAY[ strtoupper($status) ];
} else {
$this->status = self::STATUS_ARRAY[ strtoupper($current_status) ] ;
}
return $this;
}
public function getMail(): ?string
{
return $this->mail;
}
public function setMail(string $mail): self
{
$this->mail = $mail;
return $this;
}
public function getSessionFormation(): ?Sessionsformation
{
return $this->sessionFormation;
}
public function setSessionFormation(?Sessionsformation $sessionFormation): self
{
$this->sessionFormation = $sessionFormation;
return $this;
}
public function getMotif(): ?string
{
return $this->motif;
}
public function setMotif(string $motif): self
{
$this->motif = $motif;
return $this;
}
public function getExportData()
{
return \array_merge([
'Session' => $this->getSessionFormation()->getTitre(),
'Utilisateur' => $this->getUser()->getUsername(),
'Fonction' => $this->getFonction(),
'E-mail' => $this->getMail() ?? '',
'Teléphone' => $this->getTel(),
'statut' => $this->getStatus() ?? '',
'Proposition' => $this->getMotif() ?? '',
]);
}
}