Sections dropdown is updated when changing network
This commit is contained in:
@@ -84,4 +84,44 @@ class NetworksectionController extends mfBaseController {
|
||||
$this->layout()->setFlash("Bauabschnitt gelöscht", "success");
|
||||
$this->redirect("Network", "Index", [], "view=sections&net=".$network_id);
|
||||
}
|
||||
|
||||
protected function apiAction() {
|
||||
$do = $this->request->do;
|
||||
$data = [];
|
||||
|
||||
switch($do) {
|
||||
case "getSections":
|
||||
$return = $this->getSectionsApi();
|
||||
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 getSectionsApi() {
|
||||
$network_id = $this->request->network_id;
|
||||
if(!is_numeric($network_id) || $network_id < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$network = new Network($network_id);
|
||||
if(!$network->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sections = NetworksectionModel::search(['network_id' => $network_id]);
|
||||
$return = [];
|
||||
foreach($sections as $section) {
|
||||
$return[$section->id] = $section->network->name." - ".$section->name;
|
||||
}
|
||||
return ["sections" => $return];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user