src/Entity/Oficina.php line 24

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