<?php
namespace App\Entity;
use App\Entity\Traits\TimestampableTrait;
use App\Repository\TblOperationTravailRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=TblOperationTravailRepository::class)
* @Gedmo\Loggable
*/
class TblOperationTravail
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=RefDureeOperationTravail::class)
* @ORM\JoinColumn(nullable=false)
* @Gedmo\Versioned
*/
private $dureeOperationTravail;
/**
* @ORM\ManyToOne(targetEntity=RefTypeOperationTravail::class)
* @ORM\JoinColumn(nullable=false)
* @Gedmo\Versioned
*/
private $typeOperationTravail;
/**
* @ORM\ManyToMany(targetEntity=TblParcelle::class, inversedBy="tblOperationTravail" ,cascade={"persist"})
* @ORM\JoinTable(name="lnk_operationTravail_parcelle",
* joinColumns={
* @ORM\JoinColumn(name="operationTravail_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="parcelle_id", referencedColumnName="id", nullable=false )
* }
* )
*/
private $parcelle;
/**
* @ORM\Column(type="time")
* @Gedmo\Versioned
*/
private $heureDebut;
/**
* @ORM\Column(type="time")
* @Gedmo\Versioned
*/
private $heureFin;
/**
* @ORM\Column(type="date")
* @Gedmo\Versioned
*/
private $dateOperation;
/**
* @ORM\ManyToOne(targetEntity=TblPersonnel::class , inversedBy="tblOperationsTravail")
* @ORM\JoinColumn(nullable=false)
* @Gedmo\Versioned
*/
private $personnel;
/**
* @ORM\Column(type="float")
* @Gedmo\Versioned
*/
private $montantTJM;
public function __construct()
{
$this->parcelle = new ArrayCollection();
}
use TimestampableTrait;
public function getId(): ?int
{
return $this->id;
}
public function getDureeOperationTravail(): ?RefDureeOperationTravail
{
return $this->dureeOperationTravail;
}
public function setDureeOperationTravail(?RefDureeOperationTravail $dureeOperationTravail): self
{
$this->dureeOperationTravail = $dureeOperationTravail;
return $this;
}
public function getTypeOperationTravail(): ?RefTypeOperationTravail
{
return $this->typeOperationTravail;
}
public function setTypeOperationTravail(?RefTypeOperationTravail $typeOperationTravail): self
{
$this->typeOperationTravail = $typeOperationTravail;
return $this;
}
public function getHeureDebut(): ?\DateTimeInterface
{
return $this->heureDebut;
}
public function setHeureDebut(?\DateTimeInterface $heureDebut): self
{
$this->heureDebut = $heureDebut;
return $this;
}
public function getHeureFin(): ?\DateTimeInterface
{
return $this->heureFin;
}
public function setHeureFin(?\DateTimeInterface $heureFin): self
{
$this->heureFin = $heureFin;
return $this;
}
public function getDateOperation(): ?\DateTimeInterface
{
return $this->dateOperation;
}
public function setDateOperation(?\DateTimeInterface $dateOperation): self
{
$this->dateOperation = $dateOperation;
return $this;
}
public function getPersonnel(): ?TblPersonnel
{
return $this->personnel;
}
public function setPersonnel(?TblPersonnel $personnel): self
{
$this->personnel = $personnel;
return $this;
}
public function getMontantTJM(): ?float
{
return $this->montantTJM;
}
public function setMontantTJM(float $montantTJM): self
{
$this->montantTJM = $montantTJM;
return $this;
}
public function toArrayDatatable($urlEdit)
{
return [
$this->getPersonnel()->__toString(),
"<span class='badge badge-outline text-green'>".$this->getTypeOperationTravail()."</span>",
number_format($this->getMontantTJM()*$this->getDureeOperationTravail()->getValeurJour(), 2, ",", " "),
$this->getDureeOperationTravail()->__toString(),
$this->getParcellestr(),
$this->getDateOperation()->format('Y-m-d'),
'<a class="btn btn-primary" title="Modifier" href=' . $urlEdit . '><i class="ti ti-edit"></i></a>',
];
}
public function getParcellestr()
{
$result = '';
foreach($this->getParcelle() as $parcelle) {
$result .= $parcelle->getParcelle(). '<br>';
}
return $result;
}
/**
* @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;
}
}