<?php
namespace App\Entity;
use App\Repository\ReceptionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ReceptionRepository::class)
*/
class Reception
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Agent::class, inversedBy="receptions")
*/
private $client;
/**
* @ORM\ManyToOne(targetEntity=Utilisateur::class, inversedBy="receptions")
*/
private $user;
/**
* @ORM\Column(type="string", length=255)
*/
private $recunumero;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $dateOperation;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $truckingNumber;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $supplier;
/**
* @ORM\Column(type="string", length=100)
*/
private $destination;
/**
* @ORM\Column(type="string", length=10)
*/
private $alert;
/**
* @ORM\Column(type="string", length=14)
*/
private $type;
/**
* @ORM\Column(type="boolean")
*/
private $isCharge;
/**
* @ORM\Column(type="boolean")
*/
private $isCalcule;
/**
* @ORM\Column(type="string", length=20)
*/
private $conteneurtype;
/**
* @ORM\Column(type="string", length=400)
*/
private $imageBon;
/**
* @ORM\Column(type="string", length=400)
*/
private $imageColis;
private $days;
/**
* @ORM\Column(type="string", length=20)
*/
private $fret;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $alias;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $numero;
/**
* @ORM\Column(type="string", length=10)
*/
private $werehouse;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $fournisseur;
/**
* @ORM\OneToMany(targetEntity=TmpReception::class, mappedBy="reception",cascade={"persist"})
*/
private $tmpReceptions;
private $totalCBM;
private $totalTONNE;
private $totalKG;
private $totalColis;
private $totalNatureColis;
private $totalCBMVille;
private $totalTonneVille;
private $totalKGVille;
/**
* @ORM\Column(type="string", length=100)
*/
private $flutterid;
/**
* @ORM\Column(type="string", length=20)
*/
private $provenance;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $numeroRecuStore;
/**
* @ORM\Column(type="string", length=20)
*/
private $montantValeur;
/**
* @ORM\Column(type="string", length=10)
*/
private $charge;
/**
* @ORM\Column(type="string", length=20)
*/
private $quantite;
/**
* @ORM\Column(type="string", length=20)
*/
private $quantiteCharge;
/**
* @ORM\ManyToOne(targetEntity=Ville::class, inversedBy="receptions")
* @ORM\JoinColumn(nullable=false)
*/
private $ville;
/**
* @ORM\ManyToOne(targetEntity=Ville::class, inversedBy="destville")
*/
private $destville;
public function __construct()
{
$this->isCharge = false;
$this->isCalcule = false;
$this->numeroRecuStore = 'AFI-';
$this->fournisseur = '#######';
$this->montantValeur = '0';
$this->type = 'LEGER';
$this->fret = '400';
$this->charge = '1';
$this->quantite = '0';
$this->quantiteCharge = '0';
$this->flutterid = md5($this->recunumero + 1).$this->truckingNumber;
$this->dateOperation = new \DateTimeImmutable();
$this->tmpConteneurReceptions = new ArrayCollection();
$this->tmpReceptions = new ArrayCollection();
}
public function getDays()
{
$create = $this->getDateOperation();
$later = new \DateTime(date('Y-m-d'));
$this->days = $later->diff($create)->format("%a");
return $this->days;
}
public function getId(): ?int
{
return $this->id;
}
public function getClient(): ?agent
{
return $this->client;
}
public function setClient(?agent $client): self
{
$this->client = $client;
return $this;
}
public function getUser(): ?utilisateur
{
return $this->user;
}
public function setUser(?utilisateur $user): self
{
$this->user = $user;
return $this;
}
public function getRecunumero(): ?string
{
return $this->recunumero;
}
public function setRecunumero(string $recunumero): self
{
$this->recunumero = $recunumero;
return $this;
}
public function getDateOperation(): ?\DateTimeImmutable
{
return $this->dateOperation;
}
public function setDateOperation(\DateTimeImmutable $dateOperation): self
{
$this->dateOperation = $dateOperation;
return $this;
}
public function getSupplier(): ?string
{
return $this->supplier;
}
public function setSupplier(?string $supplier): self
{
$this->supplier = $supplier;
return $this;
}
public function getTruckingNumber(): ?string
{
return $this->truckingNumber;
}
public function setTruckingNumber(?string $truckingNumber): self
{
$this->truckingNumber = $truckingNumber;
return $this;
}
public function getDestination(): ?string
{
return $this->destination;
}
public function setDestination(string $destination): self
{
$this->destination = $destination;
return $this;
}
public function getAlert(): ?string
{
return $this->alert;
}
public function setAlert(string $alert): self
{
$this->alert = $alert;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function isIsCharge(): ?bool
{
return $this->isCharge;
}
public function setIsCharge(bool $isCharge): self
{
$this->isCharge = $isCharge;
return $this;
}
public function isIsCalcule(): ?bool
{
return $this->isCalcule;
}
public function setIsCalcule(bool $isCalcule): self
{
$this->isCalcule = $isCalcule;
return $this;
}
public function getConteneurtype(): ?string
{
return $this->conteneurtype;
}
public function setConteneurtype(string $conteneurtype): self
{
$this->conteneurtype = $conteneurtype;
return $this;
}
public function getImageBon(): ?string
{
return $this->imageBon;
}
public function setImageBon(string $imageBon): self
{
$this->imageBon = $imageBon;
return $this;
}
public function getImageColis(): ?string
{
return $this->imageColis;
}
public function setImageColis(string $imageColis): self
{
$this->imageColis = $imageColis;
return $this;
}
public function getFret(): ?string
{
return $this->fret;
}
public function setFret(string $fret): self
{
$this->fret = $fret;
return $this;
}
public function getAlias(): ?string
{
return $this->alias;
}
public function setAlias(?string $alias): self
{
$this->alias = $alias;
return $this;
}
public function getNumero(): ?string
{
return $this->numero;
}
public function setNumero(?string $numero): self
{
$this->numero = $numero;
return $this;
}
public function getWerehouse(): ?string
{
return $this->werehouse;
}
public function setWerehouse(string $werehouse): self
{
$this->werehouse = $werehouse;
return $this;
}
public function getFournisseur(): ?string
{
return $this->fournisseur;
}
public function setFournisseur(?string $fournisseur): self
{
$this->fournisseur = $fournisseur;
return $this;
}
public function getTotalCBM()
{
$total = 0;
foreach($this->getTmpReceptions() as $v){
if($v->getUnite() == 'CBM'){
if($this->isCalcule){
$total = $total + ($v->getVolume() * $v->getQuantite());
}else{
$total = $total + $v->getVolume();
}
}
}
return $this->totalCBM = $total;
}
public function getTotalTONNE()
{
$total = 0;
foreach($this->getTmpReceptions() as $v){
if($v->getUnite() == 'TONNE'){
if($this->isCalcule){
$total = $total + ($v->getTonne() * $v->getQuantite());
}else{
$total = $total + $v->getTonne();
}
}
}
return $this->totalTONNE = $total;
}
/**
* @return mixed
*/
public function getTotalKG()
{
$total = 0;
foreach($this->getTmpReceptions() as $v){
if($v->getUnite() == 'KG'){
if($this->isCalcule){
$total = $total + ($v->getVolume() * $v->getQuantite());
}else{
$total = $total + $v->getVolume();
}
}
}
return $this->totalKG = $total;
}
/**
* @return mixed
*/
public function getTotalColis()
{
$total = 0;
foreach($this->getTmpReceptions() as $v){
$total = $total + $v->getQuantite();
}
return $this->totalColis = $total;
}
/**
* @return mixed
*/
public function getTotalNatureColis()
{
$total = '';
foreach($this->getTmpReceptions() as $v){
$total = $total.' '.$v->getQuantite().' '.$v->getNature().', ';
}
return $this->totalNatureColis = $total;
}
/**
* @return Collection<int, TmpReception>
*/
public function getTmpReceptions(): Collection
{
return $this->tmpReceptions;
}
public function addTmpReception(TmpReception $tmpReception): self
{
if (!$this->tmpReceptions->contains($tmpReception)) {
$this->tmpReceptions[] = $tmpReception;
$tmpReception->setReception($this);
}
return $this;
}
public function removeTmpReception(TmpReception $tmpReception): self
{
if ($this->tmpReceptions->removeElement($tmpReception)) {
// set the owning side to null (unless already changed)
if ($tmpReception->getReception() === $this) {
$tmpReception->setReception(null);
}
}
return $this;
}
public function getFlutterid(): ?string
{
return $this->flutterid;
}
public function setFlutterid(string $flutterid): self
{
$this->flutterid = $flutterid;
return $this;
}
public function getProvenance(): ?string
{
return $this->provenance;
}
public function setProvenance(string $provenance): self
{
$this->provenance = $provenance;
return $this;
}
public function getNumeroRecuStore(): ?string
{
return $this->numeroRecuStore;
}
public function setNumeroRecuStore(?string $numeroRecuStore): self
{
$this->numeroRecuStore = $numeroRecuStore;
return $this;
}
public function getMontantValeur(): ?string
{
return $this->montantValeur;
}
public function setMontantValeur(string $montantValeur): self
{
$this->montantValeur = $montantValeur;
return $this;
}
public function getCharge(): ?string
{
return $this->charge;
}
public function setCharge(string $charge): self
{
$this->charge = $charge;
return $this;
}
public function getQuantite(): ?string
{
return $this->quantite;
}
public function setQuantite(string $quantite): self
{
$this->quantite = $quantite;
return $this;
}
public function getQuantiteCharge(): ?string
{
return $this->quantiteCharge;
}
public function setQuantiteCharge(string $quantiteCharge): self
{
$this->quantiteCharge = $quantiteCharge;
return $this;
}
public function getVille(): ?Ville
{
return $this->ville;
}
public function setVille(?Ville $ville): self
{
$this->ville = $ville;
return $this;
}
public function getDestville(): ?Ville
{
return $this->destville;
}
public function setDestville(?Ville $destville): self
{
$this->destville = $destville;
return $this;
}
public function getTotalCBMVille() : ?string
{
$total = 0;
foreach ($this->getDestville() as $vv) {
if ($vv->getUnite() == 'CBM') {
$total = $total + $this->getTotalCBM();
}
}
return $this->totalCBMVille = $total;
}
/**
* @return mixed
*/
public function getTotalTONNEVille() : ?string
{
$total = 0;
foreach ($this->getDestville() as $v) {
foreach ($v->getTmpReceptions() as $vv) {
if ($vv->getUnite() == 'TONNE') {
$total = $total + ($vv->getTonne() * $vv->getQuantite());
}
}
}
$this->totalTonneVille = $total;
return $this->totalTonneVille;
}
public function getTotalKGVille() : ?string
{
$total = 0;
foreach ($this->getDestville() as $v) {
foreach ($v->getTmpReceptions() as $vv) {
if ($vv->getUnite() == 'KG') {
$total = $total + ($vv->getVolume() * $vv->getQuantite());
}
}
}
return $this->totalKGVille = $total;
}
}