From bf5bc71e2456512d037187a55875351c90c7e60f Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Mon, 17 Feb 2025 12:55:59 +0100 Subject: [PATCH] Added Stats inside ConstructionConsent --- Layout/default/ConstructionConsent/Index.php | 90 +++++++++++++++++++ .../ConstructionConsent.php | 36 ++++++++ .../ConstructionConsentController.php | 21 +++++ public/assets/css/thetool.css | 8 ++ 4 files changed, 155 insertions(+) diff --git a/Layout/default/ConstructionConsent/Index.php b/Layout/default/ConstructionConsent/Index.php index 82b2ea4c9..20b4fe4d1 100644 --- a/Layout/default/ConstructionConsent/Index.php +++ b/Layout/default/ConstructionConsent/Index.php @@ -89,6 +89,96 @@ $pagination_entity_name = "Zustimmungserklärungen"; +
+
+ +
+ +
+
+
+ + null, + 'header' => 'Liste der Zustimmungserklärungen', + 'icon' => 'fas fa-file-signature', + 'text' => 'Objekttyp', + 'sub' => [ + 'Straße/Grundstück ['.$stats['street'].']', + 'Gebäude ['.$stats['building'].']' + ], + 'color' => '#6c757d' + ], + [ + 'key' => 'inspection_planner', + 'header' => 'Begehung Planer durchgeführt', + 'icon' => 'fas fa-clipboard-check', + 'denominator' => $stats['building'], + 'color' => '#28a745' + ], + [ + 'key' => 'conduit_installed_building', + 'header' => 'Leerrohr im Gebäude', + 'icon' => 'fas fa-house-user', + 'denominator' => $stats['building'], + 'color' => '#17a2b8' + ], + [ + 'key' => 'conduit_installed_ftu', + 'header' => 'Leerrohr bis HAK', + 'icon' => 'fas fa-road', + 'denominator' => $stats['street'], + 'color' => '#f5b902' + ], + [ + 'key' => 'inhouse_cabling', + 'header' => 'Inhouse erledigt', + 'icon' => 'fas fa-plug', + 'denominator' => $stats['building'], + 'color' => '#007bff' + ] + ]; + + foreach ($cardConfig as $config) { + $height = 96 + 25 * (isset($config['sub']) ? count($config['sub']) : 0); + $text = $config['key'] ? + $stats[$config['key']].' / '.$config['denominator'].' ('. + round(($stats[$config['key']]/$config['denominator'])*100).'%)' : + $config['text']; + ?> +
+
+
+
+ +
+
+

+ +
+ +

+ +
+ +
+
+
+ +
+
+
+
diff --git a/application/ConstructionConsent/ConstructionConsent.php b/application/ConstructionConsent/ConstructionConsent.php index 37243778f..83fb93883 100644 --- a/application/ConstructionConsent/ConstructionConsent.php +++ b/application/ConstructionConsent/ConstructionConsent.php @@ -531,6 +531,42 @@ class ConstructionConsent extends mfBaseModel { } } + if(array_key_exists("inspection_planner", $filter)) { + $inspection_planner = $filter["inspection_planner"]; + if($inspection_planner == "!NULL") { + $where .= " AND inspection_planner IS NOT NULL"; + } elseif($inspection_planner == "NULL") { + $where .= " AND inspection_planner IS NULL"; + } + } + + if(array_key_exists("conduit_installed_building", $filter)) { + $conduit_installed_building = $filter["conduit_installed_building"]; + if($conduit_installed_building == "!NULL") { + $where .= " AND conduit_installed_building IS NOT NULL"; + } elseif($conduit_installed_building == "NULL") { + $where .= " AND conduit_installed_building IS NULL"; + } + } + + if(array_key_exists("conduit_installed_ftu", $filter)) { + $conduit_installed_ftu = $filter["conduit_installed_ftu"]; + if($conduit_installed_ftu == "!NULL") { + $where .= " AND conduit_installed_ftu IS NOT NULL"; + } elseif($conduit_installed_ftu == "NULL") { + $where .= " AND conduit_installed_ftu IS NULL"; + } + } + + if(array_key_exists("inhouse_cabling", $filter)) { + $inhouse_cabling = $filter["inhouse_cabling"]; + if($inhouse_cabling == "!NULL") { + $where .= " AND inhouse_cabling IS NOT NULL"; + } elseif($inhouse_cabling == "NULL") { + $where .= " AND inhouse_cabling IS NULL"; + } + } + if(array_key_exists("add-where", $filter)) { diff --git a/application/ConstructionConsent/ConstructionConsentController.php b/application/ConstructionConsent/ConstructionConsentController.php index c07fb68ab..1745f807d 100644 --- a/application/ConstructionConsent/ConstructionConsentController.php +++ b/application/ConstructionConsent/ConstructionConsentController.php @@ -72,6 +72,7 @@ class ConstructionConsentController extends mfBaseController { $items = ConstructionConsent::search($filter, $pagination); $this->layout->set("items", $items); + $this->layout()->set("stats", $this->generateStats($filter)); if(array_key_exists("project_id", $filter) && $filter["project_id"]) { $project = new ConstructionConsentProject($filter["project_id"]); @@ -936,4 +937,24 @@ class ConstructionConsentController extends mfBaseController { return ["message" => "ConstructionConsent saved successfully"]; } + + private function generateStats($baseFilter = []): array { + $allCount = ConstructionConsent::count([...$baseFilter]); + $streetCount = ConstructionConsent::count(["object_type" => "street", ...$baseFilter]); + $buildingCount = ConstructionConsent::count(["object_type" => "building", ...$baseFilter]); + $inspection_planner = ConstructionConsent::count(["inspection_planner" => "!NULL", ...$baseFilter]); + $conduit_installed_building = ConstructionConsent::count(["conduit_installed_building" => "!NULL", ...$baseFilter]); + $conduit_installed_ftu = ConstructionConsent::count(["conduit_installed_ftu" => "!NULL", ...$baseFilter]); + $inhouse_cabling = ConstructionConsent::count(["inhouse_cabling" => "!NULL", ...$baseFilter]); + + return [ + "all" => $allCount, + "street" => $streetCount, + "building" => $buildingCount, + "inspection_planner" => $inspection_planner, + "conduit_installed_building" => $conduit_installed_building, + "conduit_installed_ftu" => $conduit_installed_ftu, + "inhouse_cabling" => $inhouse_cabling + ]; + } } \ No newline at end of file diff --git a/public/assets/css/thetool.css b/public/assets/css/thetool.css index 49edbc532..dd26c87b8 100644 --- a/public/assets/css/thetool.css +++ b/public/assets/css/thetool.css @@ -778,3 +778,11 @@ td.controls { width: 100% !important; max-width: 100% !important; } + +.chevron-icon::before { + content: "\f077"; +} + +.collapsed .chevron-icon::before { + content: "\f078"; +} \ No newline at end of file