<?php
namespace App\Entity;
use App\Repository\CommandeSpecialRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CommandeSpecialRepository::class)
*/
class CommandeSpecial
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $createdAt;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isValidePharmacie;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isValideGrossiste;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $daysLimit;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isReadyPharmacie;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isLivrer;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $remarquePharmacie;
/**
* @ORM\OneToMany(targetEntity=CommandeSpecialLine::class, mappedBy="commandeSpecial", orphanRemoval=true)
*/
private $commandeSpecialLines;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="commandeSpecials")
*/
private $grossiste;
/**
* @ORM\ManyToOne(targetEntity=IctusTypeLivraison::class, inversedBy="commandeSpecials")
*/
private $typeLivraison;
/**
* @ORM\ManyToOne(targetEntity=IctusTypePaiement::class, inversedBy="commandeSpecials")
*/
private $typePaiement;
/**
* @ORM\ManyToOne(targetEntity=IctusPharmacie::class, inversedBy="commandeSpecials")
*/
private $pharmacie;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="commandeSpecialsIctus")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $token;
/**
* @ORM\ManyToOne(targetEntity=IctusEtatPaiement::class, inversedBy="commandeSpecials")
*/
private $etatPaiement;
/**
* @ORM\OneToMany(targetEntity=IctusHistoriquePaiement::class, mappedBy="commandeSpecial")
*/
private $ictusHistoriquePaiements;
/**
* @ORM\OneToOne(targetEntity=FacturePatient::class, mappedBy="commandespecial", cascade={"persist", "remove"})
*/
private $facturePatient;
/**
* @ORM\Column(type="integer")
*/
private $reference;
public function __construct()
{
$this->commandeSpecialLines = new ArrayCollection();
$this->ictusHistoriquePaiements = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function isIsValidePharmacie(): ?bool
{
return $this->isValidePharmacie;
}
public function setIsValidePharmacie(?bool $isValidePharmacie): self
{
$this->isValidePharmacie = $isValidePharmacie;
return $this;
}
public function isIsValideGrossiste(): ?bool
{
return $this->isValideGrossiste;
}
public function setIsValideGrossiste(?bool $isValideGrossiste): self
{
$this->isValideGrossiste = $isValideGrossiste;
return $this;
}
public function getDaysLimit(): ?int
{
return $this->daysLimit;
}
public function setDaysLimit(int $daysLimit): self
{
$this->daysLimit = $daysLimit;
return $this;
}
public function isIsReadyPharmacie(): ?bool
{
return $this->isReadyPharmacie;
}
public function setIsReadyPharmacie(?bool $isReadyPharmacie): self
{
$this->isReadyPharmacie = $isReadyPharmacie;
return $this;
}
public function isIsLivrer(): ?bool
{
return $this->isLivrer;
}
public function setIsLivrer(?bool $isLivrer): self
{
$this->isLivrer = $isLivrer;
return $this;
}
public function getRemarquePharmacie(): ?string
{
return $this->remarquePharmacie;
}
public function setRemarquePharmacie(?string $remarquePharmacie): self
{
$this->remarquePharmacie = $remarquePharmacie;
return $this;
}
/**
* @return Collection<int, CommandeSpecialLine>
*/
public function getCommandeSpecialLines(): Collection
{
return $this->commandeSpecialLines;
}
public function addCommandeSpecialLine(CommandeSpecialLine $commandeSpecialLine): self
{
if (!$this->commandeSpecialLines->contains($commandeSpecialLine)) {
$this->commandeSpecialLines[] = $commandeSpecialLine;
$commandeSpecialLine->setCommandeSpecial($this);
}
return $this;
}
public function removeCommandeSpecialLine(CommandeSpecialLine $commandeSpecialLine): self
{
if ($this->commandeSpecialLines->removeElement($commandeSpecialLine)) {
// set the owning side to null (unless already changed)
if ($commandeSpecialLine->getCommandeSpecial() === $this) {
$commandeSpecialLine->setCommandeSpecial(null);
}
}
return $this;
}
public function getGrossiste(): ?User
{
return $this->grossiste;
}
public function setGrossiste(?User $grossiste): self
{
$this->grossiste = $grossiste;
return $this;
}
public function getTypeLivraison(): ?IctusTypeLivraison
{
return $this->typeLivraison;
}
public function setTypeLivraison(?IctusTypeLivraison $typeLivraison): self
{
$this->typeLivraison = $typeLivraison;
return $this;
}
public function getTypePaiement(): ?IctusTypePaiement
{
return $this->typePaiement;
}
public function setTypePaiement(?IctusTypePaiement $typePaiement): self
{
$this->typePaiement = $typePaiement;
return $this;
}
public function getPharmacie(): ?IctusPharmacie
{
return $this->pharmacie;
}
public function setPharmacie(?IctusPharmacie $pharmacie): self
{
$this->pharmacie = $pharmacie;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(?string $token): self
{
$this->token = $token;
return $this;
}
public function getEtatPaiement(): ?IctusEtatPaiement
{
return $this->etatPaiement;
}
public function setEtatPaiement(?IctusEtatPaiement $etatPaiement): self
{
$this->etatPaiement = $etatPaiement;
return $this;
}
public function getPrixTotal()
{
$prixTotal = 0;
foreach ($this->getCommandeSpecialLines() as $dc) {
if ($this->isIsValidePharmacie() == 1) {
if ($dc->isIsValide() != 0) {
$prixTotal += ($dc->getPrixunitaire() * $dc->getQuantite());
}
} else {
$prixTotal += ($dc->getPrixunitaire() * $dc->getQuantite());
}
}
return $prixTotal;
}
public function totalProduit()
{
return count($this->getCommandeSpecialLines());
}
/**
* @return Collection<int, IctusHistoriquePaiement>
*/
public function getIctusHistoriquePaiements(): Collection
{
return $this->ictusHistoriquePaiements;
}
public function addIctusHistoriquePaiement(IctusHistoriquePaiement $ictusHistoriquePaiement): self
{
if (!$this->ictusHistoriquePaiements->contains($ictusHistoriquePaiement)) {
$this->ictusHistoriquePaiements[] = $ictusHistoriquePaiement;
$ictusHistoriquePaiement->setCommandeSpecial($this);
}
return $this;
}
public function removeIctusHistoriquePaiement(IctusHistoriquePaiement $ictusHistoriquePaiement): self
{
if ($this->ictusHistoriquePaiements->removeElement($ictusHistoriquePaiement)) {
// set the owning side to null (unless already changed)
if ($ictusHistoriquePaiement->getCommandeSpecial() === $this) {
$ictusHistoriquePaiement->setCommandeSpecial(null);
}
}
return $this;
}
public function getFacturePatient(): ?FacturePatient
{
return $this->facturePatient;
}
public function setFacturePatient(?FacturePatient $facturePatient): self
{
// unset the owning side of the relation if necessary
if ($facturePatient === null && $this->facturePatient !== null) {
$this->facturePatient->setCommandespecial(null);
}
// set the owning side of the relation if necessary
if ($facturePatient !== null && $facturePatient->getCommandespecial() !== $this) {
$facturePatient->setCommandespecial($this);
}
$this->facturePatient = $facturePatient;
return $this;
}
public function getTotalPaiement()
{
$total = 0;
foreach ($this->getIctusHistoriquePaiements() as $historique) {
$total += $historique->getMontant();
}
return $total;
}
public function getReference(): ?int
{
return $this->reference;
}
public function setReference(int $reference): self
{
$this->reference = $reference;
return $this;
}
}