src/Entity/CommandeSpecial.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CommandeSpecialRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CommandeSpecialRepository::class)
  9.  */
  10. class CommandeSpecial
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="datetime_immutable")
  20.      */
  21.     private $createdAt;
  22.     /**
  23.      * @ORM\Column(type="boolean", nullable=true)
  24.      */
  25.     private $isValidePharmacie;
  26.     /**
  27.      * @ORM\Column(type="boolean", nullable=true)
  28.      */
  29.     private $isValideGrossiste;
  30.     /**
  31.      * @ORM\Column(type="integer", nullable=true)
  32.      */
  33.     private $daysLimit;
  34.     /**
  35.      * @ORM\Column(type="boolean", nullable=true)
  36.      */
  37.     private $isReadyPharmacie;
  38.     /**
  39.      * @ORM\Column(type="boolean", nullable=true)
  40.      */
  41.     private $isLivrer;
  42.     /**
  43.      * @ORM\Column(type="text", nullable=true)
  44.      */
  45.     private $remarquePharmacie;
  46.     /**
  47.      * @ORM\OneToMany(targetEntity=CommandeSpecialLine::class, mappedBy="commandeSpecial", orphanRemoval=true)
  48.      */
  49.     private $commandeSpecialLines;
  50.     /**
  51.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="commandeSpecials")
  52.      */
  53.     private $grossiste;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=IctusTypeLivraison::class, inversedBy="commandeSpecials")
  56.      */
  57.     private $typeLivraison;
  58.     /**
  59.      * @ORM\ManyToOne(targetEntity=IctusTypePaiement::class, inversedBy="commandeSpecials")
  60.      */
  61.     private $typePaiement;
  62.     /**
  63.      * @ORM\ManyToOne(targetEntity=IctusPharmacie::class, inversedBy="commandeSpecials")
  64.      */
  65.     private $pharmacie;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="commandeSpecialsIctus")
  68.      * @ORM\JoinColumn(nullable=false)
  69.      */
  70.     private $user;
  71.     /**
  72.      * @ORM\Column(type="string", length=255, nullable=true)
  73.      */
  74.     private $token;
  75.     /**
  76.      * @ORM\ManyToOne(targetEntity=IctusEtatPaiement::class, inversedBy="commandeSpecials")
  77.      */
  78.     private $etatPaiement;
  79.     /**
  80.      * @ORM\OneToMany(targetEntity=IctusHistoriquePaiement::class, mappedBy="commandeSpecial")
  81.      */
  82.     private $ictusHistoriquePaiements;
  83.     /**
  84.      * @ORM\OneToOne(targetEntity=FacturePatient::class, mappedBy="commandespecial", cascade={"persist", "remove"})
  85.      */
  86.     private $facturePatient;
  87.     /**
  88.      * @ORM\Column(type="integer")
  89.      */
  90.     private $reference;
  91.     public function __construct()
  92.     {
  93.         $this->commandeSpecialLines = new ArrayCollection();
  94.         $this->ictusHistoriquePaiements = new ArrayCollection();
  95.     }
  96.     public function getId(): ?int
  97.     {
  98.         return $this->id;
  99.     }
  100.     public function getCreatedAt(): ?\DateTimeImmutable
  101.     {
  102.         return $this->createdAt;
  103.     }
  104.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  105.     {
  106.         $this->createdAt $createdAt;
  107.         return $this;
  108.     }
  109.     public function isIsValidePharmacie(): ?bool
  110.     {
  111.         return $this->isValidePharmacie;
  112.     }
  113.     public function setIsValidePharmacie(?bool $isValidePharmacie): self
  114.     {
  115.         $this->isValidePharmacie $isValidePharmacie;
  116.         return $this;
  117.     }
  118.     public function isIsValideGrossiste(): ?bool
  119.     {
  120.         return $this->isValideGrossiste;
  121.     }
  122.     public function setIsValideGrossiste(?bool $isValideGrossiste): self
  123.     {
  124.         $this->isValideGrossiste $isValideGrossiste;
  125.         return $this;
  126.     }
  127.     public function getDaysLimit(): ?int
  128.     {
  129.         return $this->daysLimit;
  130.     }
  131.     public function setDaysLimit(int $daysLimit): self
  132.     {
  133.         $this->daysLimit $daysLimit;
  134.         return $this;
  135.     }
  136.     public function isIsReadyPharmacie(): ?bool
  137.     {
  138.         return $this->isReadyPharmacie;
  139.     }
  140.     public function setIsReadyPharmacie(?bool $isReadyPharmacie): self
  141.     {
  142.         $this->isReadyPharmacie $isReadyPharmacie;
  143.         return $this;
  144.     }
  145.     public function isIsLivrer(): ?bool
  146.     {
  147.         return $this->isLivrer;
  148.     }
  149.     public function setIsLivrer(?bool $isLivrer): self
  150.     {
  151.         $this->isLivrer $isLivrer;
  152.         return $this;
  153.     }
  154.     public function getRemarquePharmacie(): ?string
  155.     {
  156.         return $this->remarquePharmacie;
  157.     }
  158.     public function setRemarquePharmacie(?string $remarquePharmacie): self
  159.     {
  160.         $this->remarquePharmacie $remarquePharmacie;
  161.         return $this;
  162.     }
  163.     /**
  164.      * @return Collection<int, CommandeSpecialLine>
  165.      */
  166.     public function getCommandeSpecialLines(): Collection
  167.     {
  168.         return $this->commandeSpecialLines;
  169.     }
  170.     public function addCommandeSpecialLine(CommandeSpecialLine $commandeSpecialLine): self
  171.     {
  172.         if (!$this->commandeSpecialLines->contains($commandeSpecialLine)) {
  173.             $this->commandeSpecialLines[] = $commandeSpecialLine;
  174.             $commandeSpecialLine->setCommandeSpecial($this);
  175.         }
  176.         return $this;
  177.     }
  178.     public function removeCommandeSpecialLine(CommandeSpecialLine $commandeSpecialLine): self
  179.     {
  180.         if ($this->commandeSpecialLines->removeElement($commandeSpecialLine)) {
  181.             // set the owning side to null (unless already changed)
  182.             if ($commandeSpecialLine->getCommandeSpecial() === $this) {
  183.                 $commandeSpecialLine->setCommandeSpecial(null);
  184.             }
  185.         }
  186.         return $this;
  187.     }
  188.     public function getGrossiste(): ?User
  189.     {
  190.         return $this->grossiste;
  191.     }
  192.     public function setGrossiste(?User $grossiste): self
  193.     {
  194.         $this->grossiste $grossiste;
  195.         return $this;
  196.     }
  197.     public function getTypeLivraison(): ?IctusTypeLivraison
  198.     {
  199.         return $this->typeLivraison;
  200.     }
  201.     public function setTypeLivraison(?IctusTypeLivraison $typeLivraison): self
  202.     {
  203.         $this->typeLivraison $typeLivraison;
  204.         return $this;
  205.     }
  206.     public function getTypePaiement(): ?IctusTypePaiement
  207.     {
  208.         return $this->typePaiement;
  209.     }
  210.     public function setTypePaiement(?IctusTypePaiement $typePaiement): self
  211.     {
  212.         $this->typePaiement $typePaiement;
  213.         return $this;
  214.     }
  215.     public function getPharmacie(): ?IctusPharmacie
  216.     {
  217.         return $this->pharmacie;
  218.     }
  219.     public function setPharmacie(?IctusPharmacie $pharmacie): self
  220.     {
  221.         $this->pharmacie $pharmacie;
  222.         return $this;
  223.     }
  224.     public function getUser(): ?User
  225.     {
  226.         return $this->user;
  227.     }
  228.     public function setUser(?User $user): self
  229.     {
  230.         $this->user $user;
  231.         return $this;
  232.     }
  233.     public function getToken(): ?string
  234.     {
  235.         return $this->token;
  236.     }
  237.     public function setToken(?string $token): self
  238.     {
  239.         $this->token $token;
  240.         return $this;
  241.     }
  242.     public function getEtatPaiement(): ?IctusEtatPaiement
  243.     {
  244.         return $this->etatPaiement;
  245.     }
  246.     public function setEtatPaiement(?IctusEtatPaiement $etatPaiement): self
  247.     {
  248.         $this->etatPaiement $etatPaiement;
  249.         return $this;
  250.     }
  251.     public function getPrixTotal()
  252.     {
  253.         $prixTotal 0;
  254.         foreach ($this->getCommandeSpecialLines() as $dc) {
  255.             if ($this->isIsValidePharmacie() == 1) {
  256.                 if ($dc->isIsValide() != 0) {
  257.                     $prixTotal += ($dc->getPrixunitaire() * $dc->getQuantite());
  258.                 }
  259.             } else {
  260.                 $prixTotal += ($dc->getPrixunitaire() * $dc->getQuantite());
  261.             }
  262.         }
  263.         return $prixTotal;
  264.     }
  265.     public function totalProduit()
  266.     {
  267.         return count($this->getCommandeSpecialLines());
  268.     }
  269.     /**
  270.      * @return Collection<int, IctusHistoriquePaiement>
  271.      */
  272.     public function getIctusHistoriquePaiements(): Collection
  273.     {
  274.         return $this->ictusHistoriquePaiements;
  275.     }
  276.     public function addIctusHistoriquePaiement(IctusHistoriquePaiement $ictusHistoriquePaiement): self
  277.     {
  278.         if (!$this->ictusHistoriquePaiements->contains($ictusHistoriquePaiement)) {
  279.             $this->ictusHistoriquePaiements[] = $ictusHistoriquePaiement;
  280.             $ictusHistoriquePaiement->setCommandeSpecial($this);
  281.         }
  282.         return $this;
  283.     }
  284.     public function removeIctusHistoriquePaiement(IctusHistoriquePaiement $ictusHistoriquePaiement): self
  285.     {
  286.         if ($this->ictusHistoriquePaiements->removeElement($ictusHistoriquePaiement)) {
  287.             // set the owning side to null (unless already changed)
  288.             if ($ictusHistoriquePaiement->getCommandeSpecial() === $this) {
  289.                 $ictusHistoriquePaiement->setCommandeSpecial(null);
  290.             }
  291.         }
  292.         return $this;
  293.     }
  294.     public function getFacturePatient(): ?FacturePatient
  295.     {
  296.         return $this->facturePatient;
  297.     }
  298.     public function setFacturePatient(?FacturePatient $facturePatient): self
  299.     {
  300.         // unset the owning side of the relation if necessary
  301.         if ($facturePatient === null && $this->facturePatient !== null) {
  302.             $this->facturePatient->setCommandespecial(null);
  303.         }
  304.         // set the owning side of the relation if necessary
  305.         if ($facturePatient !== null && $facturePatient->getCommandespecial() !== $this) {
  306.             $facturePatient->setCommandespecial($this);
  307.         }
  308.         $this->facturePatient $facturePatient;
  309.         return $this;
  310.     }
  311.     public function getTotalPaiement()
  312.     {
  313.         $total 0;
  314.         foreach ($this->getIctusHistoriquePaiements() as $historique) {
  315.             $total += $historique->getMontant();
  316.         }
  317.         return $total;
  318.     }
  319.     public function getReference(): ?int
  320.     {
  321.         return $this->reference;
  322.     }
  323.     public function setReference(int $reference): self
  324.     {
  325.         $this->reference $reference;
  326.         return $this;
  327.     }
  328. }