<?php
namespace App\Entity;
use App\Entity\Traits\TimestampableTrait;
use App\Repository\TblMouvementRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass=TblMouvementRepository::class)
* @Gedmo\Loggable
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
*/
class TblMouvement
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="date")
* @Gedmo\Versioned
*/
private $dateMouvement;
/**
* @ORM\Column(type="float")
* @Gedmo\Versioned
*/
private $quantite;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Gedmo\Versioned
*/
private $NumFacture;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="acheter_par", referencedColumnName="user_id")
* })
* @Gedmo\Blameable(on="create")
* @Gedmo\Versioned
*/
private $acheterPar;
/**
* @ORM\ManyToOne(targetEntity=RefEtatMouvement::class)
* @ORM\JoinColumn(nullable=false)
* @Gedmo\Versioned
*/
private $etatMouvement;
/**
* @ORM\ManyToOne(targetEntity=RefTypeMouvement::class)
* @ORM\JoinColumn(nullable=false)
* @Gedmo\Versioned
*/
private $typeMouvement;
/**
* @ORM\Column(type="float", nullable=true)
* @Gedmo\Versioned
*/
private $prixAchatUnitaire;
/**
* @ORM\Column(type="text", nullable=true)
* @Gedmo\Versioned
*/
private $description;
/**
* @ORM\ManyToMany(targetEntity=TblFile::class,cascade={"persist"})
* @ORM\JoinTable(name="lnk_tbl_mouvement_tbl_file",
* joinColumns={
* @ORM\JoinColumn(name="tbl_mouvement_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="tbl_file_id", referencedColumnName="id", nullable=false)
* }
* )
*/
private $files;
/**
* @ORM\ManyToOne(targetEntity=RefTypeStock::class, inversedBy="mouvements")
* @ORM\JoinColumn(nullable=true)
*/
private $entrepot;
/**
* @ORM\ManyToOne(targetEntity=RefTypeProduit::class, inversedBy="mouvements")
* @ORM\JoinColumn(nullable=false)
* @Gedmo\Versioned
*/
private $typeProduit;
/**
* @ORM\ManyToMany(targetEntity=TblParcelle::class, inversedBy="mouvements" ,cascade={"persist"})
* @ORM\JoinTable(name="lnk_tbl_mouvement_parcelle",
* joinColumns={
* @ORM\JoinColumn(name="mouvement_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="parcelle_id", referencedColumnName="id", nullable=false )
* }
* )
*/
private $parcelle;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="mouvements")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="consommateur", referencedColumnName="user_id")
* })
*/
private $consommateur;
/**
* @ORM\ManyToOne(targetEntity=TblOperations::class, inversedBy="tblMouvements")
*/
private $operations;
/**
* @ORM\OneToOne(targetEntity=TblDetailProduitOperation::class, mappedBy="mouvement", cascade={"persist", "remove"})
*/
private $detailProduitOperation;
/**
* @ORM\OneToOne(targetEntity=TblDetailQuantiteParcelle::class, mappedBy="mouvement", cascade={"persist", "remove"})
*/
private $tblDetailQuantiteParcelle;
/**
* @ORM\ManyToOne(targetEntity=TblPersonnel::class, inversedBy="tblMouvements")
*/
private $personnel;
use Workflowable;
public function __construct()
{
$this->files = new ArrayCollection();
$this->parcelle = new ArrayCollection();
}
use TimestampableTrait;
public function toArrayDatatable($urlEdit)
{
return [
$this->getDateMouvement()->format('d/m/Y'),
$this->getTypeMouvementIcon(),
$this->getTypeProduit()->__toString(),
$this->getQuantite().' '.$this->getTypeProduit()->getUnite(),
number_format($this->getPrixAchatUnitaire() * $this->getQuantite(), 2, ",", " "),
$this->getPersonnel()?$this->getPersonnel()->__toString():"--",
$this->getDescription(),
$this->getEtatMouvementIcon(),
$this->getIconsMouvement($urlEdit),
];
}
public function getId(): ?int
{
return $this->id;
}
public function getDateMouvement(): ?\DateTimeInterface
{
return $this->dateMouvement;
}
public function setDateMouvement(\DateTimeInterface $dateMouvement): self
{
$this->dateMouvement = $dateMouvement;
return $this;
}
public function getTypeProduit(): ?RefTypeProduit
{
return $this->typeProduit;
}
public function setTypeProduit(?RefTypeProduit $typeProduit): self
{
$this->typeProduit = $typeProduit;
return $this;
}
public function getQuantite(): ?float
{
return $this->quantite;
}
public function setQuantite(?float $quantite): self
{
$this->quantite = $quantite;
return $this;
}
public function getNumFacture(): ?string
{
return $this->NumFacture;
}
public function setNumFacture(?string $NumFacture): self
{
$this->NumFacture = $NumFacture;
return $this;
}
public function getAcheterPar(): ?User
{
return $this->acheterPar;
}
public function setAcheterPar(?User $acheterPar): self
{
$this->acheterPar = $acheterPar;
return $this;
}
public function getEtatMouvement(): ?RefEtatMouvement
{
return $this->etatMouvement;
}
public function setEtatMouvement(?RefEtatMouvement $etatMouvement): self
{
$this->etatMouvement = $etatMouvement;
return $this;
}
public function getTypeMouvement(): ?RefTypeMouvement
{
return $this->typeMouvement;
}
public function setTypeMouvement(?RefTypeMouvement $typeMouvement): self
{
$this->typeMouvement = $typeMouvement;
return $this;
}
public function getPrixAchatUnitaire(): ?float
{
return $this->prixAchatUnitaire;
}
public function setPrixAchatUnitaire(float $prixAchatUnitaire): self
{
$this->prixAchatUnitaire = $prixAchatUnitaire;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection<int, TblFile>
*/
public function getFiles(): Collection
{
return $this->files;
}
public function addFile(TblFile $file): self
{
if (!$this->files->contains($file)) {
$this->files[] = $file;
}
return $this;
}
public function removeFile(TblFile $file): self
{
$this->files->removeElement($file);
return $this;
}
public function getEntrepot(): ?RefTypeStock
{
return $this->entrepot;
}
public function setEntrepot(?RefTypeStock $entrepot): self
{
$this->entrepot = $entrepot;
return $this;
}
/**
* @return Collection<int, TblParcelle>
*/
public function getParcelle(): Collection
{
return $this->parcelle;
}
public function addParcelle(TblParcelle $parcelle): self
{
if (!$this->parcelle->contains($parcelle)) {
$this->parcelle[] = $parcelle;
}
return $this;
}
public function removeParcelle(TblParcelle $parcelle): self
{
$this->parcelle->removeElement($parcelle);
return $this;
}
public function getConsommateur(): ?User
{
return $this->consommateur;
}
public function setConsommateur(?User $consommateur): self
{
$this->consommateur = $consommateur;
return $this;
}
public function getOperations(): ?TblOperations
{
return $this->operations;
}
public function setOperations(?TblOperations $operations): self
{
$this->operations = $operations;
return $this;
}
public function getDetailProduitOperation(): ?TblDetailProduitOperation
{
return $this->detailProduitOperation;
}
public function setDetailProduitOperation(?TblDetailProduitOperation $detailProduitOperation): self
{
// unset the owning side of the relation if necessary
if ($detailProduitOperation === null && $this->detailProduitOperation !== null) {
$this->detailProduitOperation->setMouvement(null);
}
// set the owning side of the relation if necessary
if ($detailProduitOperation !== null && $detailProduitOperation->getMouvement() !== $this) {
$detailProduitOperation->setMouvement($this);
}
$this->detailProduitOperation = $detailProduitOperation;
return $this;
}
public function getTblDetailQuantiteParcelle(): ?TblDetailQuantiteParcelle
{
return $this->tblDetailQuantiteParcelle;
}
public function setTblDetailQuantiteParcelle(?TblDetailQuantiteParcelle $tblDetailQuantiteParcelle): self
{
// unset the owning side of the relation if necessary
if ($tblDetailQuantiteParcelle === null && $this->tblDetailQuantiteParcelle !== null) {
$this->tblDetailQuantiteParcelle->setMouvement(null);
}
// set the owning side of the relation if necessary
if ($tblDetailQuantiteParcelle !== null && $tblDetailQuantiteParcelle->getMouvement() !== $this) {
$tblDetailQuantiteParcelle->setMouvement($this);
}
$this->tblDetailQuantiteParcelle = $tblDetailQuantiteParcelle;
return $this;
}
public function getPersonnel(): ?TblPersonnel
{
return $this->personnel;
}
public function setPersonnel(?TblPersonnel $personnel): self
{
$this->personnel = $personnel;
return $this;
}
}