|
|
@@ -11,14 +11,19 @@ use Searches\LocationSearch;
|
|
|
JSON::header();
|
|
|
|
|
|
$customer = Customer::get($id);
|
|
|
-if(!$customer) JSON::fail("Customer not found.");
|
|
|
+if(!$customer) {
|
|
|
+ JSON::fail("Customer not found.");
|
|
|
+}
|
|
|
|
|
|
-if(!Core::$user->hasPermission($customer)) throw new Exception(__("No permission."));
|
|
|
+$user = Core::$user;
|
|
|
+if(!$user->hasPermission($customer)) {
|
|
|
+ throw new RuntimeException(__("No permission."));
|
|
|
+}
|
|
|
|
|
|
switch($action) {
|
|
|
case "get-locations":
|
|
|
|
|
|
- $search = new LocationSearch($customer);
|
|
|
+ $search = new LocationSearch($customer, $user);
|
|
|
|
|
|
$id = http::value("id", "int");
|
|
|
$internal_id = http::value("internal_id", "trim");
|
|
|
@@ -42,7 +47,7 @@ switch($action) {
|
|
|
|
|
|
$locations = $search->run();
|
|
|
|
|
|
- $output = LocationHelper::getMarkerDataForLocations($locations, $min_date, $max_date);
|
|
|
+ $output = LocationHelper::getMarkerDataForLocations($locations, $min_date, $max_date, ["user" => $user]);
|
|
|
|
|
|
JSON::success([
|
|
|
"locations" => $output
|