hasPermission($customer)) throw new Exception(__("No permission.")); switch($action) { case "get-locations": $nvp = [ "customer_id" => $customer->id, "archived" => 0, "closed" => 0 ]; $id = http::value("id", "int"); $internal_id = http::value("internal_id", "trim"); $name = http::value("name", "trim"); $legal_entity_name = http::value("legal_entity_name", "trim"); $include_archived = http::value("include_archived", "int"); $include_closed = http::value("include_closed", "int"); $hide_tested = Http::value("hide_tested", "int"); $min_date = http::value("min_date"); $max_date = http::value("max_date"); if($id) $nvp["id"] = $id; if($internal_id) $nvp["internal_id"] = db::escape($internal_id); if($name) $nvp["name"] = Constraint::contains($name); if($legal_entity_name) $nvp["$legal_entity_name"] = Constraint::contains($legal_entity_name); if($include_archived) unset($nvp["archived"]); if($include_closed) unset($nvp["closed"]); $locations = Location::query($nvp, ["sort" => "name", "order" => "asc"]); $output = LocationHelper::getMarkerDataForLocations($locations, $min_date, $max_date); if($hide_tested) { $output = array_filter($output, static function(array $result) { return !isset($result["test"]); }); $output = array_values($output); } JSON::success([ "locations" => $output ]); break; }