Added map to Building/Index
This commit is contained in:
@@ -341,4 +341,44 @@ class BuildingController extends mfBaseController {
|
||||
}
|
||||
|
||||
|
||||
protected function apiAction() {
|
||||
if(!$this->me->is(["Admin","netowner","pipeplanner"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
$do = $this->request->do;
|
||||
$data = [];
|
||||
|
||||
switch($do) {
|
||||
case "findBuildings":
|
||||
$return = $this->findBuildingsApi();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
|
||||
if(!is_array($return) || !count($return)) {
|
||||
$data = ["status" => "error"];
|
||||
$this->returnJson($data);
|
||||
}
|
||||
$data['status'] = "OK";
|
||||
$data['result'] = $return;
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
private function findBuildingsApi() {
|
||||
$buildings = [];
|
||||
$filter = $this->request->filter;
|
||||
|
||||
|
||||
$results = BuildingModel::search($filter);
|
||||
|
||||
foreach($results as $building) {
|
||||
$data = $building->data;
|
||||
$data->id = $building->id;
|
||||
$buildings[] = $data;
|
||||
}
|
||||
|
||||
return ["buildings" => $buildings];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user