src/Entity/TblOperationVente.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TblOperationVenteRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Entity\Traits\TimestampableTrait;
  8. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  9. /**
  10.  * @ORM\Entity(repositoryClass=TblOperationVenteRepository::class)
  11.  */
  12. class TblOperationVente
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.  
  21.     /**
  22.      * @ORM\Column(type="date" )
  23.      */
  24.     private $date;
  25.     /**
  26.      * @ORM\Column(type="float" , nullable=true)
  27.      */
  28.     private $totalPrix;
  29.     /**
  30.      * @ORM\Column(type="float" , nullable=true)
  31.      */
  32.     private $totalCaisse;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity=RefTypeVente::class, inversedBy="tblOperationVentes")
  35.      */
  36.     private $typeVente;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity=TblDetailCharge::class, mappedBy="tblOperationVente" ,cascade={"persist"})
  39.      */
  40.     private $detailCharge;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity=TblDetailProduitVente::class, mappedBy="tblOperationVente",cascade={"persist"})
  43.      */
  44.     private $detailProduitVente;
  45.     /**
  46.      * @ORM\OneToMany(targetEntity=TblDetailQuantiteParcelle::class, mappedBy="tblOperationVente" , cascade={"persist"},orphanRemoval=true)
  47.      */
  48.     private $detailQuantiteParcelle;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="tblOperationVentes")
  51.      * @ORM\JoinColumns({
  52.      *   @ORM\JoinColumn(name="vendeur", referencedColumnName="user_id")
  53.      * })
  54.      */
  55.     private $vendeur;
  56.     /**
  57.      * @ORM\ManyToOne(targetEntity=RefVille::class, inversedBy="tblOperationVentes")
  58.      */
  59.     private $destination;
  60.     /**
  61.      * @ORM\ManyToMany(targetEntity=RefMoyenTransport::class)
  62.      * @ORM\JoinTable(name="lnk_moyen_transport_tbl_operation_vente",
  63.      *   joinColumns={
  64.      *     @ORM\JoinColumn(name="tbl_operation_vente_id", referencedColumnName="id")
  65.      *   },
  66.      *   inverseJoinColumns={
  67.      *     @ORM\JoinColumn(name="ref_moyen_transport_id", referencedColumnName="id", nullable=false)
  68.      *   }
  69.      * )
  70.      */
  71.     private $moyenTransports;
  72.     /**
  73.      * @ORM\ManyToMany(targetEntity=TblFile::class,cascade={"persist"})
  74.      * @ORM\JoinTable(name="lnk_tbl_tblOperationVente_tbl_file",
  75.      *   joinColumns={
  76.      *     @ORM\JoinColumn(name="tbl_tblOperationVentes_id", referencedColumnName="id")
  77.      *   },
  78.      *   inverseJoinColumns={
  79.      *     @ORM\JoinColumn(name="tbl_file_id", referencedColumnName="id", nullable=false)
  80.      *   }
  81.      * )
  82.      */
  83.     private $files;
  84.     /**
  85.      * @ORM\Column(type="string", length=255, nullable=true)
  86.      */
  87.     private $matricule;
  88.     use WorkflowableVente;
  89.     use TimestampableTrait;
  90.     public function __construct()
  91.     {
  92.         $this->detailCharge = new ArrayCollection();
  93.         $this->detailProduitVente = new ArrayCollection();
  94.         $this->detailQuantiteParcelle = new ArrayCollection();
  95.         $this->moyenTransports = new ArrayCollection();
  96.         $this->files = new ArrayCollection();
  97.     }
  98.     public function getId(): ?int
  99.     {
  100.         return $this->id;
  101.     }
  102.     public function getDate(): ?\DateTimeInterface
  103.     {
  104.         return $this->date;
  105.     }
  106.     public function setDate(\DateTimeInterface $date): self
  107.     {
  108.         $this->date $date;
  109.         return $this;
  110.     }
  111.     public function getTotalPrix(): ?float
  112.     {
  113.         return $this->totalPrix;
  114.     }
  115.     public function setTotalPrix(float $totalPrix): self
  116.     {
  117.         $this->totalPrix $totalPrix;
  118.         return $this;
  119.     }
  120.     public function getTotalCaisse(): ?float
  121.     {
  122.         return $this->totalCaisse;
  123.     }
  124.     public function setTotalCaisse(float $totalCaisse): self
  125.     {
  126.         $this->totalCaisse $totalCaisse;
  127.         return $this;
  128.     }
  129.     public function getTypeVente(): ?RefTypeVente
  130.     {
  131.         return $this->typeVente;
  132.     }
  133.     public function setTypeVente(?RefTypeVente $typeVente): self
  134.     {
  135.         $this->typeVente $typeVente;
  136.         return $this;
  137.     }
  138.     public function toArrayDatatable($urlEdit,$urlShow)
  139.     {
  140.         return [
  141.             $this->getDate()->format('d/m/Y'),
  142.             $this->getVendeur()->__toString(),
  143.             $this->getProfitOperationVente()." DH",
  144.             $this->getTransportsToString(),
  145.             $this->getMatricule()?: "--",
  146.             $this->getTotalCaisse(),
  147.             $this->getetatAvancementForOperation().' %',
  148.             '<a class="btn btn-primary" title="Modifier" href=' $urlEdit '><i class="ti ti-edit"></i></a> <a class="btn btn-default" href=' $urlShow '><i class="ti ti-eye"></i></a>'
  149.         ];
  150.     }
  151.     public function getTransportsToString()
  152.     {
  153.         $result '';
  154.         
  155.         foreach($this->getMoyenTransports() as $moyen) {
  156.          $result .= $moyen->getLibelle(). '<br>'
  157.         }
  158.         return $result;
  159.     }
  160.     public function getTotalQuantiteForParcelle()
  161.     {
  162.         $reste 0;
  163.         foreach($this->detailQuantiteParcelle as $detailQuantite){
  164.             if( $detailQuantite->getDeletedAt() == null ){
  165.             $reste += $detailQuantite->getQuantite();
  166.             } 
  167.         }
  168.        
  169.         
  170.         return $reste;
  171.     } 
  172.     public function getTotalCaisseForParcelle()
  173.     {
  174.         $reste 0;
  175.         foreach($this->detailQuantiteParcelle as $detailQuantite){
  176.             $reste += $detailQuantite->getCaisse();
  177.         }
  178.        
  179.         
  180.         return $reste;
  181.     }       
  182.      public function getTotalCaisseForProduitVente()
  183.     {
  184.         $reste 0;
  185.         foreach($this->detailProduitVente as $detailProduit){
  186.             $reste += $detailProduit->getCaisse();
  187.         }
  188.        
  189.         
  190.         return $reste;
  191.     }    
  192.      public function getTotalQuantiteForVente()
  193.     {
  194.         $reste 0;
  195.         foreach($this->detailProduitVente as $detailProduit){
  196.             if( $detailProduit->getDeletedAt() == null ){
  197.             $reste += $detailProduit->getQuantite();
  198.             }
  199.         }
  200.        
  201.         
  202.         return $reste;
  203.     }
  204.     public function getTotalPrixVenteEtQuantite()
  205.     {
  206.         $reste 0;
  207.         foreach($this->detailProduitVente as $detailProduit){
  208.             if( $detailProduit->getDeletedAt() == null ){
  209.             $reste += $detailProduit->getPrixVente() * $detailProduit->getQuantite();
  210.             }
  211.         }
  212.        
  213.         return $reste;
  214.     }
  215.     public function getProfitOperationVente()
  216.     {
  217.         return $this->getTotalPrixVenteEtQuantite()-$this->getTotalMontantForCharge();
  218.     } 
  219.     public function getTotalMontantForCharge()
  220.     {
  221.         $reste 0;
  222.         foreach($this->detailCharge as $detailCharges){
  223.             if( $detailCharges->getDeletedAt() == null ){
  224.             $reste += $detailCharges->getMontant();
  225.             }
  226.         }
  227.        
  228.         
  229.         return $reste;
  230.     }    
  231.      public function getTotalQuantiteForCharge()
  232.     {
  233.         $reste 0;
  234.         foreach($this->detailCharge as $detailCharges){
  235.             $reste += $detailCharges->getQuantite();
  236.         }
  237.        
  238.         
  239.         return $reste;
  240.     }
  241.     public function getetatAvancementForOperation()
  242.     {
  243.         $etatAvancement 0;
  244.         if($this->getTotalQuantiteForParcelle()){
  245.         $etatAvancement intval($this->getTotalQuantiteForVente() * 100 $this->getTotalQuantiteForParcelle());
  246.     }
  247.         return  $etatAvancement?:0;
  248.     }
  249.     /**
  250.      * @return Collection<int, TblDetailCharge>
  251.      */
  252.     public function getDetailCharge(): Collection
  253.     {
  254.         return $this->detailCharge;
  255.     }
  256.     public function addDetailCharge(TblDetailCharge $detailCharge): self
  257.     {
  258.         if (!$this->detailCharge->contains($detailCharge)) {
  259.             $this->detailCharge[] = $detailCharge;
  260.             $detailCharge->setTblOperationVente($this);
  261.         }
  262.         return $this;
  263.     }
  264.     public function removeDetailCharge(TblDetailCharge $detailCharge): self
  265.     {
  266.         if ($this->detailCharge->removeElement($detailCharge)) {
  267.             // set the owning side to null (unless already changed)
  268.             if ($detailCharge->getTblOperationVente() === $this) {
  269.                 $detailCharge->setTblOperationVente(null);
  270.             }
  271.         }
  272.         return $this;
  273.     }
  274.     /**
  275.      * @return Collection<int, TblDetailProduitVente>
  276.      */
  277.     public function getDetailProduitVente(): Collection
  278.     {
  279.         return $this->detailProduitVente;
  280.     }
  281.     public function addDetailProduitVente(TblDetailProduitVente $detailProduitVente): self
  282.     {
  283.         if (!$this->detailProduitVente->contains($detailProduitVente)) {
  284.             $this->detailProduitVente[] = $detailProduitVente;
  285.             $detailProduitVente->setTblOperationVente($this);
  286.         }
  287.         return $this;
  288.     }
  289.     public function removeDetailProduitVente(TblDetailProduitVente $detailProduitVente): self
  290.     {
  291.         if ($this->detailProduitVente->removeElement($detailProduitVente)) {
  292.             // set the owning side to null (unless already changed)
  293.             if ($detailProduitVente->getTblOperationVente() === $this) {
  294.                 $detailProduitVente->setTblOperationVente(null);
  295.             }
  296.         }
  297.         return $this;
  298.     }
  299.     /**
  300.      * @return Collection<int, TblDetailQuantiteParcelle>
  301.      */
  302.     public function getDetailQuantiteParcelle(): Collection
  303.     {
  304.         return $this->detailQuantiteParcelle;
  305.     }
  306.     public function addDetailQuantiteParcelle(TblDetailQuantiteParcelle $detailQuantiteParcelle): self
  307.     {
  308.         if (!$this->detailQuantiteParcelle->contains($detailQuantiteParcelle)) {
  309.             $this->detailQuantiteParcelle[] = $detailQuantiteParcelle;
  310.             $detailQuantiteParcelle->setTblOperationVente($this);
  311.         }
  312.         return $this;
  313.     }
  314.     public function removeDetailQuantiteParcelle(TblDetailQuantiteParcelle $detailQuantiteParcelle): self
  315.     {
  316.         if ($this->detailQuantiteParcelle->removeElement($detailQuantiteParcelle)) {
  317.             // set the owning side to null (unless already changed)
  318.             if ($detailQuantiteParcelle->getTblOperationVente() === $this) {
  319.                 $detailQuantiteParcelle->setTblOperationVente(null);
  320.             }
  321.         }
  322.         return $this;
  323.     }
  324.     public function getVendeur(): ?User
  325.     {
  326.         return $this->vendeur;
  327.     }
  328.     public function setVendeur(?User $vendeur): self
  329.     {
  330.         $this->vendeur $vendeur;
  331.         return $this;
  332.     }
  333.     public function getDestination(): ?RefVille
  334.     {
  335.         return $this->destination;
  336.     }
  337.     public function setDestination(?RefVille $destination): self
  338.     {
  339.         $this->destination $destination;
  340.         return $this;
  341.     }
  342.     /**
  343.      * @return Collection<int, RefMoyenTransport>
  344.      */
  345.     public function getMoyenTransports(): Collection
  346.     {
  347.         return $this->moyenTransports;
  348.     }
  349.     public function addMoyenTransport(RefMoyenTransport $moyenTransport): self
  350.     {
  351.         if (!$this->moyenTransports->contains($moyenTransport)) {
  352.             $this->moyenTransports[] = $moyenTransport;
  353.         }
  354.         return $this;
  355.     }
  356.     public function removeMoyenTransport(RefMoyenTransport $moyenTransport): self
  357.     {
  358.         if ($this->moyenTransports->removeElement($moyenTransport)) {
  359.             
  360.         }
  361.         return $this;
  362.     }
  363.     /**
  364.      * @return Collection<int, TblFile>
  365.      */
  366.     public function getFiles(): Collection
  367.     {
  368.         return $this->files;
  369.     }
  370.     public function addFile(TblFile $file): self
  371.     {
  372.         if (!$this->files->contains($file)) {
  373.             $this->files[] = $file;
  374.         }
  375.         return $this;
  376.     }
  377.     public function removeFile(TblFile $file): self
  378.     {
  379.         $this->files->removeElement($file);
  380.         return $this;
  381.     }
  382.     public function getMatricule(): ?string
  383.     {
  384.         return $this->matricule;
  385.     }
  386.     public function setMatricule(?string $matricule): self
  387.     {
  388.         $this->matricule $matricule;
  389.         return $this;
  390.     }
  391. }