<?php
namespace App\Entity;
use App\Entity\Traits\TimestampableTrait;
use App\Repository\TblOperationsRepository;
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=TblOperationsRepository::class)
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
*/
class TblOperations
{
const DELETE_OPERATION = 1;
const ADD_OPERATION = 2;
const UPDATE_OPERATION = 3;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=RefStatut::class, inversedBy="tblOperations")
*/
private $statut;
/**
* @ORM\ManyToOne(targetEntity=RefOperations::class, inversedBy="tblOperations")
*/
private $typeOperations;
/**
* @ORM\ManyToMany(targetEntity=TblParcelle::class, inversedBy="tblOperations")
* @ORM\JoinTable(name="lnk_operations_parcelle",
* joinColumns={
* @ORM\JoinColumn(name="operations_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="parcelle_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
* }
* )
*/
private $parcelles;
/**
* @ORM\ManyToMany(targetEntity=TblPersonnel::class, inversedBy="tblOperations")
* @ORM\JoinTable(name="lnk_operations_personnel",
* joinColumns={
* @ORM\JoinColumn(name="operations_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="personnel_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
* }
* )
*/
private $personnel;
/**
* @ORM\ManyToMany(targetEntity=RefMaterials::class, inversedBy="tblOperations")
* @ORM\JoinTable(name="lnk_operations_materiels",
* joinColumns={
* @ORM\JoinColumn(name="operations_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="materiels_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
* }
* )
*/
private $materiels;
/**
* @ORM\Column(type="date")
*/
private $date;
/**
* @ORM\Column(type="float" , nullable=true)
*/
private $temps;
/**
* @ORM\OneToMany(targetEntity=TblDetailProduitOperation::class, mappedBy="operations" , cascade={"persist"})
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id", nullable=false, referencedColumnName="id")
* })
*/
private $detailProduitOperations;
/**
* @ORM\OneToMany(targetEntity=TblMouvement::class, mappedBy="operations")
*/
private $tblMouvements;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
use TimestampableTrait;
public function __construct()
{
$this->parcelles = new ArrayCollection();
$this->personnel = new ArrayCollection();
$this->materiels = new ArrayCollection();
$this->detailProduitOperations = new ArrayCollection();
$this->tblMouvements = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getStatut(): ?RefStatut
{
return $this->statut;
}
public function setStatut(?RefStatut $statut): self
{
$this->statut = $statut;
return $this;
}
public function getTypeOperations(): ?RefOperations
{
return $this->typeOperations;
}
public function setTypeOperations(?RefOperations $typeOperations): self
{
$this->typeOperations = $typeOperations;
return $this;
}
/**
* @return Collection<int, TblParcelle>
*/
public function getParcelles(): Collection
{
return $this->parcelles;
}
public function addParcelle(TblParcelle $parcelle): self
{
if (!$this->parcelles->contains($parcelle)) {
$this->parcelles[] = $parcelle;
}
return $this;
}
public function removeParcelle(TblParcelle $parcelle): self
{
$this->parcelles->removeElement($parcelle);
return $this;
}
/**
* @return Collection<int, TblPersonnel>
*/
public function getPersonnel(): Collection
{
return $this->personnel;
}
public function addPersonnel(TblPersonnel $personnel): self
{
if (!$this->personnel->contains($personnel)) {
$this->personnel[] = $personnel;
}
return $this;
}
public function removePersonnel(TblPersonnel $personnel): self
{
$this->personnel->removeElement($personnel);
return $this;
}
/**
* @return Collection<int, RefMaterials>
*/
public function getMateriels(): Collection
{
return $this->materiels;
}
public function addMateriel(RefMaterials $materiel): self
{
if (!$this->materiels->contains($materiel)) {
$this->materiels[] = $materiel;
}
return $this;
}
public function removeMateriel(RefMaterials $materiel): self
{
$this->materiels->removeElement($materiel);
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getTemps(): ?float
{
return $this->temps;
}
public function setTemps(?float $temps): self
{
$this->temps = $temps;
return $this;
}
use Workflowable;
public function toArrayDatatable($urlEdit)
{
return [
$this->getDate()->format('d/m/Y'),
$this->getTypeOperations()->getLibelle(),
$this->getOperationsStatutIcon(),
$this->getParcellesToString(),
$this->getTemps() ? $this->getTemps().'h': '',
$this->getPersonnelToString(),
$this->getMaterielsToString(),
'<a class="btn btn-primary" title="Modifier" href=' . $urlEdit . '><i class="ti ti-edit"></i></a>',
];
}
public function getMaterielsToString()
{
$result = '';
foreach($this->getMateriels() as $materiel) {
$result .= $materiel->getLibelle(). '<br>';
}
return $result;
}
public function getParcellesToString()
{
$result = '';
foreach($this->getParcelles() as $materiel) {
$result .= $materiel->__toString(). '<br>';
}
return $result;
}
public function getPersonnelToString()
{
$result = '';
foreach($this->getPersonnel() as $materiel) {
$result .= $materiel->__toString(). '<br>';
}
return $result;
}
/**
* @return Collection<int, TblDetailProduitOperation>
*/
public function getDetailProduitOperations(): Collection
{
return $this->detailProduitOperations;
}
public function addDetailProduitOperation(TblDetailProduitOperation $detailProduitOperation): self
{
if (!$this->detailProduitOperations->contains($detailProduitOperation)) {
$this->detailProduitOperations[] = $detailProduitOperation;
$detailProduitOperation->setOperations($this);
}
return $this;
}
public function removeDetailProduitOperation(TblDetailProduitOperation $detailProduitOperation): self
{
if ($this->detailProduitOperations->removeElement($detailProduitOperation)) {
// set the owning side to null (unless already changed)
if ($detailProduitOperation->getOperations() === $this) {
$detailProduitOperation->setOperations(null);
}
}
return $this;
}
/**
* @return Collection<int, TblMouvement>
*/
public function getTblMouvements(): Collection
{
return $this->tblMouvements;
}
public function addTblMouvement(TblMouvement $tblMouvement): self
{
if (!$this->tblMouvements->contains($tblMouvement)) {
$this->tblMouvements[] = $tblMouvement;
$tblMouvement->setOperations($this);
}
return $this;
}
public function removeTblMouvement(TblMouvement $tblMouvement): self
{
if ($this->tblMouvements->removeElement($tblMouvement)) {
// set the owning side to null (unless already changed)
if ($tblMouvement->getOperations() === $this) {
$tblMouvement->setOperations(null);
}
}
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
}