src/Entity/Oficina.php line 24
- <?php
- namespace App\Entity;
- // use Dinamic\AdminBundle\Entity\OficinaErp;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\DBAL\Types\Types;
- use Doctrine\ORM\Mapping as ORM;
- use Doctrine\Common\Collections\ArrayCollection;
- use Symfony\Component\Validator\Constraints as Assert;
- use JMS\Serializer\Annotation as JMS;
- use JsonSerializable;
- use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
- use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
- /**
- * Oficina
- *
- * @ORM\Table(name="oficina")
- * @ORM\Entity(repositoryClass="App\Repository\OficinaRepository")
- *
- */
- class Oficina implements JsonSerializable, TranslatableInterface
- {
- use TranslatableTrait;
- public function __toString() {
- return $this->nombre;
- }
- /**
- * @var integer
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var string
- *
- * @ORM\Column(name="nombre", type="string", length=100, nullable=false)
- * @JMS\Groups({"api-order"})
- */
- private $nombre;
- /**
- * @var alt
- *
- * @ORM\Column(name="alt", type="string", length=255, nullable=true)
- */
- private $alt;
- /**
- * @var string
- *
- * @ORM\Column(name="latitud", type="string", length=100, nullable=true)
- */
- private $latitud;
- /**
- * @var string
- *
- * @ORM\Column(name="longitud", type="string", length=100, nullable=true)
- */
- private $longitud;
- /**
- * @var string
- *
- * @ORM\Column(name="telefono", type="string", length=20, nullable=true)
- */
- private $telefono;
- /**
- * @var string
- *
- * @ORM\Column(name="direccion", type="string", length=255, nullable=true)
- */
- private $direccion;
- /**
- * @ORM\ManyToOne(targetEntity="Provincia", inversedBy="oficinas")
- * @ORM\JoinColumn(name="provincia", referencedColumnName="id")
- */
- private $provincia;
- /**
- * @ORM\OneToMany(targetEntity="Cotizaciones", mappedBy="oficina", cascade={"remove"})
- * @ORM\OrderBy({"dia" = "DESC"})
- */
- private $cotizaciones;
- /**
- * @var string
- *
- * @ORM\Column(name="codigo_postal", type="text", nullable=false)
- */
- private $codigoPostal;
- /**
- * @ORM\ManyToOne(targetEntity="Localidad")
- * @ORM\JoinColumn(name="localidad", referencedColumnName="id", nullable=false)
- */
- private $localidad;
- /**
- * @ORM\ManyToOne(targetEntity="OficinaErp")
- * @ORM\JoinColumn(name="oficinaERP", referencedColumnName="id", nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $oficinaERP;
- /**
- * @Assert\Valid()
- * @ORM\OneToMany(targetEntity="Reserva", mappedBy="oficina",cascade={"persist"})
- */
- private $reservas;
- /**
- *
- * @Assert\Valid()
- * @ORM\OneToMany(targetEntity="FranjaDias", mappedBy="oficina", cascade={"persist", "remove"}, orphanRemoval=true)
- */
- private $franjas;
- /**
- * @ORM\ManyToMany(targetEntity="Servicio", inversedBy="oficinas")
- * @ORM\JoinTable(name="oficina_servicio")
- */
- private $servicios;
- /**
- * @Assert\Valid()
- * @ORM\OneToMany(targetEntity="Stock", mappedBy="oficina", cascade={"persist", "remove"}, orphanRemoval=true)
- */
- private $stocks;
- /**
- * @var string
- *
- * @ORM\ManyToOne(targetEntity="Imagen")
- */
- protected $imagen;
- /**
- * @var string
- *
- * @ORM\ManyToOne(targetEntity="Imagen")
- */
- protected $imagenMapa;
- /**
- * @Assert\Valid()
- * @ORM\OneToMany(targetEntity="Existencia", mappedBy="oficina")
- */
- private $existencias;
- /**
- * @var integer
- *
- * @ORM\Column(name="peso", type="integer", nullable=false)
- */
- private $peso=0;
- /**
- * @ORM\ManyToMany(targetEntity="App\Entity\DayOff", mappedBy="oficinas")
- */
- // private $dayoffs;
- /**
- * @Assert\Valid()
- * @ORM\OneToMany(targetEntity="App\Entity\DayOff", mappedBy="oficina", cascade={"persist", "remove"}, orphanRemoval=true)
- */
- private $dayoffs;
- /**
- * @var ArrayCollection
- *
- * @ORM\OneToMany(targetEntity="Alerta", mappedBy="oficina", orphanRemoval=true)
- */
- protected $alerts;
- /**
- * @var boolean
- *
- * @ORM\Column(name="activo", type="boolean", options={"default":1})
- */
- private $activo=true;
- /**
- * @var string
- *
- * @ORM\Column(name="url_google", type="string", nullable=true)
- */
- private $urlGoogle;
- public function __call($method, $args)
- {
- //return $this->proxyCurrentLocaleTranslation($method, $arguments);
- if (!method_exists(self::getTranslationEntityClass(), $method)) {
- $method = 'get'. ucfirst($method);
- }
- return $this->proxyCurrentLocaleTranslation($method, $args);
- }
- public function __construct() {
- $this->reservas = new ArrayCollection();
- $this->franjas = new ArrayCollection();
- $this->servicios = new ArrayCollection();
- $this->dayoffs = new ArrayCollection();
- $this->stocks = new ArrayCollection();
- $this->stockDias = new ArrayCollection();
- $this->cotizaciones = new ArrayCollection();
- $this->existencias = new ArrayCollection();
- $this->traducciones = new ArrayCollection();
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set nombre
- *
- * @param string $nombre
- * @return Oficina
- */
- public function setNombre($nombre)
- {
- $this->nombre = $nombre;
- return $this;
- }
- /**
- * Get slug
- *
- * @return string
- */
- public function getNombre()
- {
- return $this->nombre;
- }
- /**
- * Set cotizaciones
- *
- * @param string $cotizaciones
- * @return Oficina
- */
- public function setCotizaciones($cotizaciones)
- {
- $this->cotizaciones = $cotizaciones;
- return $this;
- }
- /**
- * Get slug
- *
- * @return string
- */
- public function getCotizaciones()
- {
- return $this->cotizaciones;
- }
- /**
- * Set alt
- *
- * @param string $alt
- * @return Oficina
- */
- public function setAlt($alt)
- {
- $this->alt = $alt;
- return this;
- }
- /**
- * Get alt
- *
- * @return string
- */
- public function getAlt()
- {
- return $this->alt;
- }
- /**
- * Set latitud
- *
- * @param string $latitud
- * @return Oficina
- */
- public function setLatitud($latitud)
- {
- $this->latitud = $latitud;
- return $this;
- }
- /**
- * Get latitud
- *
- * @return string
- */
- public function getLatitud()
- {
- return $this->latitud;
- }
- /**
- * Set stocks
- *
- * @param Stock $stock
- * @return Oficina
- */
- public function setStocks($stocks)
- {
- $this->stocks = $stocks;
- return $this;
- }
- /**
- * Get stocks
- *
- * @return boolean
- */
- public function getStocks()
- {
- return $this->stocks;
- }
- public function addStock(Stock $stock): self
- {
- if (!$this->stocks->contains($stock)) {
- $this->stocks->add($stock);
- $stock->setOficina($this);
- }
- return $this;
- }
- public function removeStock(Stock $stock): self
- {
- if ($this->stocks->removeElement($stock)) {
- // set the owning side to null (unless already changed)
- if ($stock->getOficina() === $this) {
- $stock->setOficina(null);
- }
- }
- return $this;
- }
- /**
- * Set longitud
- *
- * @param string $longitud
- * @return Oficina
- */
- public function setLongitud($longitud)
- {
- $this->longitud = $longitud;
- return $this;
- }
- /**
- * Get longitud
- *
- * @return string
- */
- public function getLongitud()
- {
- return $this->longitud;
- }
- /**
- * Set telefono
- *
- * @param string $telefono
- * @return Oficina
- */
- public function setTelefono($telefono)
- {
- $this->telefono = $telefono;
- return $this;
- }
- /**
- * Get telefono
- *
- * @return string
- */
- public function getTelefono()
- {
- return $this->telefono;
- }
- /**
- * Set direccion
- *
- * @param string $direccion
- * @return Oficina
- */
- public function setDireccion($direccion)
- {
- $this->direccion = $direccion;
- return $this;
- }
- /**
- * Get direccion
- *
- * @return string
- */
- public function getDireccion()
- {
- return $this->direccion;
- }
- /**
- * Set provincia
- *
- * @param Provincia $provincia
- * @return Oficina
- */
- public function setProvincia(Provincia $provincia)
- {
- $this->provincia = $provincia;
- return $this;
- }
- /**
- * Get provincia
- *
- * @return Provincia
- */
- public function getProvincia()
- {
- return $this->provincia;
- }
- /**
- * Set oficinaERP
- *
- * @param OficinaErp oficinaERP
- * @return Oficina
- */
- public function setOficinaERP(OficinaErp $oficinaERP)
- {
- $this->oficinaERP = $oficinaERP;
- return $this;
- }
- /**
- * Get oficinaERP
- *
- * @return oficinaErp
- */
- public function getOficinaErp()
- {
- return $this->oficinaERP;
- }
- /**
- * Set codigoPostal
- *
- * @param string $codigoPostal
- * @return Oficina
- */
- public function setCodigoPostal($codigoPostal)
- {
- $this->codigoPostal = $codigoPostal;
- return $this;
- }
- /**
- * Get codigoPostal
- *
- * @return string
- */
- public function getCodigoPostal()
- {
- return $this->codigoPostal;
- }
- /**
- * Set localidad
- *
- * @param string $localidad
- * @return Oficina
- */
- public function setLocalidad($localidad)
- {
- $this->localidad = $localidad;
- return $this;
- }
- /**
- * Get localidad
- *
- * @return string
- */
- public function getLocalidad()
- {
- return $this->localidad;
- }
- /**
- * Set franjas
- *
- * @param ArrayColection $franjas
- * @return Oficina
- */
- public function setFranjas($franjas)
- {
- $this->franjas=$franjas;
- return $this;
- }
- /**
- * get franjas
- * @return Franjas
- */
- public function getFranjas()
- {
- return $this->franjas;
- }
- /**
- * add FranjaDias
- *
- * @param addFranjaDias $franja
- * @return Oficina
- */
- public function addFranja(FranjaDias $franja){
- $franja->setOficina($this);
- $this->franjas[]=$franja;
- return $this;
- }
- /**
- * Remove Franjadias
- *
- * @return Oficina
- */
- public function removeFranja(FranjaDias $franja)
- {
- $this->franjas->removeElement($franja);
- //$franja->setOficina(null);
- }
- /**
- * Set servicios
- *
- * @param ArrayColection $servicios
- * @return Oficina
- */
- public function setServicios($servicios)
- {
- $this->servicios=$servicios;
- return $this;
- }
- /**
- * Get servicios
- *
- * @return ArrayCollection
- */
- public function getServicios()
- {
- return $this->servicios;
- }
- /**
- * add servicios
- *
- * @param servicios $servicios
- * @return Oficina
- */
- public function addServicio(Servicio $servicio)
- {
- $servicio->addOficina($this);
- $this->servicios[]=$servicio;
- return $this;
- }
- public function getOficina(){
- $oficina['id']=$this->id;
- $oficina['nombre']=$this->nombre;
- foreach($this->franjas as $franja){
- $oficina['franjas'][]=$franja->getFranjaDias();
- }
- return $oficina;
- }
- public function jsonSerialize()
- {
- return array(
- 'id' => $this->id,
- 'nombre'=> $this->nombre,
- 'franjas' => $this->franjas
- );
- }
- /**
- * Set existencias
- *
- * @param ArrayColection $existencias
- * @return Oficina
- */
- public function setExistencias($existencias)
- {
- $this->existencias=$existencias;
- return $this;
- }
- /**
- * add existencia
- *
- * @param Existencia $existencias
- * @return Oficina
- */
- public function addExistencia(Existencia $existencia)
- {
- $this->existencias[]=$existencia;
- return $this;
- }
- /**
- * Remove existencia
- *
- * @return Oficina
- */
- public function removeExistencia(Existencia $existencia)
- {
- $this->existencias->removeElement($existencia);
- return $this;
- //$franja->setOficina(null);
- }
- /**
- * Get existencias
- *
- * @return ArrayCollection
- */
- public function getExistencias()
- {
- return $this->existencias;
- }
- /**
- * Set peso
- *
- * @param integer $peso
- * @return Oficina
- */
- public function setPeso($peso)
- {
- $this->peso=$peso;
- return $this;
- }
- /**
- * Get peso
- *
- * @return integer
- */
- public function getPeso()
- {
- return $this->peso;
- }
- public function permiteCompra()
- {
- // var_dump ($this->servicios->getValues());
- return $this->servicios->exists(function($key, $value) {
- return $value->getId() == '1';
- });
- }
- public function addCotizacione(Cotizaciones $cotizacione): self
- {
- if (!$this->cotizaciones->contains($cotizacione)) {
- $this->cotizaciones->add($cotizacione);
- $cotizacione->setOficina($this);
- }
- return $this;
- }
- public function removeCotizacione(Cotizaciones $cotizacione): self
- {
- if ($this->cotizaciones->removeElement($cotizacione)) {
- // set the owning side to null (unless already changed)
- if ($cotizacione->getOficina() === $this) {
- $cotizacione->setOficina(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, Reserva>
- */
- public function getReservas(): Collection
- {
- return $this->reservas;
- }
- public function addReserva(Reserva $reserva): self
- {
- if (!$this->reservas->contains($reserva)) {
- $this->reservas->add($reserva);
- $reserva->setOficina($this);
- }
- return $this;
- }
- public function removeReserva(Reserva $reserva): self
- {
- if ($this->reservas->removeElement($reserva)) {
- // set the owning side to null (unless already changed)
- if ($reserva->getOficina() === $this) {
- $reserva->setOficina(null);
- }
- }
- return $this;
- }
- public function removeServicio(Servicio $servicio): self
- {
- $this->servicios->removeElement($servicio);
- return $this;
- }
- public function getImagen(): ?Imagen
- {
- return $this->imagen;
- }
- public function setImagen(?Imagen $imagen): self
- {
- $this->imagen = $imagen;
- return $this;
- }
- public function getImagenMapa(): ?Imagen
- {
- return $this->imagenMapa;
- }
- public function setImagenMapa(?Imagen $imagenMapa): self
- {
- $this->imagenMapa = $imagenMapa;
- return $this;
- }
- /**
- * @return Dayoffs
- */
- public function getDayoffs()
- {
- return $this->dayoffs;
- }
- /**
- * Set dayoffs
- *
- * @param ArrayColection $dayoffs
- * @return DayOff
- */
- public function setDayoffs($dayoffs)
- {
- $this->dayoffs=$dayoffs;
- return $this;
- }
- public function addDayoff(DayOff $dayoff): self
- {
- $dayoff->setOficina($this);
- $this->dayoffs[]=$dayoff;
- return $this;
- }
- public function removeDayoff(DayOff $dayoff): self
- {
- $this->dayoffs->removeElement($dayoff);
- return $this;
- }
- /**
- * Get activo
- *
- * @return bool
- */
- public function getActivo()
- {
- return $this->activo;
- }
- /**
- * Set activo
- *
- * @param bool $activo
- * @return Activo
- */
- public function setActivo($activo)
- {
- $this->activo = $activo;
- return $this;
- }
- public function getUrlGoogle()
- {
- return $this->urlGoogle;
- }
- public function setUrlGoogle($urlGoogle)
- {
- $this->urlGoogle = $urlGoogle;
- return $this;
- }
- }