From a8e552416b0b456a0fa7921764e6af8329ee38f8 Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Wed, 11 Jun 2025 11:40:56 +0200 Subject: [PATCH] added new features --- .../ConstructionConsent/Consentform.pdf.php | 15 +++++ Layout/default/ConstructionConsent/Index.php | 8 +++ Layout/default/ConstructionConsent/View.php | 55 ++++++++++++++++++- .../ConstructionConsent.php | 9 +++ .../ConstructionConsentController.php | 15 +++++ ...00_construction_consent_add_prioritize.php | 28 ++++++++++ 6 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 db/migrations/20250611112000_construction_consent_add_prioritize.php diff --git a/Layout/default/ConstructionConsent/Consentform.pdf.php b/Layout/default/ConstructionConsent/Consentform.pdf.php index 52a2ee30b..a43c80881 100644 --- a/Layout/default/ConstructionConsent/Consentform.pdf.php +++ b/Layout/default/ConstructionConsent/Consentform.pdf.php @@ -468,6 +468,21 @@ foreach ($owners as $owner): + + + + + + + + + + + + + + +
Ort, Datum
diff --git a/Layout/default/ConstructionConsent/Index.php b/Layout/default/ConstructionConsent/Index.php index 44ee32ad5..5e0eae8f8 100644 --- a/Layout/default/ConstructionConsent/Index.php +++ b/Layout/default/ConstructionConsent/Index.php @@ -155,6 +155,14 @@ $pagination_entity_name = "Zustimmungserklärungen"; " />
+
+ + +
diff --git a/Layout/default/ConstructionConsent/View.php b/Layout/default/ConstructionConsent/View.php index bcd50acae..26bb69ee3 100644 --- a/Layout/default/ConstructionConsent/View.php +++ b/Layout/default/ConstructionConsent/View.php @@ -126,6 +126,12 @@ $pagination_entity_name = "Adressen"; approve_override) ? "checked='checked'" : ""?> /> + + Priorisieren + + prioritize) ? "checked='checked'" : ""?> /> + + object_type == "building"): ?>

Metadaten

@@ -1151,11 +1157,16 @@ $pagination_entity_name = "Adressen"; $("#approve_override").on("change", function() { const reason = prompt("Bitte geben Sie einen Grund für das Überschreiben der Genehmigung ein:"); + if (reason != null && reason.length < 3) { + notify("error", "Begründung muss mindestens 3 Zeichen lang sein"); + $(this).prop("checked", false); + switcheries.forEach(s => s.setPosition()); + ret if (reason != null) { $.post("", { consent_id: id?>, text: `Genehmigung überschreiben wurde ${$(this).prop("checked") ? "aktiviert" : "deaktiviert"} | Begründung: ${reason}` - }, function(success) { + }, function (success) { if (success.status != "OK") { notify("error", "Status konnte nicht gespeichert werden"); } else { @@ -1166,6 +1177,47 @@ $pagination_entity_name = "Adressen"; $.get("", { consent_id: 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'); + } + }}); + + // do the same for prioritize + $("#prioritize").on("change", function() { + const reason = prompt("Bitte geben Sie einen Grund für die Priorisierung ein:"); + // reason must be atleast 3 characters long + if (reason != null && reason.length < 3) { + notify("error", "Begründung muss mindestens 3 Zeichen lang sein"); + $(this).prop("checked", false); + switcheries.forEach(s => s.setPosition()); + return; + } + if (reason != null) { + $.post("", { + consent_id: id?>, + text: `Priorisierung 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: id?>, + checked: $(this).prop("checked") ? 1 : 0 }, function(success) { if (success.status != "OK") { notify("error", "Status konnte nicht gespeichert werden"); @@ -1177,6 +1229,7 @@ $pagination_entity_name = "Adressen"; }, 'json'); } }); + }); $(document).ready(function() { diff --git a/application/ConstructionConsent/ConstructionConsent.php b/application/ConstructionConsent/ConstructionConsent.php index 765795cd2..cddce2f75 100644 --- a/application/ConstructionConsent/ConstructionConsent.php +++ b/application/ConstructionConsent/ConstructionConsent.php @@ -637,6 +637,15 @@ FROM ConstructionConsent } } + if(array_key_exists("prioritize", $filter)) { + $approve_override = $filter["prioritize"]; + if($approve_override == "!NULL") { + $where .= " AND (prioritize IS NOT NULL AND prioritize != 0)"; + } elseif($approve_override == "NULL") { + $where .= " AND (prioritize IS NULL OR prioritize = 0)"; + } + } + if(array_key_exists("conduit_installed_ftu", $filter)) { $conduit_installed_ftu = $filter["conduit_installed_ftu"]; if($conduit_installed_ftu == "!NULL") { diff --git a/application/ConstructionConsent/ConstructionConsentController.php b/application/ConstructionConsent/ConstructionConsentController.php index c9b3afc7d..54b33b590 100644 --- a/application/ConstructionConsent/ConstructionConsentController.php +++ b/application/ConstructionConsent/ConstructionConsentController.php @@ -1078,6 +1078,21 @@ class ConstructionConsentController extends mfBaseController { } + protected function prioritizeAction() { + $consent_id = $this->request->consent_id; + $checked = $this->request->checked; + + $consent = new ConstructionConsent($consent_id); + if(!$consent->id) { + $this->returnJson(["status" => "error"]); + } + + $consent->update(["prioritize" => $checked]); + $consent->save(); + + $this->returnJson(["status" => "OK"]); + } + protected function importConstructionConsentOwnersAction() { $projectId = $this->request->project_id; $importData = json_decode(file_get_contents('php://input'), true); diff --git a/db/migrations/20250611112000_construction_consent_add_prioritize.php b/db/migrations/20250611112000_construction_consent_add_prioritize.php new file mode 100644 index 000000000..9f368d67d --- /dev/null +++ b/db/migrations/20250611112000_construction_consent_add_prioritize.php @@ -0,0 +1,28 @@ +getEnvironment() == "thetool") { + $ConstructionConsentTable = $this->table("ConstructionConsent"); + if (!$ConstructionConsentTable->hasColumn("prioritize")) { + $ConstructionConsentTable + ->addColumn("approve_override", "tinyinteger", ["default" => 0]) + ->update(); + } + } + } + + public function down(): void { + if ($this->getEnvironment() == "thetool") { + $ConstructionConsentTable = $this->table("ConstructionConsent"); + if ($ConstructionConsentTable->hasColumn("prioritize")) { + $ConstructionConsentTable + ->removeColumn("prioritize") + ->update(); + } + } + } +}