src/Domain/Entity/Expediente.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Domain\Entity;
  3. use App\Domain\Enum\TipoProcedimientoTramiteEnum;
  4. use App\Shared\Domain\ApplicationCore\Interfaces\EntityInterface;
  5. use DateTimeInterface;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Uid\Uuid;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. class Expediente implements EntityInterface
  13. {
  14.     private ?Uuid $id null;
  15.     private ?string $key null;
  16.     private ?string $nombre null;
  17.     /**
  18.      * @var string|null
  19.      * @Assert\NotBlank(message="not_blank")
  20.      */
  21.     private ?string $numeroExpediente null;
  22.     private ?string $descripcion null;
  23.     private ?DateTimeInterface $createdAt null;
  24.     private ?DateTimeInterface $updatedAt null;
  25.     private ?DateTimeInterface $deletedAt null;
  26.     private ?EstadoExpediente $estadoExpediente null;
  27.     private ?ExpedienteCabecera $cabecera null;
  28.     /**
  29.      * @var MetadataExpediente|null
  30.      * @Assert\NotBlank(message="not_blank")
  31.      */
  32.     private ?MetadataExpediente $metadata null;
  33.     private ?SonataUserUser $creador null;
  34.     private ?Entidad $entidad null;
  35.     private ?DocumentacionRegistro $solicitud null;
  36.     private Collection $tramites;
  37.     private Collection $minutas;
  38.     private Collection $responsables;
  39.     private Collection $registros;
  40.     private Collection $representacions;
  41.     public function __construct()
  42.     {
  43.         $this->tramites = new ArrayCollection();
  44.         $this->minutas = new ArrayCollection();
  45.         $this->responsables = new ArrayCollection();
  46.         $this->registros = new ArrayCollection();
  47.         $this->representacions = new ArrayCollection();
  48.     }
  49.     public function __toString(): string
  50.     {
  51.         return $this->getNumeroExpediente()??'X/0000/2024';
  52.     }
  53.     public function getKey(): ?string
  54.     {
  55.         return $this->key;
  56.     }
  57.     public function setKey(?string $key): static
  58.     {
  59.         $this->key $key;
  60.         return $this;
  61.     }
  62.     public function getNumeroExpediente(): ?string
  63.     {
  64.         return $this->numeroExpediente;
  65.     }
  66.     public function setNumeroExpediente(?string $numeroExpediente): static
  67.     {
  68.         $this->numeroExpediente $numeroExpediente;
  69.         return $this;
  70.     }
  71.     public function getNombre(): ?string
  72.     {
  73.         return $this->nombre;
  74.     }
  75.     public function setNombre(?string $nombre): static
  76.     {
  77.         $this->nombre $nombre;
  78.         return $this;
  79.     }
  80.     public function getDescripcion(): ?string
  81.     {
  82.         return $this->descripcion;
  83.     }
  84.     public function setDescripcion(?string $descripcion): static
  85.     {
  86.         $this->descripcion $descripcion;
  87.         return $this;
  88.     }
  89.     public function getCreatedAt(): ?\DateTimeInterface
  90.     {
  91.         return $this->createdAt;
  92.     }
  93.     public function setCreatedAt(\DateTimeInterface $createdAt): static
  94.     {
  95.         $this->createdAt $createdAt;
  96.         return $this;
  97.     }
  98.     public function getUpdatedAt(): ?\DateTimeInterface
  99.     {
  100.         return $this->updatedAt;
  101.     }
  102.     public function setUpdatedAt(\DateTimeInterface $updatedAt): static
  103.     {
  104.         $this->updatedAt $updatedAt;
  105.         return $this;
  106.     }
  107.     public function getDeletedAt(): ?\DateTimeInterface
  108.     {
  109.         return $this->deletedAt;
  110.     }
  111.     public function setDeletedAt(?\DateTimeInterface $deletedAt): static
  112.     {
  113.         $this->deletedAt $deletedAt;
  114.         return $this;
  115.     }
  116.     public function getId(): ?Uuid
  117.     {
  118.         return $this->id;
  119.     }
  120.     /**
  121.      * @return Collection<int, Tramite>
  122.      */
  123.     public function getTramites(): Collection
  124.     {
  125.         return $this->tramites;
  126.     }
  127.     public function addTramite(Tramite $tramite): static
  128.     {
  129.         if (!$this->tramites->contains($tramite)) {
  130.             $this->tramites->add($tramite);
  131.             $tramite->setExpediente($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeTramite(Tramite $tramite): static
  136.     {
  137.         if ($this->tramites->removeElement($tramite)) {
  138.             // set the owning side to null (unless already changed)
  139.             if ($tramite->getExpediente() === $this) {
  140.                 $tramite->setExpediente(null);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145.     /**
  146.      * @return Collection<int, Minuta>
  147.      */
  148.     public function getMinutas(): Collection
  149.     {
  150.         return $this->minutas;
  151.     }
  152.     public function addMinuta(Minuta $minuta): static
  153.     {
  154.         if (!$this->minutas->contains($minuta)) {
  155.             $this->minutas->add($minuta);
  156.             $minuta->setExpediente($this);
  157.         }
  158.         return $this;
  159.     }
  160.     public function removeMinuta(Minuta $minuta): static
  161.     {
  162.         if ($this->minutas->removeElement($minuta)) {
  163.             // set the owning side to null (unless already changed)
  164.             if ($minuta->getExpediente() === $this) {
  165.                 $minuta->setExpediente(null);
  166.             }
  167.         }
  168.         return $this;
  169.     }
  170.     public function getEstadoExpediente(): ?EstadoExpediente
  171.     {
  172.         return $this->estadoExpediente;
  173.     }
  174.     public function setEstadoExpediente(?EstadoExpediente $estadoExpediente): static
  175.     {
  176.         $this->estadoExpediente $estadoExpediente;
  177.         return $this;
  178.     }
  179.     public function getMetadata(): ?MetadataExpediente
  180.     {
  181.         return $this->metadata;
  182.     }
  183.     public function setMetadata(?MetadataExpediente $metadata): static
  184.     {
  185.         $this->metadata $metadata;
  186.         return $this;
  187.     }
  188.     public function getCreador(): ?SonataUserUser
  189.     {
  190.         return $this->creador;
  191.     }
  192.     public function setCreador(?SonataUserUser $creador): static
  193.     {
  194.         $this->creador $creador;
  195.         return $this;
  196.     }
  197.     public function getEntidad(): ?Entidad
  198.     {
  199.         return $this->entidad;
  200.     }
  201.     public function setEntidad(?Entidad $entidad): static
  202.     {
  203.         $this->entidad $entidad;
  204.         return $this;
  205.     }
  206.     /**
  207.      * @return Collection<int, SonataUserUser>
  208.      */
  209.     public function getResponsables(): Collection
  210.     {
  211.         return $this->responsables;
  212.     }
  213.     public function addResponsable(SonataUserUser $responsable): static
  214.     {
  215.         if (!$this->responsables->contains($responsable)) {
  216.             $this->responsables->add($responsable);
  217.         }
  218.         return $this;
  219.     }
  220.     public function removeResponsable(SonataUserUser $responsable): static
  221.     {
  222.         $this->responsables->removeElement($responsable);
  223.         return $this;
  224.     }
  225.     public function getCabecera(): ?ExpedienteCabecera
  226.     {
  227.         return $this->cabecera;
  228.     }
  229.     public function setCabecera(?ExpedienteCabecera $cabecera): static
  230.     {
  231.         $this->cabecera $cabecera;
  232.         return $this;
  233.     }
  234.     public function getTipo(): ?string
  235.     {
  236.         switch ($this->getTramites()?->last()->getProcedimiento())
  237.         {
  238.             case TipoProcedimientoTramiteEnum::PROCEDIMIENTO_EC:
  239.                  $return 'EC';
  240.                 break;
  241.             case TipoProcedimientoTramiteEnum::PROCEDIMIENTO_M:
  242.                 $return 'M';
  243.                 break;
  244.             case TipoProcedimientoTramiteEnum::PROCEDIMIENTO_C:
  245.                 $return 'C';
  246.                 break;
  247.             case TipoProcedimientoTramiteEnum::PROCEDIMIENTO_A:
  248.                 $return 'A';
  249.                 break;
  250.             default:
  251.                 $return null;
  252.                 break;
  253.         }
  254.         return $return;
  255.     }
  256.     public function getEmpresa(): ?string
  257.     {
  258.         $data json_decode($this->getCustom(), true);
  259.         switch ($data['entidad'])
  260.         {
  261.             case 'EMPRESA':
  262.             case '0':
  263.                 $tipo 'E';
  264.                 break;
  265.             case 'SECTOR':
  266.             case '1':
  267.                 $tipo 'S';
  268.                 break;
  269.             default:
  270.                 $tipo '---';
  271.                 break;
  272.         }
  273.         return $tipo;
  274.     }
  275.     public function getEmpresaNombre(): ?string
  276.     {
  277.         $data json_decode($this->getCustom(), true);
  278.         switch ($data['entidad'])
  279.         {
  280.             case 'EMPRESA':
  281.             case '0':
  282.                 $id $data['empresa'];
  283.                 break;
  284.             case 'SECTOR':
  285.             case '1':
  286.                 $id $data['sector'];
  287.                 break;
  288.             default:
  289.                 $id null;
  290.                 break;
  291.         }
  292.         return $id;
  293.     }
  294.     /**
  295.      * @return Collection<int, DocumentacionRegistro>
  296.      */
  297.     public function getRegistros(): Collection
  298.     {
  299.         return $this->registros;
  300.     }
  301.     public function addRegistro(DocumentacionRegistro $registro): static
  302.     {
  303.         if (!$this->registros->contains($registro)) {
  304.             $this->registros->add($registro);
  305.             $registro->setExpediente($this);
  306.         }
  307.         return $this;
  308.     }
  309.     public function removeRegistro(DocumentacionRegistro $registro): static
  310.     {
  311.         if ($this->registros->removeElement($registro)) {
  312.             // set the owning side to null (unless already changed)
  313.             if ($registro->getExpediente() === $this) {
  314.                 $registro->setExpediente(null);
  315.             }
  316.         }
  317.         return $this;
  318.     }
  319.     public function getFase():?string
  320.     {
  321.         return $this->getEstadoExpediente()?->getSubestado();
  322.     }
  323.     public function getSubFase():?string
  324.     {
  325.         return $this->getTramites()?->last()->getNombre();
  326.     }
  327.     public function getSolicitud(): ?DocumentacionRegistro
  328.     {
  329.         return $this->solicitud;
  330.     }
  331.     public function setSolicitud(?DocumentacionRegistro $solicitud): static
  332.     {
  333.         $this->solicitud $solicitud;
  334.         return $this;
  335.     }
  336.     public function getCustom():?string
  337.     {
  338.         return $this->getSolicitud()?->getCustom()->getForm();
  339.     }
  340.     /**
  341.      * @return Collection<int, Representacion>
  342.      */
  343.     public function getRepresentacions(): Collection
  344.     {
  345.         return $this->representacions;
  346.     }
  347.     public function addRepresentacion(Representacion $representacion): static
  348.     {
  349.         if (!$this->representacions->contains($representacion)) {
  350.             $this->representacions->add($representacion);
  351.             $representacion->setExpediente($this);
  352.         }
  353.         return $this;
  354.     }
  355.     public function removeRepresentacion(Representacion $representacion): static
  356.     {
  357.         if ($this->representacions->removeElement($representacion)) {
  358.             // set the owning side to null (unless already changed)
  359.             if ($representacion->getExpediente() === $this) {
  360.                 $representacion->setExpediente(null);
  361.             }
  362.         }
  363.         return $this;
  364.     }
  365. }