ConstructionConsent Basic Building data

This commit is contained in:
Frank Schubert
2025-01-20 15:24:14 +01:00
parent 269456eed6
commit e82e66ceae
5 changed files with 136 additions and 19 deletions
@@ -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]);
}