src/Entity/Comun/Proyecto.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Comun;
  3. use App\Entity\Accion\ProyectoReunion;
  4. use App\Entity\Admin\Area;
  5. use App\Entity\Admin\Cliente;
  6. use App\Entity\Admin\Empleada;
  7. use App\Entity\Admin\Servicio;
  8. use App\Repository\Comun\ProyectoRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use App\Entity\Accesos\Tercero;
  13. use App\Entity\Comun\Justificacion;
  14. use App\Entity\Comun\Gasto;
  15. #[ORM\Entity(repositoryClassProyectoRepository::class)]
  16. class Proyecto
  17. {
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column(type'integer')]
  21.     private $id;
  22.     #[ORM\Column(type'string'length255)]
  23.     private $nombre;
  24.     #[ORM\Column(type'date')]
  25.     private $fechaInicio;
  26.     #[ORM\ManyToOne(targetEntityCliente::class, inversedBy'proyectos')]
  27.     #[ORM\JoinColumn(nullablefalse)]
  28.     private $cliente;
  29.     #[ORM\Column(type'float')]
  30.     private $financiacion;
  31.     
  32.     #[ORM\ManyToOne(targetEntityArea::class, inversedBy'proyectos')]
  33.     #[ORM\JoinColumn(nullablefalse)]
  34.     private $area;
  35.     #[ORM\ManyToOne(targetEntityServicio::class, inversedBy'proyectos')]
  36.     #[ORM\JoinColumn(nullablefalse)]
  37.     private $servicio;
  38.     #[ORM\ManyToOne(targetEntityEmpleada::class, inversedBy'proyectos')]
  39.     #[ORM\JoinColumn(nullablefalse)]
  40.     private $responsable;
  41.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'proyectos')]
  42.     private $padre;
  43.     #[ORM\OneToMany(mappedBy'padre'targetEntityself::class)]
  44.     private $proyectos;
  45.     #[ORM\OneToMany(mappedBy'proyecto'targetEntityTarea::class)]
  46.     private $tareas;
  47.     
  48.     #[ORM\OneToMany(mappedBy'proyecto'targetEntityTercero::class)]
  49.     private $terceros;
  50.     #[ORM\Column(type'boolean')]
  51.     private $multiple;
  52.     #[ORM\OneToMany(mappedBy'proyecto'targetEntityJustificacion::class)]
  53.     private $justificacions;
  54.     #[ORM\OneToMany(mappedBy'proyecto'targetEntityConvenio::class)]
  55.     private $convenios;
  56.     #[ORM\OneToMany(mappedBy'proyecto'targetEntityGasto::class)]
  57.     private $gastos;
  58.     #[ORM\OneToMany(mappedBy'proyecto'targetEntityFichaje::class)]
  59.     private $fichajes;
  60.     #[ORM\OneToMany(mappedBy'proyecto'targetEntityProyectoReunion::class)]
  61.     private $observaciones;
  62.     #[ORM\Column(type'integer')]
  63.     private $estado;
  64.     #[ORM\OneToMany(mappedBy'proyecto'targetEntityProyectoEmpleada::class)]
  65.     private $proyectoEmpleadas;
  66.     #[ORM\Column(type'date')]
  67.     private $fechaFin;
  68.     public function __construct()
  69.     {
  70.         $this->proyectos = new ArrayCollection();
  71.         $this->tareas = new ArrayCollection();
  72.         $this->justificacions = new ArrayCollection();
  73.         $this->convenios = new ArrayCollection();
  74.         $this->gastos = new ArrayCollection();
  75.         $this->fichajes = new ArrayCollection();
  76.         $this->observaciones = new ArrayCollection();
  77.         $this->proyectoEmpleadas = new ArrayCollection();
  78.     }
  79.     public function getId(): ?int
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function getNombre(): ?string
  84.     {
  85.         return $this->nombre;
  86.     }
  87.     public function setNombre(string $nombre): self
  88.     {
  89.         $this->nombre $nombre;
  90.         return $this;
  91.     }
  92.     public function getFechaInicio(): ?\DateTimeInterface
  93.     {
  94.         return $this->fechaInicio;
  95.     }
  96.     public function setFechaInicio(\DateTimeInterface $fechaInicio): self
  97.     {
  98.         $this->fechaInicio $fechaInicio;
  99.         return $this;
  100.     }
  101.     public function getCliente(): ?Cliente
  102.     {
  103.         return $this->cliente;
  104.     }
  105.     public function setCliente(?Cliente $cliente): self
  106.     {
  107.         $this->cliente $cliente;
  108.         return $this;
  109.     }
  110.     public function getFinanciacion(): ?float
  111.     {
  112.         return $this->financiacion;
  113.     }
  114.     public function setFinanciacion(float $financiacion): self
  115.     {
  116.         $this->financiacion $financiacion;
  117.         return $this;
  118.     }
  119.     public function getArea(): ?Area
  120.     {
  121.         return $this->area;
  122.     }
  123.     public function setArea(?Area $area): self
  124.     {
  125.         $this->area $area;
  126.         return $this;
  127.     }
  128.     public function getServicio(): ?Servicio
  129.     {
  130.         return $this->servicio;
  131.     }
  132.     public function setServicio(?Servicio $servicio): self
  133.     {
  134.         $this->servicio $servicio;
  135.         return $this;
  136.     }
  137.     public function getResponsable(): ?Empleada
  138.     {
  139.         return $this->responsable;
  140.     }
  141.     public function setResponsable(?Empleada $responsable): self
  142.     {
  143.         $this->responsable $responsable;
  144.         return $this;
  145.     }
  146.     public function getPadre(): ?self
  147.     {
  148.         return $this->padre;
  149.     }
  150.     public function setPadre(?self $padre): self
  151.     {
  152.         $this->padre $padre;
  153.         return $this;
  154.     }
  155.     /**
  156.      * @return Collection<int, self>
  157.      */
  158.     public function getProyectos(): Collection
  159.     {
  160.         return $this->proyectos;
  161.     }
  162.     public function addProyecto(self $proyecto): self
  163.     {
  164.         if (!$this->proyectos->contains($proyecto)) {
  165.             $this->proyectos[] = $proyecto;
  166.             $proyecto->setPadre($this);
  167.         }
  168.         return $this;
  169.     }
  170.     public function removeProyecto(self $proyecto): self
  171.     {
  172.         if ($this->proyectos->removeElement($proyecto)) {
  173.             // set the owning side to null (unless already changed)
  174.             if ($proyecto->getPadre() === $this) {
  175.                 $proyecto->setPadre(null);
  176.             }
  177.         }
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection<int, Tarea>
  182.      */
  183.     public function getTareas(): Collection
  184.     {
  185.         return $this->tareas;
  186.     }
  187.     public function addTarea(Tarea $tarea): self
  188.     {
  189.         if (!$this->tareas->contains($tarea)) {
  190.             $this->tareas[] = $tarea;
  191.             $tarea->setProyecto($this);
  192.         }
  193.         return $this;
  194.     }
  195.     public function removeTarea(Tarea $tarea): self
  196.     {
  197.         if ($this->tareas->removeElement($tarea)) {
  198.             // set the owning side to null (unless already changed)
  199.             if ($tarea->getProyecto() === $this) {
  200.                 $tarea->setProyecto(null);
  201.             }
  202.         }
  203.         return $this;
  204.     }
  205.     public function getMultiple(): ?bool
  206.     {
  207.         return $this->multiple;
  208.     }
  209.     public function setMultiple(bool $multiple): self
  210.     {
  211.         $this->multiple $multiple;
  212.         return $this;
  213.     }
  214.     /**
  215.      * @return Collection<int, Justificacion>
  216.      */
  217.     public function getJustificacions(): Collection
  218.     {
  219.         return $this->justificacions;
  220.     }
  221.     public function addJustificacion(Justificacion $justificacion): self
  222.     {
  223.         if (!$this->justificacions->contains($justificacion)) {
  224.             $this->justificacions[] = $justificacion;
  225.             $justificacion->setProyecto($this);
  226.         }
  227.         return $this;
  228.     }
  229.     public function removeJustificacion(Justificacion $justificacion): self
  230.     {
  231.         if ($this->justificacions->removeElement($justificacion)) {
  232.             // set the owning side to null (unless already changed)
  233.             if ($justificacion->getProyecto() === $this) {
  234.                 $justificacion->setProyecto(null);
  235.             }
  236.         }
  237.         return $this;
  238.     }
  239.     /**
  240.      * @return Collection<int, Convenio>
  241.      */
  242.     public function getConvenios(): Collection
  243.     {
  244.         return $this->convenios;
  245.     }
  246.     public function addConvenio(Convenio $convenio): self
  247.     {
  248.         if (!$this->convenios->contains($convenio)) {
  249.             $this->convenios[] = $convenio;
  250.             $convenio->setProyecto($this);
  251.         }
  252.         return $this;
  253.     }
  254.     public function removeConvenio(Convenio $convenio): self
  255.     {
  256.         if ($this->convenios->removeElement($convenio)) {
  257.             // set the owning side to null (unless already changed)
  258.             if ($convenio->getProyecto() === $this) {
  259.                 $convenio->setProyecto(null);
  260.             }
  261.         }
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return Collection<int, Gasto>
  266.      */
  267.     public function getGastos(): Collection
  268.     {
  269.         return $this->gastos;
  270.     }
  271.     public function addGasto(Gasto $gasto): self
  272.     {
  273.         if (!$this->gastos->contains($gasto)) {
  274.             $this->gastos[] = $gasto;
  275.             $gasto->setProyecto($this);
  276.         }
  277.         return $this;
  278.     }
  279.     public function removeGasto(Gasto $gasto): self
  280.     {
  281.         if ($this->gastos->removeElement($gasto)) {
  282.             // set the owning side to null (unless already changed)
  283.             if ($gasto->getProyecto() === $this) {
  284.                 $gasto->setProyecto(null);
  285.             }
  286.         }
  287.         return $this;
  288.     }
  289.     /**
  290.      * @return Collection<int, Fichaje>
  291.      */
  292.     public function getFichajes(): Collection
  293.     {
  294.         return $this->fichajes;
  295.     }
  296.     public function addFichaje(Fichaje $fichaje): self
  297.     {
  298.         if (!$this->fichajes->contains($fichaje)) {
  299.             $this->fichajes[] = $fichaje;
  300.             $fichaje->setProyecto($this);
  301.         }
  302.         return $this;
  303.     }
  304.     public function removeFichaje(Fichaje $fichaje): self
  305.     {
  306.         if ($this->fichajes->removeElement($fichaje)) {
  307.             // set the owning side to null (unless already changed)
  308.             if ($fichaje->getProyecto() === $this) {
  309.                 $fichaje->setProyecto(null);
  310.             }
  311.         }
  312.         return $this;
  313.     }
  314.     public function __toString() {
  315.         return $this->nombre;
  316.     }
  317.     
  318.     public function getTerceros() {
  319.         return $this->terceros;
  320.     }
  321.     public function setTerceros($terceros): void {
  322.         $this->terceros $terceros;
  323.     }
  324.   
  325.     public function addTercero(Tercero $tercero): self
  326.     {
  327.         if (!$this->terceros->contains($tercero)) {
  328.             $this->terceros[] = $tercero;
  329.             $tercero->setProyecto($this);
  330.         }
  331.         return $this;
  332.     }
  333.     public function removeTercero(Tercero $tercero): self
  334.     {
  335.         if ($this->terceros->removeElement($tercero)) {
  336.             // set the owning side to null (unless already changed)
  337.             if ($tercero->getProyecto() === $this) {
  338.                 $tercero->setProyecto(null);
  339.             }
  340.         }
  341.         return $this;
  342.     }
  343.     /**
  344.      * @return Collection<int, ProyectoReunion>
  345.      */
  346.     public function getObservaciones(): Collection
  347.     {
  348.         return $this->observaciones;
  349.     }
  350.     public function addObservacione(ProyectoReunion $observacione): self
  351.     {
  352.         if (!$this->observaciones->contains($observacione)) {
  353.             $this->observaciones[] = $observacione;
  354.             $observacione->setProyecto($this);
  355.         }
  356.         return $this;
  357.     }
  358.     public function removeObservacione(ProyectoReunion $observacione): self
  359.     {
  360.         if ($this->observaciones->removeElement($observacione)) {
  361.             // set the owning side to null (unless already changed)
  362.             if ($observacione->getProyecto() === $this) {
  363.                 $observacione->setProyecto(null);
  364.             }
  365.         }
  366.         return $this;
  367.     }
  368.     public function getEstado(): ?int
  369.     {
  370.         return $this->estado;
  371.     }
  372.     public function setEstado(int $estado): self
  373.     {
  374.         $this->estado $estado;
  375.         return $this;
  376.     }
  377.     
  378.     public  function estadoToString(){
  379.         if($this->estado==0){
  380.             return "proyecto.sinIniciar";
  381.         }
  382.         if($this->estado==1){
  383.             return "proyecto.iniciado";
  384.         }
  385.         if($this->estado==2){
  386.             return "proyecto.finalizado";
  387.         }
  388.     }
  389.     
  390.     public function getGastado(){
  391.         $gastos$this->gastos;
  392.         $convenios$this->convenios;
  393.         $gastado=0;
  394.         foreach($gastos as $gasto){
  395.             $gastado+=$gasto->getCantidad();
  396.         }
  397.         foreach ($convenios as $convenio){
  398.             $gastado+=$convenio->getCantidad();
  399.         }
  400.         
  401.         return $gastado;
  402.     }
  403.     public function getRestante(){
  404.         return $this->financiacion-$this->getGastado();
  405.     }
  406.     /**
  407.      * @return Collection<int, ProyectoEmpleada>
  408.      */
  409.     public function getProyectoEmpleadas(): Collection
  410.     {
  411.         return $this->proyectoEmpleadas;
  412.     }
  413.     public function addProyectoEmpleada(ProyectoEmpleada $proyectoEmpleada): self
  414.     {
  415.         if (!$this->proyectoEmpleadas->contains($proyectoEmpleada)) {
  416.             $this->proyectoEmpleadas[] = $proyectoEmpleada;
  417.             $proyectoEmpleada->setProyecto($this);
  418.         }
  419.         return $this;
  420.     }
  421.     public function removeProyectoEmpleada(ProyectoEmpleada $proyectoEmpleada): self
  422.     {
  423.         if ($this->proyectoEmpleadas->removeElement($proyectoEmpleada)) {
  424.             // set the owning side to null (unless already changed)
  425.             if ($proyectoEmpleada->getProyecto() === $this) {
  426.                 $proyectoEmpleada->setProyecto(null);
  427.             }
  428.         }
  429.         return $this;
  430.     }
  431.     public function getFechaFin(): ?\DateTimeInterface
  432.     {
  433.         return $this->fechaFin;
  434.     }
  435.     public function setFechaFin(\DateTimeInterface $fechaFin): self
  436.     {
  437.         $this->fechaFin $fechaFin;
  438.         return $this;
  439.     }
  440. }