diff --git a/src/Entity/CommunityResource.php b/src/Entity/CommunityResource.php
index ca14bac..8d08339 100644
--- a/src/Entity/CommunityResource.php
+++ b/src/Entity/CommunityResource.php
@@ -5,6 +5,7 @@ namespace App\Entity;
use App\Enums\County;
use App\Enums\ResourceType;
use App\Enums\State;
+use App\Libs\Libs;
use App\Repository\CommunityResourceRepository;
use DateTime;
use DateTimeZone;
@@ -258,7 +259,7 @@ class CommunityResource
public function getContactCard(): ?string
{
- $formattedPhone = ($this->phone ? '(' . substr($this->phone, 0, 3) . ') ' . substr($this->phone, 3, 3) . '-' . substr($this->phone, 6) : '');
+ $formattedPhone = ($this->phone ? Libs::formatPhone($this->phone) : '');
return ($this->email ? "$this->email
" : '') .
($this->phone ? "$formattedPhone" : '');
}
@@ -309,8 +310,8 @@ class CommunityResource
return 'C';
}
- $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->monClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis'));
- if ($closeAt <= new DateTime()) {
+ $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->monClose->format('H:i:s'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
+ if ($closeAt <= new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE']))) {
return 'C';
}
@@ -347,8 +348,8 @@ class CommunityResource
return 'C';
}
- $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->tueClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis'));
- if ($closeAt <= new DateTime()) {
+ $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->tueClose->format('H:i:s'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
+ if ($closeAt <= new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE']))) {
return 'C';
}
@@ -385,9 +386,8 @@ class CommunityResource
return 'C';
}
- $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->wedClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis'));
-
- if ($closeAt <= new DateTime("now", new DateTimeZone('America/Indiana/Indianapolis'))) {
+ $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->wedClose->format('H:i:s'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
+ if ($closeAt <= new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE']))) {
return 'C';
}
@@ -424,8 +424,8 @@ class CommunityResource
return 'C';
}
- $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->thuClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis'));
- if ($closeAt <= new DateTime()) {
+ $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->thuClose->format('H:i:s'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
+ if ($closeAt <= new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE']))) {
return 'C';
}
@@ -462,8 +462,8 @@ class CommunityResource
return 'C';
}
- $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->friClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis'));
- if ($closeAt <= new DateTime()) {
+ $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->friClose->format('H:i:s'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
+ if ($closeAt <= new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE']))) {
return 'C';
}
@@ -500,8 +500,8 @@ class CommunityResource
return 'C';
}
- $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->satClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis'));
- if ($closeAt <= new DateTime()) {
+ $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->satClose->format('H:i:s'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
+ if ($closeAt <= new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE']))) {
return 'C';
}
@@ -538,8 +538,8 @@ class CommunityResource
return 'C';
}
- $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->sunClose->format('H:i:s'), new DateTimeZone('America/Indiana/Indianapolis'));
- if ($closeAt <= new DateTime()) {
+ $closeAt = new DateTime($this->today->format('Y-m-d') . ' ' . $this->sunClose->format('H:i:s'), new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
+ if ($closeAt <= new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE']))) {
return 'C';
}
@@ -548,7 +548,7 @@ class CommunityResource
public function getHours(): ?string
{
- $this->today = new DateTime('now', new DateTimeZone('America/Indiana/Indianapolis'));
+ $this->today = new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
switch ($this->today->format('w')) {
case 0:
return $this->sun();
@@ -672,4 +672,15 @@ class CommunityResource
return $this;
}
+
+ public function _toInfoWindow(): string
+ {
+ return <<name}
+ {$this->address}
+ {$this->city}, {$this->state->value} {$this->zip}
+ {$this->servicesAvailable}
+ {$this->getContactCard()}
+ EOL;
+ }
}