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.     public function __construct()
  65.     {
  66.         $this->proyectos = new ArrayCollection();
  67.         $this->tareas = new ArrayCollection();
  68.         $this->justificacions = new ArrayCollection();
  69.         $this->convenios = new ArrayCollection();
  70.         $this->gastos = new ArrayCollection();
  71.         $this->fichajes = new ArrayCollection();
  72.         $this->observaciones = new ArrayCollection();
  73.     }
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     public function getNombre(): ?string
  79.     {
  80.         return $this->nombre;
  81.     }
  82.     public function setNombre(string $nombre): self
  83.     {
  84.         $this->nombre $nombre;
  85.         return $this;
  86.     }
  87.     public function getFechaInicio(): ?\DateTimeInterface
  88.     {
  89.         return $this->fechaInicio;
  90.     }
  91.     public function setFechaInicio(\DateTimeInterface $fechaInicio): self
  92.     {
  93.         $this->fechaInicio $fechaInicio;
  94.         return $this;
  95.     }
  96.     public function getCliente(): ?Cliente
  97.     {
  98.         return $this->cliente;
  99.     }
  100.     public function setCliente(?Cliente $cliente): self
  101.     {
  102.         $this->cliente $cliente;
  103.         return $this;
  104.     }
  105.     public function getFinanciacion(): ?float
  106.     {
  107.         return $this->financiacion;
  108.     }
  109.     public function setFinanciacion(float $financiacion): self
  110.     {
  111.         $this->financiacion $financiacion;
  112.         return $this;
  113.     }
  114.     public function getArea(): ?Area
  115.     {
  116.         return $this->area;
  117.     }
  118.     public function setArea(?Area $area): self
  119.     {
  120.         $this->area $area;
  121.         return $this;
  122.     }
  123.     public function getServicio(): ?Servicio
  124.     {
  125.         return $this->servicio;
  126.     }
  127.     public function setServicio(?Servicio $servicio): self
  128.     {
  129.         $this->servicio $servicio;
  130.         return $this;
  131.     }
  132.     public function getResponsable(): ?Empleada
  133.     {
  134.         return $this->responsable;
  135.     }
  136.     public function setResponsable(?Empleada $responsable): self
  137.     {
  138.         $this->responsable $responsable;
  139.         return $this;
  140.     }
  141.     public function getPadre(): ?self
  142.     {
  143.         return $this->padre;
  144.     }
  145.     public function setPadre(?self $padre): self
  146.     {
  147.         $this->padre $padre;
  148.         return $this;
  149.     }
  150.     /**
  151.      * @return Collection<int, self>
  152.      */
  153.     public function getProyectos(): Collection
  154.     {
  155.         return $this->proyectos;
  156.     }
  157.     public function addProyecto(self $proyecto): self
  158.     {
  159.         if (!$this->proyectos->contains($proyecto)) {
  160.             $this->proyectos[] = $proyecto;
  161.             $proyecto->setPadre($this);
  162.         }
  163.         return $this;
  164.     }
  165.     public function removeProyecto(self $proyecto): self
  166.     {
  167.         if ($this->proyectos->removeElement($proyecto)) {
  168.             // set the owning side to null (unless already changed)
  169.             if ($proyecto->getPadre() === $this) {
  170.                 $proyecto->setPadre(null);
  171.             }
  172.         }
  173.         return $this;
  174.     }
  175.     /**
  176.      * @return Collection<int, Tarea>
  177.      */
  178.     public function getTareas(): Collection
  179.     {
  180.         return $this->tareas;
  181.     }
  182.     public function addTarea(Tarea $tarea): self
  183.     {
  184.         if (!$this->tareas->contains($tarea)) {
  185.             $this->tareas[] = $tarea;
  186.             $tarea->setProyecto($this);
  187.         }
  188.         return $this;
  189.     }
  190.     public function removeTarea(Tarea $tarea): self
  191.     {
  192.         if ($this->tareas->removeElement($tarea)) {
  193.             // set the owning side to null (unless already changed)
  194.             if ($tarea->getProyecto() === $this) {
  195.                 $tarea->setProyecto(null);
  196.             }
  197.         }
  198.         return $this;
  199.     }
  200.     public function getMultiple(): ?bool
  201.     {
  202.         return $this->multiple;
  203.     }
  204.     public function setMultiple(bool $multiple): self
  205.     {
  206.         $this->multiple $multiple;
  207.         return $this;
  208.     }
  209.     /**
  210.      * @return Collection<int, Justificacion>
  211.      */
  212.     public function getJustificacions(): Collection
  213.     {
  214.         return $this->justificacions;
  215.     }
  216.     public function addJustificacion(Justificacion $justificacion): self
  217.     {
  218.         if (!$this->justificacions->contains($justificacion)) {
  219.             $this->justificacions[] = $justificacion;
  220.             $justificacion->setProyecto($this);
  221.         }
  222.         return $this;
  223.     }
  224.     public function removeJustificacion(Justificacion $justificacion): self
  225.     {
  226.         if ($this->justificacions->removeElement($justificacion)) {
  227.             // set the owning side to null (unless already changed)
  228.             if ($justificacion->getProyecto() === $this) {
  229.                 $justificacion->setProyecto(null);
  230.             }
  231.         }
  232.         return $this;
  233.     }
  234.     /**
  235.      * @return Collection<int, Convenio>
  236.      */
  237.     public function getConvenios(): Collection
  238.     {
  239.         return $this->convenios;
  240.     }
  241.     public function addConvenio(Convenio $convenio): self
  242.     {
  243.         if (!$this->convenios->contains($convenio)) {
  244.             $this->convenios[] = $convenio;
  245.             $convenio->setProyecto($this);
  246.         }
  247.         return $this;
  248.     }
  249.     public function removeConvenio(Convenio $convenio): self
  250.     {
  251.         if ($this->convenios->removeElement($convenio)) {
  252.             // set the owning side to null (unless already changed)
  253.             if ($convenio->getProyecto() === $this) {
  254.                 $convenio->setProyecto(null);
  255.             }
  256.         }
  257.         return $this;
  258.     }
  259.     /**
  260.      * @return Collection<int, Gasto>
  261.      */
  262.     public function getGastos(): Collection
  263.     {
  264.         return $this->gastos;
  265.     }
  266.     public function addGasto(Gasto $gasto): self
  267.     {
  268.         if (!$this->gastos->contains($gasto)) {
  269.             $this->gastos[] = $gasto;
  270.             $gasto->setProyecto($this);
  271.         }
  272.         return $this;
  273.     }
  274.     public function removeGasto(Gasto $gasto): self
  275.     {
  276.         if ($this->gastos->removeElement($gasto)) {
  277.             // set the owning side to null (unless already changed)
  278.             if ($gasto->getProyecto() === $this) {
  279.                 $gasto->setProyecto(null);
  280.             }
  281.         }
  282.         return $this;
  283.     }
  284.     /**
  285.      * @return Collection<int, Fichaje>
  286.      */
  287.     public function getFichajes(): Collection
  288.     {
  289.         return $this->fichajes;
  290.     }
  291.     public function addFichaje(Fichaje $fichaje): self
  292.     {
  293.         if (!$this->fichajes->contains($fichaje)) {
  294.             $this->fichajes[] = $fichaje;
  295.             $fichaje->setProyecto($this);
  296.         }
  297.         return $this;
  298.     }
  299.     public function removeFichaje(Fichaje $fichaje): self
  300.     {
  301.         if ($this->fichajes->removeElement($fichaje)) {
  302.             // set the owning side to null (unless already changed)
  303.             if ($fichaje->getProyecto() === $this) {
  304.                 $fichaje->setProyecto(null);
  305.             }
  306.         }
  307.         return $this;
  308.     }
  309.     public function __toString() {
  310.         return $this->nombre;
  311.     }
  312.     
  313.     public function getTerceros() {
  314.         return $this->terceros;
  315.     }
  316.     public function setTerceros($terceros): void {
  317.         $this->terceros $terceros;
  318.     }
  319.   
  320.     public function addTercero(Tercero $tercero): self
  321.     {
  322.         if (!$this->terceros->contains($tercero)) {
  323.             $this->terceros[] = $tercero;
  324.             $tercero->setProyecto($this);
  325.         }
  326.         return $this;
  327.     }
  328.     public function removeTercero(Tercero $tercero): self
  329.     {
  330.         if ($this->terceros->removeElement($tercero)) {
  331.             // set the owning side to null (unless already changed)
  332.             if ($tercero->getProyecto() === $this) {
  333.                 $tercero->setProyecto(null);
  334.             }
  335.         }
  336.         return $this;
  337.     }
  338.     /**
  339.      * @return Collection<int, ProyectoReunion>
  340.      */
  341.     public function getObservaciones(): Collection
  342.     {
  343.         return $this->observaciones;
  344.     }
  345.     public function addObservacione(ProyectoReunion $observacione): self
  346.     {
  347.         if (!$this->observaciones->contains($observacione)) {
  348.             $this->observaciones[] = $observacione;
  349.             $observacione->setProyecto($this);
  350.         }
  351.         return $this;
  352.     }
  353.     public function removeObservacione(ProyectoReunion $observacione): self
  354.     {
  355.         if ($this->observaciones->removeElement($observacione)) {
  356.             // set the owning side to null (unless already changed)
  357.             if ($observacione->getProyecto() === $this) {
  358.                 $observacione->setProyecto(null);
  359.             }
  360.         }
  361.         return $this;
  362.     }
  363.     public function getEstado(): ?int
  364.     {
  365.         return $this->estado;
  366.     }
  367.     public function setEstado(int $estado): self
  368.     {
  369.         $this->estado $estado;
  370.         return $this;
  371.     }
  372.     
  373.     public  function estadoToString(){
  374.         if($this->estado==0){
  375.             return "proyecto.sinIniciar";
  376.         }
  377.         if($this->estado==1){
  378.             return "proyecto.iniciado";
  379.         }
  380.         if($this->estado==2){
  381.             return "proyecto.finalizado";
  382.         }
  383.     }
  384.     
  385.     public function getGastado(){
  386.         $gastos$this->gastos;
  387.         $convenios$this->convenios;
  388.         $gastado=0;
  389.         foreach($gastos as $gasto){
  390.             $gastado+=$gasto->getCantidad();
  391.         }
  392.         foreach ($convenios as $convenio){
  393.             $gastado+=$convenio->getCantidad();
  394.         }
  395.         
  396.         return $gastado;
  397.     }
  398.     public function getRestante(){
  399.         return $this->financiacion-$this->getGastado();
  400.     }
  401. }