add infowindow method for mapping, convert datetime creation to use company timezone

This commit is contained in:
Ryan Prather 2025-01-10 14:46:19 +00:00
parent e1e4c12801
commit 351cc7c3ac

View File

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