src/Entity/Seguridad.php line 1282

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\SeguridadRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use ApiPlatform\Core\Annotation\ApiFilter;
  10. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  11. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  12. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  13. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\RangeFilter
  14. use Doctrine\ORM\Event\LifecycleEventArgs;
  15. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  16. /**
  17.  * @ApiResource(
  18.  *      normalizationContext={"groups"={"seguridad"}},
  19.  *      denormalizationContext={"groups"={"write"}},
  20.  * )
  21.  * @ApiFilter(SearchFilter::class, properties={
  22.  *                                      "aprobacion": "exact",
  23.  *                                      "unidadFuncional.ruta.proyecto": "exact",
  24.  *                                      "segmento.tramo":"exact",
  25.  *                                      "unidadFuncional": "exact",
  26.  *                                      "tipoElementoDesc":"exact", 
  27.  *                                      "tramo" : "exact",
  28.  *                                      "segmento":"exact",
  29.  *                                      "estado": "exact",
  30.  *                                      "abInicio": "exact",
  31.  *                                      "margen": "exact", 
  32.  *                                      "status": "exact",
  33.  *                                      "tipoElemento":"exact"
  34.  *                                  })
  35.  * @ApiFilter(BooleanFilter::class, properties={"status"})
  36.  * 
  37.  * @ApiFilter(OrderFilter::class, properties={
  38.  *                                      "id",  
  39.  *                                      "abInicio", 
  40.  *                                      "margen", 
  41.  *                                      "estado", 
  42.  *                                      "updatedAt", 
  43.  *                                      "status", 
  44.  *                                      "tipoElementoDesc", 
  45.  *                                      "updatedAt", 
  46.  *                                      "smartCode"
  47.  * })
  48.  * @ApiFilter(RangeFilter::class, properties={"segmento.abInicio", "segmento.abFin"})
  49.  * @ORM\HasLifecycleCallbacks
  50.  * @ORM\Entity(repositoryClass=SeguridadRepository::class)
  51.  * @ApiFilter(PropertyFilter::class)
  52.  */
  53. class Seguridad extends BaseEntity
  54. {
  55.     /**
  56.      * @ORM\Id()
  57.      * @ORM\GeneratedValue()
  58.      * @ORM\Column(type="integer")
  59.      */
  60.     private $id;
  61.     /**
  62.      * @ORM\OneToOne(targetEntity=Proveedor::class, cascade={"persist"})
  63.      * @ORM\JoinColumn(nullable=true)
  64.      * @Groups({"seguridad", "write"})
  65.      */
  66.     private $proveedor;
  67.     /**
  68.      * @ORM\OneToOne(targetEntity=Segmento::class, cascade={"persist",})
  69.      * @ORM\JoinColumn(nullable=true)
  70.      * @Groups({"seguridad", "write"})
  71.      */
  72.     public $segmento;
  73.     /**
  74.      * @ORM\OneToOne(targetEntity=Tramo::class, cascade={"persist"})
  75.      * @ORM\JoinColumn(nullable=true)
  76.      * @Groups({"seguridad", "write"})
  77.      */
  78.     private $tramo;
  79.     /**
  80.      * @ORM\OneToOne(targetEntity=UnidadFuncional::class, cascade={"persist"})
  81.      * @ORM\JoinColumn(nullable=true)
  82.      * @Groups({"seguridad", "write"})
  83.      */
  84.     private $unidadFuncional;
  85.     /**
  86.      * @ORM\OneToOne(targetEntity=TipoElemento::class, cascade={"persist"})
  87.      * @ORM\JoinColumn(nullable=true)
  88.      * @Groups({"seguridad", "write"})
  89.      */
  90.     public $tipoElemento;
  91.     /**
  92.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  93.      * @Groups({"seguridad", "write"})
  94.      */
  95.     private $tramos;
  96.     /**
  97.      * @ORM\Column(type="string", length=100)
  98.      * @Groups({"seguridad", "write"})
  99.      */
  100.     private $material;
  101.     /**
  102.      * @ORM\Column(type="string", length=100)
  103.      * @Groups({"seguridad", "write"})
  104.      */
  105.     private $mot_remplazo;
  106.     /**
  107.      * @ORM\Column(type="string", length=100, nullable=true)
  108.      * @Groups({"seguridad", "write"})
  109.      */
  110.     private $perfil;
  111.     /**
  112.      * @ORM\Column(type="string", length=100)
  113.      * @Groups({"seguridad", "write"})
  114.      */
  115.     private $observaciones;
  116.     /**
  117.      * @ORM\Column(type="string", length=250)
  118.      * @Groups({"seguridad", "write"})
  119.      */
  120.     private $elementoReemplazo_id;
  121.     /**
  122.      * @ORM\Column(type="string", length=250, nullable=true)
  123.      * @Groups({"seguridad", "write"})
  124.      */
  125.     private $motivoReemplazo;
  126.     /**
  127.      * @ORM\Column(type="string", length=200)
  128.      * @Groups({"seguridad", "write"})
  129.      */
  130.     private $estado;
  131.     /**
  132.      * @ORM\Column(type="string", length=20)
  133.      * @Groups({"seguridad", "write"})
  134.      */
  135.     private $condicion_elemento;
  136.     /**
  137.      * @ORM\Column(type="string", length=20)
  138.      * @Groups({"seguridad", "write"})
  139.      */
  140.     private $margen;
  141.     /**
  142.      * @ORM\Column(type="string", length=20, nullable=true)
  143.      * @Groups({"seguridad", "write"})
  144.      */
  145.     private $tope;
  146.     /**
  147.      * @ORM\Column(type="string", length=20)
  148.      * @Groups({"seguridad", "write"})
  149.      */
  150.     private $defensa;
  151.     /**
  152.      * @ORM\Column(type="string", length=200, nullable=true)
  153.      * @Groups({"seguridad", "write"})
  154.      */
  155.     private $seccion;
  156.     /**
  157.      * @ORM\Column(type="boolean")
  158.      * @Groups({"seguridad", "write"})
  159.      */
  160.     private $mantenimiento false;
  161.     /**
  162.      * @ORM\Column(type="decimal", precision=10, scale=4)
  163.      * @Groups({"seguridad", "write"})
  164.      */
  165.     private $abInicio;
  166.     /**
  167.      * @ORM\Column(type="date")
  168.      * @Groups({"seguridad", "write"})
  169.      */
  170.     private $fechaInstalacion;
  171.     /**
  172.      * @ORM\Column(type="decimal", precision=10, scale=2)
  173.      * @Groups({"seguridad", "write"})
  174.      */
  175.     private $cant_alt;
  176.     /**
  177.      * @ORM\Column(type="integer", nullable=true)
  178.      * @Groups({"seguridad", "write"})
  179.      */
  180.     private $topes;
  181.     /**
  182.      * @ORM\Column(type="decimal", precision=10, scale=1)
  183.      * @Groups({"seguridad", "write"})
  184.      */
  185.     private $altura;
  186.      /**
  187.      * @ORM\Column(type="string", length=10)
  188.      * @Groups({"seguridad", "write"})
  189.      */
  190.     private $posteMetalico;
  191.     /**
  192.      * @ORM\Column(type="decimal", precision=10, scale=1, nullable=true)
  193.      * @Groups({"seguridad", "write"})
  194.      */
  195.     private $diametro;
  196.     /**
  197.      * @ORM\Column(type="decimal", precision=10, scale=1)
  198.      * @Groups({"seguridad", "write"})
  199.      */
  200.     private $cant_ancho;
  201.     /**
  202.      * @ORM\Column(type="integer")
  203.      * @Groups({"seguridad", "write"})
  204.      */
  205.     private $postes;
  206.     /**
  207.      * @ORM\Column(type="integer")
  208.      * @Groups({"seguridad", "write"})
  209.      */
  210.     private $terminales;
  211.     /**
  212.      * @ORM\Column(type="integer")
  213.      * @Groups({"seguridad", "write"})
  214.      */
  215.     private $cant_capta;
  216.     /**
  217.      * @ORM\Column(type="integer")
  218.      * @Groups({"seguridad", "write"})
  219.      */
  220.     private $garantia;
  221.     /**
  222.      * @ORM\Column(type="decimal", precision=10, scale=6)
  223.      * @Groups({"seguridad", "write"})
  224.      */
  225.     private $cant_elem;
  226.     /**
  227.      * @ORM\Column(type="decimal", precision=10, scale=6)
  228.      * @Groups({"seguridad", "write"})
  229.      */
  230.     private $cant_largo;
  231.     /**
  232.      * @ORM\Column(type="decimal", precision=10, scale=2)
  233.      * @Groups({"seguridad", "write"})
  234.      */
  235.     private $largo;
  236.     /**
  237.      * @ORM\Column(type="integer")
  238.      * @Groups({"seguridad", "write"})
  239.      */
  240.     private $tornillos;
  241.     /**
  242.      * @ORM\Column(type="integer")
  243.      * @Groups({"seguridad", "write"})
  244.      */
  245.     private $unidades;
  246.     /**
  247.      * @ORM\Column(type="integer")
  248.      * @Groups({"seguridad", "write"})
  249.      */
  250.     private $captafaros;
  251.     /**
  252.      * @ORM\Column(type="integer")
  253.      * @Groups({"seguridad", "write"})
  254.      */
  255.     private $codigo;
  256.     /**
  257.      * @ORM\Column(type="float")
  258.      * @Groups({"seguridad", "write"})
  259.      */
  260.     private $ca_largo;
  261.     /**
  262.      * @ORM\Column(type="float")
  263.      * @Groups({"seguridad", "write"})
  264.      */
  265.     private $ca_ancho;
  266.     /**
  267.      * @ORM\Column(type="float", nullable=true)
  268.      * @Groups({"seguridad", "write"})
  269.      */
  270.     private $ca_altura;
  271.     /**
  272.      * @ORM\Column(type="float")
  273.      * @Groups({"seguridad", "write"})
  274.      */
  275.     private $calibre_mm;
  276.     /**
  277.      * @ORM\Column(type="boolean", nullable=true)
  278.      * @Groups({"seguridad", "write"})
  279.      */
  280.     private $status 1;
  281.     /**
  282.      * @ORM\OneToMany(targetEntity=UbicacionSeguridad::class, mappedBy="elemento", orphanRemoval=false, cascade={"persist", "remove"})
  283.      * @Groups({"seguridad", "write"})
  284.      */
  285.     private $ubicaciones;
  286.     /**
  287.      * @ORM\Column(type="string", length=100, nullable=true)
  288.      * @Groups({"seguridad", "write"})
  289.      */
  290.     private $smartCode;
  291.     /**
  292.      * @ORM\Column(type="string", length=100)
  293.      * @Groups({"seguridad", "write"})
  294.      */
  295.     private $tipoElementoDesc;
  296.     /**
  297.      * @Groups({"seguridad", "write"})
  298.      * @ORM\OneToMany(targetEntity="App\Entity\ImageSeguridadVial", mappedBy="recurso", cascade={"persist", "remove"})
  299.      */
  300.     public $images
  301.     /**
  302.      * @Groups({ "write", "seguridad" })
  303.      * @ORM\Column(type="string", nullable=true)
  304.      */
  305.     private $createdIn;
  306.     /**
  307.      * @Groups({"write", "seguridad"})
  308.      * @ORM\Column(type="string", nullable=true)
  309.      */
  310.     private $updatedIn;
  311.     /**
  312.      * @Groups({"write", "seguridad"})
  313.      * @ORM\Column(type="string", length=50, nullable=true)
  314.      */
  315.     private $aprobacion;
  316.     /**
  317.      * @ORM\Column(type="string", length=255, nullable=true)
  318.      * @Groups({"seguridad", "write"})
  319.      */
  320.     private $sentido;
  321.     /**
  322.      * @ORM\Column(type="decimal", precision=10, scale=4, nullable=true)
  323.      * @Groups({"seguridad", "write"})
  324.      */
  325.     private $pInicio;
  326.     /**
  327.      * @ORM\Column(type="decimal", precision=10, scale=4, nullable=true)
  328.      * @Groups({"seguridad", "write"})
  329.      */
  330.     private $pFin;
  331.     /**
  332.      * @ORM\Column(type="decimal", precision=10, scale=4, nullable=true)
  333.      * @Groups({"seguridad", "write"})
  334.      */
  335.     private $abFin;
  336.     /**
  337.      * @param Images[] $Images
  338.     */
  339.     public function setImages(array $images): void
  340.     {
  341.         
  342.       $this->images $images;
  343.       if( !is_null$this->images ) ){
  344.           foreach( $this->images as $image ){
  345.               $image -> recurso $this;
  346.           }
  347.       }
  348.         
  349.     }
  350.     public function __construct()
  351.     {
  352.         $this->ubicaciones = new ArrayCollection();
  353.         $this->images = new ArrayCollection();
  354.     }
  355.     /**
  356.      * @ORM\PreRemove
  357.      */
  358.     public function preRemove(LifecycleEventArgs $args): void {
  359.         $tableOrigin "seguridad";
  360.         $oldData "";
  361.         $idDelete $args->getObject()->getId();
  362.         $smartCodeDelete $args->getObject()->getSmartCode();
  363.         $tipoElementoDelete $args->getObject()->getTipoElemento()->getId();
  364.         $manager $args->getEntityManager();
  365.         $conn $manager->getConnection();
  366.         $queryColumansTables "SELECT * FROM ${tableOrigin} e WHERE e.id = ${idDelete};";
  367.         $stmt $conn->query($queryColumansTables);
  368.         $columnsTables $stmt->fetch();
  369.         foreach ($columnsTables as $key => $value) {
  370.             $oldData .= "${key} ${value}^";
  371.         }
  372.         $audit = new Audit();
  373.         $audit->setType("Eliminación");
  374.         $audit->setTableOrigin($tableOrigin);
  375.         $audit->setOld($oldData);
  376.         $audit->setNew("");
  377.         $audit->setIdElement($idDelete);
  378.         $audit->setModule("Inventario");
  379.         $audit->setFunctionality("Sistemas de contención vehicular");
  380.         $audit->setSmartCode($smartCodeDelete);
  381.         $audit->setSubElement($tipoElementoDelete);
  382.         $audit->setTableMaster(1);
  383.         $manager->persist($audit);
  384.         $manager->flush();
  385.     }
  386.     public function getId(): ?int
  387.     {
  388.         return $this->id;
  389.     }
  390.     public function getProveedor(): ?Proveedor
  391.     {
  392.         return $this->proveedor;
  393.     }
  394.     public function setProveedor(Proveedor $proveedor): self
  395.     {
  396.         $this->proveedor $proveedor;
  397.         return $this;
  398.     }
  399.     public function getSegmento(): ?Segmento
  400.     {
  401.         return $this->segmento;
  402.     }
  403.     public function setSegmento(Segmento $segmento): self
  404.     {
  405.         $this->segmento $segmento;
  406.         return $this;
  407.     }
  408.     public function getTramo(): ?Tramo
  409.     {
  410.         return $this->tramo;
  411.     }
  412.     public function setTramo(Tramo $tramo): self
  413.     {
  414.         $this->tramo $tramo;
  415.         return $this;
  416.     }
  417.     public function getUnidadFuncional(): ?UnidadFuncional
  418.     {
  419.         return $this->unidadFuncional;
  420.     }
  421.     public function setUnidadFuncional(UnidadFuncional $unidadFuncional): self
  422.     {
  423.         $this->unidadFuncional $unidadFuncional;
  424.         return $this;
  425.     }
  426.     public function getTipoElemento(): ?TipoElemento
  427.     {
  428.         return $this->tipoElemento;
  429.     }
  430.     public function setTipoElemento(TipoElemento $tipoElemento): self
  431.     {
  432.         $this->tipoElemento $tipoElemento;
  433.         return $this;
  434.     }
  435.     public function getTramos(): ?string
  436.     {
  437.         return $this->tramos;
  438.     }
  439.     public function setTramos($tramos): self
  440.     {
  441.         $this->tramos $tramos;
  442.         return $this;
  443.     }
  444.     public function getMaterial(): ?string
  445.     {
  446.         return $this->material;
  447.     }
  448.     public function setMaterial(string $material): self
  449.     {
  450.         $this->material $material;
  451.         return $this;
  452.     }
  453.     public function getMotRemplazo(): ?string
  454.     {
  455.         return $this->mot_remplazo;
  456.     }
  457.     public function setMotRemplazo(string $mot_remplazo): self
  458.     {
  459.         $this->mot_remplazo $mot_remplazo;
  460.         return $this;
  461.     }
  462.     public function getPerfil(): ?string
  463.     {
  464.         return $this->perfil;
  465.     }
  466.     public function setPerfil($perfil): self
  467.     {
  468.         $this->perfil $perfil;
  469.         return $this;
  470.     }
  471.     public function getObservaciones(): ?string
  472.     {
  473.         return $this->observaciones;
  474.     }
  475.     public function setObservaciones(string $observaciones): self
  476.     {
  477.         $this->observaciones $observaciones;
  478.         return $this;
  479.     }
  480.     public function getElementoReemplazoId(): ?string
  481.     {
  482.         return $this->elementoReemplazo_id;
  483.     }
  484.     /**
  485.      * @Groups({"seguridad"})
  486.      */
  487.     public function getElementoReemplazo_id(): ?string
  488.     {
  489.         return $this->elementoReemplazo_id;
  490.     }
  491.     public function setElementoReemplazoId($elementoReemplazo_id): self
  492.     {
  493.         $this->elementoReemplazo_id $elementoReemplazo_id;
  494.         return $this;
  495.     }
  496.     /**
  497.      * @Groups({"write"})
  498.      */
  499.     public function setElementoReemplazo_id($elementoReemplazo_id): self
  500.     {
  501.         $this->elementoReemplazo_id $elementoReemplazo_id;
  502.         return $this;
  503.     }
  504.     public function getMotivoReemplazo(): ?string
  505.     {
  506.         return $this->motivoReemplazo;
  507.     }
  508.     public function setMotivoReemplazo(?string $motivoReemplazo): self
  509.     {
  510.         $this->motivoReemplazo $motivoReemplazo;
  511.         return $this;
  512.     }
  513.     public function getEstado(): ?string
  514.     {
  515.         return $this->estado;
  516.     }
  517.     public function setEstado(string $estado): self
  518.     {
  519.         $this->estado $estado;
  520.         return $this;
  521.     }
  522.     /**
  523.      * @Groups({"seguridad"})
  524.      */
  525.     public function getCondicionElemento(): ?string
  526.     {
  527.         return $this->condicion_elemento;
  528.     }
  529.     /**
  530.      * @Groups({"write"})
  531.      */
  532.     public function setCondicionElemento(string $condicion_elemento): self
  533.     {
  534.         $this->condicion_elemento $condicion_elemento;
  535.         return $this;
  536.     }
  537.     public function getMargen(): ?string
  538.     {
  539.         return $this->margen;
  540.     }
  541.     public function setMargen(string $margen): self
  542.     {
  543.         $this->margen $margen;
  544.         return $this;
  545.     }
  546.     public function getTope(): ?string
  547.     {
  548.         return $this->tope;
  549.     }
  550.     public function setTope($tope): self
  551.     {
  552.         $this->tope $tope;
  553.         return $this;
  554.     }
  555.     public function getDefensa(): ?string
  556.     {
  557.         return $this->defensa;
  558.     }
  559.     public function setDefensa($defensa): self
  560.     {
  561.         $this->defensa $defensa;
  562.         return $this;
  563.     }
  564.     public function getSeccion(): ?string
  565.     {
  566.         return $this->seccion;
  567.     }
  568.     public function setSeccion($seccion): self
  569.     {
  570.         $this->seccion $seccion;
  571.         return $this;
  572.     }
  573.     public function getMantenimiento(): ?bool
  574.     {
  575.         return $this->mantenimiento;
  576.     }
  577.     public function setMantenimiento($mantenimiento): self
  578.     {
  579.         $this->mantenimiento $mantenimiento;
  580.         return $this;
  581.     }
  582.     public function getAbInicio(): ?string
  583.     {
  584.         return $this->abInicio;
  585.     }
  586.     public function setAbInicio(string $abInicio): self
  587.     {
  588.         $this->abInicio $abInicio;
  589.         return $this;
  590.     }
  591.     public function getFechaInstalacion(): ?\DateTimeInterface
  592.     {
  593.         return $this->fechaInstalacion;
  594.     }
  595.     public function setFechaInstalacion(\DateTimeInterface $fechaInstalacion): self
  596.     {
  597.         $this->fechaInstalacion $fechaInstalacion;
  598.         return $this;
  599.     }
  600.     public function getCantAlt(): ?string
  601.     {
  602.         return $this->cant_alt;
  603.     }
  604.     public function setCantAlt(string $cant_alt): self
  605.     {
  606.         $this->cant_alt $cant_alt;
  607.         return $this;
  608.     }
  609.     public function getTopes(): ?int
  610.     {
  611.         return $this->topes;
  612.     }
  613.     public function setTopes($topes): self
  614.     {
  615.         $this->topes $topes;
  616.         return $this;
  617.     }
  618.     /**
  619.      * @Groups({"seguridad"})
  620.      */
  621.     public function getAltura(): ?string
  622.     {
  623.         return $this->altura;
  624.     }
  625.     /**
  626.      * @Groups({"write"})
  627.      */
  628.     public function setAltura($altura): self
  629.     {
  630.         $this->altura $altura;
  631.         return $this;
  632.     }
  633.     /**
  634.      * @Groups({"seguridad"})
  635.      */
  636.     public function getPosteMetalico(): ?string
  637.     {
  638.         return $this->posteMetalico;
  639.     }
  640.     /**
  641.      * @Groups({"write"})
  642.      */
  643.     public function setPosteMetalico($posteMetalico): self
  644.     {
  645.         $this->posteMetalico $posteMetalico;
  646.         return $this;
  647.     }
  648.     public function getDiametro(): ?string
  649.     {
  650.         return $this->diametro;
  651.     }
  652.     public function setDiametro($diametro): self
  653.     {
  654.         $this->diametro $diametro;
  655.         return $this;
  656.     }
  657.     public function getCantAncho(): ?string
  658.     {
  659.         return $this->cant_ancho;
  660.     }
  661.     /**
  662.      * @Groups({"seguridad"})
  663.      */
  664.     public function getCant_ancho(): ?string
  665.     {
  666.         return $this->cant_ancho;
  667.     }
  668.     public function setCantAncho($cant_ancho): self
  669.     {
  670.         $this->cant_ancho $cant_ancho;
  671.         return $this;
  672.     }
  673.     /**
  674.      * @Groups({"write"})
  675.      */
  676.     public function setCant_ancho($cant_ancho): self
  677.     {
  678.         $this->cant_ancho $cant_ancho;
  679.         return $this;
  680.     }
  681.     public function getPostes(): ?int
  682.     {
  683.         return $this->postes;
  684.     }
  685.     public function setPostes($postes): self
  686.     {
  687.         $this->postes $postes;
  688.         return $this;
  689.     }
  690.     public function getTerminales(): ?int
  691.     {
  692.         return $this->terminales;
  693.     }
  694.     public function setTerminales($terminales): self
  695.     {
  696.         $this->terminales $terminales;
  697.         return $this;
  698.     }
  699.     public function getCantCapta(): ?int
  700.     {
  701.         return $this->cant_capta;
  702.     }
  703.     /**
  704.      * @Groups({"seguridad"})
  705.      */
  706.     public function getCant_capta(): ?int
  707.     {
  708.         return $this->cant_capta;
  709.     }
  710.     public function setCantCapta($cant_capta): self
  711.     {
  712.         $this->cant_capta $cant_capta;
  713.         return $this;
  714.     }
  715.     /**
  716.      * @Groups({"write"})
  717.      */
  718.     public function setCant_capta($cant_capta): self
  719.     {
  720.         $this->cant_capta $cant_capta;
  721.         return $this;
  722.     }
  723.     public function getGarantia(): ?int
  724.     {
  725.         return $this->garantia;
  726.     }
  727.     public function setGarantia(int $garantia): self
  728.     {
  729.         $this->garantia $garantia;
  730.         return $this;
  731.     }
  732.     public function getCantElem(): ?string
  733.     {
  734.         return $this->cant_elem;
  735.     }
  736.     /**
  737.      * @Groups({"seguridad"})
  738.      */
  739.     public function getCant_elem(): ?string
  740.     {
  741.         return $this->cant_elem;
  742.     }
  743.     public function setCantElem($cant_elem): self
  744.     {
  745.         $this->cant_elem $cant_elem;
  746.         return $this;
  747.     }
  748.     /**
  749.      * @Groups({"write"})
  750.      */
  751.     public function setCant_elem($cant_elem): self
  752.     {
  753.         $this->cant_elem $cant_elem;
  754.         return $this;
  755.     }
  756.     public function getCantLargo(): ?string
  757.     {
  758.         return $this->cant_largo;
  759.     }
  760.     /**
  761.      * @groups({"seguridad"})
  762.      */
  763.     public function getCant_largo(): ?string
  764.     {
  765.         return $this->cant_largo;
  766.     }
  767.     public function setCantLargo($cant_largo): self
  768.     {
  769.         $this->cant_largo $cant_largo;
  770.         return $this;
  771.     }
  772.     /**
  773.      * @groups({"write"})
  774.      */
  775.     public function setCant_largo($cant_largo): self
  776.     {
  777.         $this->cant_largo $cant_largo;
  778.         return $this;
  779.     }
  780.     public function getLargo(): ?string
  781.     {
  782.         return $this->largo;
  783.     }
  784.     public function setLargo($largo): self
  785.     {
  786.         $this->largo $largo;
  787.         return $this;
  788.     }
  789.     public function getTornillos(): ?int
  790.     {
  791.         return $this->tornillos;
  792.     }
  793.     public function setTornillos($tornillos): self
  794.     {
  795.         $this->tornillos $tornillos;
  796.         return $this;
  797.     }
  798.     public function getUnidades(): ?int
  799.     {
  800.         return $this->unidades;
  801.     }
  802.     public function setUnidades($unidades): self
  803.     {
  804.         $this->unidades $unidades;
  805.         return $this;
  806.     }
  807.     public function getCaptafaros(): ?int
  808.     {
  809.         return $this->captafaros;
  810.     }
  811.     public function setCaptafaros($captafaros): self
  812.     {
  813.         $this->captafaros $captafaros;
  814.         return $this;
  815.     }
  816.     public function getCodigo(): ?int
  817.     {
  818.         return $this->codigo;
  819.     }
  820.     public function setCodigo(int $codigo): self
  821.     {
  822.         $this->codigo $codigo;
  823.         return $this;
  824.     }
  825.     public function getCaLargo(): ?float
  826.     {
  827.         return $this->ca_largo;
  828.     }
  829.     /**
  830.      * @Groups({"seguridad"})
  831.      */
  832.     public function getCa_largo(): ?float
  833.     {
  834.         return $this->ca_largo;
  835.     }
  836.     public function setCaLargo($ca_largo): self
  837.     {
  838.         $this->ca_largo $ca_largo;
  839.         return $this;
  840.     }
  841.     /**
  842.      * @Groups({"write"})
  843.      */
  844.     public function setCa_largo($ca_largo): self
  845.     {
  846.         $this->ca_largo $ca_largo;
  847.         return $this;
  848.     }
  849.     public function getCaAncho(): ?float
  850.     {
  851.         return $this->ca_ancho;
  852.     }
  853.     public function setCaAncho($ca_ancho): self
  854.     {
  855.         $this->ca_ancho $ca_ancho;
  856.         return $this;
  857.     }
  858.     /**
  859.      * @Groups({"seguridad"})
  860.      */
  861.     public function getCa_ancho(): ?float
  862.     {
  863.         return $this->ca_ancho;
  864.     }
  865.     /**
  866.      * @Groups({"write"})
  867.      */
  868.     public function setCa_ancho($ca_ancho): self
  869.     {
  870.         $this->ca_ancho $ca_ancho;
  871.         return $this;
  872.     }
  873.     public function getCaAltura(): ?float
  874.     {
  875.         return $this->ca_altura;
  876.     }
  877.     public function setCaAltura($ca_altura): self
  878.     {
  879.         $this->ca_altura $ca_altura;
  880.         return $this;
  881.     }
  882.     /**
  883.      * @Groups({"seguridad"}) */    
  884.     public function getCa_altura(): ?float
  885.     {
  886.         return $this->ca_altura;
  887.     }
  888.     /**
  889.      * @Groups({"write"})
  890.      */
  891.     public function setCa_altura($ca_altura): self
  892.     {
  893.         $this->ca_altura $ca_altura;
  894.         return $this;
  895.     }
  896.     public function getCalibreMm(): ?float
  897.     {
  898.         return $this->calibre_mm;
  899.     }
  900.     public function setCalibreMm($calibre_mm): self
  901.     {
  902.         $this->calibre_mm $calibre_mm;
  903.         return $this;
  904.     }
  905. /**
  906.  * @Groups({"seguridad"})
  907.  */
  908.     public function getCalibre_mm(): ?float
  909.     {
  910.         return $this->calibre_mm;
  911.     }
  912.     public function setCalibre_mm($calibre_mm): self
  913.     {
  914.         $this->calibre_mm $calibre_mm;
  915.         return $this;
  916.     }
  917. /**
  918.  * @Groups({"write"})
  919.  */
  920.     public function getStatus(): ?bool
  921.     {
  922.         return $this->status;
  923.     }
  924.     public function setStatus($status): self
  925.     {
  926.         $this->status $status;
  927.         return $this;
  928.     }
  929.     /**
  930.      * @return Collection|UbicacionSeguridad[]
  931.      */
  932.     public function getUbicaciones(): Collection
  933.     {
  934.         return $this->ubicaciones;
  935.     }
  936.     public function addUbicacione(UbicacionSeguridad $ubicacione): self
  937.     {
  938.         if (!$this->ubicaciones->contains($ubicacione)) {
  939.             $this->ubicaciones[] = $ubicacione;
  940.             $ubicacione->setElemento($this);
  941.         }
  942.         return $this;
  943.     }
  944.     public function removeUbicacione(UbicacionSeguridad $ubicacione): self
  945.     {
  946.         if ($this->ubicaciones->contains($ubicacione)) {
  947.             $this->ubicaciones->removeElement($ubicacione);
  948.             // set the owning side to null (unless already changed)
  949.             if ($ubicacione->getElemento() === $this) {
  950.                 $ubicacione->setElemento(null);
  951.             }
  952.         }
  953.         return $this;
  954.     }
  955.     public function getSmartCode(): ?string
  956.     {
  957.         return $this->smartCode;
  958.     }
  959.     public function setSmartCode($smartCode): self
  960.     {
  961.         $this->smartCode $smartCode;
  962.         return $this;
  963.     }
  964.     public function getTipoElementoDesc(): ?string
  965.     {
  966.         return $this->tipoElementoDesc;
  967.     }
  968.     public function setTipoElementoDesc(string $tipoElementoDesc): self
  969.     {
  970.         $this->tipoElementoDesc $tipoElementoDesc;
  971.         return $this;
  972.     }
  973.     /**
  974.      * @return string
  975.      * @Groups({"seguridad"})
  976.      */
  977.     public function getLatitudInicial(){
  978.         if(!is_null($this->ubicaciones[1]))
  979.         {
  980.             return $this->ubicaciones[0]->lat;
  981.         }
  982.     }
  983.     /**
  984.      * @return string
  985.      * @Groups({"seguridad"})
  986.      */
  987.     public function getLongitudInicial()
  988.     {
  989.         if(!is_null($this->ubicaciones[1]))
  990.         {
  991.             return $this->ubicaciones[0]->lng;
  992.         }
  993.     }
  994.     /**
  995.      * @return string
  996.      * @Groups({"seguridad"})
  997.      */
  998.     public function getLatitudFinal()
  999.     {
  1000.         if(!is_null($this->ubicaciones[1]))
  1001.         {
  1002.             return $this->ubicaciones[1]->lat;
  1003.         }
  1004.     }
  1005.     /**
  1006.      * @return string
  1007.      * @Groups({"seguridad"})
  1008.      */
  1009.     public function getLongitudFinal(){
  1010.         if(!is_null($this->ubicaciones[1]))
  1011.         {
  1012.             return $this->ubicaciones[1]->lng;
  1013.         }    
  1014.     }
  1015.     /**
  1016.   *
  1017.   * @ORM\PrePersist
  1018.   */
  1019.  public function prePersist(LifecycleEventArgs $args){
  1020.                                         if($this->condicion_elemento == "Reemplazo") {
  1021.                                             
  1022.                                              $query $args->getEntityManager()->createQuery("UPDATE ".get_class($this)." seg SET seg.status = 0, seg.estado = 'Inactivo' WHERE seg.id = ?1");
  1023.                                              $query->setParameter(1,  $this->idFormatter("toID"$this->elementoReemplazo_id));
  1024.                                              $query->execute();
  1025.                                      
  1026.                                          }
  1027.                                          
  1028.                                          $query $args->getEntityManager()->createQuery('SELECT MAX(e.codigo)+1 FROM '.get_class($this).' e WHERE e.segmento = ?1 AND e.tipoElemento = ?2');
  1029.                                          $query->setParameter(1$this->segmento);
  1030.                                          $query->setParameter(2$this->tipoElemento);
  1031.                                          $this->codigo $query->getSingleScalarResult();
  1032.                                          if( is_null$this->codigo ) ){
  1033.                                             $this->codigo 1;
  1034.                                          }
  1035.                                          $this->setSmartCode($this->getFullCodigoConsecutivo());
  1036.                                       }
  1037.  
  1038.     /**
  1039.    *
  1040.    * @ORM\PreUpdate
  1041.    */
  1042.   public function preUpdate(LifecycleEventArgs $args){
  1043.      if($this->condicion_elemento == "Reemplazo" && $args->hasChangedField("elementoReemplazo_id")) {
  1044.          $reemplazoActual $args->getOldValue('elementoReemplazo_id');
  1045.          $query $args->getEntityManager()->createQuery("UPDATE ".get_class($this)." seg SET seg.status = 1, seg.estado = 'Activo' WHERE seg.id = ?1");
  1046.          $query->setParameter(1$this->idFormatter("toID"$this->reemplazoActual));
  1047.          $query->execute();
  1048.  
  1049.          $query $args->getEntityManager()->createQuery("UPDATE ".get_class($this)." seg SET seg.status = 0, seg.estado = 'Inactivo' WHERE seg.id = ?1");
  1050.          $query->setParameter(1$this->idFormatter("toID"$this->elementoReemplazo_id));
  1051.          $query->execute();
  1052.      }
  1053.      $this->setSmartCode($this->getFullCodigoConsecutivo());
  1054.  }
  1055.   /**
  1056.      * @return string
  1057.      *
  1058.      * @Groups({"seguridad"})
  1059.      */
  1060.     public function getFullCodigo(){
  1061.         $id $this->id;
  1062.         if($id 10){
  1063.           return ($this->segmento $this->segmento->tramo->unidadFuncional->getfullCodigos() : '') .'::''SEG' .'::' $this->segmento->tramo->codigo '::'$this->segmento->codigo '::' $this->tipoElemento->getId() . '::' . ("00" $id);
  1064.         }
  1065.         if($id >= 10){
  1066.           return ($this->segmento $this->segmento->tramo->unidadFuncional->getfullCodigos() : '') .'::''SEG''::' $this->segmento->tramo->codigo '::'$this->segmento->codigo '::' $this->tipoElemento->getId() . '::' .("0" $id);
  1067.         }
  1068.         if($id 99){
  1069.           return ($this->segmento $this->segmento->tramo->unidadFuncional->getfullCodigos() : '') .'::''SEG''::' $this->segmento->tramo->codigo '::'$this->segmento->codigo '::' $this->tipoElemento->getId() . '::' .($id);
  1070.         }
  1071.         // return $this->id;
  1072.         
  1073.      }
  1074.       /**
  1075.      * @return string
  1076.      *
  1077.      * @Groups({"seguridad", "read"})
  1078.      */
  1079.     public function getFullCodigoConsecutivo(){
  1080.         $id $this->codigo;
  1081.         if($id 10){
  1082.           return ($this->segmento $this->segmento->tramo->unidadFuncional->getfullCodigos() : '') .'::''SEG' .'::' $this->segmento->tramo->codigo '::'$this->segmento->codigo '::' $this->tipoElemento->getId() . '::' . ("00" $id);
  1083.         }
  1084.         if($id >= 10){
  1085.           return ($this->segmento $this->segmento->tramo->unidadFuncional->getfullCodigos() : '') .'::''SEG''::' $this->segmento->tramo->codigo '::'$this->segmento->codigo '::' $this->tipoElemento->getId() . '::' .("0" $id);
  1086.         }
  1087.         if($id 99){
  1088.           return ($this->segmento $this->segmento->tramo->unidadFuncional->getfullCodigos() : '') .'::''SEG''::' $this->segmento->tramo->codigo '::'$this->segmento->codigo '::' $this->tipoElemento->getId() . '::' .($id);
  1089.         }
  1090.         // return $this->id;
  1091.         
  1092.      }
  1093.     
  1094.      /**
  1095.      * @return int
  1096.      * @Groups({"seguridad"})
  1097.      */
  1098.     public function getFullResta(){
  1099.         $resta $this->abFin $this->abInicio;
  1100.         $resta2 =number_format($resta3'.'' ');
  1101.         return $resta2;        
  1102.     }
  1103.          /**
  1104.      * @return string
  1105.      *
  1106.      * @Groups({"seguridad"})
  1107.      */
  1108.     public function getcaptafaro(){
  1109.         $captafaros=$this->captafaros;
  1110.         $vacioNULL;
  1111.        $cant_capta=$this->cant_capta;
  1112.        if($captafaros == $vacio){
  1113.            return $cant_capta;
  1114.        }elseif($cant_capta == $vacio){
  1115.            return $captafaros;
  1116.        }
  1117.        
  1118.     }
  1119.     /**
  1120.  * $option -> 1) toID, 2) toIRI
  1121.  * $value -> valor a formatear
  1122.  */
  1123. public function idFormatter ($option$value) {
  1124.     $return "";
  1125.     $explode explode("/"$value);
  1126.   
  1127.     switch ($option) {
  1128.       case "toID":
  1129.         if(count($explode) == 1) {
  1130.           $return $value;
  1131.         } else {
  1132.           $return =  $explode[2];
  1133.         }
  1134.       break;
  1135.       
  1136.       case "toIRI":
  1137.         if(count($explode) == 3) {
  1138.           $return =  $value;
  1139.         } else {
  1140.           $return "{$value}";
  1141.         }
  1142.       break;
  1143.     }
  1144.   
  1145.     return $return;
  1146.   }
  1147.   /**
  1148.      * @return array
  1149.      * @Groups({"seguridad"})
  1150.      */
  1151.     public function getUbicaciones1(){
  1152.         return $this->ubicaciones;
  1153.     } 
  1154.     public function getCreatedIn(): ?string
  1155.     {
  1156.         if ($this->createdIn === "movil") {
  1157.             $this->createdIn "Aplicación móvil";
  1158.         } else if ($this->createdIn === "api") {
  1159.             $this->createdIn "Aplicación web";
  1160.         }
  1161.         return $this->createdIn;
  1162.     }
  1163.     public function setCreatedIn(?string $createdIn): self
  1164.     {
  1165.         if ($createdIn === "Aplicación móvil") {
  1166.             $this->createdIn "movil";
  1167.         } else if ($createdIn === "Aplicación web") {
  1168.             $this->createdIn "api";
  1169.         }else{
  1170.             $this->createdIn $createdIn;
  1171.         }
  1172.         return $this;
  1173.     }
  1174.     public function getUpdatedIn(): ?string
  1175.     {
  1176.         if($this->updatedIn === "movil"){
  1177.             $this->updatedIn "Aplicación móvil";
  1178.         } else if ($this->updatedIn === "api") {
  1179.             $this->updatedIn "Aplicación web";
  1180.         }
  1181.         return $this->updatedIn;
  1182.     }
  1183.     public function setUpdatedIn(?string $updatedIn): self
  1184.     {
  1185.         if ($updatedIn === "Aplicación móvil") {
  1186.             $this->updatedIn "movil";
  1187.         } else if ($updatedIn === "Aplicación web") {
  1188.             $this->updatedIn "api";
  1189.         }else{
  1190.             $this->updatedIn $updatedIn;
  1191.         }
  1192.         return $this;
  1193.     }
  1194.     public function getAprobacion(): ?string
  1195.     {
  1196.         return $this->aprobacion;
  1197.     }
  1198.     public function setAprobacion(?string $aprobacion): self
  1199.     {
  1200.         $this->aprobacion $aprobacion;
  1201.         return $this;
  1202.     }
  1203.     public function getSentido(): ?string
  1204.     {
  1205.         return $this->sentido;
  1206.     }
  1207.     public function setSentido(?string $sentido): self
  1208.     {
  1209.         $this->sentido $sentido;
  1210.         return $this;
  1211.     }
  1212.     public function getPInicio(): ?string
  1213.     {
  1214.         return $this->pInicio;
  1215.     }
  1216.     public function setPInicio(?string $pInicio): self
  1217.     {
  1218.         $this->pInicio $pInicio;
  1219.         return $this;
  1220.     }
  1221.     public function getPFin(): ?string
  1222.     {
  1223.         return $this->pFin;
  1224.     }
  1225.     public function setPFin(?string $pFin): self
  1226.     {
  1227.         $this->pFin $pFin;
  1228.         return $this;
  1229.     }
  1230.     public function getAbFin(): ?string
  1231.     {
  1232.         return $this->abFin;
  1233.     }
  1234.     public function setAbFin(?string $abFin): self
  1235.     {
  1236.         $this->abFin $abFin;
  1237.         return $this;
  1238.     }
  1239. }