added contact edit button

This commit is contained in:
Luca Haid
2025-03-25 10:38:20 +01:00
parent 7be3446383
commit 321726718f
11 changed files with 157 additions and 50 deletions
@@ -10,7 +10,11 @@ class ConstructionConsentController extends mfBaseController {
$this->me = $me;
$this->layout()->set("me", $me);
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908,2187]))) $this->redirect("Dashboard");
if ($this->me->is("Admin")) $this->constructionConsentProjects = array_column(ConstructionConsentProject::getAll(), 'id');
else {
$constructionConsentProjects = json_decode((new WorkerFlag($this->me->id, "constructionConsent_projects"))->value() ?? '[]');
empty($constructionConsentProjects) ? $this->redirect("Dashboard") : $this->constructionConsentProjects = $constructionConsentProjects;
}
}
protected function indexAction() : void {
@@ -54,6 +58,7 @@ class ConstructionConsentController extends mfBaseController {
//var_dump($_SESSION, $filter);exit;
$this->layout->set("allowed_projects", $this->constructionConsentProjects);
$this->layout->set("filter", $filter);
$filter = $this->getPreparedFilter($filter);
@@ -93,7 +98,13 @@ class ConstructionConsentController extends mfBaseController {
}
}
if (isset($new_filter['project_id']) && !in_array($new_filter['project_id'], $this->constructionConsentProjects) && strlen($new_filter['project_id']) > 0) {
$this->redirect("ConstructionConsent");
}
if (empty($new_filter['project_id'])) {
$new_filter['project_id'] = $this->constructionConsentProjects;
}
return $new_filter;
}
@@ -108,7 +119,7 @@ class ConstructionConsentController extends mfBaseController {
}
$item = new ConstructionConsent($id);
if(!$item || !$item->id) {
if(!$item || !$item->id || !in_array($item->constructionconsentproject_id, $this->constructionConsentProjects)) {
$this->layout()->setFlash("Zustimmungserklärung nicht gefunden", "error");
$this->redirect("ConstructionConsent");
}
@@ -121,6 +132,7 @@ class ConstructionConsentController extends mfBaseController {
if($this->request->project_id) {
$this->layout()->set("project_id", $this->request->project_id);
}
$this->layout()->set("allowed_projects", $this->constructionConsentProjects);
}
protected function editAction() : void {
@@ -224,7 +236,10 @@ class ConstructionConsentController extends mfBaseController {
$mode = "add";
}
//var_dump($r->get());exit;
if (!in_array($r->constructionconsentproject_id, $this->constructionConsentProjects)) {
$this->layout()->setFlash("Sie haben keine Berechtigung für dieses Projekt", "error");
$this->redirect("ConstructionConsent");
}
$data = [];
$data["constructionconsentproject_id"] = $r->constructionconsentproject_id;