<?php
namespace App\Entity;
use App\Repository\BilletRepository;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: BilletRepository::class)]
class Billet
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateAchat = null;
#[ORM\ManyToOne]
#[ORM\OrderBy(["nom" => "ASC"])]
private ?Cour $cour = null;
#[ORM\ManyToOne(targetEntity: SerieBillet::class, cascade: ['persist'], inversedBy: 'billets')]
private ?SerieBillet $serieBillet = null;
#[ORM\ManyToOne]
#[ORM\OrderBy(["nom" => "ASC"])]
private ?Category $category = null;
#[ORM\Column(type: "integer", nullable: true)]
private ?int $nbr = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $escalier = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $rang = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $place = null;
#[ORM\ManyToOne(targetEntity: Acheteur::class)]
#[ORM\OrderBy(["prenom" => "ASC"])]
private ?Acheteur $acheteur = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $note = null;
#[ORM\Column(nullable: true)]
private ?float $tarif = null;
#[ORM\Column]
private ?bool $papier = null;
#[ORM\Column(nullable: true)]
private ?float $commision = null;
#[ORM\Column(nullable: true)]
private ?bool $active = null;
#[ORM\ManyToOne(targetEntity: Tribune::class)]
#[ORM\OrderBy(["nom" => "ASC"])]
private ?Tribune $tribune = null;
#[ORM\ManyToOne(targetEntity: Session::class)]
#[ORM\OrderBy(["codeSession" => "ASC"])]
private ?Session $session = null;
#[ORM\OneToOne(mappedBy: "billet", targetEntity: Attribution::class, cascade: ['remove'])]
private $attribution;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $noteBillet = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $noteSerieBillet = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $file = null;
#[Assert\File(maxSize: "6000000")]
private ?File $fileUpload = null;
public function __construct()
{
$this->dateAchat = new \DateTime('now');
}
public function getId(): ?int
{
return $this->id;
}
public function getDateAchat(): ?\DateTimeInterface
{
return $this->dateAchat;
}
public function setDateAchat(?\DateTimeInterface $dateAchat): self
{
$this->dateAchat = $dateAchat;
return $this;
}
public function getCour(): ?Cour
{
return $this->cour;
}
public function setCour(?Cour $cour): self
{
$this->cour = $cour;
return $this;
}
public function getCategory(): ?Category
{
return $this->category;
}
public function setCategory(?Category $category): self
{
$this->category = $category;
return $this;
}
public function getNbr(): ?int
{
return $this->nbr;
}
public function setNbr(?int $nbr): self
{
$this->nbr = $nbr;
return $this;
}
public function getEscalier(): ?string
{
return $this->escalier;
}
public function setEscalier(?string $escalier): self
{
$this->escalier = $escalier;
return $this;
}
public function getRang(): ?string
{
return $this->rang;
}
public function setRang(?string $rang): self
{
$this->rang = $rang;
return $this;
}
public function getPlace(): ?string
{
return $this->place;
}
public function setPlace(?string $place): self
{
$this->place = $place;
return $this;
}
public function getAcheteur(): ?Acheteur
{
return $this->acheteur;
}
public function setAcheteur(?Acheteur $acheteur): self
{
$this->acheteur = $acheteur;
return $this;
}
public function getSerieBillet(): ?SerieBillet
{
return $this->serieBillet;
}
public function setSerieBillet(?SerieBillet $serieBillet): self
{
$this->serieBillet = $serieBillet;
return $this;
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(?string $note): self
{
$this->note = $note;
return $this;
}
public function getTarif(): ?float
{
return $this->tarif;
}
public function setTarif(?float $tarif): self
{
$this->tarif = $tarif;
return $this;
}
public function isPapier(): ?bool
{
return $this->papier;
}
public function setPapier(bool $papier): self
{
$this->papier = $papier;
return $this;
}
public function getCommision(): ?float
{
return $this->commision;
}
public function setCommision(?float $commision): self
{
$this->commision = $commision;
return $this;
}
public function isActive(): ?bool
{
return $this->getSerieBillet()->isActive();
}
public function setActive(?bool $active): self
{
$this->active = $active;
return $this;
}
public function getTribune(): ?Tribune
{
return $this->tribune;
}
public function setTribune(?Tribune $tribune): self
{
$this->tribune = $tribune;
return $this;
}
public function getSession(): ?Session
{
return $this->session;
}
public function setSession(?Session $session): self
{
$this->session = $session;
return $this;
}
public function __toString(): string
{
// TODO: Implement __toString() method.
return $this->acheteur->getNom().' '.$this->acheteur->getPrenom(). ' - '.$this->session->getDescription();
}
public function getAttribution(): ?Attribution
{
return $this->attribution;
}
public function setAttribution(Attribution $attribution): self
{
$this->attribution = $attribution;
// set the owning side of the relation if necessary
if ($attribution->getBillet() !== $this) {
$attribution->setBillet($this);
}
return $this;
}
public function getNoteBillet(): ?string
{
return $this->noteBillet;
}
public function setNoteBillet(?string $noteBillet): self
{
$this->noteBillet = $noteBillet;
return $this;
}
public function getNoteSerieBillet(): ?string
{
return $this->noteSerieBillet;
}
public function setNoteSerieBillet(?string $noteSerieBillet): self
{
$this->noteSerieBillet = $noteSerieBillet;
return $this;
}
public function getFile(): ?string
{
return $this->file;
}
public function setFile(?string $file): self
{
$this->file = $file;
return $this;
}
public function getFileUpload(): ?File
{
return $this->fileUpload;
}
public function setFileUpload(?File $fileUpload): self
{
$this->fileUpload = $fileUpload;
return $this;
}
public function getLocalizedDate(): string
{
setlocale(LC_ALL, 'fr_FR.utf8');
return strftime('%A %d %B %Y', ($this->dateAchat) ? $this->dateAchat->getTimestamp() : time());
}
public function getClient(): ?string
{
if(!is_null($this->attribution)) return $this->attribution->getCommande()->getClient()->getFullName();
return '';
}
public function getSpectateur(): ?string
{
if(!is_null($this->attribution)) return $this->attribution->getSpectateur()->getNom();
return '';
}
public function getStatut(): ?string
{
if(!is_null($this->attribution)) return $this->attribution->getStatut();
return Commande::COMMANDE_STATUS_SAISIE;
}
public function getNoteSerie(): ?string
{
return $this->getSerieBillet()->getNote();
}
}