<?php
namespace App\Entity;
use App\Repository\SucursalRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=SucursalRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class Sucursal
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $nombre;
/**
* @ORM\Column(type="decimal", precision=30, scale=20)
*/
private $lat;
/**
* @ORM\Column(type="decimal", precision=30, scale=20)
*/
private $lng;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $poligono;
/**
* @ORM\Column(type="string", length=15, nullable=true)
*/
private $color;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $mon_open_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $mon_closed_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $tue_open_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $tue_closed_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $wed_open_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $wed_closed_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $thu_open_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $thu_closed_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $fri_open_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $fri_closed_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $sat_open_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $sat_closed_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $sun_open_at;
/**
* @ORM\Column(type="time", nullable=true)
*/
private $sun_closed_at;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $is_enabled;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $is_enabled_programming;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $is_enabled_reservation;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $is_active;
/**
* @ORM\Column(type="integer")
*/
private $deliveryCapacity;
/**
* @ORM\Column(type="integer")
*/
private $numberDeliveryMen;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $codalmvent;
/**
* @ORM\Column(type="string", length=255)
*/
private $server;
/**
* @ORM\Column(type="string", length=255)
*/
private $server_db;
/**
* @ORM\Column(type="string", length=255)
*/
private $server_user;
/**
* @ORM\Column(type="string", length=255)
*/
private $server_pass;
public function __toString(): string
{
return $this->nombre;
}
public function getId(): ?int
{
return $this->id;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function getLat(): ?string
{
return $this->lat;
}
public function setLat(string $lat): self
{
$this->lat = $lat;
return $this;
}
public function getLng(): ?string
{
return $this->lng;
}
public function setLng(string $lng): self
{
$this->lng = $lng;
return $this;
}
public function getColor(): ?string
{
return $this->color;
}
public function setColor(?string $color): self
{
$this->color = $color;
return $this;
}
public function getPoligono(): ?array
{
return $this->poligono;
}
public function setPoligono(?array $poligono): self
{
$this->poligono = $poligono;
return $this;
}
public function getMonOpenAt(): ?\DateTimeInterface
{
return $this->mon_open_at;
}
public function setMonOpenAt(?\DateTimeInterface $mon_open_at): self
{
$this->mon_open_at = $mon_open_at;
return $this;
}
public function getMonClosedAt(): ?\DateTimeInterface
{
return $this->mon_closed_at;
}
public function setMonClosedAt(?\DateTimeInterface $mon_closed_at): self
{
$this->mon_closed_at = $mon_closed_at;
return $this;
}
public function getTueOpenAt(): ?\DateTimeInterface
{
return $this->tue_open_at;
}
public function setTueOpenAt(?\DateTimeInterface $tue_open_at): self
{
$this->tue_open_at = $tue_open_at;
return $this;
}
public function getTueClosedAt(): ?\DateTimeInterface
{
return $this->tue_closed_at;
}
public function setTueClosedAt(?\DateTimeInterface $tue_closed_at): self
{
$this->tue_closed_at = $tue_closed_at;
return $this;
}
public function getWedOpenAt(): ?\DateTimeInterface
{
return $this->wed_open_at;
}
public function setWedOpenAt(?\DateTimeInterface $wed_open_at): self
{
$this->wed_open_at = $wed_open_at;
return $this;
}
public function getWedClosedAt(): ?\DateTimeInterface
{
return $this->wed_closed_at;
}
public function setWedClosedAt(?\DateTimeInterface $wed_closed_at): self
{
$this->wed_closed_at = $wed_closed_at;
return $this;
}
public function getThuOpenAt(): ?\DateTimeInterface
{
return $this->thu_open_at;
}
public function setThuOpenAt(?\DateTimeInterface $thu_open_at): self
{
$this->thu_open_at = $thu_open_at;
return $this;
}
public function getThuClosedAt(): ?\DateTimeInterface
{
return $this->thu_closed_at;
}
public function setThuClosedAt(?\DateTimeInterface $thu_closed_at): self
{
$this->thu_closed_at = $thu_closed_at;
return $this;
}
public function getFriOpenAt(): ?\DateTimeInterface
{
return $this->fri_open_at;
}
public function setFriOpenAt(?\DateTimeInterface $fri_open_at): self
{
$this->fri_open_at = $fri_open_at;
return $this;
}
public function getFriClosedAt(): ?\DateTimeInterface
{
return $this->fri_closed_at;
}
public function setFriClosedAt(?\DateTimeInterface $fri_closed_at): self
{
$this->fri_closed_at = $fri_closed_at;
return $this;
}
public function getSatOpenAt(): ?\DateTimeInterface
{
return $this->sat_open_at;
}
public function setSatOpenAt(?\DateTimeInterface $sat_open_at): self
{
$this->sat_open_at = $sat_open_at;
return $this;
}
public function getSatClosedAt(): ?\DateTimeInterface
{
return $this->sat_closed_at;
}
public function setSatClosedAt(?\DateTimeInterface $sat_closed_at): self
{
$this->sat_closed_at = $sat_closed_at;
return $this;
}
public function getSunOpenAt(): ?\DateTimeInterface
{
return $this->sun_open_at;
}
public function setSunOpenAt(?\DateTimeInterface $sun_open_at): self
{
$this->sun_open_at = $sun_open_at;
return $this;
}
public function getSunClosedAt(): ?\DateTimeInterface
{
return $this->sun_closed_at;
}
public function setSunClosedAt(?\DateTimeInterface $sun_closed_at): self
{
$this->sun_closed_at = $sun_closed_at;
return $this;
}
public function getIsEnabled(): ?bool
{
return $this->is_enabled;
}
public function setIsEnabled(?bool $is_enabled): self
{
$this->is_enabled = $is_enabled;
return $this;
}
public function getIsEnabledProgramming(): ?bool
{
return $this->is_enabled_programming;
}
public function setIsEnabledProgramming(?bool $is_enabled_programming): self
{
$this->is_enabled_programming = $is_enabled_programming;
return $this;
}
public function getIsEnabledReservation(): ?bool
{
return $this->is_enabled_reservation;
}
public function setIsEnabledReservation(?bool $is_enabled_reservation): self
{
$this->is_enabled_reservation = $is_enabled_reservation;
return $this;
}
public function getIsActive(): ?bool
{
return $this->is_active;
}
public function setIsActive(?bool $is_active): self
{
$this->is_active = $is_active;
return $this;
}
public function getState()
{
if (!$this->getIsActive()) {
return false;
}
$today = strtolower(date('D'));
$time = date('G:i:s');
switch ($today) {
case 'mon':
$open_at = $this->getMonOpenAt();
$close_at = $this->getMonClosedAt();
break;
case 'tue':
$open_at = $this->getTueOpenAt();
$close_at = $this->getTueClosedAt();
break;
case 'wed':
$open_at = $this->getWedOpenAt();
$close_at = $this->getWedClosedAt();
break;
case 'thu':
$open_at = $this->getThuOpenAt();
$close_at = $this->getThuClosedAt();
break;
case 'fri':
$open_at = $this->getFriOpenAt();
$close_at = $this->getFriClosedAt();
break;
case 'sat':
$open_at = $this->getSatOpenAt();
$close_at = $this->getSatClosedAt();
break;
case 'sun':
$open_at = $this->getSunOpenAt();
$close_at = $this->getSunClosedAt();
break;
}
if ($open_at == null or $close_at == null) {
return false;
}
if (date_format($open_at, 'H:i:s') <= $time and date_format($close_at, 'H:i:s') >= $time) {
return true;
} else {
return false;
}
}
public function getDeliveryCapacity(): ?int
{
return $this->deliveryCapacity;
}
public function setDeliveryCapacity(int $deliveryCapacity): self
{
$this->deliveryCapacity = $deliveryCapacity;
return $this;
}
public function getNumberDeliveryMen(): ?int
{
return $this->numberDeliveryMen;
}
public function setNumberDeliveryMen(int $numberDeliveryMen): self
{
$this->numberDeliveryMen = $numberDeliveryMen;
return $this;
}
public function getOrderCapacity(): ?int
{
return $this->getDeliveryCapacity() * $this->getNumberDeliveryMen();
}
public function isIsEnabled(): ?bool
{
return $this->is_enabled;
}
public function isIsEnabledProgramming(): ?bool
{
return $this->is_enabled_programming;
}
public function isIsEnabledReservation(): ?bool
{
return $this->is_enabled_reservation;
}
public function isIsActive(): ?bool
{
return $this->is_active;
}
public function getCodalmvent(): ?string
{
return $this->codalmvent;
}
public function setCodalmvent(string $codalmvent): self
{
$this->codalmvent = $codalmvent;
return $this;
}
// ------------------------------
public function getServer(): ?string
{
return $this->server;
}
public function setServer(?string $server): self
{
$this->server = $server;
return $this;
}
public function getServerDB(): ?string
{
return $this->server_db;
}
public function setServerDB(?string $server_db): self
{
$this->server_db = $server_db;
return $this;
}
public function getServerUser(): ?string
{
return $this->server_user;
}
public function setServerUser(?string $server_user): self
{
$this->server_user = $server_user;
return $this;
}
public function getServerPass(): ?string
{
return $this->server_pass;
}
public function setServerPass(?string $server_pass): self
{
if ($server_pass !== null && $server_pass !== "") {
// Asigna el valor encriptado solo si no es nulo ni vacío
$this->server_pass = $server_pass; // Aquí idealmente deberías llamar a tu servicio de encriptación si no se hace en otro lado
}
return $this;
}
}