Merge branch 'ConstructionConsent/add-permission' into 'master'
added contact edit button See merge request fronk/thetool!1139
This commit is contained in:
@@ -8,8 +8,12 @@
|
||||
<li class="breadcrumb-item"><a href="<?= self::getUrl("Dashboard") ?>"><?= MFAPPNAME_SLUG ?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("ConstructionConsentProject")?>">Zustimmungserklärungsprojekte</a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("ConstructionConsent")?>">Zustimmungserklärungen</a></li>
|
||||
<?php if(isset($item)): ?>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("ConstructionConsent", "View", ["id" => $item->id])?>"><?=htmlentities($item->name)?></a></li>
|
||||
<li class="breadcrumb-item active">bearbeiten</li>
|
||||
<?php endif; ?>
|
||||
<li class="breadcrumb-item active">
|
||||
<?= ($Action == "add") ? "Neue " : "" ?>Zustimmungserklärung <?= ($Action == "edit") ? "bearbeiten " : "" ?>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Zustimmungserklärung</h4>
|
||||
@@ -37,7 +41,7 @@
|
||||
<label class="col-lg-2 col-form-label" for="constructionconsentproject_id">Projekt *</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="constructionconsentproject_id" id="constructionconsentproject_id">
|
||||
<?php foreach(ConstructionConsentProject::getAll() as $project): ?>
|
||||
<?php foreach(ConstructionConsentProject::search(['id' => $allowed_projects]) as $project): ?>
|
||||
<option value="<?=$project->id?>" <?=(isset($project_id) && $project_id == $project->id || isset($item) && $item->constructionconsentproject_id == $project->id) ? "selected='selected'" : ""?>><?=$project->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
@@ -204,7 +208,7 @@
|
||||
<h5 class="card-header">Plan Vorschau <button type='button' id="delete-rimo-plan" class='ml-2 btn btn-sm btn-outline-danger pointer <?=($item->file && $item->file->file && $item->file->file->fileExists()) ? "" : "hidden" ?>' onclick='deletePlan()'><i class='fas fa-fw fa-trash'></i> Plan löschen</button></h5>
|
||||
<div class="card-body" id="rimo-plan-container">
|
||||
<input type="hidden" name="submit_plan_file_id" id="submit_plan_file_id" value="" />
|
||||
<img id="plan_preview" style="max-width: 1200px;" <?=($item->file && $item->file->file && $item->file->file->fileExists()) ? "src=".$item->file->file->asDataUrl()."" : "" ?> />
|
||||
<img id="plan_preview" style="max-width: 1200px;" <?=(isset($item) && $item->file && $item->file->file && $item->file->file->fileExists()) ? "src=".$item->file->file->asDataUrl()."" : "" ?> />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ $pagination_entity_name = "Zustimmungserklärungen";
|
||||
<label class="form-label" for="filter_project_id">Projekt</label>
|
||||
<select name="filter[project_id]" id="filter_project_id" class="form-control">
|
||||
<option value="">Alle</option>
|
||||
<?php foreach(ConstructionConsentProject::getAll() as $p): ?>
|
||||
<?php foreach(ConstructionConsentProject::search(['id' => $allowed_projects]) as $p): ?>
|
||||
<option value="<?=$p->id?>" <?=(is_array($filter) && array_key_exists("project_id", $filter) && $p->id == $filter["project_id"]) ? "selected='selected'" : ""?>><?=$p->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
@@ -257,6 +257,38 @@ $siteTitle = "Benutzer";
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<h4 class="card-title mb-3">Zustimmungserklärungen</h4>
|
||||
|
||||
|
||||
<div class="form-group" id="constructionconsent-projects-container">
|
||||
<label for="constructionconsent_projects">Zustimmungserklärungsprojekte:</label>
|
||||
<?php
|
||||
$constructionConsent_projects = [];
|
||||
if($user->id) {
|
||||
$constructionConsent_projects = json_decode((new WorkerFlag($user->id, "constructionConsent_projects"))->value());
|
||||
if(!$constructionConsent_projects) {
|
||||
$constructionConsent_projects = [];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<select name="constructionconsent_projects[]" id="constructionconsent_projects"
|
||||
class="form-control" multiple="multiple">
|
||||
<?php foreach(ConstructionConsentProject::getAll() as $project): ?>
|
||||
<option value="<?=$project->id?>" <?=(in_array($project->id, $constructionConsent_projects)) ? "selected='selected'" : ""?>><?=$project->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<small>Benutzer kann nur Zustimmungserklärungen in diesen Projekten sehen</small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
@@ -481,6 +513,11 @@ $siteTitle = "Benutzer";
|
||||
placeholder: "",
|
||||
closeOnSelect: false
|
||||
});
|
||||
$("#constructionconsent_projects").select2({
|
||||
allowClear: true,
|
||||
placeholder: "",
|
||||
closeOnSelect: false
|
||||
});
|
||||
|
||||
<?php if(!$user || (!$user->is("preorderfront") && !$user->is("preorderaddressreporting")) ): ?>
|
||||
//$("#preorder-network-container").hide();
|
||||
|
||||
@@ -437,6 +437,8 @@ class ConstructionConsent extends mfBaseModel {
|
||||
$project_id = $filter['project_id'];
|
||||
if(is_numeric($project_id)) {
|
||||
$where .= " AND ConstructionConsent.constructionconsentproject_id=$project_id";
|
||||
} else if (is_array($project_id)) {
|
||||
$where .= " AND ConstructionConsent.constructionconsentproject_id IN (".implode(",", $project_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -11,7 +11,11 @@ class ConstructionConsentContactController extends mfBaseController
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $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 saveAction()
|
||||
@@ -38,6 +42,11 @@ class ConstructionConsentContactController extends mfBaseController
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
if (!in_array($cc->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Sie sind nicht berechtigt, diese Zustimmungserklärung zu bearbeiten", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data["constructionconsent_id"] = $cc_id;
|
||||
$data["type"] = $r->type;
|
||||
@@ -88,6 +97,11 @@ class ConstructionConsentContactController extends mfBaseController
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
if (!in_array($cc->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Sie sind nicht berechtigt, diese Zustimmungserklärung zu bearbeiten", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$contact->delete();
|
||||
|
||||
$this->layout()->setFlash("Ansprechpartner wurde gelöscht.", "success");
|
||||
|
||||
@@ -9,7 +9,11 @@ class ConstructionConsentJournalController extends mfBaseController {
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $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 saveAction() {
|
||||
@@ -28,6 +32,11 @@ class ConstructionConsentJournalController extends mfBaseController {
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
if (!in_array($consent->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Sie sind nicht berechtigt, diese Zustimmungserklärung zu bearbeiten", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$text = trim(htmlentities($r->text));
|
||||
if(!$text) {
|
||||
$this->layout()->setFlash("Bitte Text eingeben", "error");
|
||||
|
||||
@@ -11,7 +11,11 @@ class ConstructionConsentOwnerController 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 uploadDocumentAction() {
|
||||
@@ -76,6 +80,11 @@ class ConstructionConsentOwnerController extends mfBaseController
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
if (!in_array($cc->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Sie sind nicht berechtigt, diese Zustimmungserklärung zu bearbeiten", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data["constructionconsent_id"] = $cc_id;
|
||||
$data["title"] = $r->title;
|
||||
@@ -128,6 +137,11 @@ class ConstructionConsentOwnerController extends mfBaseController
|
||||
|
||||
$consent = $owner->consent;
|
||||
|
||||
if (!in_array($consent->constructionconsentproject_id, $this->constructionConsentProjects)) {
|
||||
$this->layout()->setFlash("Sie sind nicht berechtigt, diese Zustimmungserklärung zu bearbeiten", "error");
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
foreach($owner->files as $file) {
|
||||
$file->file->delete();
|
||||
$file->delete();
|
||||
|
||||
@@ -152,21 +152,16 @@ class ConstructionConsentProject extends mfBaseModel {
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM ConstructionConsentProject
|
||||
LEFT JOIN ConstructionConsentNetwork ON (ConstructionConsentNetwork.constructionconsentproject_id = ConstructionConsentNetwork.id)
|
||||
WHERE $where
|
||||
GROUP BY ConstructionConsentProject.id
|
||||
";
|
||||
$sql = "SELECT COUNT(*) AS cnt FROM ConstructionConsentProject WHERE $where";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
$result = $db->query($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
if ($result && $db->num_rows($result) > 0) {
|
||||
$data = $db->fetch_object($result);
|
||||
return (int)$data->cnt;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -217,6 +212,22 @@ class ConstructionConsentProject extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("id", $filter)) {
|
||||
if(is_numeric($filter["id"])) {
|
||||
$where .= " AND ConstructionConsentProject.id = ".$filter["id"];
|
||||
} elseif(is_array($filter["id"])) {
|
||||
$ids = [];
|
||||
foreach($filter["id"] as $id) {
|
||||
if(is_numeric($id)) {
|
||||
$ids[] = $id;
|
||||
}
|
||||
}
|
||||
if(count($ids)) {
|
||||
$where .= " AND ConstructionConsentProject.id IN (".implode(",", $ids).")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -286,6 +286,13 @@ class UserController extends mfBaseController
|
||||
$pn->delete();
|
||||
}
|
||||
|
||||
$constructionConsentProjects = $user->getFlag("constructionConsent_projects");
|
||||
if (is_array($r->constructionconsent_projects) && count($r->constructionconsent_projects)) {
|
||||
$constructionConsentProjects->value(json_encode($r->constructionconsent_projects));
|
||||
$constructionConsentProjects->save();
|
||||
} else {
|
||||
$constructionConsentProjects->delete();
|
||||
}
|
||||
|
||||
// employee number
|
||||
$enum = new WorkerFlag($user->id, "employee_number");
|
||||
|
||||
Reference in New Issue
Block a user