Merge branch 'ConstructionConsent/add-netzgebiet-id' into 'master'
- See merge request fronk/thetool!1297
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
class ConstructionConsent extends mfBaseModel {
|
||||
protected $forcestr = ["name", "ez", "kg", "gst", "gstnr", "usage_length"];
|
||||
private $project;
|
||||
private $netzgebiet;
|
||||
private $netzgebiet_id;
|
||||
private $termnination;
|
||||
private $adb_hausnummer;
|
||||
private $adb_strasse;
|
||||
@@ -138,6 +140,15 @@ class ConstructionConsent extends mfBaseModel {
|
||||
return $this->project;
|
||||
}
|
||||
|
||||
if($name == 'netzgebiet') {
|
||||
if(!$this->data->netzgebiet_id) return null;
|
||||
$netzgebiet = new ADBNetzgebiet($this->data->netzgebiet_id);
|
||||
if($netzgebiet->id) {
|
||||
$this->netzgebiet = $netzgebiet;
|
||||
}
|
||||
return $this->netzgebiet;
|
||||
}
|
||||
|
||||
if($name == "adb_hausnummer") {
|
||||
if(!$this->adb_hausnummer_id) return null;
|
||||
$hausnummer = new ADBHausnummer($this->adb_hausnummer_id);
|
||||
@@ -597,7 +608,7 @@ FROM ConstructionConsent
|
||||
if(array_key_exists("network", $filter)) {
|
||||
$network = FronkDB::singleton()->escape($filter["network"]);
|
||||
if($network) {
|
||||
$where .= " AND vh.netzgebiet_id=$network";
|
||||
$where .= " AND (vh.netzgebiet_id=$network OR ConstructionConsent.netzgebiet_id=$network)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -257,6 +257,7 @@ class ConstructionConsentController extends mfBaseController {
|
||||
|
||||
$data = [];
|
||||
$data["constructionconsentproject_id"] = $r->constructionconsentproject_id;
|
||||
$data["netzgebiet_id"] = $r->netzgebiet_id;
|
||||
$data["object_type"] = $r->object_type;
|
||||
$data["name"] = $r->name;
|
||||
$data["adb_hausnummer_id"] = $r->adb_hausnummer_id;
|
||||
@@ -531,6 +532,9 @@ class ConstructionConsentController extends mfBaseController {
|
||||
case "findAddress":
|
||||
$return = $this->findAddressApi();
|
||||
break;
|
||||
case "getNetzgebieteApi":
|
||||
$return = $this->getNetzgebieteApi();
|
||||
break;
|
||||
case "getRimoPlanPreview":
|
||||
$return = $this->getRimoPlanPreviewApi();
|
||||
break;
|
||||
@@ -1112,4 +1116,21 @@ class ConstructionConsentController extends mfBaseController {
|
||||
return true;
|
||||
}
|
||||
|
||||
private function getNetzgebieteApi() {
|
||||
$project_id = $this->request->project_id;
|
||||
if(!is_numeric($project_id) || $project_id < 1) self::sendError("Invalid project id");
|
||||
|
||||
$project = new ConstructionConsentProject($project_id);
|
||||
if(!$project->id) self::sendError("Project not found");
|
||||
|
||||
$parsedNetworks = array_map(function($network) {
|
||||
return [
|
||||
"value" => $network->id,
|
||||
"text" => $network->name,
|
||||
];
|
||||
}, array_values($project->adb_networks));
|
||||
|
||||
self::returnJson(["results" => $parsedNetworks]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user