diff --git a/Layout/default/ConstructionConsentProject/Form.php b/Layout/default/ConstructionConsentProject/Form.php
new file mode 100644
index 000000000..776a59b50
--- /dev/null
+++ b/Layout/default/ConstructionConsentProject/Form.php
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Layout/default/ConstructionConsentProject/Index.php b/Layout/default/ConstructionConsentProject/Index.php
new file mode 100644
index 000000000..0867b7e33
--- /dev/null
+++ b/Layout/default/ConstructionConsentProject/Index.php
@@ -0,0 +1,112 @@
+getUrl($Mod,"Index");
+$pagination_baseurl_params = ["filter" => $filter];
+$pagination_entity_name = "Zustimmungserklärungsprojekte";
+?>
+
+
+
+
+
+
+
+
+
Zustimmmungserklärungen
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | Projektname |
+ Netzgebiete |
+ |
+
+
+
+ | =$project->name?> |
+
+ networks) && count($project->networks)): ?>
+
+ networks as $network): ?>
+ - =$network->adb_netzgebiet->name?>
+
+
+
+ |
+
+ $project->id])?>">
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/ConstructionConsentFile/ConstructionConsentFile.php b/application/ConstructionConsentFile/ConstructionConsentFile.php
new file mode 100644
index 000000000..8a04cf568
--- /dev/null
+++ b/application/ConstructionConsentFile/ConstructionConsentFile.php
@@ -0,0 +1,180 @@
+$name == null) {
+
+ if($name == "creator") {
+ $user = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
+ if($user) {
+ $this->creator = $user;
+ return $this->creator;
+ }
+ $this->creator = new User($this->create_by);
+ if($this->creator->id) {
+ mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
+ }
+ return $this->creator;
+ }
+
+ if($name == "editor") {
+ $this->editor = new User($this->edit_by);
+ return $this->editor;
+ }
+
+ $classname = ucfirst($name);
+ $idfield = $name."_id";
+ $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
+ if(!$this->$name) {
+ $this->$name = new $classname($this->$idfield);
+ }
+
+ if($this->$name->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
+ return $this->$name;
+ } else {
+ return null;
+ }
+ }
+
+ return $this->$name;
+ }
+
+ /********************************
+ * Begin static Model functions
+ */
+
+ public static function create(Array $data) {
+ $model = new ConstructionConsentFile();
+
+ $table_fields = [
+ "constructionconsent_id", "file_id", "filename",
+ "create_by","edit_by","create","edit"
+ ];
+
+ foreach($data as $field => $value) {
+ if(in_array($field, $table_fields)) {
+ $model->$field = $value;
+ }
+ }
+
+ $me = new User();
+ $me->loadMe();
+
+ if($model->create_by === null) {
+ $model->create_by = $me->id;
+ }
+ if($model->edit_by === null) {
+ $model->edit_by = $me->id;
+ }
+
+ return $model;
+ }
+
+ public static function getAll() {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("ConstructionConsentFile", "*", "1 = 1 ORDER BY file_id");
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[] = new ConstructionConsentFile($data);
+ }
+ }
+ return $items;
+
+ }
+
+ public static function getFirst($filter = []) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $res = $db->select("ConstructionConsentFile", "*", "$where ORDER BY file_id LIMIT 1");
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new ConstructionConsentFile($data);
+ if($item->id) {
+ return $item;
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static function count($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT COUNT(*) as cnt FROM `ConstructionConsentFile`
+ WHERE $where
+ ";
+
+ mfLoghandler::singleton()->debug($sql);
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ return $data->cnt;
+ }
+ return 0;
+ }
+
+ public static function search($filter, $limit=false) {
+ $items = [];
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+
+ $sql = "SELECT ConstructionConsentFile.* FROM `ConstructionConsentFile`
+ WHERE $where
+ ORDER BY file_id
+ ";
+
+ mfLoghandler::singleton()->debug($sql);
+ if(is_array($limit) && count($limit)) {
+ if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
+ } elseif(is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['count'];
+ }
+ }
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[] = new ConstructionConsentFile($data);
+ }
+ }
+ return $items;
+ }
+
+ private static function getSqlFilter($filter) {
+ $where = "1=1 ";
+
+ $db = FronkDB::singleton();
+
+ //var_dump($filter);exit;
+ if(array_key_exists("mailtemplate_id", $filter)) {
+ $mailtemplate_id = $filter['mailtemplate_id'];
+ if(is_numeric($mailtemplate_id)) {
+ $where .= " AND ConstructionConsentFile.`mailtemplate_id` = $mailtemplate_id";
+ }
+ }
+
+ if(array_key_exists("file_id", $filter)) {
+ $file_id = $filter['file_id'];
+ if(is_numeric($file_id)) {
+ $where .= " AND ConstructionConsentFile.`file_id` = $file_id";
+ }
+ }
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+}
\ No newline at end of file
diff --git a/application/ConstructionConsentJournal/ConstructionConsentJournal.php b/application/ConstructionConsentJournal/ConstructionConsentJournal.php
new file mode 100644
index 000000000..a0e97f73f
--- /dev/null
+++ b/application/ConstructionConsentJournal/ConstructionConsentJournal.php
@@ -0,0 +1,167 @@
+$name == null) {
+
+
+ $classname = ucfirst($name);
+ $idfield = $name."_id";
+ $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
+ if(!$this->$name) {
+ $this->$name = new $classname($this->$idfield);
+ }
+
+ if($this->$name->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
+ return $this->$name;
+ } else {
+ return null;
+ }
+
+ }
+
+ return $this->$name;
+ }
+
+ /********************************
+ * Begin static Model functions
+ */
+
+ public static function create(Array $data) {
+ $model = new ConstructionConsentJournal();
+
+ $table_fields = [
+ "constructionconsent_id", "type", "value", "text",
+ "create_by","edit_by","create","edit"
+ ];
+
+ foreach($data as $field => $value) {
+ if(in_array($field, $table_fields)) {
+ $model->$field = $value;
+ }
+ }
+
+ $me = new User();
+ $me->loadMe();
+
+ if($model->create_by === null) {
+ $model->create_by = $me->id;
+ }
+ if($model->edit_by === null) {
+ $model->edit_by = $me->id;
+ }
+
+ return $model;
+ }
+
+ public static function getAll() {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("ConstructionConsentJournal", "*", "1 = 1 ORDER BY `create`");
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[] = new ConstructionConsentJournal($data);
+ }
+ }
+ return $items;
+
+ }
+
+ public static function getFirst($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT * FROM ConstructionConsentJournal
+ WHERE $where
+ ORDER BY `create` LIMIT 1";
+ //var_dump($sql);exit;
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new ConstructionConsentJournal($data);
+ if($item->id) {
+ return $item;
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static function count($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT COUNT(*) as cnt FROM ConstructionConsentJournal
+ WHERE $where";
+
+ //mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ return $data->cnt;
+ }
+ return 0;
+ }
+
+ public static function search($filter, $limit = false, $order = false) {
+ //var_dump($filter);exit;
+ $items = [];
+
+ if(!$order) {
+ $order = "`create` ASC";
+ }
+
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT * FROM ConstructionConsentJournal
+ WHERE $where
+ ORDER BY $order";
+
+ if(is_array($limit) && count($limit)) {
+ if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
+ } elseif(is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['count'];
+ }
+ }
+
+ mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[$data->id] = new ConstructionConsentJournal($data);
+ }
+ }
+
+ return $items;
+ }
+
+ private static function getSqlFilter($filter) {
+ $where = "1=1 ";
+
+ if(array_key_exists("constructionconsent_id", $filter)) {
+ $constructionconsent_id = $filter['constructionconsent_id'];
+ if(is_numeric($constructionconsent_id)) {
+ $where .= " AND constructionconsent_id=$constructionconsent_id";
+ }
+ }
+
+
+
+ if(array_key_exists("add-where", $filter)) {
+ $where .= " ".$filter['add-where'];
+ }
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+
+}
diff --git a/application/ConstructionConsentNetwork/ConstructionConsentNetwork.php b/application/ConstructionConsentNetwork/ConstructionConsentNetwork.php
new file mode 100644
index 000000000..eb7e36291
--- /dev/null
+++ b/application/ConstructionConsentNetwork/ConstructionConsentNetwork.php
@@ -0,0 +1,187 @@
+$name == null) {
+
+ if($name == "adb_netzgebiet") {
+ $netzgebiet = new ADBNetzgebiet($this->adb_netzgebiet_id);
+ if(!$netzgebiet->id) {
+ return null;
+ }
+ $this->adb_netzgebiet = $netzgebiet;
+ return $this->adb_netzgebiet;
+ }
+
+ $classname = ucfirst($name);
+ $idfield = $name."_id";
+ $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
+ if(!$this->$name) {
+ $this->$name = new $classname($this->$idfield);
+ }
+
+ if($this->$name->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
+ return $this->$name;
+ } else {
+ return null;
+ }
+
+ }
+
+ return $this->$name;
+ }
+
+ /********************************
+ * Begin static Model functions
+ */
+
+ public static function create(Array $data) {
+ $model = new ConstructionConsentNetwork();
+
+ $table_fields = [
+ "constructionconsentproject_id", "adb_netzgebiet_id",
+ "create_by","edit_by","create","edit"
+ ];
+
+ foreach($data as $field => $value) {
+ if(in_array($field, $table_fields)) {
+ $model->$field = $value;
+ }
+ }
+
+ $me = new User();
+ $me->loadMe();
+
+ if($model->create_by === null) {
+ $model->create_by = $me->id;
+ }
+ if($model->edit_by === null) {
+ $model->edit_by = $me->id;
+ }
+
+ return $model;
+ }
+
+ public static function getAll() {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("ConstructionConsentNetwork", "*", "1 = 1 ORDER BY adb_netzgebiet_id");
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[] = new ConstructionConsentNetwork($data);
+ }
+ }
+ return $items;
+
+ }
+
+ public static function getFirst($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT ConstructionConsentNetwork.* FROM ConstructionConsentNetwork
+ WHERE $where
+ ORDER BY adb_netzgebiet_id
+ LIMIT 1";
+ //var_dump($sql);exit;
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new ConstructionConsentNetwork($data);
+ if($item->id) {
+ return $item;
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static function count($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT COUNT(*) as cnt FROM ConstructionConsentNetwork
+ WHERE $where
+ ORDER BY adb_netzgebiet_id
+ ";
+
+ //mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ return $data->cnt;
+ }
+ return 0;
+ }
+
+ public static function search($filter, $limit = false, $order = false) {
+ //var_dump($filter);exit;
+ $items = [];
+
+ if(!$order) {
+ $order = "adb_netzgebiet_id ASC";
+ }
+
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT ConstructionConsentNetwork.* FROM ConstructionConsentNetwork
+ WHERE $where
+ GROUP BY ConstructionConsentNetwork.id
+ ORDER BY $order";
+
+ if(is_array($limit) && count($limit)) {
+ if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
+ } elseif(is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['count'];
+ }
+ }
+
+ mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[$data->id] = new ConstructionConsentNetwork($data);
+ }
+ }
+
+ return $items;
+ }
+
+ private static function getSqlFilter($filter) {
+ $where = "1=1 ";
+
+
+
+ if(array_key_exists("constructionconsentproject_id", $filter)) {
+ $constructionconsentproject_id = $filter["constructionconsentproject_id"];
+ if(is_numeric($constructionconsentproject_id)) {
+ $where .= " AND constructionconsentproject_id='$constructionconsentproject_id'";
+ }
+ }
+
+ if(array_key_exists("adb_netzgebiet_id", $filter)) {
+ $adb_netzgebiet_id = $filter["adb_netzgebiet_id"];
+ if(is_numeric($adb_netzgebiet_id)) {
+ $where .= " AND adb_netzgebiet_id='$adb_netzgebiet_id'";
+ }
+ }
+
+
+ if(array_key_exists("add-where", $filter)) {
+ $where .= " ".$filter['add-where'];
+ }
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+}
\ No newline at end of file
diff --git a/application/ConstructionConsentOwner/ConstructionConsentOwner.php b/application/ConstructionConsentOwner/ConstructionConsentOwner.php
new file mode 100644
index 000000000..eb381dd89
--- /dev/null
+++ b/application/ConstructionConsentOwner/ConstructionConsentOwner.php
@@ -0,0 +1,167 @@
+$name == null) {
+
+
+ $classname = ucfirst($name);
+ $idfield = $name."_id";
+ $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
+ if(!$this->$name) {
+ $this->$name = new $classname($this->$idfield);
+ }
+
+ if($this->$name->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
+ return $this->$name;
+ } else {
+ return null;
+ }
+
+ }
+
+ return $this->$name;
+ }
+
+ /********************************
+ * Begin static Model functions
+ */
+
+ public static function create(Array $data) {
+ $model = new ConstructionConsentOwner();
+
+ $table_fields = [
+ "constructionconsent_id", "owner_name", "owner_street", "owner_zip", "owner_city", "owner_country", "owner_phone",
+ "owner_fax", "owner_email", "status", "result", "create_by","edit_by","create","edit"
+ ];
+
+ foreach($data as $field => $value) {
+ if(in_array($field, $table_fields)) {
+ $model->$field = $value;
+ }
+ }
+
+ $me = new User();
+ $me->loadMe();
+
+ if($model->create_by === null) {
+ $model->create_by = $me->id;
+ }
+ if($model->edit_by === null) {
+ $model->edit_by = $me->id;
+ }
+
+ return $model;
+ }
+
+ public static function getAll() {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("ConstructionConsentOwner", "*", "1 = 1 ORDER BY owner_name");
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[] = new ConstructionConsentOwner($data);
+ }
+ }
+ return $items;
+
+ }
+
+ public static function getFirst($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT * FROM ConstructionConsentOwner
+ WHERE $where
+ ORDER BY adb_hausnummer_id LIMIT 1";
+ //var_dump($sql);exit;
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new ConstructionConsentOwner($data);
+ if($item->id) {
+ return $item;
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static function count($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT COUNT(*) as cnt FROM ConstructionConsentOwner
+ WHERE $where";
+
+ //mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ return $data->cnt;
+ }
+ return 0;
+ }
+
+ public static function search($filter, $limit = false, $order = false) {
+ //var_dump($filter);exit;
+ $items = [];
+
+ if(!$order) {
+ $order = "owner_name ASC";
+ }
+
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT * FROM ConstructionConsentOwner
+ WHERE $where
+ ORDER BY $order";
+
+ if(is_array($limit) && count($limit)) {
+ if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
+ } elseif(is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['count'];
+ }
+ }
+
+ mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[$data->id] = new ConstructionConsentOwner($data);
+ }
+ }
+
+ return $items;
+ }
+
+ private static function getSqlFilter($filter) {
+ $where = "1=1 ";
+
+ if(array_key_exists("constructionconsent_id", $filter)) {
+ $constructionconsent_id = $filter['constructionconsent_id'];
+ if(is_numeric($constructionconsent_id)) {
+ $where .= " AND constructionconsent_id=$constructionconsent_id";
+ }
+ }
+
+
+
+ if(array_key_exists("add-where", $filter)) {
+ $where .= " ".$filter['add-where'];
+ }
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+
+}
diff --git a/application/ConstructionConsentProject/ConstructionConsentProject.php b/application/ConstructionConsentProject/ConstructionConsentProject.php
new file mode 100644
index 000000000..0d6397eb3
--- /dev/null
+++ b/application/ConstructionConsentProject/ConstructionConsentProject.php
@@ -0,0 +1,208 @@
+$name == null) {
+
+ if($name == "consents") {
+ $consents = ConstructionConsent::search(["constructionconsentproject_id" => $this->id]);
+ if(!$consents) {
+ return [];
+
+ }
+ $this->consents = $consents;
+ return $this->consents;
+ }
+
+ if($name == "networks") {
+ $networks = ConstructionConsentNetwork::search(["constructionconsentproject_id" => $this->id]);
+ if(!$networks) {
+ return [];
+ }
+ foreach($networks as $network) {
+ $this->networks[$network->id] = $network;
+ }
+ return $this->networks;
+ }
+
+ if($name == "adb_networks") {
+ $networks = ConstructionConsentNetwork::search(["constructionconsentproject_id" => $this->id]);
+ if(!$networks) {
+ return [];
+ }
+ foreach($networks as $network) {
+ $this->networks[$network->adb_netzgebiet->id] = $network->adb_netzgebiet_id;
+ }
+ return $this->networks;
+ }
+
+ $classname = ucfirst($name);
+ $idfield = $name."_id";
+ $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
+ if(!$this->$name) {
+ $this->$name = new $classname($this->$idfield);
+ }
+
+ if($this->$name->id) {
+ mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
+ return $this->$name;
+ } else {
+ return null;
+ }
+
+ }
+
+ return $this->$name;
+ }
+
+ /********************************
+ * Begin static Model functions
+ */
+
+ public static function create(Array $data) {
+ $model = new ConstructionConsentProject();
+
+ $table_fields = [
+ "name", "note",
+ "create_by","edit_by","create","edit"
+ ];
+
+ foreach($data as $field => $value) {
+ if(in_array($field, $table_fields)) {
+ $model->$field = $value;
+ }
+ }
+
+ $me = new User();
+ $me->loadMe();
+
+ if($model->create_by === null) {
+ $model->create_by = $me->id;
+ }
+ if($model->edit_by === null) {
+ $model->edit_by = $me->id;
+ }
+
+ return $model;
+ }
+
+ public static function getAll() {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("ConstructionConsentProject", "*", "1 = 1 ORDER BY name");
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[] = new ConstructionConsentProject($data);
+ }
+ }
+ return $items;
+
+ }
+
+ public static function getFirst($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT ConstructionConsentProject.* FROM ConstructionConsentProject
+ LEFT JOIN ConstructionConsentNetwork ON (ConstructionConsentNetwork.constructionconsentproject_id = ConstructionConsentNetwork.id)
+ WHERE $where
+ GROUP BY ConstructionConsentProject.id
+ ORDER BY name
+ LIMIT 1";
+ //var_dump($sql);exit;
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new ConstructionConsentProject($data);
+ if($item->id) {
+ return $item;
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static function count($filter) {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT COUNT(*) as cnt FROM ConstructionConsentProject
+ LEFT JOIN ConstructionConsentNetwork ON (ConstructionConsentNetwork.constructionconsentproject_id = ConstructionConsentNetwork.id)
+ WHERE $where
+ GROUP BY ConstructionConsentProject.id
+ ";
+
+ //mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ return $data->cnt;
+ }
+ return 0;
+ }
+
+ public static function search($filter, $limit = false, $order = false) {
+ //var_dump($filter);exit;
+ $items = [];
+
+ if(!$order) {
+ $order = "name ASC";
+ }
+
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $sql = "SELECT ConstructionConsentProject.* FROM ConstructionConsentProject
+ LEFT JOIN ConstructionConsentNetwork ON (ConstructionConsentNetwork.constructionconsentproject_id = ConstructionConsentNetwork.id)
+ WHERE $where
+ GROUP BY ConstructionConsentProject.id
+ ORDER BY $order";
+
+ if(is_array($limit) && count($limit)) {
+ if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
+ } elseif(is_numeric($limit['count'])) {
+ $sql .= " LIMIT ".$limit['count'];
+ }
+ }
+
+ mfLoghandler::singleton()->debug($sql);
+
+ $res = $db->query($sql);
+ if($db->num_rows($res)) {
+ while($data = $db->fetch_object($res)) {
+ $items[$data->id] = new ConstructionConsentProject($data);
+ }
+ }
+
+ return $items;
+ }
+
+ private static function getSqlFilter($filter) {
+ $where = "1=1 ";
+
+ if(array_key_exists("name", $filter)) {
+ $name = FronkDB::singleton()->escape($filter["name"]);
+ if($name) {
+ $where .= " AND name='$name'";
+ }
+ }
+
+
+
+ if(array_key_exists("add-where", $filter)) {
+ $where .= " ".$filter['add-where'];
+ }
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+}
\ No newline at end of file
diff --git a/application/ConstructionConsentProject/ConstructionConsentProjectController.php b/application/ConstructionConsentProject/ConstructionConsentProjectController.php
new file mode 100644
index 000000000..f342b6161
--- /dev/null
+++ b/application/ConstructionConsentProject/ConstructionConsentProjectController.php
@@ -0,0 +1,130 @@
+needlogin = true;
+ $me = new User();
+ $me->loadMe();
+ $this->me = $me;
+ $this->layout()->set("me", $me);
+
+ if (!$me->is(["Admin"])) {
+ $this->redirect("Dashboard");
+ }
+ }
+
+ protected function indexAction() : void {
+ $this->layout()->setTemplate("ConstructionConsentProject/Index");
+
+ $projects = ConstructionConsentProject::getAll();
+ $this->layout()->set("projects", $projects);
+
+ }
+
+ protected function addAction() {
+ $this->layout()->setTemplate("ConstructionConsentProject/Form");
+
+
+ }
+
+ protected function editAction() {
+ $id = $this->request->id;
+ if(!$id || $id < 1) {
+ $this->layout()->setFlash("Projekt nicht gefunden", "error");
+ $this->redirect("ConstructionConsentProject");
+ }
+
+ $project = new ConstructionConsentProject($id);
+ if(!$project->id) {
+ $this->layout()->setFlash("Projekt nicht gefunden", "error");
+ $this->redirect("ConstructionConsentProject");
+ }
+
+ $this->layout()->set("project", $project);
+ return $this->addAction();
+ }
+
+ protected function saveAction() {
+ if(!$this->me->is("Admin")) {
+ $this->redirect("ConstructionConsent");
+ }
+
+ $r = $this->request;
+ //var_dump($r->get());exit;
+ $id = $r->id;
+ if(is_numeric($id) && $id > 0) {
+ $mode = "edit";
+ $project = new ConstructionConsentProject($id);
+ if(!$project->id) {
+ $this->layout()->setFlash("Zustimmungserklärungsprojekt nicht gefunden", "error");
+ $this->redirect("ConstructionConsentProject");
+ }
+ } else {
+ $id = false;
+ $mode = "add";
+ }
+
+ $data = [];
+ $data["name"] = $r->name;
+
+ if(!$r->name) {
+ $this->layout()->setFlash("Bitte alle erforderlichen Felder ausfüllen", "error");
+ $this->redirect("ConstructionConsentProject");
+ }
+ if(!is_array($r->adb_netzgebiet_id) || !count($r->adb_netzgebiet_id)) {
+ $this->layout()->setFlash("Bitte alle erforderlichen Felder ausfüllen", "error");
+ $this->redirect("ConstructionConsentProject");
+ }
+
+ $netzgebiete = [];
+
+ foreach($r->adb_netzgebiet_id as $netzgebiet_id) {
+ $netzgebiet = new ADBNetzgebiet($netzgebiet_id);
+ if(!$netzgebiet->id) continue;
+
+ $netzgebiete[] = $netzgebiet_id;
+ }
+
+ if($mode == "add") {
+ $project = ConstructionConsentProject::create($data);
+ } else {
+ $project->update($data);
+ }
+
+ if(!$project->save()) {
+ $this->layout()->setFlash("Fehler beim Speichern", "error");
+ if($mode == "add") {
+ $this->redirect("ConstructionConsentProject", "add");
+ } else {
+ $this->redirect("ConstructionConsentProject", "edit", ["id" => $project->id]);
+ }
+ }
+
+ //save networks
+ foreach($netzgebiete as $netzgebiet_id) {
+ $ccn = ConstructionConsentNetwork::getFirst(["constructionconsentproject_id" => $project->id, "adb_netzgebiet_id" => $netzgebiet_id]);
+ if(!$ccn) {
+ $ccn = ConstructionConsentNetwork::create([
+ "constructionconsentproject_id" => $project->id,
+ "adb_netzgebiet_id" => $netzgebiet_id
+ ]);
+ $ccn->save();
+ }
+ }
+
+ foreach(ConstructionConsentNetwork::search(["constructionconsentproject_id" => $project->id]) as $ccn) {
+ if(!in_array($ccn->adb_netzgebiet_id, $netzgebiete)) {
+ $ccn->delete();
+ }
+ }
+
+ $this->layout()->setFlash("Zustimmungserklärungsprojekt erfolgreich gespeichert", "success");
+ $this->redirect("ConstructionConsentProject");
+
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/db/migrations/20241210131036_create_construction_consent_project.php b/db/migrations/20241210131036_create_construction_consent_project.php
new file mode 100644
index 000000000..f6eb72b44
--- /dev/null
+++ b/db/migrations/20241210131036_create_construction_consent_project.php
@@ -0,0 +1,141 @@
+getEnvironment() == "thetool") {
+ $ccp = $this->table("ConstructionConsentProject");
+ $ccp->addColumn("name", "string", ["null" => false, "limit" => 255]);
+ $ccp->addColumn("sender_name", "string", ["null" => false, "limit" => 64]);
+ $ccp->addColumn("sender_email", "string", ["null" => false, "limit" => 64]);
+ $ccp->addColumn("sender_reply_to", "string", ["null" => false, "limit" => 64]);
+ $ccp->addColumn("email", "string", ["null" => false, "limit" => 64]);
+ $ccp->addColumn("phone", "string", ["null" => false, "limit" => 64]);
+ $ccp->addColumn("note", "text", ["null" => true, "default" => null]);
+ $ccp->addColumn("create_by", "integer", ["null" => false]);
+ $ccp->addColumn("edit_by", "integer", ["null" => false]);
+ $ccp->addColumn("create", "integer", ["null" => false]);
+ $ccp->addColumn("edit", "integer", ["null" => false]);
+ $ccp->create();
+
+ $ccn = $this->table("ConstructionConsentNetwork");
+ $ccn->addColumn("constructionconsentproject_id", "integer", ["null" => false]);
+ $ccn->addColumn("adb_netzgebiet_id", "integer", ["null" => false]);
+ $ccn->addColumn("create_by", "integer", ["null" => false]);
+ $ccn->addColumn("edit_by", "integer", ["null" => false]);
+ $ccn->addColumn("create", "integer", ["null" => false]);
+ $ccn->addColumn("edit", "integer", ["null" => false]);
+ $ccn->create();
+
+ $cc = $this->table("ConstructionConsent");
+ $cc->addColumn("constructionconsentproject_id", "integer", ["null" => false, "after" => "id"]);
+ $cc->addColumn("name", "string", ["null" => true, "default" => null, "limit" => 255, "after" => "object_type"]);
+ $cc->addColumn("kg", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "ez"]);
+ $cc->addColumn("gst", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "kg"]);
+ $cc->addColumn("gstnr", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "gst"]);
+ $cc->addColumn("usage_length", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "gstnr"]);
+ $cc->addColumn("usage_pipe_on_plot", "integer", ["null" => false, "default" => 0, "after" => "usage_length"]);
+ $cc->addColumn("usage_pipe_in_building", "integer", ["null" => false, "default" => 0, "after" => "usage_pipe_on_plot"]);
+ $cc->addColumn("usage_manhole", "integer", ["null" => false, "default" => 0, "after" => "usage_pipe_in_building"]);
+ $cc->addColumn("usage_owner", "integer", ["null" => false, "default" => 0, "after" => "usage_manhole"]);
+ $cc->addColumn("result_text", "text", ["null" => true, "default" => null, "after" => "result"]);
+ $cc->addColumn("note", "text", ["null" => true, "default" => null, "after" => "result_text"]);
+ $cc->removeColumn("owner_name");
+ $cc->removeColumn("owner_street");
+ $cc->removeColumn("owner_zip");
+ $cc->removeColumn("owner_city");
+ $cc->removeColumn("owner_country");
+ $cc->removeColumn("owner_phone");
+ $cc->removeColumn("owner_fax");
+ $cc->removeColumn("owner_email");
+ $cc->update();
+
+ $cco = $this->table("ConstructionConsentOwner");
+ $cco->addColumn("constructionconsent_id", "integer", ["null" => false]);
+ $cco->addColumn("owner_name", "string", ["null" => true, "default" => null, "limit" => "255"]);
+ $cco->addColumn("owner_street", "string", ["null" => true, "default" => null, "limit" => "64"]);
+ $cco->addColumn("owner_zip", "string", ["null" => true, "default" => null, "limit" => "32"]);
+ $cco->addColumn("owner_city", "string", ["null" => true, "default" => null, "limit" => "64"]);
+ $cco->addColumn("owner_country", "string", ["null" => true, "default" => null, "limit" => "64"]);
+ $cco->addColumn("owner_phone", "string", ["null" => true, "default" => null, "limit" => "64"]);
+ $cco->addColumn("owner_fax", "string", ["null" => true, "default" => null, "limit" => "64"]);
+ $cco->addColumn("owner_email", "string", ["null" => true, "default" => null, "limit" => "64"]);
+ $cco->addColumn("status", "enum", ["null" => false, "default" => "new", "values" => "new,requested,answered"]);
+ $cco->addColumn("result", "enum", ["null" => true, "default" => null, "values" => "success,failure"]);
+ $cco->addColumn("create_by", "integer", ["null" => false]);
+ $cco->addColumn("edit_by", "integer", ["null" => false]);
+ $cco->addColumn("create", "integer", ["null" => false]);
+ $cco->addColumn("edit", "integer", ["null" => false]);
+ $cco->create();
+
+ $ccj = $this->table("ConstructionConsentJournal");
+ $ccj->addColumn("constructionconsent_id", "integer", ["null" => false]);
+ $ccj->addColumn("type", "string", ["null" => false]);
+ $ccj->addColumn("value", "string", ["null" => false, "limit" => 64]);
+ $ccj->addColumn("text", "string", ["null" => false, "limit" => 64]);
+ $ccj->addColumn("create_by", "integer", ["null" => false]);
+ $ccj->addColumn("edit_by", "integer", ["null" => false]);
+ $ccj->addColumn("create", "integer", ["null" => false]);
+ $ccj->addColumn("edit", "integer", ["null" => false]);
+ $ccj->create();
+
+ $ccf = $this->table("ConstructionConsentFile");
+ $ccf->addColumn("constructionconsent_id", "integer", ["null" => false]);
+ $ccf->addColumn("file_id", "integer", ["null" => false]);
+ $ccf->addColumn("filename", "string", ["null" => false]);
+ $ccf->addColumn("create_by", "integer", ["null" => false]);
+ $ccf->addColumn("edit_by", "integer", ["null" => false]);
+ $ccf->addColumn("create", "integer", ["null" => false]);
+ $ccf->addColumn("edit", "integer", ["null" => false]);
+ $ccf->create();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+ $this->table("ConstructionConsentFile")->drop()->save();
+ $this->table("ConstructionConsentJournal")->drop()->save();
+ $this->table("ConstructionConsentOwner")->drop()->save();
+ $this->table("ConstructionConsentNetwork")->drop()->save();
+ $this->table("ConstructionConsentProject")->drop()->save();
+
+ $cc = $this->table("ConstructionConsent");
+ $cc->removeColumn("constructionconsentproject_id");
+ $cc->removeColumn("name");
+ $cc->removeColumn("kg");
+ $cc->removeColumn("gst");
+ $cc->removeColumn("gstnr");
+ $cc->removeColumn("usage_length");
+ $cc->removeColumn("usage_pipe_on_plot");
+ $cc->removeColumn("usage_pipe_in_building");
+ $cc->removeColumn("usage_manhole");
+ $cc->removeColumn("usage_owner");
+ $cc->removeColumn("result_text");
+ $cc->removeColumn("note");
+
+ $cc->addColumn("owner_name", "string", ["null" => true, "default" => null, "limit" => "255", "after" => "ez"]);
+ $cc->addColumn("owner_street", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_name"]);
+ $cc->addColumn("owner_zip", "string", ["null" => true, "default" => null, "limit" => "32", "after" => "owner_street"]);
+ $cc->addColumn("owner_city", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_zip"]);
+ $cc->addColumn("owner_country", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_city"]);
+ $cc->addColumn("owner_phone", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_country"]);
+ $cc->addColumn("owner_fax", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_phone"]);
+ $cc->addColumn("owner_email", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_fax"]);
+
+ $cc->update();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}