Merge branch 'fronkdev' into 'master'

ConstructionConsent Basic Building data

See merge request fronk/thetool!924
This commit is contained in:
Frank Schubert
2025-01-20 14:24:45 +00:00
5 changed files with 136 additions and 19 deletions
@@ -10,6 +10,7 @@ class ConstructionConsent extends mfBaseModel {
private $file;
private $creator;
private $editor;
private $preorder_count;
private $footer_text = "Energie Steiermark Breitband GmbH, A-8010 Graz, Leonhardgürtel 10, Telefon +43 (0)316 9000-0\nSitz Graz, FN 576705x, Landesgericht für ZRS Graz, ATU 77949678, breitband@e-steiermark.com, www.e-steiermark.com";
private $footer_font = "ITC Officina Sans Std";
@@ -53,7 +54,7 @@ class ConstructionConsent extends mfBaseModel {
if($this->$name == null) {
if($name == "project") {
$project = new ConstructionConsentProject($this->id);
$project = new ConstructionConsentProject($this->constructionconsentproject_id);
if($project->id) {
$this->project = $project;
}
@@ -78,6 +79,24 @@ class ConstructionConsent extends mfBaseModel {
return $this->adb_strasse;
}
if($name == "preorder_count") {
if(!$this->adb_hausnummer_id) {
return 0;
}
$preorder_count = 0;
foreach(PreorderModel::search(["adb_hausnummer_id" => $this->adb_hausnummer_id]) as $preorder) {
if($preorder->connection_count) {
$preorder_count += $preorder->connection_count;
} else {
$preorder_count++;
}
}
if($preorder_count) {
$this->preorder_count = $preorder_count;
}
return $this->preorder_count;
}
if($name == "owners") {
if(!$this->id) return null;
@@ -186,9 +186,10 @@ class ConstructionConsentController extends mfBaseController {
protected function saveAction() {
$r = $this->request;
//var_dump($r->get());exit;
$id = $r->id;
if(is_numeric($id) && $id > 0) {
//var_dump($id);exit;
$mode = "edit";
$item = new ConstructionConsent($id);
if(!$item->id) {
@@ -200,10 +201,13 @@ class ConstructionConsentController extends mfBaseController {
$mode = "add";
}
//var_dump($r->get());exit;
$data = [];
$data["constructionconsentproject_id"] = $r->constructionconsentproject_id;
$data["object_type"] = $r->object_type;
$data["name"] = $r->name;
$data["adb_hausnummer_id"] = $r->adb_hausnummer_id;
$data["adb_strasse_id"] = $r->adb_strasse_id;
$data["ez"] = $r->ez;
$data["kg"] = $r->kg;
@@ -228,11 +232,28 @@ class ConstructionConsentController extends mfBaseController {
return $this->addAction();
}
if(!$data["object_type"] || !$data["adb_strasse_id"]) {
if(!$data["object_type"]) {
$this->layout()->setFlash("Bitte alle benötigten Felder ausfüllen", "error");
return $this->addAction();
}
if($data["object_type"] == "address") {
if(!$data["adb_hausnummer_id"]) {
$this->layout()->setFlash("Kein Gebäude ausgewählt", "error");
return $this->addAction();
}
unset($data["adb_strasse_id"]);
}
if($data["object_type"] == "street") {
if(!$data["adb_strasse_id"]) {
$this->layout()->setFlash("Keine Straße ausgewählt", "error");
return $this->addAction();
}
unset($data["adb_hausnummer_id"]);
}
//var_dump($data, $item);exit;
if(!$item->save()) {
$this->layout()->setFlash("Fehler beim Speichern", "error");
return $this->addAction();
@@ -255,13 +276,13 @@ class ConstructionConsentController extends mfBaseController {
if($file && $file->id) {
$ccf = ConstructionConsentFile::create([
'constructionconsent_id' => $id,
'constructionconsent_id' => $item->id,
'file_id' => $file->id,
'filename' => "zustimmungserklärung-" . $item->id . "-plan.png",
]);
// delete previous image
$img = ConstructionConsentFile::getFirst(["constructionconsent_id" => $id]);
$img = ConstructionConsentFile::getFirst(["constructionconsent_id" => $item->id]);
if ($img) {
$img->file->delete();
$img->delete();
@@ -274,7 +295,7 @@ class ConstructionConsentController extends mfBaseController {
$this->layout()->setFlash("Zustimmungserklärung erfolgreich gespeichert", "success");
$this->redirect("ConstructionConsent", "View", ["id" => $id]);
$this->redirect("ConstructionConsent", "View", ["id" => $item->id]);
}