src/Entity/TblOperations.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\TimestampableTrait;
  4. use App\Repository\TblOperationsRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. /**
  10.  * @ORM\Entity(repositoryClass=TblOperationsRepository::class)
  11.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
  12.  */
  13. class TblOperations
  14. {
  15.     const DELETE_OPERATION 1;
  16.     const ADD_OPERATION 2;
  17.     const UPDATE_OPERATION 3
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=RefStatut::class, inversedBy="tblOperations")
  26.      */
  27.     private $statut;
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity=RefOperations::class, inversedBy="tblOperations")
  30.      */
  31.     private $typeOperations;
  32.     /**
  33.      * @ORM\ManyToMany(targetEntity=TblParcelle::class, inversedBy="tblOperations")
  34.      * @ORM\JoinTable(name="lnk_operations_parcelle",
  35.      *   joinColumns={
  36.      *     @ORM\JoinColumn(name="operations_id", referencedColumnName="id")
  37.      *   },
  38.      *   inverseJoinColumns={
  39.      *     @ORM\JoinColumn(name="parcelle_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  40.      *   }
  41.      * )
  42.      */
  43.     private $parcelles;
  44.     /**
  45.      * @ORM\ManyToMany(targetEntity=TblPersonnel::class, inversedBy="tblOperations")
  46.      * @ORM\JoinTable(name="lnk_operations_personnel",
  47.      *   joinColumns={
  48.      *     @ORM\JoinColumn(name="operations_id", referencedColumnName="id")
  49.      *   },
  50.      *   inverseJoinColumns={
  51.      *     @ORM\JoinColumn(name="personnel_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  52.      *   }
  53.      * )
  54.      */
  55.     private $personnel;
  56.     /**
  57.      * @ORM\ManyToMany(targetEntity=RefMaterials::class, inversedBy="tblOperations")
  58.      * @ORM\JoinTable(name="lnk_operations_materiels",
  59.      *   joinColumns={
  60.      *     @ORM\JoinColumn(name="operations_id", referencedColumnName="id")
  61.      *   },
  62.      *   inverseJoinColumns={
  63.      *     @ORM\JoinColumn(name="materiels_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  64.      *   }
  65.      * )
  66.      */
  67.     private $materiels;
  68.     /**
  69.      * @ORM\Column(type="date")
  70.      */
  71.     private $date;
  72.     /**
  73.      * @ORM\Column(type="float" , nullable=true)
  74.      */
  75.     private $temps;
  76.     /**
  77.      * @ORM\OneToMany(targetEntity=TblDetailProduitOperation::class, mappedBy="operations" , cascade={"persist"})
  78.      * @ORM\JoinColumns({
  79.      *   @ORM\JoinColumn(name="id", nullable=false, referencedColumnName="id")
  80.      * })   
  81.      */
  82.     private $detailProduitOperations;
  83.     /**
  84.      * @ORM\OneToMany(targetEntity=TblMouvement::class, mappedBy="operations")
  85.      */
  86.     private $tblMouvements;
  87.     /**
  88.      * @ORM\Column(type="text", nullable=true)
  89.      */
  90.     private $description;
  91.     use TimestampableTrait;
  92.     public function __construct()
  93.     {
  94.         $this->parcelles = new ArrayCollection();
  95.         $this->personnel = new ArrayCollection();
  96.         $this->materiels = new ArrayCollection();
  97.         $this->detailProduitOperations = new ArrayCollection();
  98.         $this->tblMouvements = new ArrayCollection();
  99.     }
  100.     public function getId(): ?int
  101.     {
  102.         return $this->id;
  103.     }   
  104.     public function getStatut(): ?RefStatut
  105.     {
  106.         return $this->statut;
  107.     }
  108.     public function setStatut(?RefStatut $statut): self
  109.     {
  110.         $this->statut $statut;
  111.         return $this;
  112.     }
  113.     public function getTypeOperations(): ?RefOperations
  114.     {
  115.         return $this->typeOperations;
  116.     }
  117.     public function setTypeOperations(?RefOperations $typeOperations): self
  118.     {
  119.         $this->typeOperations $typeOperations;
  120.         return $this;
  121.     }
  122.     /**
  123.      * @return Collection<int, TblParcelle>
  124.      */
  125.     public function getParcelles(): Collection
  126.     {
  127.         return $this->parcelles;
  128.     }
  129.     public function addParcelle(TblParcelle $parcelle): self
  130.     {
  131.         if (!$this->parcelles->contains($parcelle)) {
  132.             $this->parcelles[] = $parcelle;
  133.         }
  134.         return $this;
  135.     }
  136.     public function removeParcelle(TblParcelle $parcelle): self
  137.     {
  138.         $this->parcelles->removeElement($parcelle);
  139.         return $this;
  140.     }
  141.     /**
  142.      * @return Collection<int, TblPersonnel>
  143.      */
  144.     public function getPersonnel(): Collection
  145.     {
  146.         return $this->personnel;
  147.     }
  148.     public function addPersonnel(TblPersonnel $personnel): self
  149.     {
  150.         if (!$this->personnel->contains($personnel)) {
  151.             $this->personnel[] = $personnel;
  152.         }
  153.         return $this;
  154.     }
  155.     public function removePersonnel(TblPersonnel $personnel): self
  156.     {
  157.         $this->personnel->removeElement($personnel);
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return Collection<int, RefMaterials>
  162.      */
  163.     public function getMateriels(): Collection
  164.     {
  165.         return $this->materiels;
  166.     }
  167.     public function addMateriel(RefMaterials $materiel): self
  168.     {
  169.         if (!$this->materiels->contains($materiel)) {
  170.             $this->materiels[] = $materiel;
  171.         }
  172.         return $this;
  173.     }
  174.     public function removeMateriel(RefMaterials $materiel): self
  175.     {
  176.         $this->materiels->removeElement($materiel);
  177.         return $this;
  178.     }
  179.     public function getDate(): ?\DateTimeInterface
  180.     {
  181.         return $this->date;
  182.     }
  183.     public function setDate(\DateTimeInterface $date): self
  184.     {
  185.         $this->date $date;
  186.         return $this;
  187.     }
  188.     public function getTemps(): ?float
  189.     {
  190.         return $this->temps;
  191.     }
  192.     public function setTemps(?float $temps): self
  193.     {
  194.         $this->temps $temps;
  195.         return $this;
  196.     }
  197.     use Workflowable;
  198.     public function toArrayDatatable($urlEdit)
  199.     {
  200.         return [
  201.             $this->getDate()->format('d/m/Y'),
  202.             $this->getTypeOperations()->getLibelle(),
  203.             $this->getOperationsStatutIcon(),
  204.             $this->getParcellesToString(),
  205.             $this->getTemps() ? $this->getTemps().'h''',
  206.             $this->getPersonnelToString(),
  207.             $this->getMaterielsToString(),
  208.             '<a class="btn btn-primary" title="Modifier" href=' $urlEdit '><i class="ti ti-edit"></i></a>',
  209.         ];
  210.     }
  211.     public function getMaterielsToString()
  212.     {
  213.         $result '';
  214.         
  215.         foreach($this->getMateriels() as $materiel) {
  216.          $result .= $materiel->getLibelle(). '<br>'
  217.         }
  218.         return $result;
  219.     }
  220.     public function getParcellesToString()
  221.     {
  222.         $result '';
  223.         
  224.         foreach($this->getParcelles() as $materiel) {
  225.          $result .= $materiel->__toString(). '<br>'
  226.         }
  227.         return $result;
  228.     }
  229.     public function getPersonnelToString()
  230.     {
  231.         $result '';
  232.         
  233.         foreach($this->getPersonnel() as $materiel) {
  234.          $result .= $materiel->__toString(). '<br>'
  235.         }
  236.         return $result;
  237.     }
  238.     /**
  239.      * @return Collection<int, TblDetailProduitOperation>
  240.      */
  241.     public function getDetailProduitOperations(): Collection
  242.     {
  243.         return $this->detailProduitOperations;
  244.     }
  245.     public function addDetailProduitOperation(TblDetailProduitOperation $detailProduitOperation): self
  246.     {
  247.         if (!$this->detailProduitOperations->contains($detailProduitOperation)) {
  248.             $this->detailProduitOperations[] = $detailProduitOperation;
  249.             $detailProduitOperation->setOperations($this);
  250.         }
  251.         return $this;
  252.     }
  253.     public function removeDetailProduitOperation(TblDetailProduitOperation $detailProduitOperation): self
  254.     {
  255.         if ($this->detailProduitOperations->removeElement($detailProduitOperation)) {
  256.             // set the owning side to null (unless already changed)
  257.             if ($detailProduitOperation->getOperations() === $this) {
  258.                 $detailProduitOperation->setOperations(null);
  259.             }
  260.         }
  261.         return $this;
  262.     }
  263.     /**
  264.      * @return Collection<int, TblMouvement>
  265.      */
  266.     public function getTblMouvements(): Collection
  267.     {
  268.         return $this->tblMouvements;
  269.     }
  270.     public function addTblMouvement(TblMouvement $tblMouvement): self
  271.     {
  272.         if (!$this->tblMouvements->contains($tblMouvement)) {
  273.             $this->tblMouvements[] = $tblMouvement;
  274.             $tblMouvement->setOperations($this);
  275.         }
  276.         return $this;
  277.     }
  278.     public function removeTblMouvement(TblMouvement $tblMouvement): self
  279.     {
  280.         if ($this->tblMouvements->removeElement($tblMouvement)) {
  281.             // set the owning side to null (unless already changed)
  282.             if ($tblMouvement->getOperations() === $this) {
  283.                 $tblMouvement->setOperations(null);
  284.             }
  285.         }
  286.         return $this;
  287.     }
  288.     public function getDescription(): ?string
  289.     {
  290.         return $this->description;
  291.     }
  292.     public function setDescription(?string $description): self
  293.     {
  294.         $this->description $description;
  295.         return $this;
  296.     }
  297. }