diff --git a/.env.dist b/.env.dist index 4e10dffc..87f679ac 100644 --- a/.env.dist +++ b/.env.dist @@ -42,3 +42,6 @@ POLICY_MOBILE=insertmobilepolicyidhere # OTP OTP_MODE=settotestorrandom + +# geofence +GEOFENCE=settotrueorfalse diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 075879bb..aefb8792 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -839,18 +839,24 @@ class APIController extends Controller $long = $req->request->get('long'); $lat = $req->request->get('lat'); - /* // geofence - $is_covered = $geo->isCovered($long, $lat); - if (!$is_covered) - { - // TODO: put geofence error message in config file somewhere - $res->setError(true) - ->setErrorMessage('Oops! Our service is limited to Metro Manila only. We will update you as soon as we are able to cover your area'); - return $res->getReturnResponse(); - } - */ + // check if geofence is on + $dotenv = new Dotenv(); + $dotenv->loadEnv(__DIR__.'/../../.env'); + $geo_flag = $_ENV['GEOFENCE']; + + if ($geo_flag == 'true') + { + $is_covered = $geo->isCovered($long, $lat); + if (!$is_covered) + { + // TODO: put geofence error message in config file somewhere + $res->setError(true) + ->setErrorMessage('Oops! Our service is limited to Metro Manila, Baguio, and Laguna only. We will update you as soon as we are able to cover your area'); + return $res->getReturnResponse(); + } + } $jo = new JobOrder(); $jo->setSource(TransactionOrigin::MOBILE_APP)