From 5f752da41f9d8430bf2888fd7cc4256c80aeddee Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Fri, 10 Jan 2025 12:35:25 +0100 Subject: [PATCH] WIP 2025-01-09 ConstructionConsent --- Layout/default/ConstructionConsent/Form.php | 12 +- Layout/default/ConstructionConsent/Index.php | 2 + Layout/default/ConstructionConsent/View.php | 249 ++++++++++++++++++ .../ConstructionConsent.php | 50 +++- .../ConstructionConsentController.php | 32 ++- .../ConstructionConsentOwner.php | 10 +- ...nstruction_consent_termination_id_null.php | 31 +++ ...construction_consent_owner_rename_cols.php | 38 +++ 8 files changed, 403 insertions(+), 21 deletions(-) create mode 100644 Layout/default/ConstructionConsent/View.php create mode 100644 db/migrations/20250108173124_construction_consent_termination_id_null.php create mode 100644 db/migrations/20250109143713_construction_consent_owner_rename_cols.php diff --git a/Layout/default/ConstructionConsent/Form.php b/Layout/default/ConstructionConsent/Form.php index f4e2caefd..28fa975bb 100644 --- a/Layout/default/ConstructionConsent/Form.php +++ b/Layout/default/ConstructionConsent/Form.php @@ -25,7 +25,7 @@ Zustimmungserklärung -
"> + "> "/>
@@ -36,7 +36,7 @@
@@ -115,7 +115,7 @@
@@ -125,7 +125,7 @@
@@ -135,7 +135,7 @@
@@ -145,7 +145,7 @@
diff --git a/Layout/default/ConstructionConsent/Index.php b/Layout/default/ConstructionConsent/Index.php index cbd9644c6..95762d7f9 100644 --- a/Layout/default/ConstructionConsent/Index.php +++ b/Layout/default/ConstructionConsent/Index.php @@ -90,6 +90,7 @@ $pagination_entity_name = "Zustimmungserklärungen"; + @@ -103,6 +104,7 @@ $pagination_entity_name = "Zustimmungserklärungen"; +
Name Objekttyp Objektadresse GST-Nr.
$item->id])?>">name?> object_type)?> object_type == "street"): ?> diff --git a/Layout/default/ConstructionConsent/View.php b/Layout/default/ConstructionConsent/View.php new file mode 100644 index 000000000..978f5b352 --- /dev/null +++ b/Layout/default/ConstructionConsent/View.php @@ -0,0 +1,249 @@ + + + + +
+
+
+
+ +
+

Zustimmungserkärungen

+
+
+
+ + +
+
+ + + +
+
+ +
+
+

Zustimmungserklärung name?>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Projektproject->name?>
Objekttypobject_type, "consent")?>
Straßeadb_strasse->gemeinde->name?>, adb_strasse->name?>
Geplante Längeusage_length?>
Geplante Nutzung + usage_pipe_on_plot): ?> + + + + + Verlegung von Rohren und Lichtwellenleitern am Grundstück
+ + usage_pipe_in_building): ?> + + + + + Verlegung von Rohren und Lichtwellenleitern in den darauf befindlichen Gebäuden
+ + usage_manhole): ?> + + + + + Errichtung eines Schachtes/einer Kabelmontagegrube und/oder eines LWL-Verteilschrankes/einer LWL-Abschlussbox
+ + usage_owner): ?> + + + + + Die Nutzung der Liegenschaft seitens BB dient der Eigenversorgung der GE und/oder dessen Nutzer(in) und wird dieser entgeltlos zugestimmt +

Grundbuchdaten

EZez?>
KGkg?>
GSTgst?>
GSTNRgstnr?>
Erstelltcreate)?> (creator->name?>)
Letzte Bearbeitungedit)?> (editor->name?>)
+
+
+
+ +
+ +
+
+

Objektbesitzer + Neuen Besitzer hinzufügen +

+ + + + owners) || !count($item->owners)): ?> + Noch keine Besitzer bekannt + + owners as $owner): ?> +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Name:name?>
Anschrift: + street?>
+ zip?> city?>
+ country?> +
Telefon:phone?>
Fax:fax?>
Email:email?>
Anfragestatusstatus, "consent")?>
Anfrage Resultatresult, "consent")?>
+
+
+ + +
+
+
+ +
+
+
+ + + + + + + \ No newline at end of file diff --git a/application/ConstructionConsent/ConstructionConsent.php b/application/ConstructionConsent/ConstructionConsent.php index 25da31767..761347196 100644 --- a/application/ConstructionConsent/ConstructionConsent.php +++ b/application/ConstructionConsent/ConstructionConsent.php @@ -1,14 +1,25 @@ $name == null) { + if($name == "project") { + $project = new ConstructionConsentProject($this->id); + if($project->id) { + $this->project = $project; + } + return $this->project; + } + if($name == "adb_hausnummer") { if(!$this->adb_hausnummer_id) return null; $hausnummer = new ADBHausnummer($this->adb_hausnummer_id); @@ -27,6 +38,38 @@ class ConstructionConsent extends mfBaseModel { return $this->adb_strasse; } + if($name == "owners") { + if(!$this->id) return null; + + $owners = ConstructionConsentOwner::search(["constructionconsent_id" => $this->id]); + if(count($owners)) { + $this->owners = $owners; + } + return $this->owners; + } + + + if($name == "creator") { + $this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); + if($this->creator === null) { + $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 = mfValuecache::singleton()->get("Worker-id-".$this->edit_by); + if($this->editor === null) { + $this->editor = new User($this->edit_by); + if($this->editor->id) { + mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor); + } + } + return $this->editor; + } $classname = ucfirst($name); $idfield = $name."_id"; @@ -55,8 +98,9 @@ class ConstructionConsent extends mfBaseModel { $model = new ConstructionConsent(); $table_fields = [ - "termination_id","adb_wohneinheit_id","object_type","ez","owner_name","owner_street","owner_zip","owner_city", - "owner_country","status","result","create_by","edit_by","create","edit" + "constructionconsentproject_id", "termination_id","adb_hausnummer_id", "adb_strasse_id", "object_type", "name", "ez", "kg", "gst", "gstnr", + "usage_length", "usage_pipe_on_plot", "usage_pipe_in_building", "usage_manhole", "usage_owner", + "status", "result", "result_text", "note", "create_by","edit_by","create","edit" ]; foreach($data as $field => $value) { diff --git a/application/ConstructionConsent/ConstructionConsentController.php b/application/ConstructionConsent/ConstructionConsentController.php index 37b6d8779..3de0ed517 100644 --- a/application/ConstructionConsent/ConstructionConsentController.php +++ b/application/ConstructionConsent/ConstructionConsentController.php @@ -90,6 +90,25 @@ class ConstructionConsentController extends mfBaseController { return $new_filter; } + protected function viewAction() : void { + $this->layout()->setTemplate("ConstructionConsent/View"); + + $id = $this->request->id; + if(!is_numeric($id) || $id < 1) { + $this->layout()->setFlash("Zustimmungserklärung nicht gefunden", "error"); + $this->redirect("ConstructionConsent"); + } + + $item = new ConstructionConsent($id); + if(!$item || !$item->id) { + $this->layout()->setFlash("Zustimmungserklärung nicht gefunden", "error"); + $this->redirect("ConstructionConsent"); + } + + $this->layout()->set("item", $item); + + } + protected function addAction() : void { $this->layout()->setTemplate("ConstructionConsent/Form"); } @@ -131,16 +150,16 @@ class ConstructionConsentController extends mfBaseController { $data["constructionconsentproject_id"] = $r->constructionconsentproject_id; $data["object_type"] = $r->object_type; $data["name"] = $r->name; - $data["adb_street_id"] = $r->adb_street_id; + $data["adb_strasse_id"] = $r->adb_strasse_id; $data["ez"] = $r->ez; $data["kg"] = $r->kg; $data["gst"] = $r->gst; $data["gstnr"] = $r->gstnr; - $data["usage_length"] = $r->usage_length; - $data["usage_pipe_on_plot"] = $r->usage_pipe_on_plot; - $data["usage_pipe_in_building"] = $r->usage_pipe_in_building; - $data["usage_manhole"] = $r->usage_manhole; - $data["usage_owner"] = $r->usage_owner; + $data["usage_length"] = $r->usage_length ?: null; + $data["usage_pipe_on_plot"] = $r->usage_pipe_on_plot ? 1 : 0; + $data["usage_pipe_in_building"] = $r->usage_pipe_in_building ? 1 : 0; + $data["usage_manhole"] = $r->usage_manhole ? 1 : 0; + $data["usage_owner"] = $r->usage_owner ? 1 : 0; if($mode == "add") { $item = ConstructionConsent::create($data); @@ -258,7 +277,6 @@ class ConstructionConsentController extends mfBaseController { $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"); diff --git a/application/ConstructionConsentOwner/ConstructionConsentOwner.php b/application/ConstructionConsentOwner/ConstructionConsentOwner.php index eb381dd89..1c00ff4dc 100644 --- a/application/ConstructionConsentOwner/ConstructionConsentOwner.php +++ b/application/ConstructionConsentOwner/ConstructionConsentOwner.php @@ -33,8 +33,8 @@ class ConstructionConsentOwner extends mfBaseModel { $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" + "constructionconsent_id", "name", "street", "zip", "city", "country", "phone", + "fax", "email", "status", "result", "create_by","edit_by","create","edit" ]; foreach($data as $field => $value) { @@ -61,7 +61,7 @@ class ConstructionConsentOwner extends mfBaseModel { $db = FronkDB::singleton(); - $res = $db->select("ConstructionConsentOwner", "*", "1 = 1 ORDER BY owner_name"); + $res = $db->select("ConstructionConsentOwner", "*", "1 = 1 ORDER BY name"); if($db->num_rows($res)) { while($data = $db->fetch_object($res)) { $items[] = new ConstructionConsentOwner($data); @@ -77,7 +77,7 @@ class ConstructionConsentOwner extends mfBaseModel { $where = self::getSqlFilter($filter); $sql = "SELECT * FROM ConstructionConsentOwner WHERE $where - ORDER BY adb_hausnummer_id LIMIT 1"; + ORDER BY name LIMIT 1"; //var_dump($sql);exit; $res = $db->query($sql); if($db->num_rows($res)) { @@ -114,7 +114,7 @@ class ConstructionConsentOwner extends mfBaseModel { $items = []; if(!$order) { - $order = "owner_name ASC"; + $order = "name ASC"; } $db = FronkDB::singleton(); diff --git a/db/migrations/20250108173124_construction_consent_termination_id_null.php b/db/migrations/20250108173124_construction_consent_termination_id_null.php new file mode 100644 index 000000000..285c156dc --- /dev/null +++ b/db/migrations/20250108173124_construction_consent_termination_id_null.php @@ -0,0 +1,31 @@ +getEnvironment() == "thetool") { + $cc = $this->table("ConstructionConsent"); + $cc->changeColumn("termination_id", "integer", ["null" => true, "default" => null]); + $cc->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} diff --git a/db/migrations/20250109143713_construction_consent_owner_rename_cols.php b/db/migrations/20250109143713_construction_consent_owner_rename_cols.php new file mode 100644 index 000000000..c306d8bad --- /dev/null +++ b/db/migrations/20250109143713_construction_consent_owner_rename_cols.php @@ -0,0 +1,38 @@ +getEnvironment() == "thetool") { + $cco = $this->table("ConstructionConsentOwner"); + $cco->renameColumn("owner_name", "name"); + $cco->renameColumn("owner_street", "street"); + $cco->renameColumn("owner_zip", "zip"); + $cco->renameColumn("owner_city", "city"); + $cco->renameColumn("owner_country", "country"); + $cco->renameColumn("owner_phone", "phone"); + $cco->renameColumn("owner_fax", "fax"); + $cco->renameColumn("owner_email", "email"); + $cco->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + + } + + if($this->getEnvironment() == "addressdb") { + + } + } +}