first draft of case addresses and itineraries

This commit is contained in:
2024-12-31 23:01:37 +00:00
parent 1b5ca4bd34
commit 6c340b4229
14 changed files with 1272 additions and 8 deletions

View File

@ -0,0 +1,194 @@
<?php
namespace App\Entity;
use App\Repository\CaseItineraryRepository;
use DateInterval;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;
use Symfony\UX\Map\Point;
#[ORM\Entity(repositoryClass: CaseItineraryRepository::class)]
class CaseItinerary
{
#[ORM\Id]
#[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
private ?Uuid $id = null;
#[ORM\Column(type: Types::TIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $departure = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?Location $originLocation = null;
#[ORM\Column(type: Types::TIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $arrival = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?Location $destLocation = null;
#[ORM\Column]
private ?bool $caseMileage = null;
#[ORM\Column]
private ?DateInterval $duration = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?MemberCase $memberCase = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $date = null;
#[ORM\Column(nullable: true)]
private ?float $distance = null;
#[ORM\Column(nullable: true)]
private ?array $gpsRoute = null;
public function getId(): ?Uuid
{
return $this->id;
}
public function getDeparture(): ?\DateTimeInterface
{
return $this->departure;
}
public function setDeparture(?\DateTimeInterface $departure): static
{
$this->departure = $departure;
return $this;
}
public function getOriginLocation(): ?Location
{
return $this->originLocation;
}
public function setOriginLocation(?Location $originLocation): static
{
$this->originLocation = $originLocation;
return $this;
}
public function getArrival(): ?\DateTimeInterface
{
return $this->arrival;
}
public function setArrival(?\DateTimeInterface $arrival): static
{
$this->arrival = $arrival;
return $this;
}
public function getDestLocation(): ?Location
{
return $this->destLocation;
}
public function setDestLocation(?Location $destLocation): static
{
$this->destLocation = $destLocation;
return $this;
}
public function isCaseMileage(): ?bool
{
return $this->caseMileage;
}
public function setCaseMileage(bool $caseMileage): static
{
$this->caseMileage = $caseMileage;
return $this;
}
public function getDuration(): ?DateInterval
{
return $this->duration;
}
public function setDuration(?DateInterval $duration): static
{
//$this->calcDuration();
$this->duration = $duration;
return $this;
}
public function calcDuration()
{
$this->duration = $this->departure - $this->arrival;
}
public function getMemberCase(): ?MemberCase
{
return $this->memberCase;
}
public function setMemberCase(?MemberCase $memberCase): static
{
$this->memberCase = $memberCase;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): static
{
$this->date = $date;
return $this;
}
public function getDistance(): ?float
{
return $this->distance;
}
public function setDistance(?float $distance): static
{
$this->distance = $distance;
return $this;
}
public function getGpsRoute(): ?array
{
return $this->gpsRoute;
}
public function setGpsRoute(?array $gpsRoute): static
{
$this->gpsRoute = $gpsRoute;
return $this;
}
public function getGPSPolyLines(): array
{
$points = [];
foreach ($this->gpsRoute as $route) {
$points[] = new Point($route['lat'], $route['lon']);
}
return $points;
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Entity;
use App\Repository\CaseLocationRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: CaseLocationRepository::class)]
class CaseLocation
{
#[ORM\Id]
#[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
private ?Uuid $id = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?MemberCase $memberCase = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?Location $location = null;
public function getId(): ?int
{
return $this->id;
}
public function getMemberCase(): ?MemberCase
{
return $this->memberCase;
}
public function setMemberCase(?MemberCase $memberCase): static
{
$this->memberCase = $memberCase;
return $this;
}
public function getLocation(): ?Location
{
return $this->location;
}
public function setLocation(?Location $location): static
{
$this->location = $location;
return $this;
}
}

140
src/Entity/Location.php Normal file
View File

@ -0,0 +1,140 @@
<?php
namespace App\Entity;
use App\Enums\State;
use App\Repository\LocationRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: LocationRepository::class)]
class Location
{
#[ORM\Id]
#[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
private ?Uuid $id = null;
#[ORM\Column(length: 45)]
private ?string $name = null;
#[ORM\Column(length: 255)]
private ?string $address = null;
#[ORM\Column(length: 100, nullable: true)]
private ?string $city = null;
#[ORM\Column(length: 10, nullable: true)]
private ?State $state = null;
#[ORM\Column(nullable: true)]
private ?int $zip = null;
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 6, nullable: true)]
private ?string $lat = null;
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 6, nullable: true)]
private ?string $lon = null;
public function getId(): ?Uuid
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): static
{
$this->address = $address;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): static
{
$this->city = $city;
return $this;
}
public function getState(): ?State
{
return $this->state;
}
public function setState(?State $state): static
{
$this->state = $state;
return $this;
}
public function getZip(): ?int
{
return $this->zip;
}
public function setZip(?int $zip): static
{
$this->zip = $zip;
return $this;
}
public function getFormattedAddress(): string
{
return "{$this->address}<br/>{$this->city}, {$this->state->value} {$this->zip}";
}
public function getLat(): ?string
{
return $this->lat;
}
public function setLat(?string $lat): static
{
$this->lat = $lat;
return $this;
}
public function getLon(): ?string
{
return $this->lon;
}
public function setLon(?string $lon): static
{
$this->lon = $lon;
return $this;
}
public function __toString(): string
{
return "{$this->address} {$this->city}, {$this->state->value} {$this->zip}";
}
}