Skip to content

Commit

Permalink
Show nearby tickets
Browse files Browse the repository at this point in the history
Nearby tickets are within a bounding box of 0.0002 latitude

I think this is roughly 10 meters radius

Updates #376
  • Loading branch information
inghamn committed Sep 23, 2020
1 parent f232de8 commit 8502186
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crm/blocks/html/locations/locationInfo.inc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ if ($this->location || ($this->ticket->getLatitude() && $this->ticket->getLongit

$t = $this->ticket ? 1 : 0;

// Other tickets at this location
if ($tickets) {
$block = new Block('tickets/ticketList.inc', [
'ticketList' => $tickets,
Expand All @@ -71,6 +72,17 @@ if ($this->location || ($this->ticket->getLatitude() && $this->ticket->getLongit
if ($this->ticket) { $block->filterTicket = $this->ticket; }
echo $block->render('html', $this->template);
}

// Other nearby tickets
if ($this->ticket->getLatitude() && $this->ticket->getLongitude()) {
$bbox = TicketTable::nearbyBoundingBox($this->ticket->getLatitude(), $this->ticket->getLongitude());
$tickets = $table->find(['bbox'=>implode(',', $bbox)]);

$block->ticketList = $tickets;
$block->title = 'Nearby tickets';
$block->fields = ['status', 'enteredDate', 'location'];
echo $block->render('html', $this->template);
}
echo "
</section>
";
Expand Down
13 changes: 13 additions & 0 deletions crm/src/Application/Models/TicketTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,17 @@ public static function isValidSearch($request)
)) ? true : false;
}

/**
* Prepares a bounding box for finding nearby tickets
* @see self::find()
*/
public static function nearbyBoundingBox(float $lat, float $lon): array
{
return [
$lat - 0.0001,
$lon - 0.0001,
$lat + 0.0001,
$lon + 0.0001
];
}
}

0 comments on commit 8502186

Please sign in to comment.