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.     // orphanRemoval removed: an order must never be deleted merely because it was
  40.     // detached from this in-memory collection (that caused mass order loss on client
  41.     // save). Real order deletions go through the explicit deleteFromIndex route.
  42.     #[ORM\OneToMany(mappedBy'client'targetEntityCommande::class, cascade: ['persist'])]
  43.     private Collection $commandes;
  44.     public function __construct()
  45.     {
  46.         $this->commandes = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getEvent(): ?Events
  53.     {
  54.         return $this->event;
  55.     }
  56.     public function setEvent(?Events $event): self
  57.     {
  58.         $this->event $event;
  59.         return $this;
  60.     }
  61.     public function getNom(): ?string
  62.     {
  63.         return $this->nom;
  64.     }
  65.     public function setNom(?string $nom): self
  66.     {
  67.         $this->nom $nom;
  68.         return $this;
  69.     }
  70.     public function getPrenom(): ?string
  71.     {
  72.         return $this->prenom;
  73.     }
  74.     public function setPrenom(?string $prenom): self
  75.     {
  76.         $this->prenom $prenom;
  77.         return $this;
  78.     }
  79.     public function getMail(): ?string
  80.     {
  81.         return $this->mail;
  82.     }
  83.     public function setMail(string $mail): self
  84.     {
  85.         $this->mail $mail;
  86.         return $this;
  87.     }
  88.     public function getTel(): ?string
  89.     {
  90.         return $this->tel;
  91.     }
  92.     public function setTel(?string $tel): self
  93.     {
  94.         $this->tel $tel;
  95.         return $this;
  96.     }
  97.     public function getSociete(): ?string
  98.     {
  99.         return $this->societe;
  100.     }
  101.     public function setSociete(?string $societe): self
  102.     {
  103.         $this->societe $societe;
  104.         return $this;
  105.     }
  106.     public function getNote(): ?string
  107.     {
  108.         return $this->note;
  109.     }
  110.     public function setNote(?string $note): self
  111.     {
  112.         $this->note $note;
  113.         return $this;
  114.     }
  115.     public function getStatut(): ?Statut
  116.     {
  117.         return $this->statut;
  118.     }
  119.     public function setStatut(?Statut $statut): self
  120.     {
  121.         $this->statut $statut;
  122.         return $this;
  123.     }
  124.     public function getCouleur(): ?Couleur
  125.     {
  126.         return $this->couleur;
  127.     }
  128.     public function setCouleur(?Couleur $couleur): self
  129.     {
  130.         $this->couleur $couleur;
  131.         return $this;
  132.     }
  133.     public function getModePaiement(): ?ModePaiement
  134.     {
  135.         return $this->modePaiement;
  136.     }
  137.     public function setModePaiement(?ModePaiement $modePaiement): self
  138.     {
  139.         $this->modePaiement $modePaiement;
  140.         return $this;
  141.     }
  142.     public function getLangue(): ?Langue
  143.     {
  144.         return $this->langue;
  145.     }
  146.     public function setLangue(?Langue $langue): self
  147.     {
  148.         $this->langue $langue;
  149.         return $this;
  150.     }
  151.     public function isPaye(): ?bool
  152.     {
  153.         return $this->paye;
  154.     }
  155.     public function setPaye(?bool $paye): self
  156.     {
  157.         $this->paye $paye;
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return string|null
  162.      */
  163.     public function getColorCode(): ?string
  164.     {
  165.         // Vérifiez si l'entité COLOR est associée à l'acheteur
  166.         if (null === $this->couleur) {
  167.             return null;
  168.         }
  169.         // Récupérez le code couleur de l'entité COLOR associée
  170.         return $this->couleur->getCode();
  171.     }
  172.     public function getTotalCommandes(?int $eventId null, ?string $statut 'all'): float
  173.     {
  174.         $total 0;
  175.         /** @var Commande $commande */
  176.         foreach ($this->getCommandes() as $commande) {
  177.             if(!is_null($eventId) && $commande->getSession()->getEvent()->getId() == $eventId && ($statut == "all" || ($statut == $commande->getStatut()))) {
  178.                 $total += $commande->getTotal();
  179.             }
  180.         }
  181.         return $total;
  182.     }
  183.     public function getTotalSerieBillet(?int $eventId null, ?string $statut 'all'): int
  184.     {
  185.         $count 0;
  186.         foreach ($this->getCommandes() as $commande) {
  187.             if (!is_null($eventId) && $commande->getSession()->getEvent()->getId() == $eventId && ($statut == "all" || ($statut == $commande->getStatut()))) $count++;
  188.         }
  189.         return $count;
  190.     }
  191.     public function getTotalBillet(?int $eventId null, ?string $statut 'all'): int
  192.     {
  193.         $total 0;
  194.         /** @var Commande $commande */
  195.         foreach ($this->getCommandes() as $commande) {
  196.             if (!is_null($eventId) && $commande->getSession()->getEvent()->getId() == $eventId && ($statut == "all" || ($statut == $commande->getStatut()))) $total += $commande->getNbr();
  197.         }
  198.         return $total;
  199.     }
  200.     /**
  201.      * @return Collection<int, Commande>
  202.      */
  203.     public function getCommandes(): array
  204.     {
  205.         $currentEventId null;
  206.         if (isset($_COOKIE['current_event_id'])) {
  207.             $currentEventId $_COOKIE['current_event_id'];
  208.         }
  209.         $commandes = [];
  210.         foreach ($this->commandes as $commande) {
  211.             if($commande->getEvent()->getId() == $currentEventId) {
  212.                 $commandes[] = $commande;
  213.             }
  214.         }
  215.         return $commandes;
  216.     }
  217.     public function addCommande(Commande $commande): self
  218.     {
  219.         if (!$this->commandes->contains($commande)) {
  220.             $this->commandes->add($commande);
  221.             $commande->setClient($this);
  222.         }
  223.         return $this;
  224.     }
  225.     public function removeCommande(Commande $commande): self
  226.     {
  227.         if ($this->commandes->removeElement($commande)) {
  228.             // set the owning side to null (unless already changed)
  229.             if ($commande->getClient() === $this) {
  230.                 $commande->setClient(null);
  231.             }
  232.         }
  233.         return $this;
  234.     }
  235.     public function __toString(): string
  236.     {
  237.         // TODO: Implement __toString() method.
  238.         return $this->prenom.' '.$this->nom;
  239.     }
  240.     public function getFullName(): string
  241.     {
  242.         return $this->getNom().' '.$this->getPrenom();
  243.     }
  244.     public function __clone(): void
  245.     {
  246.         if ($this->id) {
  247.             $this->id null;
  248.             $this->event null;
  249.             $this->commandes = new ArrayCollection();
  250.         }
  251.     }
  252. }