src/Entity/Client.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ClientRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassClientRepository::class)]
  9. class Client
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne]
  16.     private ?Events $event null;
  17.     #[ORM\Column(length50nullabletrue)]
  18.     private ?string $nom null;
  19.     #[ORM\Column(length50nullabletrue)]
  20.     private ?string $prenom null;
  21.     #[ORM\Column(length100)]
  22.     private ?string $mail null;
  23.     #[ORM\Column(length50nullabletrue)]
  24.     private ?string $tel null;
  25.     #[ORM\Column(length50nullabletrue)]
  26.     private ?string $societe null;
  27.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  28.     private ?string $note null;
  29.     #[ORM\ManyToOne]
  30.     private ?Statut $statut null;
  31.     #[ORM\ManyToOne]
  32.     private ?Couleur $couleur null;
  33.     #[ORM\ManyToOne]
  34.     private ?ModePaiement $modePaiement null;
  35.     #[ORM\ManyToOne]
  36.     private ?Langue $langue null;
  37.     #[ORM\Column(nullabletrue)]
  38.     private ?bool $paye null;
  39.     #[ORM\OneToMany(mappedBy'client'targetEntityCommande::class, cascade: ['persist'], orphanRemovaltrue)]
  40.     private Collection $commandes;
  41.     public function __construct()
  42.     {
  43.         $this->commandes = new ArrayCollection();
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getEvent(): ?Events
  50.     {
  51.         return $this->event;
  52.     }
  53.     public function setEvent(?Events $event): self
  54.     {
  55.         $this->event $event;
  56.         return $this;
  57.     }
  58.     public function getNom(): ?string
  59.     {
  60.         return $this->nom;
  61.     }
  62.     public function setNom(?string $nom): self
  63.     {
  64.         $this->nom $nom;
  65.         return $this;
  66.     }
  67.     public function getPrenom(): ?string
  68.     {
  69.         return $this->prenom;
  70.     }
  71.     public function setPrenom(?string $prenom): self
  72.     {
  73.         $this->prenom $prenom;
  74.         return $this;
  75.     }
  76.     public function getMail(): ?string
  77.     {
  78.         return $this->mail;
  79.     }
  80.     public function setMail(string $mail): self
  81.     {
  82.         $this->mail $mail;
  83.         return $this;
  84.     }
  85.     public function getTel(): ?string
  86.     {
  87.         return $this->tel;
  88.     }
  89.     public function setTel(?string $tel): self
  90.     {
  91.         $this->tel $tel;
  92.         return $this;
  93.     }
  94.     public function getSociete(): ?string
  95.     {
  96.         return $this->societe;
  97.     }
  98.     public function setSociete(?string $societe): self
  99.     {
  100.         $this->societe $societe;
  101.         return $this;
  102.     }
  103.     public function getNote(): ?string
  104.     {
  105.         return $this->note;
  106.     }
  107.     public function setNote(?string $note): self
  108.     {
  109.         $this->note $note;
  110.         return $this;
  111.     }
  112.     public function getStatut(): ?Statut
  113.     {
  114.         return $this->statut;
  115.     }
  116.     public function setStatut(?Statut $statut): self
  117.     {
  118.         $this->statut $statut;
  119.         return $this;
  120.     }
  121.     public function getCouleur(): ?Couleur
  122.     {
  123.         return $this->couleur;
  124.     }
  125.     public function setCouleur(?Couleur $couleur): self
  126.     {
  127.         $this->couleur $couleur;
  128.         return $this;
  129.     }
  130.     public function getModePaiement(): ?ModePaiement
  131.     {
  132.         return $this->modePaiement;
  133.     }
  134.     public function setModePaiement(?ModePaiement $modePaiement): self
  135.     {
  136.         $this->modePaiement $modePaiement;
  137.         return $this;
  138.     }
  139.     public function getLangue(): ?Langue
  140.     {
  141.         return $this->langue;
  142.     }
  143.     public function setLangue(?Langue $langue): self
  144.     {
  145.         $this->langue $langue;
  146.         return $this;
  147.     }
  148.     public function isPaye(): ?bool
  149.     {
  150.         return $this->paye;
  151.     }
  152.     public function setPaye(?bool $paye): self
  153.     {
  154.         $this->paye $paye;
  155.         return $this;
  156.     }
  157.     /**
  158.      * @return string|null
  159.      */
  160.     public function getColorCode(): ?string
  161.     {
  162.         // Vérifiez si l'entité COLOR est associée à l'acheteur
  163.         if (null === $this->couleur) {
  164.             return null;
  165.         }
  166.         // Récupérez le code couleur de l'entité COLOR associée
  167.         return $this->couleur->getCode();
  168.     }
  169.     public function getTotalCommandes(?int $eventId null, ?string $statut 'all'): float
  170.     {
  171.         $total 0;
  172.         /** @var Commande $commande */
  173.         foreach ($this->getCommandes() as $commande) {
  174.             if(!is_null($eventId) && $commande->getSession()->getEvent()->getId() == $eventId && ($statut == "all" || ($statut == $commande->getStatut()))) {
  175.                 $total += $commande->getTotal();
  176.             }
  177.         }
  178.         return $total;
  179.     }
  180.     public function getTotalSerieBillet(?int $eventId null, ?string $statut 'all'): int
  181.     {
  182.         $count 0;
  183.         foreach ($this->getCommandes() as $commande) {
  184.             if (!is_null($eventId) && $commande->getSession()->getEvent()->getId() == $eventId && ($statut == "all" || ($statut == $commande->getStatut()))) $count++;
  185.         }
  186.         return $count;
  187.     }
  188.     public function getTotalBillet(?int $eventId null, ?string $statut 'all'): int
  189.     {
  190.         $total 0;
  191.         /** @var Commande $commande */
  192.         foreach ($this->getCommandes() as $commande) {
  193.             if (!is_null($eventId) && $commande->getSession()->getEvent()->getId() == $eventId && ($statut == "all" || ($statut == $commande->getStatut()))) $total += $commande->getNbr();
  194.         }
  195.         return $total;
  196.     }
  197.     /**
  198.      * @return Collection<int, Commande>
  199.      */
  200.     public function getCommandes(): array
  201.     {
  202.         $currentEventId null;
  203.         if (isset($_COOKIE['current_event_id'])) {
  204.             $currentEventId $_COOKIE['current_event_id'];
  205.         }
  206.         $commandes = [];
  207.         foreach ($this->commandes as $commande) {
  208.             if($commande->getEvent()->getId() == $currentEventId) {
  209.                 $commandes[] = $commande;
  210.             }
  211.         }
  212.         return $commandes;
  213.     }
  214.     public function addCommande(Commande $commande): self
  215.     {
  216.         if (!$this->commandes->contains($commande)) {
  217.             $this->commandes->add($commande);
  218.             $commande->setClient($this);
  219.         }
  220.         return $this;
  221.     }
  222.     public function removeCommande(Commande $commande): self
  223.     {
  224.         if ($this->commandes->removeElement($commande)) {
  225.             // set the owning side to null (unless already changed)
  226.             if ($commande->getClient() === $this) {
  227.                 $commande->setClient(null);
  228.             }
  229.         }
  230.         return $this;
  231.     }
  232.     public function __toString(): string
  233.     {
  234.         // TODO: Implement __toString() method.
  235.         return $this->prenom.' '.$this->nom;
  236.     }
  237.     public function getFullName(): string
  238.     {
  239.         return $this->getNom().' '.$this->getPrenom();
  240.     }
  241.     public function __clone(): void
  242.     {
  243.         if ($this->id) {
  244.             $this->id null;
  245.             $this->event null;
  246.             $this->commandes = new ArrayCollection();
  247.         }
  248.     }
  249. }