Add geofence checking to JO form. #463
This commit is contained in:
parent
87eee41958
commit
ce70966117
3 changed files with 39 additions and 0 deletions
|
|
@ -262,3 +262,8 @@ jo_cancel_reasons:
|
||||||
path: /ajax/jo_cancel_reasons
|
path: /ajax/jo_cancel_reasons
|
||||||
controller: App\Controller\JobOrderController::cancelReasons
|
controller: App\Controller\JobOrderController::cancelReasons
|
||||||
methods: [GET]
|
methods: [GET]
|
||||||
|
|
||||||
|
jo_geofence:
|
||||||
|
path: /ajax/job-order/geofence
|
||||||
|
controller: App\Controller\JobOrderController::checkGeofence
|
||||||
|
methods: [GET]
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ use App\Service\MapTools;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
use App\Service\APNSClient;
|
use App\Service\APNSClient;
|
||||||
use App\Service\InventoryManager;
|
use App\Service\InventoryManager;
|
||||||
|
use App\Service\GeofenceTracker;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
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")
|
* @Menu(selected="jo_autoassign")
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -992,6 +992,26 @@ $(function() {
|
||||||
|
|
||||||
function selectPoint(lat, lng)
|
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
|
// clear markers
|
||||||
markerLayerGroup.clearLayers();
|
markerLayerGroup.clearLayers();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue