src/Entity/Sucursal.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SucursalRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass=SucursalRepository::class)
  8.  * @ORM\HasLifecycleCallbacks()
  9.  */
  10. class Sucursal
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $nombre;
  22.     /**
  23.      * @ORM\Column(type="decimal", precision=30, scale=20)
  24.      */
  25.     private $lat;
  26.     /**
  27.      * @ORM\Column(type="decimal", precision=30, scale=20)
  28.      */
  29.     private $lng;
  30.     /**
  31.      * @ORM\Column(type="json", nullable=true)
  32.      */
  33.     private $poligono;
  34.     /**
  35.      * @ORM\Column(type="string", length=15, nullable=true)
  36.      */
  37.     private $color;
  38.     /**
  39.      * @ORM\Column(type="time", nullable=true)
  40.      */
  41.     private $mon_open_at;
  42.     /**
  43.      * @ORM\Column(type="time", nullable=true)
  44.      */
  45.     private $mon_closed_at;
  46.     /**
  47.      * @ORM\Column(type="time", nullable=true)
  48.      */
  49.     private $tue_open_at;
  50.     /**
  51.      * @ORM\Column(type="time", nullable=true)
  52.      */
  53.     private $tue_closed_at;
  54.     /**
  55.      * @ORM\Column(type="time", nullable=true)
  56.      */
  57.     private $wed_open_at;
  58.     /**
  59.      * @ORM\Column(type="time", nullable=true)
  60.      */
  61.     private $wed_closed_at;
  62.     /**
  63.      * @ORM\Column(type="time", nullable=true)
  64.      */
  65.     private $thu_open_at;
  66.     /**
  67.      * @ORM\Column(type="time", nullable=true)
  68.      */
  69.     private $thu_closed_at;
  70.     /**
  71.      * @ORM\Column(type="time", nullable=true)
  72.      */
  73.     private $fri_open_at;
  74.     /**
  75.      * @ORM\Column(type="time", nullable=true)
  76.      */
  77.     private $fri_closed_at;
  78.     /**
  79.      * @ORM\Column(type="time", nullable=true)
  80.      */
  81.     private $sat_open_at;
  82.     /**
  83.      * @ORM\Column(type="time", nullable=true)
  84.      */
  85.     private $sat_closed_at;
  86.     /**
  87.      * @ORM\Column(type="time", nullable=true)
  88.      */
  89.     private $sun_open_at;
  90.     /**
  91.      * @ORM\Column(type="time", nullable=true)
  92.      */
  93.     private $sun_closed_at;
  94.     /**
  95.      * @ORM\Column(type="boolean", nullable=true)
  96.      */
  97.     private $is_enabled;
  98.     /**
  99.      * @ORM\Column(type="boolean", nullable=true)
  100.      */
  101.     private $is_enabled_programming;
  102.     /**
  103.      * @ORM\Column(type="boolean", nullable=true)
  104.      */
  105.     private $is_enabled_reservation;
  106.     /**
  107.      * @ORM\Column(type="boolean", nullable=true)
  108.      */
  109.     private $is_active;
  110.     /**
  111.      * @ORM\Column(type="integer")
  112.      */
  113.     private $deliveryCapacity;
  114.     /**
  115.      * @ORM\Column(type="integer")
  116.      */
  117.     private $numberDeliveryMen;
  118.     /**
  119.      * @ORM\Column(type="string", nullable=true)
  120.      */
  121.     private $codalmvent;
  122.     /**
  123.      * @ORM\Column(type="string", length=255)
  124.      */
  125.     private $server;
  126.     /**
  127.      * @ORM\Column(type="string", length=255)
  128.      */
  129.     private $server_db;
  130.     /**
  131.      * @ORM\Column(type="string", length=255)
  132.      */
  133.     private $server_user;
  134.     /**
  135.      * @ORM\Column(type="string", length=255)
  136.      */
  137.     private $server_pass;
  138.     public function __toString(): string
  139.     {
  140.         return $this->nombre;
  141.     }
  142.     public function getId(): ?int
  143.     {
  144.         return $this->id;
  145.     }
  146.     public function getNombre(): ?string
  147.     {
  148.         return $this->nombre;
  149.     }
  150.     public function setNombre(string $nombre): self
  151.     {
  152.         $this->nombre $nombre;
  153.         return $this;
  154.     }
  155.     public function getLat(): ?string
  156.     {
  157.         return $this->lat;
  158.     }
  159.     public function setLat(string $lat): self
  160.     {
  161.         $this->lat $lat;
  162.         return $this;
  163.     }
  164.     public function getLng(): ?string
  165.     {
  166.         return $this->lng;
  167.     }
  168.     public function setLng(string $lng): self
  169.     {
  170.         $this->lng $lng;
  171.         return $this;
  172.     }
  173.     public function getColor(): ?string
  174.     {
  175.         return $this->color;
  176.     }
  177.     public function setColor(?string $color): self
  178.     {
  179.         $this->color $color;
  180.         return $this;
  181.     }
  182.     public function getPoligono(): ?array
  183.     {
  184.         return $this->poligono;
  185.     }
  186.     public function setPoligono(?array $poligono): self
  187.     {
  188.         $this->poligono $poligono;
  189.         return $this;
  190.     }
  191.     public function getMonOpenAt(): ?\DateTimeInterface
  192.     {
  193.         return $this->mon_open_at;
  194.     }
  195.     public function setMonOpenAt(?\DateTimeInterface $mon_open_at): self
  196.     {
  197.         $this->mon_open_at $mon_open_at;
  198.         return $this;
  199.     }
  200.     public function getMonClosedAt(): ?\DateTimeInterface
  201.     {
  202.         return $this->mon_closed_at;
  203.     }
  204.     public function setMonClosedAt(?\DateTimeInterface $mon_closed_at): self
  205.     {
  206.         $this->mon_closed_at $mon_closed_at;
  207.         return $this;
  208.     }
  209.     public function getTueOpenAt(): ?\DateTimeInterface
  210.     {
  211.         return $this->tue_open_at;
  212.     }
  213.     public function setTueOpenAt(?\DateTimeInterface $tue_open_at): self
  214.     {
  215.         $this->tue_open_at $tue_open_at;
  216.         return $this;
  217.     }
  218.     public function getTueClosedAt(): ?\DateTimeInterface
  219.     {
  220.         return $this->tue_closed_at;
  221.     }
  222.     public function setTueClosedAt(?\DateTimeInterface $tue_closed_at): self
  223.     {
  224.         $this->tue_closed_at $tue_closed_at;
  225.         return $this;
  226.     }
  227.     public function getWedOpenAt(): ?\DateTimeInterface
  228.     {
  229.         return $this->wed_open_at;
  230.     }
  231.     public function setWedOpenAt(?\DateTimeInterface $wed_open_at): self
  232.     {
  233.         $this->wed_open_at $wed_open_at;
  234.         return $this;
  235.     }
  236.     public function getWedClosedAt(): ?\DateTimeInterface
  237.     {
  238.         return $this->wed_closed_at;
  239.     }
  240.     public function setWedClosedAt(?\DateTimeInterface $wed_closed_at): self
  241.     {
  242.         $this->wed_closed_at $wed_closed_at;
  243.         return $this;
  244.     }
  245.     public function getThuOpenAt(): ?\DateTimeInterface
  246.     {
  247.         return $this->thu_open_at;
  248.     }
  249.     public function setThuOpenAt(?\DateTimeInterface $thu_open_at): self
  250.     {
  251.         $this->thu_open_at $thu_open_at;
  252.         return $this;
  253.     }
  254.     public function getThuClosedAt(): ?\DateTimeInterface
  255.     {
  256.         return $this->thu_closed_at;
  257.     }
  258.     public function setThuClosedAt(?\DateTimeInterface $thu_closed_at): self
  259.     {
  260.         $this->thu_closed_at $thu_closed_at;
  261.         return $this;
  262.     }
  263.     public function getFriOpenAt(): ?\DateTimeInterface
  264.     {
  265.         return $this->fri_open_at;
  266.     }
  267.     public function setFriOpenAt(?\DateTimeInterface $fri_open_at): self
  268.     {
  269.         $this->fri_open_at $fri_open_at;
  270.         return $this;
  271.     }
  272.     public function getFriClosedAt(): ?\DateTimeInterface
  273.     {
  274.         return $this->fri_closed_at;
  275.     }
  276.     public function setFriClosedAt(?\DateTimeInterface $fri_closed_at): self
  277.     {
  278.         $this->fri_closed_at $fri_closed_at;
  279.         return $this;
  280.     }
  281.     public function getSatOpenAt(): ?\DateTimeInterface
  282.     {
  283.         return $this->sat_open_at;
  284.     }
  285.     public function setSatOpenAt(?\DateTimeInterface $sat_open_at): self
  286.     {
  287.         $this->sat_open_at $sat_open_at;
  288.         return $this;
  289.     }
  290.     public function getSatClosedAt(): ?\DateTimeInterface
  291.     {
  292.         return $this->sat_closed_at;
  293.     }
  294.     public function setSatClosedAt(?\DateTimeInterface $sat_closed_at): self
  295.     {
  296.         $this->sat_closed_at $sat_closed_at;
  297.         return $this;
  298.     }
  299.     public function getSunOpenAt(): ?\DateTimeInterface
  300.     {
  301.         return $this->sun_open_at;
  302.     }
  303.     public function setSunOpenAt(?\DateTimeInterface $sun_open_at): self
  304.     {
  305.         $this->sun_open_at $sun_open_at;
  306.         return $this;
  307.     }
  308.     public function getSunClosedAt(): ?\DateTimeInterface
  309.     {
  310.         return $this->sun_closed_at;
  311.     }
  312.     public function setSunClosedAt(?\DateTimeInterface $sun_closed_at): self
  313.     {
  314.         $this->sun_closed_at $sun_closed_at;
  315.         return $this;
  316.     }
  317.     public function getIsEnabled(): ?bool
  318.     {
  319.         return $this->is_enabled;
  320.     }
  321.     public function setIsEnabled(?bool $is_enabled): self
  322.     {
  323.         $this->is_enabled $is_enabled;
  324.         return $this;
  325.     }
  326.     public function getIsEnabledProgramming(): ?bool
  327.     {
  328.         return $this->is_enabled_programming;
  329.     }
  330.     public function setIsEnabledProgramming(?bool $is_enabled_programming): self
  331.     {
  332.         $this->is_enabled_programming $is_enabled_programming;
  333.         return $this;
  334.     }
  335.     public function getIsEnabledReservation(): ?bool
  336.     {
  337.         return $this->is_enabled_reservation;
  338.     }
  339.     public function setIsEnabledReservation(?bool $is_enabled_reservation): self
  340.     {
  341.         $this->is_enabled_reservation $is_enabled_reservation;
  342.         return $this;
  343.     }
  344.     public function getIsActive(): ?bool
  345.     {
  346.         return $this->is_active;
  347.     }
  348.     public function setIsActive(?bool $is_active): self
  349.     {
  350.         $this->is_active $is_active;
  351.         return $this;
  352.     }
  353.     public function getState()
  354.     {
  355.         if (!$this->getIsActive()) {
  356.             return false;
  357.         }
  358.         $today strtolower(date('D'));
  359.         $time date('G:i:s');
  360.         switch ($today) {
  361.             case 'mon':
  362.                 $open_at $this->getMonOpenAt();
  363.                 $close_at $this->getMonClosedAt();
  364.                 break;
  365.             case 'tue':
  366.                 $open_at $this->getTueOpenAt();
  367.                 $close_at $this->getTueClosedAt();
  368.                 break;
  369.             case 'wed':
  370.                 $open_at $this->getWedOpenAt();
  371.                 $close_at $this->getWedClosedAt();
  372.                 break;
  373.             case 'thu':
  374.                 $open_at $this->getThuOpenAt();
  375.                 $close_at $this->getThuClosedAt();
  376.                 break;
  377.             case 'fri':
  378.                 $open_at $this->getFriOpenAt();
  379.                 $close_at $this->getFriClosedAt();
  380.                 break;
  381.             case 'sat':
  382.                 $open_at $this->getSatOpenAt();
  383.                 $close_at $this->getSatClosedAt();
  384.                 break;
  385.             case 'sun':
  386.                 $open_at $this->getSunOpenAt();
  387.                 $close_at $this->getSunClosedAt();
  388.                 break;
  389.         }
  390.         if ($open_at == null or $close_at == null) {
  391.             return false;
  392.         }
  393.         if (date_format($open_at'H:i:s') <= $time and date_format($close_at'H:i:s') >= $time) {
  394.             return true;
  395.         } else {
  396.             return false;
  397.         }
  398.     }
  399.     public function getDeliveryCapacity(): ?int
  400.     {
  401.         return $this->deliveryCapacity;
  402.     }
  403.     public function setDeliveryCapacity(int $deliveryCapacity): self
  404.     {
  405.         $this->deliveryCapacity $deliveryCapacity;
  406.         return $this;
  407.     }
  408.     public function getNumberDeliveryMen(): ?int
  409.     {
  410.         return $this->numberDeliveryMen;
  411.     }
  412.     public function setNumberDeliveryMen(int $numberDeliveryMen): self
  413.     {
  414.         $this->numberDeliveryMen $numberDeliveryMen;
  415.         return $this;
  416.     }
  417.     public function getOrderCapacity(): ?int
  418.     {
  419.         return $this->getDeliveryCapacity() * $this->getNumberDeliveryMen();
  420.     }
  421.     public function isIsEnabled(): ?bool
  422.     {
  423.         return $this->is_enabled;
  424.     }
  425.     public function isIsEnabledProgramming(): ?bool
  426.     {
  427.         return $this->is_enabled_programming;
  428.     }
  429.     public function isIsEnabledReservation(): ?bool
  430.     {
  431.         return $this->is_enabled_reservation;
  432.     }
  433.     public function isIsActive(): ?bool
  434.     {
  435.         return $this->is_active;
  436.     }
  437.     public function getCodalmvent(): ?string
  438.     {
  439.         return $this->codalmvent;
  440.     }
  441.     public function setCodalmvent(string $codalmvent): self
  442.     {
  443.         $this->codalmvent $codalmvent;
  444.         return $this;
  445.     }
  446.     // ------------------------------
  447.     public function getServer(): ?string
  448.     {
  449.         return $this->server;
  450.     }
  451.     public function setServer(?string $server): self
  452.     {
  453.         $this->server $server;
  454.         return $this;
  455.     }
  456.     public function getServerDB(): ?string
  457.     {
  458.         return $this->server_db;
  459.     }
  460.     public function setServerDB(?string $server_db): self
  461.     {
  462.         $this->server_db $server_db;
  463.         return $this;
  464.     }
  465.     public function getServerUser(): ?string
  466.     {
  467.         return $this->server_user;
  468.     }
  469.     public function setServerUser(?string $server_user): self
  470.     {
  471.         $this->server_user $server_user;
  472.         return $this;
  473.     }
  474.     public function getServerPass(): ?string
  475.     {
  476.         return $this->server_pass;
  477.     }
  478.     public function setServerPass(?string $server_pass): self
  479.     {
  480.         if ($server_pass !== null && $server_pass !== "") {
  481.             // Asigna el valor encriptado solo si no es nulo ni vacío
  482.             $this->server_pass $server_pass// Aquí idealmente deberías llamar a tu servicio de encriptación si no se hace en otro lado
  483.         }
  484.         return $this;
  485.     }
  486. }