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

View File

@@ -10,45 +10,39 @@ class ConstructionConsentProjectController 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 {
$this->layout()->setTemplate("ConstructionConsentProject/Index");
$sessionKey = MFAPPNAME . '-ConstructionConsentProject-filter';
if ($this->request->resetFilter) {
unset($_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter']);
unset($_SESSION[$sessionKey]);
}
$filter = [];
if (is_array($this->request->filter)) {
$filter = $this->request->filter;
$_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'] = $filter;
} else {
if (array_key_exists(MFAPPNAME . '-ConstructionConsentProject-filter', $_SESSION) && count($_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'])) {
$filter = $_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'];
}
$filter = is_array($this->request->filter)
? $this->request->filter
: $_SESSION[$sessionKey] ?? [];
if (isset($this->request->filter)) {
$_SESSION[$sessionKey] = $filter;
}
$this->layout->set("filter", $filter);
$filter = $this->getPreparedFilter($filter);
// pagination defaults
$pagination = [];
$pagination['start'] = 0;
$pagination['count'] = 25;
$pagination['maxItems'] = 0;
if (is_numeric($this->request->s)) {
$pagination['start'] = intval($this->request->s);
}
//var_dump($filter);exit;
$pagination['maxItems'] = ConstructionConsentProject::count($filter);
$projects = ConstructionConsentProject::getAll();
$this->layout()->set("projects", $projects);
$this->layout()->set("pagination", $pagination);
$prepared = $this->getPreparedFilter($filter);
$prepared["id"] = $this->constructionConsentProjects;
$this->layout()->setTemplate("ConstructionConsentProject/Index");
$this->layout()->set("filter", $filter);
$this->layout()->set("projects", ConstructionConsentProject::search($prepared));
$this->layout()->set("pagination", [
'start' => (int)($this->request->s ?? 0),
'count' => 25,
'maxItems' => ConstructionConsentProject::count($prepared)
]);
}
private function getPreparedFilter($filter) {