diff --git a/Layout/default/ConstructionConsentProject/Form.php b/Layout/default/ConstructionConsentProject/Form.php
new file mode 100644
index 000000000..610ced431
--- /dev/null
+++ b/Layout/default/ConstructionConsentProject/Form.php
@@ -0,0 +1,131 @@
+
+
+
+
+
+
+
+
+
+
+
\ 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..3e3dbb18d
--- /dev/null
+++ b/Layout/default/ConstructionConsentProject/Index.php
@@ -0,0 +1,121 @@
+getUrl($Mod,"Index");
+$pagination_baseurl_params = ["filter" => $filter];
+$pagination_entity_name = "Zustimmungserklärungsprojekte";
+?>
+
+
+
+
+
+
+
+
+
Zustimmmungserklärungen
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | Projektname |
+ Netzgebiete |
+ Kontakt |
+ Email Absender |
+ Antwort an |
+ |
+
+
+
+ | =$project->name?> |
+
+ networks) && count($project->networks)): ?>
+
+ networks as $network): ?>
+ - =$network->adb_netzgebiet->name?>
+
+
+
+ |
+
+ =$project->email?>
+ =$project->phone?>
+ |
+ =$project->sender_name?> <=$project->sender_email?>> |
+ =$project->sender_reply_to?> |
+
+ $project->id])?>">
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/Admin/functions/RtrReporting.php b/application/Admin/functions/RtrReporting.php
index 84cbd34e7..ed4f752ce 100644
--- a/application/Admin/functions/RtrReporting.php
+++ b/application/Admin/functions/RtrReporting.php
@@ -6,9 +6,15 @@ class Admin_RtrReporting {
private $log;
private $flash = [];
private $systemowner_id = 1;
+ private $energie_bb_id = 209;
+ private $netowner_is_systemowner = [
+ 1473,
+ 421,
+
+ ];
private $additional_owner_networks = [
- 7 // mortantsch
+ 7, // mortantsch
];
private $ort_replace = [
"St.Ruprecht/Raab" => "Sankt Ruprecht an der Raab",
@@ -444,6 +450,95 @@ class Admin_RtrReporting {
}
+ protected function c10reportAction() {
+ $data = [];
+
+ $systemowner = new Address($this->systemowner_id);
+ $energie_bb = new Address($this->energie_bb_id);
+ if(!$energie_bb->id) {
+ return [
+ "error" => "Energie BB id nicht gesetzt",
+ "template" => "Admin/RtrReporting/Index",
+ "redirect" => "",
+ "templateVars" => []
+ ];
+ }
+
+ foreach(ContractModel::searchActive([]) as $contract) {
+ if(!is_array($contract->product->attributes) || !array_key_exists("rtr_tech_code", $contract->product->attributes) || !$contract->product->attributes["rtr_tech_code"]->value) continue;
+
+ $prov_id = false;
+ $prod_code = $contract->product->attributes["rtr_tech_code"]->value;
+ if(!$prod_code) continue;
+
+ if($contract->termination_id) {
+ $network_id = $contract->termination->building->network_id;
+ $netowner_id = $contract->termination->building->network->owner_id;
+
+ if(in_array($network_id, $this->additional_owner_networks)) {
+ $netowner_id = $this->systemowner_id;
+ }
+
+ if(in_array($netowner_id, $this->netowner_is_systemowner)) {
+ $netowner_id = $this->systemowner_id;
+ }
+
+ $netowner = new Address($netowner_id);
+
+ if($netowner->id && is_array($netowner->attributes) && array_key_exists("rtrcode", $netowner->attributes) && $netowner->attributes["rtrcode"]->value) {
+ $prov_id = $netowner->attributes["rtrcode"]->value;
+ }
+ if(!$prov_id) {
+ $this->log->debug(__METHOD__.": keine provider id trotz termination | netowner: $netowner_id ".$netowner->getCompanyOrName());
+ }
+ }
+
+ $prod_code_start = substr($prod_code, 0, 4);
+ $prod_code_p = $prod_code_start."1";
+ $prod_code_b = $prod_code_start."2";
+
+ if(!$prov_id) {
+ if($prod_code_start == "1432") {
+ // is OAN product
+ $prov_id = $energie_bb->attributes["rtrcode"]->value;
+ }
+ }
+
+ if(!$prov_id) {
+ $prov_id = $systemowner->attributes["rtrcode"]->value;
+ }
+
+ if(!array_key_exists($prov_id, $data)) {
+ $data[$prov_id] = [];
+ }
+
+ if(!in_array($prod_code_p, $data[$prov_id])) {
+ $data[$prov_id][] = $prod_code_p;
+ }
+ if(!in_array($prod_code_b, $data[$prov_id])) {
+ $data[$prov_id][] = $prod_code_b;
+ }
+ }
+
+ //var_dump($data);exit;
+
+ $csv_header = "partnernetz_id;code";
+ $csv = $csv_header."\n";
+ foreach($data as $prov_id => $prov) {
+ foreach($prov as $prod_code) {
+ $csv .= "$prov_id;";
+ $csv .= "$prod_code";
+ $csv .= "\n";
+ }
+ }
+
+ header("Content-type: text/csv; charset=utf-8");
+ header('Content-disposition: attachment; filename="rtr-C10-report-'.date('Y-m-d_H-i-s').'.csv"');
+
+ echo $csv;
+ exit;
+ }
+
/*
* 1042% = radio
* 1431% = fiber
diff --git a/application/ConstructionConsent/ConstructionConsentController.php b/application/ConstructionConsent/ConstructionConsentController.php
index 9dc42aaa4..403fbb2d5 100644
--- a/application/ConstructionConsent/ConstructionConsentController.php
+++ b/application/ConstructionConsent/ConstructionConsentController.php
@@ -88,4 +88,160 @@ class ConstructionConsentController extends mfBaseController {
$this->addAction();
}
+ protected function apiAction() {
+ if(!$this->me->is(["Admin","netowner"]) && !$this->me->can("Preorder")) {
+ $this->redirect("Dashboard");
+ }
+ $do = $this->request->do;
+ $data = [];
+
+ switch($do) {
+ case "findStreet":
+ $return = $this->findStreetApi();
+ break;
+ default:
+ $this->log->warn(__METHOD__ . ": Called API function '$do' does not exist");
+ $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 findStreetApi() {
+ $addresses = [];
+ $search = trim($this->request->q);
+ $project_id = $this->request->project_id;
+
+ $scluster_ids = [];
+
+ if($project_id) {
+ $project = new ConstructionConsentProject($project_id);
+ if(!$project->id) {
+ header("Content-Type: application/json");
+ echo json_encode(["results" => []]);
+ exit;
+ }
+
+ foreach($project->adb_networks as $network) {
+ $scluster_ids[] = $network->id;
+ }
+ } else {
+ // get all salesclusters
+ foreach(ADBNetzgebietModel::getAll() as $network) {
+ $scluster_ids[] = $network->id;
+ }
+ }
+
+ $results = [];
+
+ $search_parts = explode(" ", $search);
+
+ $ort_search = $strasse_search = $plz_search = $hausnummer_search = $gst_search = [];
+
+ foreach($search_parts as $p) {
+ $p = $this->db->escape(trim($p));
+ if(!$p) continue;
+ $ort_search[] = "ortschaft like '$p%'";
+ $strasse_search[] = "strasse like '$p%'";
+ $plz_search[] = "plz like '%$p%'";
+ $hausnummer_search[] = "hausnummer like '%$p%'";
+ $gst_search[] = "grund_nr like '%$p%'";
+ }
+
+ $where = "1=1";
+ if(count($scluster_ids)) {
+ $where .= " AND netzgebiet_id IN (".implode(', ',$scluster_ids).")";
+ }
+
+ /*if($include_gst) {
+ $sql = "SELECT * FROM view_hausnummer WHERE $where AND ((".implode(" OR ", $ort_search).") OR (".implode(" OR ", $strasse_search).") OR (".implode(" OR ", $plz_search).") OR (".implode(" OR ", $hausnummer_search).") OR (".implode(" OR ", $gst_search).") ) ORDER BY strasse, LENGTH(hausnummer), hausnummer";
+ } else {
+ $sql = "SELECT * FROM view_hausnummer WHERE $where AND ((".implode(" OR ", $ort_search).") OR (".implode(" OR ", $strasse_search).") OR (".implode(" OR ", $plz_search).") OR (".implode(" OR ", $hausnummer_search).")) ORDER BY strasse, LENGTH(hausnummer), hausnummer";
+ }*/
+
+ $sql = "SELECT strasse_id,plz,ortschaft,strasse FROM view_hausnummer
+ WHERE $where
+ AND ((".implode(" OR ", $ort_search).") OR (".implode(" OR ", $strasse_search).") OR (".implode(" OR ", $plz_search).") OR (".implode(" OR ", $hausnummer_search)."))
+ GROUP BY plz,ortschaft,strasse,strasse_id
+ ORDER BY strasse
+ ";
+
+ $this->log->debug($sql);
+
+ $adb = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
+ $res = $adb->query($sql);
+ $this->log->debug("done");
+
+ if(!$adb->num_rows($res)) {
+ header("Content-Type: application/json");
+ echo json_encode(["results" => []]);
+ exit;
+ }
+
+ while($data = $adb->fetch_object($res)) {
+ //$address_string = $data->plz." ".$data->ortschaft.", ".$data->strasse." ".$data->hausnummer;
+ $address_string = $data->plz." ".$data->ortschaft.", ".$data->strasse;
+ /*if($include_gst) {
+ $address_string .= " | GST: ".$data->grund_nr;
+ }*/
+ $sort_key = $data->plz." ".$data->ortschaft." ".$data->strasse;
+
+ $address = [];
+ $address['id'] = $data->strasse_id;
+ $address["text"] = $address_string;
+ $address['sort_key'] = $sort_key;
+ $addresses[] = $address;
+ }
+
+
+ // sort results by most occurences of search strings
+ $sort = [];
+ foreach($addresses as $key => $address) {
+ $includes_int = false;
+ $count = 0;
+ foreach($search_parts as $p) {
+ $p = $this->db->escape(trim($p));
+ if(!$p) continue;
+ if(is_numeric(($p))) {
+ $includes_int = true;
+ if(substr_count(strtolower($address['text']), strtolower($p))) {
+ $count++;
+ }
+ } else {
+ $count += substr_count(strtolower($address['text']), strtolower($p));
+ }
+ }
+ unset($address['sort_key']);
+ //echo $address['text']." $p $count
\n";
+
+ if($includes_int && (($count + 1) - count($search_parts) ) < 1) {
+ continue;
+ }
+ if(!array_key_exists($count, $sort)) {
+ $sort[$count] = [];
+ }
+ $sort[$count][] = $address;
+ }
+
+ ksort($sort, SORT_NUMERIC);
+ $sort = array_reverse($sort, true);
+ //var_dump($sort);exit;
+
+ foreach($sort as $res) {
+ foreach($res as $a) {
+ $results[] = $a;
+ }
+ }
+
+ header("Content-Type: application/json");
+ echo json_encode(["results" => $results]);
+ exit;
+
+ }
}
\ No newline at end of file
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..bf2d22864
--- /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;
+ }
+ 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", "sender_name", "sender_email", "sender_reply_to", "email", "phone", "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..47bdd40a2
--- /dev/null
+++ b/application/ConstructionConsentProject/ConstructionConsentProjectController.php
@@ -0,0 +1,186 @@
+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");
+
+ if ($this->request->resetFilter) {
+ unset($_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter']);
+ }
+
+ $filter = [];
+ if (is_array($this->request->filter)) {
+ $filter = $this->request->filter;
+ $_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'] = $filter;
+ } else {
+ if (array_key_exists(MFAPPNAME . '-ConstructionConsentProject-filter', $_SESSION) && count($_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'])) {
+ $filter = $_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'];
+ }
+ }
+
+ $this->layout->set("filter", $filter);
+ $filter = $this->getPreparedFilter($filter);
+
+ // pagination defaults
+ $pagination = [];
+ $pagination['start'] = 0;
+ $pagination['count'] = 25;
+ $pagination['maxItems'] = 0;
+
+ if (is_numeric($this->request->s)) {
+ $pagination['start'] = intval($this->request->s);
+ }
+ //var_dump($filter);exit;
+ $pagination['maxItems'] = ConstructionConsentProject::count($filter);
+
+ $projects = ConstructionConsentProject::getAll();
+ $this->layout()->set("projects", $projects);
+ $this->layout()->set("pagination", $pagination);
+
+ }
+
+ private function getPreparedFilter($filter) {
+ $new_filter = [];
+
+
+
+ if (is_array($filter) && count($filter)) {
+ foreach ($filter as $name => $value) {
+ $new_filter[$name] = $value;
+ }
+ }
+
+ return $new_filter;
+ }
+
+ 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;
+ $data["sender_name"] = $r->sender_name;
+ $data["sender_email"] = $r->sender_email;
+ $data["sender_reply_to"] = $r->sender_reply_to;
+ $data["email"] = $r->email;
+ $data["phone"] = $r->phone;
+ $data["note"] = $r->note;
+
+ if($mode == "add") {
+ $project = ConstructionConsentProject::create($data);
+ } else {
+ $project->update($data);
+ }
+ $this->layout()->set("project", $project);
+
+ if(!$r->name || !$r->sender_name || !$r->sender_email || !$r->email || !$r->phone) {
+ $this->layout()->setFlash("Bitte alle erforderlichen Felder ausfüllen", "error");
+ return $this->addAction();
+ }
+ if(!is_array($r->adb_netzgebiet_id) || !count($r->adb_netzgebiet_id)) {
+ $this->layout()->setFlash("Bitte mindestens ein Netzgebiet auswählen", "error");
+ return $this->addAction();
+ }
+
+ $netzgebiete = [];
+
+ if(!$project->save()) {
+ $this->layout()->setFlash("Fehler beim Speichern", "error");
+ return $this->addAction();
+ }
+
+ 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);
+ }*/
+
+
+
+ //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") {
+
+ }
+ }
+}