src/Entity/Valoracion.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\EstadoValoracionEnum;
  4. use App\Validator as PerseoAssert;
  5. use DateTime;
  6. use DateTimeInterface;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use JMS\Serializer\Annotation as JMS;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. /**
  15.  * @ORM\Entity(repositoryClass="App\Repository\ValoracionRepository")
  16.  * @ORM\Table(name="valoracion",
  17.  *     indexes={
  18.  *         @ORM\Index(name="idx_valoracion_fechas_estado", columns={"fecha_enviada", "fecha_aceptacion", "fecha_rechazo", "fecha_tramitacion", "fecha_tramitada"}),
  19.  *         @ORM\Index(name="idx_valoracion_fecha_deleted", columns={"fecha", "deleted_at"})
  20.  *     }
  21.  * )
  22.  * @ORM\EntityListeners({
  23.  *     "App\EntityListener\Valoracion\CalcularIDPerseoListener"
  24.  * })
  25.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  26.  * @PerseoAssert\ContraintsValidarEntidadValoracionStock()
  27.  * @PerseoAssert\ContraintsValidarEntidadValoracionSinStock()
  28.  */
  29. class Valoracion
  30. {
  31.     static $count 0;
  32.     static $anterior null;
  33.     /**
  34.      * @ORM\Id
  35.      * @ORM\Column(type="bigint", options={"unsigned":true})
  36.      * @ORM\GeneratedValue(strategy="AUTO")
  37.      * @JMS\Groups({
  38.      *     "api_v1_valoracion_serialize",
  39.      *     "api_v1_operacion_show_serialize"
  40.      * })
  41.      */
  42.     protected $id;
  43.     /**
  44.      * @ORM\Column(
  45.      *     type="string",
  46.      *     unique=true,
  47.      *     nullable=true,
  48.      *     name="id_perseo",
  49.      *     options={"comment":"Identificador perseo único generado aleatoriamente combinación letras y números"}
  50.      * )
  51.      * @JMS\Groups({
  52.      *     "api_v1_valoracion_serialize",
  53.      *     "api_v1_operacion_show_serialize"
  54.      * })
  55.      */
  56.     protected $IDperseo;
  57.     /**
  58.      * @ORM\Column(
  59.      *     type="boolean",
  60.      *     nullable=true,
  61.      *     name="tipo_cliente",
  62.      *     options={"default":0,"comment":"0 => particular, 1 => empresa"}
  63.      * )
  64.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  65.      */
  66.     protected $tipoCliente;
  67.     /**
  68.      * @ORM\Column(type="datetime", nullable=true)
  69.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  70.      */
  71.     protected $fecha;
  72.     /**
  73.      * @ORM\Column(type="boolean", nullable=true, options={"default":0})
  74.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  75.      */
  76.     protected $exportacion;
  77.     /**
  78.      * @ORM\Column(type="string", length=2, nullable=true, options={"default":"es"})
  79.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  80.      */
  81.     protected $idioma;
  82.     /**
  83.      * @ORM\Column(type="text", length=255, nullable=true)
  84.      */
  85.     protected $comentario;
  86.     /**
  87.      * @ORM\Column(type="datetime", nullable=true, name="fecha_enviada")
  88.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  89.      */
  90.     protected $fechaEnviada;
  91.     /**
  92.      * @ORM\Column(type="datetime", nullable=true, name="fecha_aceptacion")
  93.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  94.      */
  95.     protected $fechaAceptacion;
  96.     /**
  97.      * @ORM\Column(type="datetime", nullable=true, name="fecha_rechazo")
  98.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  99.      */
  100.     protected $fechaRechazo;
  101.     /**
  102.      * @ORM\Column(type="datetime", nullable=true, name="fecha_tramitacion")
  103.      * @JMS\Groups({"api_v1_valoracion_serialize"})
  104.      */
  105.     protected $fechaTramitacion;
  106.     /**
  107.      * @ORM\Column(type="datetime", nullable=true, name="fecha_tramitada")
  108.      * @JMS\Groups({"api_v1_valoracion_serialize"})
  109.      */
  110.     protected $fechaTramitada;
  111.     /**
  112.      * @ORM\Column(
  113.      *     type="smallint",
  114.      *     length=4,
  115.      *     nullable=true,
  116.      *     options={"default":0,"unsigned":true,"comment":"Indica las veces que se ha duplicado la valoración."}
  117.      * )
  118.      */
  119.     protected $duplicados;
  120.     /**
  121.      * @ORM\Column(type="float", nullable=true, precision=2, name="precio_pagar")
  122.      * @JMS\Groups({"api_v1_valoracion_serialize"})
  123.      */
  124.     protected $precioPagar;
  125.     /**
  126.      * @ORM\Column(type="text", nullable=true, name="info_tramitacion")
  127.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  128.      */
  129.     protected $infoTramitacion;
  130.     /**
  131.      * @ORM\Column(type="text", nullable=true, name="info_valoracion")
  132.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  133.      */
  134.     protected $infoValoracion;
  135.     /**
  136.      * @ORM\Column(
  137.      *     type="string",
  138.      *     nullable=true,
  139.      *     name="tipo_operacion",
  140.      *     options={"default":"COMPRA","comment":"Gestión o Compra/Permutua"}
  141.      * )
  142.      */
  143.     protected $tipoOperacion;
  144.     /**
  145.      * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  146.      * @JMS\Groups({
  147.      *     "api_v1_valoracion_serialize",
  148.      *     "api_v1_operacion_show_serialize"
  149.      * })
  150.      */
  151.     protected $deletedAt;
  152.     /**
  153.      * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  154.      * @Gedmo\Timestampable(on="update")
  155.      */
  156.     protected $updatedAt;
  157.     /**
  158.      * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  159.      * @Gedmo\Timestampable(on="create")
  160.      */
  161.     protected $createdAt;
  162.     /**
  163.      * @ORM\OneToOne(targetEntity="App\Entity\Operacion", mappedBy="valoracion")
  164.      * @JMS\Type(Operacion::class)
  165.      * @JMS\Groups({"api_v1_valoracion_serialize"})
  166.      */
  167.     protected $operacion;
  168.     /**
  169.      * @ORM\OneToMany(targetEntity="App\Entity\Valoracion", mappedBy="clone")
  170.      */
  171.     protected $clones;
  172.     /**
  173.      * @ORM\ManyToOne(targetEntity="App\Entity\Canal", inversedBy="valoraciones")
  174.      * @ORM\JoinColumn(name="canal_id", referencedColumnName="id")
  175.      * @JMS\Type(Canal::class)
  176.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  177.      */
  178.     protected $canal;
  179.     /**
  180.      * @ORM\OneToMany(targetEntity="App\Entity\ValoracionesRelojes", mappedBy="valoracion", cascade={"persist"})
  181.      */
  182.     protected $valoracionesRelojes;
  183.     /**
  184.      * @ORM\OneToMany(targetEntity="App\Entity\ValoracionesRelojesStock", mappedBy="valoracion", cascade={"persist"})
  185.      * @JMS\Type("ArrayCollection<App\Entity\ValoracionesRelojesStock>")
  186.      * @JMS\Groups({"api_v1_valoracion_serialize"})
  187.      */
  188.     protected $valoracionesRelojesStocks;
  189. // TODO cambiar cuando se activen los relojes sin stocks, crea una constraint personalizada ... controlando que exista al menos una valoración de reloj ( stock o sin stock )
  190.     /**
  191.      * @ORM\OneToMany(targetEntity="App\Entity\ValoracionesRelojesSinStock", mappedBy="valoracion", cascade={"persist"})
  192.      * @Assert\Count(
  193.      *     min = 1,
  194.      *     minMessage = "assert.entidad.valoraciones_relojes"
  195.      * )
  196.      * @JMS\Type("ArrayCollection<App\Entity\ValoracionesRelojesSinStock>")
  197.      * @JMS\Groups({"api_v1_valoracion_serialize"})
  198.      */
  199.     protected $valoracionesRelojesSinStocks;
  200.     /**
  201.      * @ORM\OneToMany(targetEntity=\App\Entity\Reloj::class, mappedBy="valoracion")
  202.      */
  203.     private $relojes;
  204.     /**
  205.      * @ORM\ManyToOne(targetEntity="App\Entity\EstadoValoracion", inversedBy="valoraciones")
  206.      * @ORM\JoinColumn(name="estado_id", referencedColumnName="id")
  207.      * @JMS\Type(EstadoValoracion::class)
  208.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  209.      */
  210.     protected $estado;
  211.     /**
  212.      * @ORM\ManyToOne(targetEntity="App\Entity\UnidadNegocio", inversedBy="valoraciones")
  213.      * @ORM\JoinColumn(name="unidad_negocio_id", referencedColumnName="id")
  214.      * @JMS\Type(UnidadNegocio::class)
  215.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  216.      */
  217.     protected $unidadNegocio;
  218.     /**
  219.      * @ORM\ManyToOne(targetEntity="App\Entity\Usuario", inversedBy="valoraciones")
  220.      * @ORM\JoinColumn(name="usuario_id", referencedColumnName="id")
  221.      * @JMS\Type(Usuario::class)
  222.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  223.      */
  224.     protected $usuario;
  225.     /**
  226.      * @ORM\ManyToOne(targetEntity="App\Entity\Cliente", inversedBy="valoraciones")
  227.      * @ORM\JoinColumn(name="cliente_id", referencedColumnName="id")
  228.      * @JMS\Type(Cliente::class)
  229.      * @JMS\Groups({"api_v1_valoracion_serialize", "api_v1_valoracion_deserialize"})
  230.      */
  231.     protected $cliente;
  232.     /**
  233.      * @ORM\ManyToOne(targetEntity="App\Entity\Valoracion", inversedBy="clones")
  234.      * @ORM\JoinColumn(name="clone_id", referencedColumnName="id")
  235.      */
  236.     protected $clone;
  237.     public function __construct()
  238.     {
  239.         $this->valoracionesRelojes = new ArrayCollection();
  240.         $this->valoracionesRelojesStocks = new ArrayCollection();
  241.         $this->valoracionesRelojesSinStocks = new ArrayCollection();
  242.         $this->clones = new ArrayCollection();
  243.         $this->relojes = new ArrayCollection();
  244.     }
  245.     public function __clone()
  246.     {
  247.         $this->setFecha(new DateTime('now'));
  248.         $this->setFechaAceptacion(null);
  249.         $this->setFechaEnviada(null);
  250.         $this->setFechaRechazo(null);
  251.         $this->setFechaTramitacion(null);
  252.         $this->setFechaTramitada(null);
  253.         $this->setEstado(null);
  254.         $this->setCreatedAt(new DateTime('now'));
  255.         $this->setUpdatedAt(new DateTime('now'));
  256.         $this->setDuplicados(null);
  257.         $valoracionesRelojes $this->getValoracionesRelojes();
  258.         foreach ($valoracionesRelojes??[] as $valoracion)
  259.         {
  260.             $valoracionClone = clone $valoracion;
  261.             $valoracionClone->setClone($valoracion);
  262.             $this->addValoracionesReloje($valoracionClone);
  263.         }
  264.     }
  265.     public function __toString(): string
  266.     {
  267.         return $this->getIDperseo()??'---';
  268.     }
  269.     public function getId(): ?string
  270.     {
  271.         return $this->id;
  272.     }
  273.     public function getIDperseo(): ?string
  274.     {
  275.         return $this->IDperseo;
  276.     }
  277.     public function setIDperseo(?string $IDperseo): self
  278.     {
  279.         $this->IDperseo $IDperseo;
  280.         return $this;
  281.     }
  282.     public function getTipoCliente(): ?bool
  283.     {
  284.         return $this->tipoCliente;
  285.     }
  286.     public function setTipoCliente(?bool $tipoCliente): self
  287.     {
  288.         $this->tipoCliente $tipoCliente;
  289.         return $this;
  290.     }
  291.     public function getFecha(): ?DateTimeInterface
  292.     {
  293.         return $this->fecha;
  294.     }
  295.     public function setFecha(?DateTimeInterface $fecha): self
  296.     {
  297.         $this->fecha $fecha;
  298.         return $this;
  299.     }
  300.     public function getExportacion(): ?bool
  301.     {
  302.         return $this->exportacion;
  303.     }
  304.     public function setExportacion(?bool $exportacion): self
  305.     {
  306.         $this->exportacion $exportacion;
  307.         return $this;
  308.     }
  309.     public function getIdioma(): ?string
  310.     {
  311.         return $this->idioma;
  312.     }
  313.     public function setIdioma(?string $idioma): self
  314.     {
  315.         $this->idioma $idioma;
  316.         return $this;
  317.     }
  318.     public function getComentario(): ?string
  319.     {
  320.         return $this->comentario;
  321.     }
  322.     public function setComentario(?string $comentario): self
  323.     {
  324.         $this->comentario $comentario;
  325.         return $this;
  326.     }
  327.     public function getFechaEnviada(): ?DateTimeInterface
  328.     {
  329.         return $this->fechaEnviada;
  330.     }
  331.     public function setFechaEnviada(?DateTimeInterface $fechaEnviada): self
  332.     {
  333.         $this->fechaEnviada $fechaEnviada;
  334.         return $this;
  335.     }
  336.     public function getFechaAceptacion(): ?DateTimeInterface
  337.     {
  338.         return $this->fechaAceptacion;
  339.     }
  340.     public function setFechaAceptacion(?DateTimeInterface $fechaAceptacion): self
  341.     {
  342.         $this->fechaAceptacion $fechaAceptacion;
  343.         return $this;
  344.     }
  345.     public function getFechaRechazo(): ?DateTimeInterface
  346.     {
  347.         return $this->fechaRechazo;
  348.     }
  349.     public function setFechaRechazo(?DateTimeInterface $fechaRechazo): self
  350.     {
  351.         $this->fechaRechazo $fechaRechazo;
  352.         return $this;
  353.     }
  354.     public function getFechaTramitacion(): ?DateTimeInterface
  355.     {
  356.         return $this->fechaTramitacion;
  357.     }
  358.     public function setFechaTramitacion(?DateTimeInterface $fechaTramitacion): self
  359.     {
  360.         $this->fechaTramitacion $fechaTramitacion;
  361.         return $this;
  362.     }
  363.     public function getDuplicados(): ?int
  364.     {
  365.         return $this->duplicados;
  366.     }
  367.     public function setDuplicados(?int $duplicados): self
  368.     {
  369.         $this->duplicados $duplicados;
  370.         return $this;
  371.     }
  372.     public function getDeletedAt(): ?DateTimeInterface
  373.     {
  374.         return $this->deletedAt;
  375.     }
  376.     public function setDeletedAt(?DateTimeInterface $deletedAt): self
  377.     {
  378.         $this->deletedAt $deletedAt;
  379.         return $this;
  380.     }
  381.     public function getUpdatedAt(): ?DateTimeInterface
  382.     {
  383.         return $this->updatedAt;
  384.     }
  385.     public function setUpdatedAt(DateTimeInterface $updatedAt): self
  386.     {
  387.         $this->updatedAt $updatedAt;
  388.         return $this;
  389.     }
  390.     public function getCreatedAt(): ?DateTimeInterface
  391.     {
  392.         return $this->createdAt;
  393.     }
  394.     public function setCreatedAt(DateTimeInterface $createdAt): self
  395.     {
  396.         $this->createdAt $createdAt;
  397.         return $this;
  398.     }
  399.     /**
  400.      * @return Collection|ValoracionesRelojes[]
  401.      */
  402.     public function getValoracionesRelojes(): Collection
  403.     {
  404. //        $iterator = $this->valoracionesRelojes->getIterator();
  405. //        $iterator->uasort(function ($a, $b) {
  406. //            return ($a->getReloj()->getStock() < $b->getReloj()->getStock()) ? -1 : 1;
  407. //        });
  408. //
  409. //        $collection = new ArrayCollection(iterator_to_array($iterator));
  410. //
  411. //        return $collection;
  412.         return $this->valoracionesRelojes;
  413.     }
  414.     public function addValoracionesReloje(ValoracionesRelojes $valoracionesReloje): self
  415.     {
  416.         if (!$this->valoracionesRelojes->contains($valoracionesReloje)) {
  417.             $this->valoracionesRelojes[] = $valoracionesReloje;
  418.             $valoracionesReloje->setValoracion($this);
  419.         }
  420.         return $this;
  421.     }
  422.     public function removeValoracionesReloje(ValoracionesRelojes $valoracionesReloje): self
  423.     {
  424.         if ($this->valoracionesRelojes->removeElement($valoracionesReloje)) {
  425.             // set the owning side to null (unless already changed)
  426.             if ($valoracionesReloje->getValoracion() === $this) {
  427.                 //$valoracionesReloje->setValoracion(null);
  428.                 $valoracionesReloje->setDeletedAt(new DateTime('now'));
  429.             }
  430.         }
  431.         return $this;
  432.     }
  433.     public function getEstado(): ?EstadoValoracion
  434.     {
  435.         return $this->estado;
  436.     }
  437.     public function setEstado(?EstadoValoracion $estado): self
  438.     {
  439.         $this->estado $estado;
  440.         return $this;
  441.     }
  442.     public function getUnidadNegocio(): ?UnidadNegocio
  443.     {
  444.         return $this->unidadNegocio;
  445.     }
  446.     public function setUnidadNegocio(?UnidadNegocio $unidadNegocio): self
  447.     {
  448.         $this->unidadNegocio $unidadNegocio;
  449.         return $this;
  450.     }
  451.     public function getUsuario(): ?Usuario
  452.     {
  453.         return $this->usuario;
  454.     }
  455.     public function setUsuario(?Usuario $usuario): self
  456.     {
  457.         $this->usuario $usuario;
  458.         return $this;
  459.     }
  460.     public function getCliente(): ?Cliente
  461.     {
  462.         return $this->cliente;
  463.     }
  464.     public function setCliente(?Cliente $cliente): self
  465.     {
  466.         $this->cliente $cliente;
  467.         return $this;
  468.     }
  469.     public function getPrecioPagar(): ?float
  470.     {
  471.         return $this->precioPagar;
  472.     }
  473.     public function setPrecioPagar(?float $precioPagar): self
  474.     {
  475.         $this->precioPagar $precioPagar;
  476.         return $this;
  477.     }
  478.     public function getInfoTramitacion(): ?string
  479.     {
  480.         return $this->infoTramitacion;
  481.     }
  482.     public function setInfoTramitacion(?string $infoTramitacion): self
  483.     {
  484.         $this->infoTramitacion $infoTramitacion;
  485.         return $this;
  486.     }
  487.     public function getInfoValoracion(): ?string
  488.     {
  489.         return $this->infoValoracion;
  490.     }
  491.     public function setInfoValoracion(?string $infoValoracion): self
  492.     {
  493.         $this->infoValoracion $infoValoracion;
  494.         return $this;
  495.     }
  496.     public function getCanal(): ?Canal
  497.     {
  498.         return $this->canal;
  499.     }
  500.     public function setCanal(?Canal $canal): self
  501.     {
  502.         $this->canal $canal;
  503.         return $this;
  504.     }
  505.     /**
  506.      * @return Collection|ValoracionesRelojesStock[]
  507.      */
  508.     public function getValoracionesRelojesStocks(): Collection
  509.     {
  510.         return $this->valoracionesRelojesStocks ?? new ArrayCollection();
  511.     }
  512.     public function addValoracionesRelojesStock(ValoracionesRelojesStock $valoracionesRelojesStock): self
  513.     {
  514.         if (!$this->valoracionesRelojesStocks->contains($valoracionesRelojesStock)) {
  515.             $this->valoracionesRelojesStocks[] = $valoracionesRelojesStock;
  516.             $valoracionesRelojesStock->setValoracion($this);
  517.         }
  518.         return $this;
  519.     }
  520.     public function removeValoracionesRelojesStock(ValoracionesRelojesStock $valoracionesRelojesStock): self
  521.     {
  522.         if ($this->valoracionesRelojesStocks->removeElement($valoracionesRelojesStock)) {
  523.             // set the owning side to null (unless already changed)
  524.             if ($valoracionesRelojesStock->getValoracion() === $this) {
  525.                 //$valoracionesRelojesStock->setValoracion(null);
  526.                 $valoracionesRelojesStock->setDeletedAt(new DateTime('now'));
  527.             }
  528.         }
  529.         return $this;
  530.     }
  531.     /**
  532.      * @return Collection|ValoracionesRelojesSinStock[]
  533.      */
  534.     public function getValoracionesRelojesSinStocks(): Collection
  535.     {
  536.         return $this->valoracionesRelojesSinStocks ?? new ArrayCollection();
  537.     }
  538.     public function addValoracionesRelojesSinStock(ValoracionesRelojesSinStock $valoracionesRelojesSinStock): self
  539.     {
  540.         if (!$this->valoracionesRelojesSinStocks->contains($valoracionesRelojesSinStock)) {
  541.             $this->valoracionesRelojesSinStocks[] = $valoracionesRelojesSinStock;
  542.             $valoracionesRelojesSinStock->setValoracion($this);
  543.         }
  544.         return $this;
  545.     }
  546.     public function removeValoracionesRelojesSinStock(ValoracionesRelojesSinStock $valoracionesRelojesSinStock): self
  547.     {
  548.         if ($this->valoracionesRelojesSinStocks->removeElement($valoracionesRelojesSinStock)) {
  549.             // set the owning side to null (unless already changed)
  550.             if ($valoracionesRelojesSinStock->getValoracion() === $this) {
  551.                 //$valoracionesRelojesSinStock->setValoracion(null);
  552.                 $valoracionesRelojesSinStock->setDeletedAt(new DateTime('now'));
  553.             }
  554.         }
  555.         return $this;
  556.     }
  557.     public function getExportValoracionesRelojesSinStock()
  558.     {
  559.         $export = [];
  560.         $stocks $this->getValoracionesRelojesSinStocks();
  561.         if(self::$anterior === $this->getIDperseo()) {
  562.             self::$count++;
  563.         }
  564.         else {
  565.             self::$count 0;
  566.             self::$anterior $this->getIDperseo();
  567.         }
  568.         if($stock $stocks->get(self::$count))
  569.         {
  570.             $export['idperso'] = $stock->getIDperseo();
  571.             $export['reloj_foto'] = $stock->getRelojFoto();
  572.             $export['reloj_marca'] = $stock->getRelojMarca()?->getNombre();
  573.             $export['reloj_modelo'] = $stock->getRelojModelo1();
  574.             $export['reloj_referencia'] = $stock->getRelojRef1();
  575.             $export['reloj_fecha'] = $stock->getRelojFecha();
  576.             $export['reloj_foto'] = $stock->getRelojFoto();
  577.             $export['reloj_estado'] = $stock->getRelojAspecto();
  578.             $export['reloj_papeles'] = $stock->getRelojPapeles();
  579.             $export['reloj_caja'] = $stock->getRelojCaja();
  580.             $export['precio_referencia'] = $stock->getPrecioReferencia();
  581.             $export['precio_promocion'] = $stock->getPrecioPromocion();
  582.             $export['precio_min_venta'] = $stock->getPrecioMinVenta();
  583.             $export['comision'] = $stock->getComision();
  584.             $export['precio_coste_total'] = $stock->getPrecioCosteTotal();
  585.             $export['margen_deseado'] = $stock->getMargenDeseado();
  586.             $export['margen_promocion'] = $stock->getMargenPromocion();
  587.             $export['margen_minimo'] = $stock->getMargenMinimo();
  588.             $export['precio_pagar'] = $stock->getPrecioPagar();
  589.             $export['informacion'] = $stock->getInfoValoracion();
  590.         }
  591.         return json_encode($export);
  592.     }
  593.     public function getExportValoracionesRelojesStock()
  594.     {
  595.         $export = [];
  596.         $stocks $this->getValoracionesRelojesStocks();
  597.         if($stock $stocks->get(self::$count))
  598.         {
  599.             $export['reloj'] = $stock->getReloj()?->getIDperseo();
  600.             $export['es_precio_chrono24'] = $stock->getIsPrecioChrono24();
  601.             $export['precio_promocion'] = $stock->getPrecioPromocion();
  602.             $export['precio_coste_total'] = $stock->getPrecioCosteTotal();
  603.             $export['descuento'] = $stock->getDescuento();
  604.             $export['informacion'] = $stock->getInfoValoracion();
  605.         }
  606.         return json_encode($export);
  607.     }
  608.     /**
  609.      * @return Collection|Valoracion[]
  610.      */
  611.     public function getClones(): Collection
  612.     {
  613.         return $this->clones;
  614.     }
  615.     public function addClone(Valoracion $clone): self
  616.     {
  617.         if (!$this->clones->contains($clone)) {
  618.             $this->clones[] = $clone;
  619.             $clone->setClone($this);
  620.         }
  621.         return $this;
  622.     }
  623.     public function removeClone(Valoracion $clone): self
  624.     {
  625.         if ($this->clones->removeElement($clone)) {
  626.             // set the owning side to null (unless already changed)
  627.             if ($clone->getClone() === $this) {
  628.                 $clone->setClone(null);
  629.             }
  630.         }
  631.         return $this;
  632.     }
  633.     public function getClone(): ?self
  634.     {
  635.         return $this->clone;
  636.     }
  637.     public function setClone(?self $clone): self
  638.     {
  639.         $this->clone $clone;
  640.         return $this;
  641.     }
  642.     public function getEstadoFecha()
  643.     {
  644.         switch($this->getEstado()?->getKey())
  645.         {
  646.             case EstadoValoracionEnum::ESTADO_ESPERA:
  647.                 $fecha $this->getFechaEnviada();
  648.                 break;
  649.             case EstadoValoracionEnum::ESTADO_ACEPTADA:
  650.                 $fecha $this->getFechaAceptacion();
  651.                 break;
  652.             case EstadoValoracionEnum::ESTADO_RECHAZADA:
  653.                 $fecha $this->getFechaRechazo();
  654.                 break;
  655.             case EstadoValoracionEnum::ESTADO_EN_TRAMITACION:
  656.                 $fecha $this->getFechaTramitacion();
  657.                 break;
  658.             default:
  659.                 $fecha null;
  660.                 break;
  661.         }
  662.         return $fecha;
  663.     }
  664.     public function getOperacion(): ?Operacion
  665.     {
  666.         return $this->operacion;
  667.     }
  668.     public function setOperacion(?Operacion $operacion): self
  669.     {
  670.         // unset the owning side of the relation if necessary
  671.         if ($operacion === null && $this->operacion !== null) {
  672.             $this->operacion->setValoracion(null);
  673.         }
  674.         // set the owning side of the relation if necessary
  675.         if ($operacion !== null && $operacion->getValoracion() !== $this) {
  676.             $operacion->setValoracion($this);
  677.         }
  678.         $this->operacion $operacion;
  679.         return $this;
  680.     }
  681.     public function isTipoCliente(): ?bool
  682.     {
  683.         return $this->tipoCliente;
  684.     }
  685.     public function isExportacion(): ?bool
  686.     {
  687.         return $this->exportacion;
  688.     }
  689.     public function getTipoOperacion(): ?string
  690.     {
  691.         return $this->tipoOperacion;
  692.     }
  693.     public function setTipoOperacion(?string $tipoOperacion): static
  694.     {
  695.         $this->tipoOperacion $tipoOperacion;
  696.         return $this;
  697.     }
  698.     public function getFechaString():?string
  699.     {
  700.         return $this->getFecha()?->format('d/m/Y H:i:s');
  701.     }
  702.     public function getFechaTramitadaString():?string
  703.     {
  704.         return $this->getFechaTramitada()?->format('d/m/Y H:i:s');
  705.     }
  706.     public function getFechaTramitacionString():?string
  707.     {
  708.         return $this->getFechaTramitacion()?->format('d/m/Y H:i:s');
  709.     }
  710.     public function getFechaAceptacionString():?string
  711.     {
  712.         return $this->getFechaAceptacion()?->format('d/m/Y H:i:s');
  713.     }
  714.     public function getFechaEnviadaString():?string
  715.     {
  716.         return $this->getFechaEnviada()?->format('d/m/Y H:i:s');
  717.     }
  718.     public function getFechaRechazoString():?string
  719.     {
  720.         return $this->getFechaRechazo()?->format('d/m/Y H:i:s');
  721.     }
  722.     public function getFechaTramitada(): ?\DateTimeInterface
  723.     {
  724.         return $this->fechaTramitada;
  725.     }
  726.     public function setFechaTramitada(?\DateTimeInterface $fechaTramitada): static
  727.     {
  728.         $this->fechaTramitada $fechaTramitada;
  729.         return $this;
  730.     }
  731.     /**
  732.      * @return Collection<int, Reloj>
  733.      */
  734.     public function getRelojes(): Collection
  735.     {
  736.         return $this->relojes;
  737.     }
  738.     public function addReloje(Reloj $reloje): static
  739.     {
  740.         if (!$this->relojes->contains($reloje)) {
  741.             $this->relojes->add($reloje);
  742.             $reloje->setValoracion($this);
  743.         }
  744.         return $this;
  745.     }
  746.     public function removeReloje(Reloj $reloje): static
  747.     {
  748.         if ($this->relojes->removeElement($reloje)) {
  749.             // set the owning side to null (unless already changed)
  750.             if ($reloje->getValoracion() === $this) {
  751.                 $reloje->setValoracion(null);
  752.             }
  753.         }
  754.         return $this;
  755.     }
  756. }