Add geofence checking to JO form. #463

This commit is contained in:
Korina Cordero 2020-08-10 09:03:21 +00:00
parent 87eee41958
commit ce70966117
3 changed files with 39 additions and 0 deletions

View file

@ -262,3 +262,8 @@ jo_cancel_reasons:
path: /ajax/jo_cancel_reasons
controller: App\Controller\JobOrderController::cancelReasons
methods: [GET]
jo_geofence:
path: /ajax/job-order/geofence
controller: App\Controller\JobOrderController::checkGeofence
methods: [GET]

View file

@ -23,6 +23,7 @@ use App\Service\MapTools;
use App\Service\MQTTClient;
use App\Service\APNSClient;
use App\Service\InventoryManager;
use App\Service\GeofenceTracker;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -1186,6 +1187,19 @@ class JobOrderController extends Controller
]);
}
// ajax call
public function checkGeofence(Request $req, GeofenceTracker $geo)
{
$lat = $req->query->get('lat');
$lng = $req->query->get('lng');
$is_covered = $geo->isCovered($lng, $lat);
return $this->json([
'is_covered' => $is_covered
]);
}
/**
* @Menu(selected="jo_autoassign")
*/

View file

@ -992,6 +992,26 @@ $(function() {
function selectPoint(lat, lng)
{
// check if point is in coverage area
$.ajax({
method: "GET",
url: "{{ url('jo_geofence') }}",
data: {
'lat': lat,
'lng': lng
}
}).done(function(response) {
if (response.is_covered === false)
{
console.log('Not in coverage area');
swal({
title: 'Warning!',
text: 'Our service is limited to some areas in Metro Manila, Laguna, and Baguio only. We will update you as soon as we are able to cover your area',
type: 'warning',
});
}
});
// clear markers
markerLayerGroup.clearLayers();