+
+
+ Besitzer aus Vorbestellung suchen:
+
+
+
+
+
+
+
Name & Anschrift
@@ -556,12 +571,6 @@ $pagination_entity_name = "Adressen";
-
- Name *
-
- Beschreibender Kurzname, z.B: Zustimmung oder Ablehnung
-
-
Datei auswählen *
@@ -1053,6 +1062,76 @@ $pagination_entity_name = "Adressen";
});
}
+
+ $(document).ready(function() {
+ $('#search-owner').select2({
+ dropdownParent: $('#newOwnerModal'),
+ ajax: {
+ url: "=self::getUrl("ConstructionConsentOwner", "searchOwner")?>",
+ dataType: 'json',
+ delay: 250,
+ data: function(params) {
+ return {
+ search: params.term
+ };
+ },
+ processResults: function(data) {
+ return {
+ results: data.map(function(item) {
+ return {
+ id: item.id,
+ text: item.text,
+ fullData: item
+ };
+ })
+ };
+ },
+ cache: true
+ },
+ minimumInputLength: 2,
+ placeholder: 'Besitzer suchen...'
+ });
+
+ $('#search-owner').on('select2:select', function(e) {
+ var selectedData = e.params.data.fullData;
+ $("#newOwnerModal input[name=firstname]").val(selectedData.firstname);
+ $("#newOwnerModal input[name=lastname]").val(selectedData.lastname);
+ $("#newOwnerModal input[name=street]").val(selectedData.street);
+ $("#newOwnerModal input[name=zip]").val(selectedData.zip);
+ $("#newOwnerModal input[name=city]").val(selectedData.city);
+ $("#newOwnerModal input[name=phone]").val(selectedData.phone);
+ $("#newOwnerModal input[name=email]").val(selectedData.email);
+ });
+
+ $("#approve_override").on("change", function() {
+ const reason = prompt("Bitte geben Sie einen Grund für das Überschreiben der Genehmigung ein:");
+ if (reason != null) {
+ $.post("", {
+ consent_id: =$item->id?>,
+ text: `Genehmigung überschreiben wurde ${$(this).prop("checked") ? "aktiviert" : "deaktiviert"} | Begründung: ${reason}`
+ }, function(success) {
+ if (success.status != "OK") {
+ notify("error", "Status konnte nicht gespeichert werden");
+ } else {
+ notify("success", "Status erfolgreich gespeichert");
+ }
+ }, 'json');
+
+ $.get("", {
+ consent_id: =$item->id?>,
+ checked: $(this).prop("checked") ? 1 : 0
+ }, function(success) {
+ if (success.status != "OK") {
+ notify("error", "Status konnte nicht gespeichert werden");
+ setTimeout(() => {location.reload()}, 150);
+ } else {
+ notify("success", "Status erfolgreich gespeichert");
+ setTimeout(() => {location.reload()}, 150);
+ }
+ }, 'json');
+ }
+ });
+ });
diff --git a/application/ConstructionConsent/ConstructionConsent.php b/application/ConstructionConsent/ConstructionConsent.php
index 4c5238e9b..29af55cc3 100644
--- a/application/ConstructionConsent/ConstructionConsent.php
+++ b/application/ConstructionConsent/ConstructionConsent.php
@@ -386,22 +386,46 @@ class ConstructionConsent extends mfBaseModel {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
- $sql = "SELECT
- ConstructionConsent.*,
- COALESCE(SUM(cwo.result = 'denied'), 0) AS denied_count,
- COALESCE(SUM(cwo.result = 'unresolvable'), 0) AS unresolvable_count,
- COALESCE(SUM(cwo.result = 'moved'), 0) AS moved_count,
- COALESCE(SUM(cwo.result = 'accepted'), 0) AS accepted_count,
- COUNT(cwo.id) AS total_owners,
- CASE
- WHEN COALESCE(SUM(cwo.result = 'denied'), 0) > 0 THEN 'red'
- WHEN COALESCE(SUM(cwo.result = 'unresolvable'), 0) > 0
- OR COALESCE(SUM(cwo.result = 'moved'), 0) > 0 THEN 'yellow'
- WHEN COALESCE(SUM(cwo.result = 'accepted'), 0) = COUNT(cwo.id)
- AND COUNT(cwo.id) > 0 THEN 'green'
- ELSE 'blue'
- END AS status_light
- FROM ConstructionConsent
+ $sql = "SELECT ConstructionConsent.*,
+ COALESCE(SUM(CASE
+ WHEN ConstructionConsent.approve_override = 1 THEN 0
+ ELSE (cwo.result = 'denied')
+ END), 0) AS denied_count,
+ COALESCE(SUM(CASE
+ WHEN ConstructionConsent.approve_override = 1 THEN 0
+ ELSE (cwo.result = 'unresolvable')
+ END), 0) AS unresolvable_count,
+ COALESCE(SUM(CASE
+ WHEN ConstructionConsent.approve_override = 1 THEN 0
+ ELSE (cwo.result = 'moved')
+ END), 0) AS moved_count,
+ COALESCE(SUM(CASE
+ WHEN ConstructionConsent.approve_override = 1 THEN 1
+ ELSE (cwo.result = 'accepted')
+ END), 0) AS accepted_count,
+ COUNT(cwo.id) AS total_owners,
+ CASE
+ WHEN ConstructionConsent.approve_override = 1 THEN 'green'
+ WHEN COALESCE(SUM(CASE
+ WHEN approve_override = 1 THEN 0
+ ELSE (cwo.result = 'denied')
+ END), 0) > 0 THEN 'red'
+ WHEN COALESCE(SUM(CASE
+ WHEN approve_override = 1 THEN 0
+ ELSE (cwo.result = 'unresolvable')
+ END), 0) > 0
+ OR COALESCE(SUM(CASE
+ WHEN approve_override = 1 THEN 0
+ ELSE (cwo.result = 'moved')
+ END), 0) > 0 THEN 'yellow'
+ WHEN COALESCE(SUM(CASE
+ WHEN approve_override = 1 THEN 1
+ ELSE (cwo.result = 'accepted')
+ END), 0) = COUNT(cwo.id)
+ AND COUNT(cwo.id) > 0 THEN 'green'
+ ELSE 'blue'
+ END AS status_light
+FROM ConstructionConsent
LEFT JOIN ConstructionConsentOwner cwo ON ConstructionConsent.id = cwo.constructionconsent_id
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer vh ON ConstructionConsent.adb_hausnummer_id = vh.hausnummer_id
LEFT JOIN `".ADDRESSDB_DBNAME."`.Strasse vs ON ConstructionConsent.adb_strasse_id = vs.id
diff --git a/application/ConstructionConsent/ConstructionConsentController.php b/application/ConstructionConsent/ConstructionConsentController.php
index 526ca58b2..047927c8b 100644
--- a/application/ConstructionConsent/ConstructionConsentController.php
+++ b/application/ConstructionConsent/ConstructionConsentController.php
@@ -111,6 +111,7 @@ class ConstructionConsentController extends mfBaseController {
protected function viewAction() : void {
$this->layout()->setTemplate("ConstructionConsent/View");
+ $this->layout()->set("is_admin", $this->me->isAdmin());
$id = $this->request->id;
if(!is_numeric($id) || $id < 1) {
@@ -1027,4 +1028,20 @@ class ConstructionConsentController extends mfBaseController {
"status_light_green" => getFilteredCount("status_light", "green", $baseFilter)
];
}
+
+ protected function approveOverrideAction() {
+ $consent_id = $this->request->consent_id;
+ $checked = $this->request->checked;
+
+ $consent = new ConstructionConsent($consent_id);
+ if(!$consent->id) {
+ $this->returnJson(["status" => "error"]);
+ }
+
+ $consent->update(["approve_override" => $checked]);
+ $consent->save();
+
+ $this->returnJson(["status" => "OK"]);
+
+ }
}
diff --git a/application/ConstructionConsentHistory/ConstructionConsentHistory.php b/application/ConstructionConsentHistory/ConstructionConsentHistory.php
index 449a20205..e2c75938b 100644
--- a/application/ConstructionConsentHistory/ConstructionConsentHistory.php
+++ b/application/ConstructionConsentHistory/ConstructionConsentHistory.php
@@ -70,14 +70,14 @@ class ConstructionConsentHistory extends mfBaseModel {
return "Nutzung Schacht/Verteiler/Abschluss";
case "usage_owner":
return "Nutzung Eigenvers. GE";
-
+ case "approve_override":
+ return "Genehmigung überschreiben";
case "rimo_plan":
return "Plan/Skizze aus Rimo";
case "plan_upload":
return "Plan/Skizze Upload";
case "constructionconsentproject_id":
return "Projekt";
-
case "inspection_planner":
return "Status Begehung mit Planer";
case "inspection_electrician";
diff --git a/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php b/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php
index d29c253fc..a3495dba5 100644
--- a/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php
+++ b/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php
@@ -20,14 +20,16 @@ class ConstructionConsentOwnerController extends mfBaseController
protected function uploadDocumentAction() {
$owner_id = $this->request->owner_id;
- $filename = trim($this->request->name);
-
$owner = new ConstructionConsentOwner($owner_id);
if(!$owner->id) {
$this->layout()->setFlash("Besitzer nicht gefunden!", "error");
$this->redirect("ConstructionConsent");
}
+ $constructionConsent = new ConstructionConsent($owner->constructionconsent_id);
+ $filename = "ZU_KG" . $constructionConsent->kg . "_EZ" . $constructionConsent->ez . "_GST" . $constructionConsent->gst . "_" . $constructionConsent->name . "_" . $owner->lastname . ".pdf";
+ $_FILES['consentOwnerUpload']['name'] = $filename;
+
if(is_array($_FILES) && array_key_exists("consentOwnerUpload", $_FILES) && !$_FILES['consentOwnerUpload']['error']) {
try {
// returns File object or throws Exception on error
@@ -221,4 +223,23 @@ class ConstructionConsentOwnerController extends mfBaseController
return ["message" => "Result saved successfully", "update" => ["id" => $owner->id, "result" => $owner->result, "result_text" => __($owner->result, "consent")]];
}
+
+ protected function searchOwnerAction() {
+ $search = $this->request->search;
+
+ $results = PreorderModel::search(['add-where' => " AND firstname LIKE '%$search%' OR lastname LIKE '%$search%'"]);
+ self::returnJson(array_map(function($result) {
+ return [
+ 'id' => $result->id,
+ 'firstname' => $result->firstname,
+ 'lastname' => $result->lastname,
+ 'street' => $result->street,
+ 'zip' => $result->zip,
+ 'city' => $result->city,
+ 'phone' => $result->phone,
+ 'email' => $result->email,
+ 'text' => $result->firstname . " " . $result->lastname . " (" . $result->street . ", " . $result->zip . " " . $result->city . ") [" . $result->phone . " | " . $result->email . "]"
+ ];
+ }, $results));
+ }
}
diff --git a/db/migrations/20250325120000_constr_consent_add_approve_override.php b/db/migrations/20250325120000_constr_consent_add_approve_override.php
new file mode 100644
index 000000000..e6f00f153
--- /dev/null
+++ b/db/migrations/20250325120000_constr_consent_add_approve_override.php
@@ -0,0 +1,23 @@
+getEnvironment() == "thetool") {
+ $ConstructionConsentTable = $this->table("ConstructionConsent");
+ $ConstructionConsentTable
+ ->addColumn("approve_override", "tinyinteger", ["default" => 0])
+ ->save();
+ }
+ }
+
+ public function down(): void {
+ if ($this->getEnvironment() == "thetool") {
+ $ConstructionConsentTable = $this->table("ConstructionConsent");
+ $ConstructionConsentTable
+ ->removeColumn("approve_override")
+ ->save();
+ }
+ }
+}