Building/Form: pipe- and lineworker is updated when network is changed

This commit is contained in:
Frank Schubert
2021-07-20 19:49:39 +02:00
parent 8a8de499c6
commit 912fafade3
8 changed files with 132 additions and 13 deletions
@@ -13,7 +13,9 @@ class DashboardController extends mfBaseController {
protected function indexAction() {
}
/*
protected function testAction() {
$search = [
'street' => "Kastellfeldgasse 20",
@@ -25,5 +27,5 @@ class DashboardController extends mfBaseController {
$coords = Gmaps_Geocoding::getCoords($search);
var_dump($coords);
exit;
}
}*/
}
+51
View File
@@ -98,4 +98,55 @@ class NetworkController extends mfBaseController {
$this->layout()->setFlash("Netzgebiet erfolgreich gespeichert.", "success");
$this->redirect("Network", "Edit", ['id' => $new_id]);
}
protected function apiAction() {
$do = $this->request->do;
$data = [];
switch($do) {
case "getPermissions":
$return = $this->getPermissionsApi();
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 getPermissionsApi() {
if(!$this->request->types) {
return false;
}
$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;
}
$types = explode("|", $this->request->types);
$permissions = [];
$nas = NetworkAddressModel::search(['network_id' => $network_id, "addresstype" => $types]);
foreach($nas as $na) {
if(!array_key_exists($na->type, $permissions)) {
$permissions[$na->type] = [];
}
$address = new Address($na->address_id);
$permissions[$na->type][$na->address_id] = str_replace(["\r","\n"]," ",$address->getCompanyOrName());
}
return ["permissions" => $permissions];
}
}
@@ -117,6 +117,7 @@ class NetworkAddressModel {
$in = [];
foreach(TT_ROLES as $role) {
if(in_array($role, $at)) {
$role = $db->escape($role);
$in[] = "NetworkAddress.type = '$role'";
}
}