src/Entity/Mantenimiento/DiagramaTarea.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Mantenimiento;
  3. use App\Repository\Mantenimiento\DiagramaTareaRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use  App\Entity\RRHH\Empleado;
  9. use  App\Entity\User;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12.  * @ORM\Entity(repositoryClass=DiagramaTareaRepository::class)
  13.  * @ORM\HasLifecycleCallbacks()
  14.  */
  15. class DiagramaTarea
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="date", nullable=true)
  25.      */
  26.     private $fecha;
  27.     /**
  28.      * @ORM\Column(name="fecha_diagrama", type="datetime")
  29.      */
  30.     private $fechaDiagramacion
  31.     /**
  32.      * @ORM\Column(type="boolean")
  33.      */
  34.     private $procesado false;
  35.     /**
  36.      * @ORM\OneToMany(targetEntity=PedidoReparacionDiagramado::class, mappedBy="diagrama", cascade={"persist", "remove"})
  37.      */
  38.     private $tareas;
  39.     /**
  40.      * @ORM\ManyToMany(targetEntity=Empleado::class)
  41.      * @ORM\JoinTable(name="resp_por_diag_tarea",
  42.      *      joinColumns={@ORM\JoinColumn(name="id_diagrama", referencedColumnName="id")},
  43.      *      inverseJoinColumns={@ORM\JoinColumn(name="id_empleado", referencedColumnName="id")}
  44.      *      )
  45.      */
  46.     private $responsables;
  47.  
  48.     /**
  49.      * @ORM\ManyToOne(targetEntity=Departamento::class)
  50.      * @ORM\JoinColumn(name="id_depto", referencedColumnName="id", nullable=true)
  51.      * @Assert\NotNull(message="El campo es requerido")
  52.      */
  53.     private $departamento;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=User::class)
  56.      * @ORM\JoinColumn(name="id_user_alta", referencedColumnName="id", nullable=true)
  57.      */
  58.     private $responsableDiagramacion;
  59.     public function __construct()
  60.     {
  61.         $this->responsables = new ArrayCollection();
  62.         $this->tareas = new ArrayCollection();
  63.     }
  64.     public function getListaEquipos()
  65.     {
  66.         $equipos = array();
  67.         foreach ($this->tareas as $tarea)
  68.         {
  69.             $eq $tarea->getEquipo();
  70.             if ($eq)
  71.             {
  72.                 $equipos[$eq->getId()] = $eq;
  73.             }
  74.         }
  75.         return implode(' // '$equipos);
  76.     }
  77.     public function getEmpleados()
  78.     {
  79.         $emples "";
  80.         foreach ($this->responsables as $resp)
  81.         {
  82.             if ($emples)
  83.             {
  84.                 $emples.= ' - ';
  85.             }
  86.             $emples.= $resp;
  87.         }
  88.         return $emples;
  89.     }
  90.     /**
  91.      * @ORM\PrePersist
  92.      */
  93.     public function setCreatedAtValue()
  94.     {
  95.         $this->fechaDiagramacion = new \DateTimeImmutable();
  96.     }
  97.     public function getId(): ?int
  98.     {
  99.         return $this->id;
  100.     }
  101.     public function getFecha(): ?\DateTimeInterface
  102.     {
  103.         return $this->fecha;
  104.     }
  105.     public function setFecha(?\DateTimeInterface $fecha): self
  106.     {
  107.         $this->fecha $fecha;
  108.         return $this;
  109.     }
  110.     public function getFechaDiagramacion(): ?\DateTimeInterface
  111.     {
  112.         return $this->fechaDiagramacion;
  113.     }
  114.     public function setFechaDiagramacion(\DateTimeInterface $fechaDiagramacion): self
  115.     {
  116.         $this->fechaDiagramacion $fechaDiagramacion;
  117.         return $this;
  118.     }
  119.     /**
  120.      * @return Collection<int, Empleado>
  121.      */
  122.     public function getResponsables(): Collection
  123.     {
  124.         return $this->responsables;
  125.     }
  126.     public function addResponsable(Empleado $responsable): self
  127.     {
  128.         if (!$this->responsables->contains($responsable)) {
  129.             $this->responsables[] = $responsable;
  130.         }
  131.         return $this;
  132.     }
  133.     public function removeResponsable(Empleado $responsable): self
  134.     {
  135.         $this->responsables->removeElement($responsable);
  136.         return $this;
  137.     }
  138.     public function getResponsableDiagramacion(): ?User
  139.     {
  140.         return $this->responsableDiagramacion;
  141.     }
  142.     public function setResponsableDiagramacion(?User $responsableDiagramacion): self
  143.     {
  144.         $this->responsableDiagramacion $responsableDiagramacion;
  145.         return $this;
  146.     }
  147.     public function isProcesado(): ?bool
  148.     {
  149.         return $this->procesado;
  150.     }
  151.     public function setProcesado(bool $procesado): self
  152.     {
  153.         $this->procesado $procesado;
  154.         return $this;
  155.     }
  156.     /**
  157.      * @return Collection<int, PedidoReparacionDiagramado>
  158.      */
  159.     public function getTareas(): Collection
  160.     {
  161.         return $this->tareas;
  162.     }
  163.     public function addTarea(PedidoReparacionDiagramado $tarea): self
  164.     {
  165.         if (!$this->tareas->contains($tarea)) {
  166.             $this->tareas[] = $tarea;
  167.             $tarea->setDiagrama($this);
  168.         }
  169.         return $this;
  170.     }
  171.     public function removeTarea(PedidoReparacionDiagramado $tarea): self
  172.     {
  173.         if ($this->tareas->removeElement($tarea)) {
  174.             // set the owning side to null (unless already changed)
  175.             if ($tarea->getDiagrama() === $this) {
  176.                 $tarea->setDiagrama(null);
  177.             }
  178.         }
  179.         return $this;
  180.     }
  181.     public function getDepartamento(): ?Departamento
  182.     {
  183.         return $this->departamento;
  184.     }
  185.     public function setDepartamento(?Departamento $departamento): self
  186.     {
  187.         $this->departamento $departamento;
  188.         return $this;
  189.     }
  190. }