src/Entity/Oficina.php line 651

  1. <?php
  2. namespace App\Entity;
  3. // use Dinamic\AdminBundle\Entity\OficinaErp;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use JMS\Serializer\Annotation as JMS;
  10. use JsonSerializable;
  11. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  12. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  13. /**
  14.  * Oficina
  15.  *
  16.  * @ORM\Table(name="oficina")
  17.  * @ORM\Entity(repositoryClass="App\Repository\OficinaRepository")
  18.  *
  19.  */
  20. class Oficina implements JsonSerializable,  TranslatableInterface
  21. {
  22.     use TranslatableTrait;
  23.     public function __toString() {
  24.         return $this->nombre;
  25.     }
  26.     /**
  27.      * @var integer
  28.      *
  29.      * @ORM\Column(name="id", type="integer")
  30.      * @ORM\Id
  31.      * @ORM\GeneratedValue(strategy="AUTO")
  32.      */
  33.     private $id;
  34.     /**
  35.      * @var string
  36.      *
  37.      * @ORM\Column(name="nombre", type="string", length=100, nullable=false)
  38.      * @JMS\Groups({"api-order"})
  39.      */
  40.     private $nombre;
  41.     /**
  42.      * @var alt
  43.      *
  44.      * @ORM\Column(name="alt", type="string", length=255, nullable=true)
  45.      */
  46.     private $alt;
  47.     /**
  48.      * @var string
  49.      *
  50.      * @ORM\Column(name="latitud", type="string", length=100, nullable=true)
  51.      */
  52.     private $latitud;
  53.     /**
  54.      * @var string
  55.      *
  56.      * @ORM\Column(name="longitud", type="string", length=100, nullable=true)
  57.      */
  58.     private $longitud;
  59.     /**
  60.      * @var string
  61.      *
  62.      * @ORM\Column(name="telefono", type="string", length=20, nullable=true)
  63.      */
  64.     private $telefono;
  65.     /**
  66.      * @var string
  67.      *
  68.      * @ORM\Column(name="direccion", type="string", length=255, nullable=true)
  69.      */
  70.     private $direccion;
  71.     /**
  72.     * @ORM\ManyToOne(targetEntity="Provincia", inversedBy="oficinas")
  73.     * @ORM\JoinColumn(name="provincia", referencedColumnName="id")
  74.     */
  75.     private $provincia;
  76.     /**
  77.      * @ORM\OneToMany(targetEntity="Cotizaciones", mappedBy="oficina", cascade={"remove"})
  78.      * @ORM\OrderBy({"dia" = "DESC"})
  79.      */
  80.     private $cotizaciones;
  81.     /**
  82.      * @var string
  83.      *
  84.      * @ORM\Column(name="codigo_postal", type="text", nullable=false)
  85.      */
  86.     private $codigoPostal;
  87.     /**
  88.     * @ORM\ManyToOne(targetEntity="Localidad")
  89.     * @ORM\JoinColumn(name="localidad", referencedColumnName="id", nullable=false)
  90.     */
  91.     private $localidad;
  92.     /**
  93.      * @ORM\ManyToOne(targetEntity="OficinaErp")
  94.      * @ORM\JoinColumn(name="oficinaERP", referencedColumnName="id", nullable=true)
  95.      * @JMS\Groups({"api-order"})
  96.      */
  97.     private $oficinaERP;
  98.     /**
  99.      * @Assert\Valid()
  100.      * @ORM\OneToMany(targetEntity="Reserva", mappedBy="oficina", cascade={"persist"})
  101.      */
  102.     private $reservas;
  103.     /**
  104.      * @Assert\Valid()
  105.      * @ORM\OneToMany(targetEntity="Reserva", mappedBy="oficinaPeticion", cascade={"persist"})
  106.      */
  107.     private $peticiones;
  108.     /**
  109.      *
  110.      * @Assert\Valid()
  111.      * @ORM\OneToMany(targetEntity="FranjaDias", mappedBy="oficina", cascade={"persist", "remove"}, orphanRemoval=true)
  112.      */
  113.     private $franjas;
  114.     /**
  115.      * @ORM\ManyToMany(targetEntity="Servicio", inversedBy="oficinas")
  116.      * @ORM\JoinTable(name="oficina_servicio")
  117.      */
  118.     private $servicios;
  119.    /**
  120.      * @Assert\Valid()
  121.      * @ORM\OneToMany(targetEntity="Stock", mappedBy="oficina", cascade={"persist", "remove"}, orphanRemoval=true)
  122.      */
  123.     private $stocks;
  124.     /**
  125.      * @var string
  126.      *
  127.      * @ORM\ManyToOne(targetEntity="Imagen") 
  128.      */
  129.     protected $imagen
  130.     
  131.     /**
  132.      * @var string
  133.      *
  134.      * @ORM\ManyToOne(targetEntity="Imagen") 
  135.      */
  136.     protected $imagenMapa
  137.     /**
  138.      * @Assert\Valid()
  139.      * @ORM\OneToMany(targetEntity="Existencia", mappedBy="oficina")
  140.      */
  141.     private $existencias;
  142.     /**
  143.      * @var integer
  144.      *
  145.      * @ORM\Column(name="peso", type="integer", nullable=false)
  146.      */
  147.     private $peso=0;
  148.     /**
  149.      * @ORM\ManyToMany(targetEntity="App\Entity\DayOff", mappedBy="oficinas")
  150.      */
  151. //     private $dayoffs;
  152.     
  153.     /**
  154.      * @Assert\Valid()
  155.      * @ORM\OneToMany(targetEntity="App\Entity\DayOff", mappedBy="oficina", cascade={"persist", "remove"}, orphanRemoval=true)
  156.      */
  157.     private $dayoffs;
  158.     /**
  159.      * @var ArrayCollection
  160.      *
  161.      * @ORM\OneToMany(targetEntity="Alerta", mappedBy="oficina", orphanRemoval=true)
  162.      */
  163.     protected $alerts;
  164.     
  165.     /**
  166.      * @var boolean
  167.      *
  168.      * @ORM\Column(name="activo", type="boolean", options={"default":1})
  169.      */
  170.     private $activo=true;
  171.     
  172.     /**
  173.      * @var string
  174.      *
  175.      * @ORM\Column(name="url_google", type="string", nullable=true)
  176.      */
  177.     private $urlGoogle;
  178.     public function __call($method$args)
  179.     {
  180.         //return $this->proxyCurrentLocaleTranslation($method, $arguments);
  181.         if (!method_exists(self::getTranslationEntityClass(), $method)) {
  182.             $method 'get'ucfirst($method);
  183.         }
  184.         return $this->proxyCurrentLocaleTranslation($method$args);        
  185.     }
  186.     public function __construct() {
  187.         $this->reservas       = new ArrayCollection();
  188.         $this->peticiones     = new ArrayCollection();
  189.         $this->franjas        = new ArrayCollection();
  190.         $this->servicios      = new ArrayCollection();
  191.         $this->dayoffs        = new ArrayCollection();
  192.         $this->stocks         = new ArrayCollection();
  193.         $this->stockDias      = new ArrayCollection();
  194.         $this->cotizaciones   = new ArrayCollection();
  195.         $this->existencias    = new ArrayCollection();
  196.         $this->traducciones   = new ArrayCollection();
  197.     }
  198.     /**
  199.      * Get id
  200.      *
  201.      * @return integer
  202.      */
  203.     public function getId()
  204.     {
  205.         return $this->id;
  206.     }
  207.     /**
  208.      * Set nombre
  209.      *
  210.      * @param string $nombre
  211.      * @return Oficina
  212.      */
  213.     public function setNombre($nombre)
  214.     {
  215.         $this->nombre $nombre;
  216.         return $this;
  217.     }
  218.     /**
  219.      * Get slug
  220.      *
  221.      * @return string
  222.      */
  223.     public function getNombre()
  224.     {
  225.         return $this->nombre;
  226.     }
  227.     /**
  228.      * Set cotizaciones
  229.      *
  230.      * @param string $cotizaciones
  231.      * @return Oficina
  232.      */
  233.     public function setCotizaciones($cotizaciones)
  234.     {
  235.         $this->cotizaciones $cotizaciones;
  236.         return $this;
  237.     }
  238.     /**
  239.      * Get slug
  240.      *
  241.      * @return string
  242.      */
  243.     public function getCotizaciones()
  244.     {
  245.         return $this->cotizaciones;
  246.     }
  247.     /**
  248.      * Set alt
  249.      *
  250.      * @param string $alt
  251.      * @return Oficina
  252.      */
  253.     public function setAlt($alt)
  254.     {
  255.         $this->alt $alt;
  256.         return this;
  257.     }
  258.     /**
  259.      * Get alt
  260.      *
  261.      * @return string
  262.      */
  263.     public function getAlt()
  264.     {
  265.         return $this->alt;
  266.     }
  267.     /**
  268.      * Set latitud
  269.      *
  270.      * @param string $latitud
  271.      * @return Oficina
  272.      */
  273.     public function setLatitud($latitud)
  274.     {
  275.         $this->latitud $latitud;
  276.         return $this;
  277.     }
  278.     /**
  279.      * Get latitud
  280.      *
  281.      * @return string
  282.      */
  283.     public function getLatitud()
  284.     {
  285.         return $this->latitud;
  286.     }
  287.     /**
  288.      * Set stocks
  289.      *
  290.      * @param Stock $stock
  291.      * @return Oficina
  292.      */
  293.     public function setStocks($stocks)
  294.     {
  295.         
  296.         $this->stocks $stocks;
  297.         return $this;
  298.     }
  299.     /**
  300.      * Get stocks
  301.      *
  302.      * @return boolean
  303.      */
  304.     public function getStocks()
  305.     {
  306.         return $this->stocks;
  307.     }
  308.     
  309.     public function addStock(Stock $stock): self
  310.     {
  311.         if (!$this->stocks->contains($stock)) {
  312.             $this->stocks->add($stock);
  313.             $stock->setOficina($this);
  314.         }
  315.         return $this;
  316.     }
  317.     public function removeStock(Stock $stock): self
  318.     {
  319.         if ($this->stocks->removeElement($stock)) {
  320.             // set the owning side to null (unless already changed)
  321.             if ($stock->getOficina() === $this) {
  322.                 $stock->setOficina(null);
  323.             }
  324.         }
  325.         return $this;
  326.     }  
  327.     /**
  328.      * Set longitud
  329.      *
  330.      * @param string $longitud
  331.      * @return Oficina
  332.      */
  333.     public function setLongitud($longitud)
  334.     {
  335.         $this->longitud $longitud;
  336.         return $this;
  337.     }
  338.     /**
  339.      * Get longitud
  340.      *
  341.      * @return string
  342.      */
  343.     public function getLongitud()
  344.     {
  345.         return $this->longitud;
  346.     }
  347.     /**
  348.      * Set telefono
  349.      *
  350.      * @param string $telefono
  351.      * @return Oficina
  352.      */
  353.     public function setTelefono($telefono)
  354.     {
  355.         $this->telefono $telefono;
  356.         return $this;
  357.     }
  358.     /**
  359.      * Get telefono
  360.      *
  361.      * @return string
  362.      */
  363.     public function getTelefono()
  364.     {
  365.         return $this->telefono;
  366.     }
  367.     /**
  368.      * Set direccion
  369.      *
  370.      * @param string $direccion
  371.      * @return Oficina
  372.      */
  373.     public function setDireccion($direccion)
  374.     {
  375.         $this->direccion $direccion;
  376.         return $this;
  377.     }
  378.     /**
  379.      * Get direccion
  380.      *
  381.      * @return string
  382.      */
  383.     public function getDireccion()
  384.     {
  385.         return $this->direccion;
  386.     }
  387.     /**
  388.      * Set provincia
  389.      *
  390.      * @param Provincia $provincia
  391.      * @return Oficina
  392.      */
  393.     public function setProvincia(Provincia $provincia)
  394.     {
  395.         $this->provincia $provincia;
  396.         return $this;
  397.     }
  398.     /**
  399.      * Get provincia
  400.      *
  401.      * @return Provincia
  402.      */
  403.     public function getProvincia()
  404.     {
  405.         return $this->provincia;
  406.     }
  407.     /**
  408.      * Set oficinaERP
  409.      *
  410.      * @param OficinaErp oficinaERP
  411.      * @return Oficina
  412.      */
  413.     public function setOficinaERP(OficinaErp $oficinaERP)
  414.     {
  415.         $this->oficinaERP $oficinaERP;
  416.         return $this;
  417.     }
  418.     /**
  419.      * Get oficinaERP
  420.      *
  421.      * @return oficinaErp
  422.      */
  423.     public function getOficinaErp()
  424.     {
  425.         return $this->oficinaERP;
  426.     }
  427.     /**
  428.      * Set codigoPostal
  429.      *
  430.      * @param string $codigoPostal
  431.      * @return Oficina
  432.      */
  433.     public function setCodigoPostal($codigoPostal)
  434.     {
  435.         $this->codigoPostal $codigoPostal;
  436.         return $this;
  437.     }
  438.     /**
  439.      * Get codigoPostal
  440.      *
  441.      * @return string
  442.      */
  443.     public function getCodigoPostal()
  444.     {
  445.         return $this->codigoPostal;
  446.     }
  447.     /**
  448.      * Set localidad
  449.      *
  450.      * @param string $localidad
  451.      * @return Oficina
  452.      */
  453.     public function setLocalidad($localidad)
  454.     {
  455.         $this->localidad $localidad;
  456.         return $this;
  457.     }
  458.     /**
  459.      * Get localidad
  460.      *
  461.      * @return string
  462.      */
  463.     public function getLocalidad()
  464.     {
  465.         return $this->localidad;
  466.     }
  467.     /**
  468.      * Set franjas
  469.      *
  470.      * @param ArrayColection $franjas
  471.      * @return Oficina
  472.      */
  473.     public function setFranjas($franjas)
  474.     {
  475.         $this->franjas=$franjas;
  476.         return $this;
  477.     }
  478.     /**
  479.      * get franjas
  480.      * @return Franjas
  481.      */
  482.     public function getFranjas()
  483.     {
  484.         return $this->franjas;
  485.     }
  486.     /**
  487.      * add FranjaDias
  488.      *
  489.      * @param addFranjaDias $franja
  490.      * @return Oficina
  491.      */
  492.     public function addFranja(FranjaDias $franja){
  493.         $franja->setOficina($this);
  494.         $this->franjas[]=$franja;
  495.         return $this;
  496.     }
  497.     /**
  498.      * Remove Franjadias
  499.      *
  500.      * @return Oficina
  501.      */
  502.     public function removeFranja(FranjaDias $franja)
  503.     {
  504.         $this->franjas->removeElement($franja);
  505.         //$franja->setOficina(null);
  506.     }
  507.     /**
  508.      * Set servicios
  509.      *
  510.      * @param ArrayColection $servicios
  511.      * @return Oficina
  512.      */
  513.     public function setServicios($servicios)
  514.     {
  515.         $this->servicios=$servicios;
  516.         return $this;
  517.     }
  518.     /**
  519.      * Get servicios
  520.      *
  521.      * @return ArrayCollection
  522.      */
  523.     public function getServicios()
  524.     {
  525.         return $this->servicios;
  526.     }
  527.     /**
  528.      * add servicios
  529.      *
  530.      * @param servicios $servicios
  531.      * @return Oficina
  532.      */
  533.     public function addServicio(Servicio $servicio)
  534.     {
  535.         $servicio->addOficina($this);
  536.         $this->servicios[]=$servicio;
  537.         return $this;
  538.     }
  539.     public function getOficina(){
  540.         $oficina['id']=$this->id;
  541.         $oficina['nombre']=$this->nombre;
  542.         foreach($this->franjas as $franja){
  543.             $oficina['franjas'][]=$franja->getFranjaDias();
  544.         }
  545.         return $oficina;
  546.     }
  547.     public function jsonSerialize()
  548.     {
  549.         return array(
  550.             'id' => $this->id,
  551.             'nombre'=> $this->nombre,
  552.             'franjas' => $this->franjas
  553.         );
  554.     }
  555.     /**
  556.      * Set existencias
  557.      *
  558.      * @param ArrayColection $existencias
  559.      * @return Oficina
  560.      */
  561.     public function setExistencias($existencias)
  562.     {
  563.         $this->existencias=$existencias;
  564.         return $this;
  565.     }
  566.     /**
  567.      * add existencia
  568.      *
  569.      * @param Existencia $existencias
  570.      * @return Oficina
  571.      */
  572.     public function addExistencia(Existencia $existencia)
  573.     {
  574.         $this->existencias[]=$existencia;
  575.         return $this;
  576.     }
  577.     /**
  578.      * Remove existencia
  579.      *
  580.      * @return Oficina
  581.      */
  582.     public function removeExistencia(Existencia $existencia)
  583.     {
  584.         $this->existencias->removeElement($existencia);
  585.         return $this;
  586.         //$franja->setOficina(null);
  587.     }
  588.     /**
  589.      * Get existencias
  590.      *
  591.      * @return ArrayCollection
  592.      */
  593.     public function getExistencias()
  594.     {
  595.         return $this->existencias;
  596.     }
  597.     /**
  598.      * Set peso
  599.      *
  600.      * @param integer $peso
  601.      * @return Oficina
  602.      */
  603.     public function setPeso($peso)
  604.     {
  605.         $this->peso=$peso;
  606.         return $this;
  607.     }
  608.     /**
  609.      * Get peso
  610.      *
  611.      * @return integer
  612.      */
  613.     public function getPeso()
  614.     {
  615.         return $this->peso;
  616.     }
  617.     public function permiteCompra()
  618.     {
  619. //         var_dump ($this->servicios->getValues());
  620.         return $this->servicios->exists(function($key$value) {
  621.             return $value->getId() == '1';
  622.         });
  623.     }
  624.     public function addCotizacione(Cotizaciones $cotizacione): self
  625.     {
  626.         if (!$this->cotizaciones->contains($cotizacione)) {
  627.             $this->cotizaciones->add($cotizacione);
  628.             $cotizacione->setOficina($this);
  629.         }
  630.         return $this;
  631.     }
  632.     public function removeCotizacione(Cotizaciones $cotizacione): self
  633.     {
  634.         if ($this->cotizaciones->removeElement($cotizacione)) {
  635.             // set the owning side to null (unless already changed)
  636.             if ($cotizacione->getOficina() === $this) {
  637.                 $cotizacione->setOficina(null);
  638.             }
  639.         }
  640.         return $this;
  641.     }
  642.     /**
  643.      * @return Collection<int, Reserva>
  644.      */
  645.     public function getReservas(): Collection
  646.     {
  647.         return $this->reservas;
  648.     }
  649.     public function addReserva(Reserva $reserva): self
  650.     {
  651.         if (!$this->reservas->contains($reserva)) {
  652.             $this->reservas->add($reserva);
  653.             $reserva->setOficina($this);
  654.         }
  655.         return $this;
  656.     }
  657.     public function removeReserva(Reserva $reserva): self
  658.     {
  659.         if ($this->reservas->removeElement($reserva)) {
  660.             // set the owning side to null (unless already changed)
  661.             if ($reserva->getOficina() === $this) {
  662.                 $reserva->setOficina(null);
  663.             }
  664.         }
  665.         return $this;
  666.     }
  667.     public function getPeticiones(): Collection
  668.     {
  669.         return $this->peticiones;
  670.     }
  671.     public function addPeticion($peticion): self
  672.     {
  673.         if (!$this->peticiones->contains($peticion)) {
  674.             $this->peticiones->add($peticion);
  675.             $peticion->setOficinaPeticion($this);
  676.         }
  677.         return $this;
  678.     }
  679.     public function removePeticion($peticion): self
  680.     {
  681.         if ($this->peticiones->removeElement($peticion)) {
  682.             // set the owning side to null (unless already changed)
  683.             if ($peticion->getOficinaPeticion() === $this) {
  684.                 $peticion->setOficinaPeticion(null);
  685.             }
  686.         }
  687.         return $this;
  688.     }
  689.     public function removeServicio(Servicio $servicio): self
  690.     {
  691.         $this->servicios->removeElement($servicio);
  692.         return $this;
  693.     }
  694.     public function getImagen(): ?Imagen
  695.     {
  696.         return $this->imagen;
  697.     }
  698.     public function setImagen(?Imagen $imagen): self
  699.     {
  700.         $this->imagen $imagen;
  701.         return $this;
  702.     }
  703.     
  704.     
  705.     public function getImagenMapa(): ?Imagen
  706.     {
  707.         return $this->imagenMapa;
  708.     }
  709.     public function setImagenMapa(?Imagen $imagenMapa): self
  710.     {
  711.         $this->imagenMapa $imagenMapa;
  712.         return $this;
  713.     }
  714.     /**
  715.      * @return Dayoffs
  716.      */
  717.     public function getDayoffs()
  718.     {
  719.         return $this->dayoffs;
  720.     }
  721.     
  722.     /**
  723.      * Set dayoffs
  724.      *
  725.      * @param ArrayColection $dayoffs
  726.      * @return DayOff
  727.      */
  728.     public function setDayoffs($dayoffs)
  729.     {
  730.         $this->dayoffs=$dayoffs;
  731.         return $this;
  732.     }
  733.     public function addDayoff(DayOff $dayoff): self
  734.     {
  735.         $dayoff->setOficina($this);
  736.         $this->dayoffs[]=$dayoff;
  737.         return $this;
  738.     }
  739.     public function removeDayoff(DayOff $dayoff): self
  740.     {
  741.         $this->dayoffs->removeElement($dayoff);
  742.         
  743.         return $this;
  744.     }
  745.     
  746.     /**
  747.      * Get activo
  748.      *
  749.      * @return bool
  750.      */
  751.     public function getActivo()
  752.     {
  753.         return $this->activo;
  754.     }
  755.     
  756.     /**
  757.      * Set activo
  758.      *
  759.      * @param bool $activo
  760.      * @return Activo
  761.      */
  762.     public function setActivo($activo)
  763.     {
  764.         $this->activo $activo;
  765.         return $this;
  766.     }
  767.     
  768.     public function getUrlGoogle()
  769.     {
  770.         return $this->urlGoogle;
  771.     }
  772.     public function setUrlGoogle($urlGoogle)
  773.     {
  774.         $this->urlGoogle $urlGoogle;
  775.         return $this;
  776.     }
  777. }