src/Entity/Client.php line 11

  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\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassClientRepository::class)]
  8. class Client
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length100)]
  15.     private ?string $nom null;
  16.     #[ORM\OneToMany(mappedBy'client'targetEntityTransportTheorique::class)]
  17.     private Collection $transportTheoriques;
  18.     #[ORM\OneToMany(mappedBy'client'targetEntityTransportReel::class)]
  19.     private Collection $transportReel;
  20.     #[ORM\OneToMany(mappedBy'client'targetEntityTransportLieu::class)]
  21.     private Collection $transportLieus;
  22.     #[ORM\Column]
  23.     private ?int $donneurOrdre null;
  24.     #[ORM\OneToMany(mappedBy'client'targetEntityContact::class)]
  25.     private Collection $contacts;
  26.     #[ORM\Column]
  27.     private ?int $actif null;
  28.     #[ORM\ManyToOne(inversedBy'clients')]
  29.     private ?SystemeClient $systemeClient null;
  30.     #[ORM\OneToMany(mappedBy'client'targetEntityGrilleTarifPalette::class)]
  31.     private Collection $grilleTarifPalettes;
  32.     #[ORM\Column(length255)]
  33.     private ?string $siret null;
  34.     #[ORM\Column(length255)]
  35.     private ?string $numTVA null;
  36.     #[ORM\OneToMany(mappedBy'client'targetEntityGrilleTarifClient::class)]
  37.     private Collection $grilleTarifClients;
  38.     #[ORM\OneToMany(mappedBy'clientDestination'targetEntityGrilleTarifClient::class)]
  39.     private Collection $grilleTarifClientDestinations;
  40.     #[ORM\OneToMany(mappedBy'destination'targetEntityPaletteMouvement::class)]
  41.     private Collection $paletteMouvements;
  42.     public function __construct()
  43.     {
  44.         $this->transportTheoriques = new ArrayCollection();
  45.         $this->transportReel = new ArrayCollection();
  46.         $this->transportLieus = new ArrayCollection();
  47.         $this->contacts = new ArrayCollection();
  48.         $this->grilleTarifPalettes = new ArrayCollection();
  49.         $this->grilleTarifClients = new ArrayCollection();
  50.         $this->grilleTarifClientDestinations = new ArrayCollection();
  51.         $this->paletteMouvements = new ArrayCollection();
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getNom(): ?string
  58.     {
  59.         return $this->nom;
  60.     }
  61.     public function setNom(string $nom): self
  62.     {
  63.         $this->nom $nom;
  64.         return $this;
  65.     }
  66.     /**
  67.      * @return Collection<int, TransportTheorique>
  68.      */
  69.     public function getTransportTheoriques(): Collection
  70.     {
  71.         return $this->transportTheoriques;
  72.     }
  73.     public function addTransportTheorique(TransportTheorique $transportTheorique): self
  74.     {
  75.         if (!$this->transportTheoriques->contains($transportTheorique)) {
  76.             $this->transportTheoriques->add($transportTheorique);
  77.             $transportTheorique->setClient($this);
  78.         }
  79.         return $this;
  80.     }
  81.     public function removeTransportTheorique(TransportTheorique $transportTheorique): self
  82.     {
  83.         if ($this->transportTheoriques->removeElement($transportTheorique)) {
  84.             // set the owning side to null (unless already changed)
  85.             if ($transportTheorique->getClient() === $this) {
  86.                 $transportTheorique->setClient(null);
  87.             }
  88.         }
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return Collection<int, TransportReel>
  93.      */
  94.     public function getTransportReel(): Collection
  95.     {
  96.         return $this->transportReel;
  97.     }
  98.     public function addTransportReel(TransportReel $transportReel): self
  99.     {
  100.         if (!$this->transportReel->contains($transportReel)) {
  101.             $this->transportReel->add($transportReel);
  102.             $transportReel->setClient($this);
  103.         }
  104.         return $this;
  105.     }
  106.     public function removeTransportReel(TransportReel $transportReel): self
  107.     {
  108.         if ($this->transportReel->removeElement($transportReel)) {
  109.             // set the owning side to null (unless already changed)
  110.             if ($transportReel->getClient() === $this) {
  111.                 $transportReel->setClient(null);
  112.             }
  113.         }
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return Collection<int, TransportLieu>
  118.      */
  119.     public function getTransportLieus(): Collection
  120.     {
  121.         return $this->transportLieus;
  122.     }
  123.     public function addTransportLieu(TransportLieu $transportLieu): self
  124.     {
  125.         if (!$this->transportLieus->contains($transportLieu)) {
  126.             $this->transportLieus->add($transportLieu);
  127.             $transportLieu->setClient($this);
  128.         }
  129.         return $this;
  130.     }
  131.     public function removeTransportLieu(TransportLieu $transportLieu): self
  132.     {
  133.         if ($this->transportLieus->removeElement($transportLieu)) {
  134.             // set the owning side to null (unless already changed)
  135.             if ($transportLieu->getClient() === $this) {
  136.                 $transportLieu->setClient(null);
  137.             }
  138.         }
  139.         return $this;
  140.     }
  141.     public function getDonneurOrdre(): ?int
  142.     {
  143.         return $this->donneurOrdre;
  144.     }
  145.     public function setDonneurOrdre(int $donneurOrdre): self
  146.     {
  147.         $this->donneurOrdre $donneurOrdre;
  148.         return $this;
  149.     }
  150.     /**
  151.      * @return Collection<int, Contact>
  152.      */
  153.     public function getContacts(): Collection
  154.     {
  155.         return $this->contacts;
  156.     }
  157.     public function addContact(Contact $contact): self
  158.     {
  159.         if (!$this->contacts->contains($contact)) {
  160.             $this->contacts->add($contact);
  161.             $contact->setClient($this);
  162.         }
  163.         return $this;
  164.     }
  165.     public function removeContact(Contact $contact): self
  166.     {
  167.         if ($this->contacts->removeElement($contact)) {
  168.             // set the owning side to null (unless already changed)
  169.             if ($contact->getClient() === $this) {
  170.                 $contact->setClient(null);
  171.             }
  172.         }
  173.         return $this;
  174.     }
  175.     public function __toString()
  176.     {
  177.         return $this->getNom();
  178.     }
  179.     public function getActif(): ?int
  180.     {
  181.         return $this->actif;
  182.     }
  183.     public function setActif(int $actif): self
  184.     {
  185.         $this->actif $actif;
  186.         return $this;
  187.     }
  188.     public function getSystemeClient(): ?SystemeClient
  189.     {
  190.         return $this->systemeClient;
  191.     }
  192.     public function setSystemeClient(?SystemeClient $systemeClient): self
  193.     {
  194.         $this->systemeClient $systemeClient;
  195.         return $this;
  196.     }
  197.     /**
  198.      * @return Collection<int, GrilleTarifPalette>
  199.      */
  200.     public function getGrilleTarifPalettes()
  201.     {
  202.         $list = array();
  203.         if(!empty($this->grilleTarifPalettes))
  204.         {
  205.             foreach($this->grilleTarifPalettes as $grilleTarifPalette)
  206.             {
  207.                 if($grilleTarifPalette->getActif()==1)
  208.                 {
  209.                     $list[] = $grilleTarifPalette;
  210.                 }
  211.             }
  212.         }
  213.         return $list;
  214.     }
  215.     public function addGrilleTarifPalette(GrilleTarifPalette $grilleTarifPalette): self
  216.     {
  217.         if (!$this->grilleTarifPalettes->contains($grilleTarifPalette)) {
  218.             $this->grilleTarifPalettes->add($grilleTarifPalette);
  219.             $grilleTarifPalette->setClient($this);
  220.         }
  221.         return $this;
  222.     }
  223.     public function removeGrilleTarifPalette(GrilleTarifPalette $grilleTarifPalette): self
  224.     {
  225.         if ($this->grilleTarifPalettes->removeElement($grilleTarifPalette)) {
  226.             // set the owning side to null (unless already changed)
  227.             if ($grilleTarifPalette->getClient() === $this) {
  228.                 $grilleTarifPalette->setClient(null);
  229.             }
  230.         }
  231.         return $this;
  232.     }
  233.     public function getGrilleTarif()
  234.     {
  235.         $listGTP = array();
  236.         if(!empty($this->getGrilleTarifPalettes()))
  237.         {
  238.             foreach($this->getGrilleTarifPalettes() as $grilleTarifPalette)
  239.             {
  240.                 if($grilleTarifPalette->getPaletteId()!=null)
  241.                 {
  242.                     if(!isset($listGTP[$grilleTarifPalette->getDestination()->getId()][$grilleTarifPalette->getPaletteId()]))
  243.                     {
  244.                         $listGTP[$grilleTarifPalette->getDestination()->getId()][$grilleTarifPalette->getPaletteId()] = 0;
  245.                     }
  246.                     $listGTP[$grilleTarifPalette->getDestination()->getId()][$grilleTarifPalette->getPaletteId()]++;
  247.                 }
  248.                 else
  249.                 {
  250.                     if(!isset($listGTP[$grilleTarifPalette->getDestination()->getId()][0]))
  251.                     {
  252.                         $listGTP[$grilleTarifPalette->getDestination()->getId()][0] = 0;
  253.                     }
  254.                     $listGTP[$grilleTarifPalette->getDestination()->getId()][0]++;
  255.                 }
  256.             }
  257.         }
  258.         return $listGTP;
  259.     }
  260.     public function getNbrGrilleTarifPalette()
  261.     {
  262.         $nbrGTP 0;
  263.         if(!empty($this->getGrilleTarifPalettes()))
  264.         {
  265.             foreach($this->getGrilleTarifPalettes() as $grilleTarifPalette)
  266.             {
  267.                 if($grilleTarifPalette->getActif()==1)
  268.                 {
  269.                     $nbrGTP++;
  270.                 }
  271.             }
  272.         }
  273.         return $nbrGTP;
  274.     }
  275.     public function getNbrGrilleTarifClient()
  276.     {
  277.         $nbrGTC 0;
  278.         if(!empty($this->getGrilleTarifClients()))
  279.         {
  280.             foreach($this->getGrilleTarifClients() as $grilleTarifClient)
  281.             {
  282.                 if($grilleTarifClient->getActif()==1)
  283.                 {
  284.                     $nbrGTC++;
  285.                 }
  286.             }
  287.         }
  288.         return $nbrGTC;
  289.     }
  290.     public function getGrilleTarifByPaletteAndQte()
  291.     {
  292.         $listGTP = array();
  293.         $listGTPTempo = array();
  294.         if(!empty($this->getGrilleTarifPalettes()))
  295.         {
  296.             foreach($this->getGrilleTarifPalettes() as $grilleTarifPalette)
  297.             {
  298.                 if(!empty($grilleTarifPalette->getGrilleTarifPaletteQtes()))
  299.                 {
  300.                     foreach($grilleTarifPalette->getGrilleTarifPaletteQtes() as $gtpq)
  301.                     {
  302.                         $listGTPTempo[$grilleTarifPalette->getDepart()->getId()][$grilleTarifPalette->getDestination()->getId()][$grilleTarifPalette->getPaletteId()][$gtpq->getQtePalette()] = array('qte'=>$gtpq->getQtePalette(),'prix'=>$gtpq->getPrix());
  303.                     }
  304.                 }
  305.             }
  306.             foreach($listGTPTempo as $idDepart => $listGTPTemps)
  307.             {
  308.                 foreach($listGTPTemps as $idDestination => $listGTPTemp)
  309.                 {
  310.                     foreach($listGTPTemp as $idPalette => $listGTPTem)
  311.                     {
  312.                         ksort($listGTPTem);
  313.                         foreach($listGTPTem as $qte => $listGTPT)
  314.                         {
  315.                             $listGTP[$idDepart][$idDestination][$idPalette][$qte] = $listGTPT;
  316.                         }
  317.                     }
  318.                 }
  319.             }
  320.         }
  321.         return $listGTP;
  322.     }
  323.     public function getSiret(): ?string
  324.     {
  325.         return $this->siret;
  326.     }
  327.     public function setSiret(string $siret): self
  328.     {
  329.         $this->siret $siret;
  330.         return $this;
  331.     }
  332.     public function getNumTVA(): ?string
  333.     {
  334.         return $this->numTVA;
  335.     }
  336.     public function setNumTVA(string $numTVA): self
  337.     {
  338.         $this->numTVA $numTVA;
  339.         return $this;
  340.     }
  341.     /**
  342.      * @return Collection<int, GrilleTarifClient>
  343.      */
  344.     public function getGrilleTarifClients(): Collection
  345.     {
  346.         return $this->grilleTarifClients;
  347.     }
  348.     public function addGrilleTarifClient(GrilleTarifClient $grilleTarifClient): self
  349.     {
  350.         if (!$this->grilleTarifClients->contains($grilleTarifClient)) {
  351.             $this->grilleTarifClients->add($grilleTarifClient);
  352.             $grilleTarifClient->setClient($this);
  353.         }
  354.         return $this;
  355.     }
  356.     public function removeGrilleTarifClient(GrilleTarifClient $grilleTarifClient): self
  357.     {
  358.         if ($this->grilleTarifClients->removeElement($grilleTarifClient)) {
  359.             // set the owning side to null (unless already changed)
  360.             if ($grilleTarifClient->getClient() === $this) {
  361.                 $grilleTarifClient->setClient(null);
  362.             }
  363.         }
  364.         return $this;
  365.     }
  366.     /**
  367.      * @return Collection<int, GrilleTarifClient>
  368.      */
  369.     public function getGrilleTarifClientDestinations(): Collection
  370.     {
  371.         return $this->grilleTarifClientDestinations;
  372.     }
  373.     public function addGrilleTarifClientDestination(GrilleTarifClient $grilleTarifClientDestination): self
  374.     {
  375.         if (!$this->grilleTarifClientDestinations->contains($grilleTarifClientDestination)) {
  376.             $this->grilleTarifClientDestinations->add($grilleTarifClientDestination);
  377.             $grilleTarifClientDestination->setClientDestination($this);
  378.         }
  379.         return $this;
  380.     }
  381.     public function removeGrilleTarifClientDestination(GrilleTarifClient $grilleTarifClientDestination): self
  382.     {
  383.         if ($this->grilleTarifClientDestinations->removeElement($grilleTarifClientDestination)) {
  384.             // set the owning side to null (unless already changed)
  385.             if ($grilleTarifClientDestination->getClientDestination() === $this) {
  386.                 $grilleTarifClientDestination->setClientDestination(null);
  387.             }
  388.         }
  389.         return $this;
  390.     }
  391.     /**
  392.      * @return Collection<int, PaletteMouvement>
  393.      */
  394.     public function getPaletteMouvements(): Collection
  395.     {
  396.         return $this->paletteMouvements;
  397.     }
  398.     public function addPaletteMouvement(PaletteMouvement $paletteMouvement): static
  399.     {
  400.         if (!$this->paletteMouvements->contains($paletteMouvement)) {
  401.             $this->paletteMouvements->add($paletteMouvement);
  402.             $paletteMouvement->setDestination($this);
  403.         }
  404.         return $this;
  405.     }
  406.     public function removePaletteMouvement(PaletteMouvement $paletteMouvement): static
  407.     {
  408.         if ($this->paletteMouvements->removeElement($paletteMouvement)) {
  409.             // set the owning side to null (unless already changed)
  410.             if ($paletteMouvement->getDestination() === $this) {
  411.                 $paletteMouvement->setDestination(null);
  412.             }
  413.         }
  414.         return $this;
  415.     }
  416. }