WIP ConstructionConsent 2025-01-13
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
class ConstructionConsentOwnerController extends mfBaseController
|
||||
{
|
||||
|
||||
protected function init(): void
|
||||
{
|
||||
$this->needlogin = true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveAction()
|
||||
{
|
||||
$r = $this->request;
|
||||
//var_dump($r->get());exit;
|
||||
$id = $r->id;
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$item = new ConstructionConsentOwner($id);
|
||||
if (!$item->id) {
|
||||
$this->layout()->setFlash("Zustimmungserklärung nicht gefunden", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
} else {
|
||||
$id = false;
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$cc_id = $r->constructionconsent_id;
|
||||
$cc = new ConstructionConsent($cc_id);
|
||||
if(!$cc_id || !$cc->id) {
|
||||
$this->layout()->setFlash("Beim Speichern ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data["constructionconsent_id"] = $cc_id;
|
||||
$data["name"] = $r->name;
|
||||
$data["street"] = $r->street;
|
||||
$data["zip"] = $r->zip;
|
||||
$data["city"] = $r->city;
|
||||
$data["country"] = $r->country;
|
||||
$data["phone"] = $r->phone;
|
||||
$data["fax"] = $r->fax;
|
||||
$data["email"] = $r->email;
|
||||
|
||||
if($mode == "add") {
|
||||
$data["status"] = "new";
|
||||
$item = ConstructionConsentOwner::create($data);
|
||||
} else {
|
||||
$item->update($data);
|
||||
}
|
||||
|
||||
if(!$item->save()) {
|
||||
$this->layout()->setFlash("Beim Speichern ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.", "error");
|
||||
} else {
|
||||
$this->layout()->setFlash("Besitzer wurde erfolgreich gespeichert.", "success");
|
||||
}
|
||||
|
||||
$this->redirect("ConstructionConsent", "View", ["id" => $cc_id]);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user