src/Entity/Reception.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ReceptionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=ReceptionRepository::class)
  9.  */
  10. class Reception
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity=Agent::class, inversedBy="receptions")
  20.      */
  21.     private $client;
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity=Utilisateur::class, inversedBy="receptions")
  24.      */
  25.     private $user;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $recunumero;
  30.     /**
  31.      * @ORM\Column(type="datetime_immutable")
  32.      */
  33.     private $dateOperation;
  34.     /**
  35.      * @ORM\Column(type="string", length=50, nullable=true)
  36.      */
  37.     private $truckingNumber;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=ArgentSupplementaire::class, mappedBy="reception", cascade={"persist", "remove"})
  40.      */
  41.     private $argentSupplements;
  42.     /**
  43.      * @ORM\Column(type="string", length=50, nullable=true)
  44.      */
  45.     private $supplier;
  46.     /**
  47.      * @ORM\Column(type="string", length=100)
  48.      */
  49.     private $destination;
  50.     /**
  51.      * @ORM\Column(type="string", length=10)
  52.      */
  53.     private $alert;
  54.     /**
  55.      * @ORM\Column(type="string", length=14)
  56.      */
  57.     private $type;
  58.     /**
  59.      * @ORM\Column(type="boolean")
  60.      */
  61.     private $isCharge;
  62.     /**
  63.      * @ORM\Column(type="boolean")
  64.      */
  65.     private $isCalcule;
  66.     /**
  67.      * @ORM\Column(type="string", length=20)
  68.      */
  69.     private $conteneurtype;
  70.     /**
  71.      * @ORM\Column(type="string", length=400)
  72.      */
  73.     private $imageBon;
  74.     /**
  75.      * @ORM\Column(type="string", length=400)
  76.      */
  77.     private $imageColis;
  78.     private $days;
  79.     /**
  80.      * @ORM\Column(type="string", length=20)
  81.      */
  82.     private $fret;
  83.     /**
  84.      * @ORM\Column(type="string", length=100, nullable=true)
  85.      */
  86.     private $alias;
  87.     /**
  88.      * @ORM\Column(type="string", length=20, nullable=true)
  89.      */
  90.     private $numero;
  91.     /**
  92.      * @ORM\Column(type="string", length=10)
  93.      */
  94.     private $werehouse;
  95.     /**
  96.      * @ORM\Column(type="string", length=100, nullable=true)
  97.      */
  98.     private $fournisseur;
  99.     /**
  100.      * @ORM\OneToMany(targetEntity=TmpReception::class, mappedBy="reception",cascade={"persist", "remove"})
  101.      */
  102.     private $tmpReceptions;
  103.     private $totalCBM;
  104.     private $totalTONNE;
  105.     private $totalKG;
  106.     private $totalColis;
  107.     private $totalNatureColis;
  108.     private $totalCBMVille;
  109.     private $totalTonneVille;
  110.     private $totalKGVille;
  111.     /**
  112.      * @ORM\Column(type="string", length=100)
  113.      */
  114.     private $flutterid;
  115.     /**
  116.      * @ORM\Column(type="string", length=20)
  117.      */
  118.     private $provenance;
  119.     /**
  120.      * @ORM\Column(type="string", length=20, nullable=true)
  121.      */
  122.     private $numeroRecuStore;
  123.     /**
  124.      * @ORM\Column(type="string", length=20)
  125.      */
  126.     private $montantValeur;
  127.     /**
  128.      * @ORM\Column(type="string", length=10)
  129.      */
  130.     private $charge;
  131.     /**
  132.      * @ORM\Column(type="string", length=20)
  133.      */
  134.     private $quantite;
  135.     /**
  136.      * @ORM\Column(type="string", length=20)
  137.      */
  138.     private $quantiteCharge;
  139.     /**
  140.      * @ORM\ManyToOne(targetEntity=Ville::class, inversedBy="receptions")
  141.      * @ORM\JoinColumn(nullable=false)
  142.      */
  143.     private $ville;
  144.     /**
  145.      * @ORM\ManyToOne(targetEntity=Ville::class, inversedBy="destville")
  146.      */
  147.     private $destville;
  148.     public function __construct()
  149.     {
  150.         $this->isCharge = false;
  151.         $this->isCalcule = false;
  152.         $this->numeroRecuStore = 'AFI-';
  153.         $this->fournisseur = '#######';
  154.         $this->montantValeur = '0';
  155.         $this->type = 'LEGER';
  156.         $this->fret = '400';
  157.         $this->charge = '1';
  158.         $this->quantite = '0';
  159.         $this->quantiteCharge = '0';
  160.        // $this->flutterid = md5($this->recunumero + 1).$this->truckingNumber;
  161.         $this->dateOperation = new \DateTimeImmutable();
  162.         $this->tmpConteneurReceptions = new ArrayCollection();
  163.         $this->tmpReceptions = new ArrayCollection();
  164.         $this->argentSupplements = new ArrayCollection();
  165.     }
  166.     public function getDays()
  167.     {
  168.         $create = $this->getDateOperation();
  169.         $later = new \DateTime(date('Y-m-d'));
  170.         $this->days = $later->diff($create)->format("%a");
  171.         return $this->days;
  172.     }
  173.     public function getId(): ?int
  174.     {
  175.         return $this->id;
  176.     }
  177.     public function getClient(): ?agent
  178.     {
  179.         return $this->client;
  180.     }
  181.     public function setClient(?agent $client): self
  182.     {
  183.         $this->client = $client;
  184.         return $this;
  185.     }
  186.     public function getUser(): ?utilisateur
  187.     {
  188.         return $this->user;
  189.     }
  190.     public function setUser(?utilisateur $user): self
  191.     {
  192.         $this->user = $user;
  193.         return $this;
  194.     }
  195.     public function getRecunumero(): ?string
  196.     {
  197.         return $this->recunumero;
  198.     }
  199.     public function setRecunumero(string $recunumero): self
  200.     {
  201.         $this->recunumero = $recunumero;
  202.         return $this;
  203.     }
  204.     public function getDateOperation(): ?\DateTimeImmutable
  205.     {
  206.         return $this->dateOperation;
  207.     }
  208.     public function setDateOperation(\DateTimeImmutable $dateOperation): self
  209.     {
  210.         $this->dateOperation = $dateOperation;
  211.         return $this;
  212.     }
  213.     public function getSupplier(): ?string
  214.     {
  215.         return $this->supplier;
  216.     }
  217.     public function setSupplier(?string $supplier): self
  218.     {
  219.         $this->supplier = $supplier;
  220.         return $this;
  221.     }
  222.     public function getTruckingNumber(): ?string
  223.     {
  224.         return $this->truckingNumber;
  225.     }
  226.     public function setTruckingNumber(?string $truckingNumber): self
  227.     {
  228.         $this->truckingNumber = $truckingNumber;
  229.         return $this;
  230.     }
  231.     public function getDestination(): ?string
  232.     {
  233.         return $this->destination;
  234.     }
  235.     public function setDestination(string $destination): self
  236.     {
  237.         $this->destination = $destination;
  238.         return $this;
  239.     }
  240.     public function getAlert(): ?string
  241.     {
  242.         return $this->alert;
  243.     }
  244.     public function setAlert(string $alert): self
  245.     {
  246.         $this->alert = $alert;
  247.         return $this;
  248.     }
  249.     public function getType(): ?string
  250.     {
  251.         return $this->type;
  252.     }
  253.     public function setType(string $type): self
  254.     {
  255.         $this->type = $type;
  256.         return $this;
  257.     }
  258.     public function isIsCharge(): ?bool
  259.     {
  260.         return $this->isCharge;
  261.     }
  262.     public function setIsCharge(bool $isCharge): self
  263.     {
  264.         $this->isCharge = $isCharge;
  265.         return $this;
  266.     }
  267.     public function isIsCalcule(): ?bool
  268.     {
  269.         return $this->isCalcule;
  270.     }
  271.     public function setIsCalcule(bool $isCalcule): self
  272.     {
  273.         $this->isCalcule = $isCalcule;
  274.         return $this;
  275.     }
  276.     public function getConteneurtype(): ?string
  277.     {
  278.         return $this->conteneurtype;
  279.     }
  280.     public function setConteneurtype(string $conteneurtype): self
  281.     {
  282.         $this->conteneurtype = $conteneurtype;
  283.         return $this;
  284.     }
  285.     public function getImageBon(): ?string
  286.     {
  287.         return $this->imageBon;
  288.     }
  289.     public function setImageBon(string $imageBon): self
  290.     {
  291.         $this->imageBon = $imageBon;
  292.         return $this;
  293.     }
  294.     public function getImageColis(): ?string
  295.     {
  296.         return $this->imageColis;
  297.     }
  298.     public function setImageColis(string $imageColis): self
  299.     {
  300.         $this->imageColis = $imageColis;
  301.         return $this;
  302.     }
  303.     public function getFret(): ?string
  304.     {
  305.         return $this->fret;
  306.     }
  307.     public function setFret(string $fret): self
  308.     {
  309.         $this->fret = $fret;
  310.         return $this;
  311.     }
  312.     public function getAlias(): ?string
  313.     {
  314.         return $this->alias;
  315.     }
  316.     public function setAlias(?string $alias): self
  317.     {
  318.         $this->alias = $alias;
  319.         return $this;
  320.     }
  321.     public function getNumero(): ?string
  322.     {
  323.         return $this->numero;
  324.     }
  325.     public function setNumero(?string $numero): self
  326.     {
  327.         $this->numero = $numero;
  328.         return $this;
  329.     }
  330.     public function getWerehouse(): ?string
  331.     {
  332.         return $this->werehouse;
  333.     }
  334.     public function setWerehouse(string $werehouse): self
  335.     {
  336.         $this->werehouse = $werehouse;
  337.         return $this;
  338.     }
  339.     public function getFournisseur(): ?string
  340.     {
  341.         return $this->fournisseur;
  342.     }
  343.     public function setFournisseur(?string $fournisseur): self
  344.     {
  345.         $this->fournisseur = $fournisseur;
  346.         return $this;
  347.     }
  348.     public function getTotalCBM()
  349.     {
  350.         $total = 0;
  351.         foreach($this->getTmpReceptions() as $v){
  352.             if($v->getUnite() == 'CBM'){
  353.                 if($this->isCalcule){
  354.                     $total = $total + ($v->getVolume() * $v->getQuantite());
  355.                 }else{
  356.                     $total = $total + $v->getVolume();
  357.                 }
  358.             }
  359.         }
  360.         return  $this->totalCBM = $total;
  361.     }
  362.     public function getTotalTONNE()
  363.     {
  364.         $total = 0;
  365.         foreach($this->getTmpReceptions() as $v){
  366.             if($v->getUnite() == 'TONNE'){
  367.                 if($this->isCalcule){
  368.                     $total = $total + ($v->getTonne() * $v->getQuantite());
  369.                 }else{
  370.                     $total = $total + $v->getTonne();
  371.                 }
  372.             }
  373.         }
  374.         return  $this->totalTONNE = $total;
  375.     }
  376.     /**
  377.      * @return mixed
  378.      */
  379.     public function getTotalKG()
  380.     {
  381.         $total = 0;
  382.         foreach($this->getTmpReceptions() as $v){
  383.             if($v->getUnite() == 'KG'){
  384.                 if($this->isCalcule){
  385.                     $total = $total + ($v->getVolume() * $v->getQuantite());
  386.                 }else{
  387.                     $total = $total + $v->getVolume();
  388.                 }
  389.             }
  390.         }
  391.         return $this->totalKG = $total;
  392.     }
  393.     /**
  394.      * @return mixed
  395.      */
  396.     public function getTotalColis()
  397.     {
  398.         $total = 0;
  399.         foreach($this->getTmpReceptions() as $v){
  400.                 $total = $total + $v->getQuantite();
  401.         }
  402.         return $this->totalColis = $total;
  403.     }
  404.     /**
  405.      * @return mixed
  406.      */
  407.     public function getTotalNatureColis()
  408.     {
  409.         $total = '';
  410.         foreach($this->getTmpReceptions() as $v){
  411.             $total = $total.' '.$v->getQuantite().' '.$v->getNature().', ';
  412.         }
  413.         return $this->totalNatureColis = $total;
  414.     }
  415.     /**
  416.      * @return Collection<int, TmpReception>
  417.      */
  418.     public function getTmpReceptions(): Collection
  419.     {
  420.         return $this->tmpReceptions;
  421.     }
  422.     public function addTmpReception(TmpReception $tmpReception): self
  423.     {
  424.         if (!$this->tmpReceptions->contains($tmpReception)) {
  425.             $this->tmpReceptions[] = $tmpReception;
  426.             $tmpReception->setReception($this);
  427.         }
  428.         return $this;
  429.     }
  430.     public function removeTmpReception(TmpReception $tmpReception): self
  431.     {
  432.         if ($this->tmpReceptions->removeElement($tmpReception)) {
  433.             // set the owning side to null (unless already changed)
  434.             if ($tmpReception->getReception() === $this) {
  435.                 $tmpReception->setReception(null);
  436.             }
  437.         }
  438.         return $this;
  439.     }
  440.     public function getFlutterid(): ?string
  441.     {
  442.         return $this->flutterid;
  443.     }
  444.     public function setFlutterid(string $flutterid): self
  445.     {
  446.         $this->flutterid = $flutterid;
  447.         return $this;
  448.     }
  449.     public function getProvenance(): ?string
  450.     {
  451.         return $this->provenance;
  452.     }
  453.     public function setProvenance(string $provenance): self
  454.     {
  455.         $this->provenance = $provenance;
  456.         return $this;
  457.     }
  458.     public function getNumeroRecuStore(): ?string
  459.     {
  460.         return $this->numeroRecuStore;
  461.     }
  462.     public function setNumeroRecuStore(?string $numeroRecuStore): self
  463.     {
  464.         $this->numeroRecuStore = $numeroRecuStore;
  465.         return $this;
  466.     }
  467.     public function getMontantValeur(): ?string
  468.     {
  469.         return $this->montantValeur;
  470.     }
  471.     public function setMontantValeur(string $montantValeur): self
  472.     {
  473.         $this->montantValeur = $montantValeur;
  474.         return $this;
  475.     }
  476.     public function getCharge(): ?string
  477.     {
  478.         return $this->charge;
  479.     }
  480.     public function setCharge(string $charge): self
  481.     {
  482.         $this->charge = $charge;
  483.         return $this;
  484.     }
  485.     public function getQuantite(): ?string
  486.     {
  487.         return $this->quantite;
  488.     }
  489.     public function setQuantite(string $quantite): self
  490.     {
  491.         $this->quantite = $quantite;
  492.         return $this;
  493.     }
  494.     public function getQuantiteCharge(): ?string
  495.     {
  496.         return $this->quantiteCharge;
  497.     }
  498.     public function setQuantiteCharge(string $quantiteCharge): self
  499.     {
  500.         $this->quantiteCharge = $quantiteCharge;
  501.         return $this;
  502.     }
  503.     public function getVille(): ?Ville
  504.     {
  505.         return $this->ville;
  506.     }
  507.     public function setVille(?Ville $ville): self
  508.     {
  509.         $this->ville = $ville;
  510.         return $this;
  511.     }
  512.     public function getDestville(): ?Ville
  513.     {
  514.         return $this->destville;
  515.     }
  516.     public function setDestville(?Ville $destville): self
  517.     {
  518.         $this->destville = $destville;
  519.         return $this;
  520.     }
  521.     public function getTotalCBMVille() : ?string
  522.     {
  523.         $total = 0;
  524.             foreach ($this->getDestville() as $vv) {
  525.                 if ($vv->getUnite() == 'CBM') {
  526.                     $total = $total + $this->getTotalCBM();
  527.                 }
  528.         }
  529.         return $this->totalCBMVille = $total;
  530.     }
  531.     /**
  532.      * @return mixed
  533.      */
  534.     public function getTotalTONNEVille() : ?string
  535.     {
  536.         $total = 0;
  537.         foreach ($this->getDestville() as $v) {
  538.             foreach ($v->getTmpReceptions() as $vv) {
  539.                 if ($vv->getUnite() == 'TONNE') {
  540.                     $total = $total + ($vv->getTonne() * $vv->getQuantite());
  541.                 }
  542.             }
  543.         }
  544.         $this->totalTonneVille = $total;
  545.         return $this->totalTonneVille;
  546.     }
  547.     public function getTotalKGVille() : ?string
  548.     {
  549.         $total = 0;
  550.         foreach ($this->getDestville() as $v) {
  551.             foreach ($v->getTmpReceptions() as $vv) {
  552.                 if ($vv->getUnite() == 'KG') {
  553.                     $total = $total + ($vv->getVolume() * $vv->getQuantite());
  554.                 }
  555.             }
  556.         }
  557.         return $this->totalKGVille = $total;
  558.     }
  559.     /**
  560.      * @return Collection<int, ArgentSupplementaire>
  561.      */
  562.     public function getArgentSupplements(): Collection
  563.     {
  564.         return $this->argentSupplements;
  565.     }
  566.     public function addArgentSupplement(ArgentSupplementaire $argentSupplement): self
  567.     {
  568.         if (!$this->argentSupplements->contains($argentSupplement)) {
  569.             $this->argentSupplements[] = $argentSupplement;
  570.             $argentSupplement->setReception($this);
  571.         }
  572.         return $this;
  573.     }
  574.     public function removeArgentSupplement(ArgentSupplementaire $argentSupplement): self
  575.     {
  576.         if ($this->argentSupplements->removeElement($argentSupplement)) {
  577.             // set the owning side to null (unless already changed)
  578.             if ($argentSupplement->getReception() === $this) {
  579.                 $argentSupplement->setReception(null);
  580.             }
  581.         }
  582.         return $this;
  583.     }
  584. }