Added Stats inside ConstructionConsent
This commit is contained in:
@@ -89,6 +89,96 @@ $pagination_entity_name = "Zustimmungserklärungen";
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<button class="btn btn-primary collapsed"
|
||||
type="button"
|
||||
data-toggle="collapse"
|
||||
data-target="#collapsibleCard"
|
||||
aria-expanded="true"
|
||||
aria-controls="collapsibleCard">
|
||||
<i class="fas fa-chevron-up chevron-icon"></i>
|
||||
Statistiken umschalten
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="collapsibleCard" class="collapse">
|
||||
<div class="card-body mb-3">
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr; grid-gap: 10px;">
|
||||
|
||||
<?php
|
||||
$cardConfig = [
|
||||
[
|
||||
'key' => 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'];
|
||||
?>
|
||||
<div class="card">
|
||||
<div class="card-body p-0" style="background-color: <?= $config['color'] ?>">
|
||||
<div class="p-2" style="height: <?= $height ?>px">
|
||||
<div class="float-right">
|
||||
<i class="<?= $config['icon'] ?> text-white widget-icon font-24"></i>
|
||||
</div>
|
||||
<h5 class="text-white font-weight-normal mt-0"><?= $config['header'] ?></h5>
|
||||
<h3 class="mt-2 text-white"><?= $text ?></h3>
|
||||
<?php if(isset($config['sub'])): ?>
|
||||
<div class="text-white font-weight-light tt-dashboard-display-card-sub-header-container">
|
||||
<?php foreach($config['sub'] as $sub): ?>
|
||||
<p class="mb-0"><?= $sub ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -778,3 +778,11 @@ td.controls {
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
.chevron-icon::before {
|
||||
content: "\f077";
|
||||
}
|
||||
|
||||
.collapsed .chevron-icon::before {
|
||||
content: "\f078";
|
||||
}
|
||||
Reference in New Issue
Block a user