Files
thetool/Layout/default/ConstructionConsent/Index.php
2025-02-17 12:55:59 +01:00

290 lines
15 KiB
PHP

<?php
$pagination_baseurl = $this->getUrl($Mod,"Index");
$pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Zustimmungserklärungen";
?>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
<li class="breadcrumb-item"><a href="<?=self::getUrl("ConstructionConsentProject")?>">Zustimmungserklärungen</a></li>
<li class="breadcrumb-item active">Übersicht<?=(array_key_exists("project_id", $filter) && $filter["project_id"]) ? " ".$project->name : ""?></li>
</ol>
</div>
<h4 class="page-title">Zustimmmungserklärungen</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body mb-3">
<h4 class="header-title mb-3"><i class="fad fa-filter fa-fw"></i> Filter</h4>
<form method="get" action="<?=self::getUrl("ConstructionConsent")?>">
<div class="row">
<div class="col-3">
<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): ?>
<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>
</div>
<div class="col-2">
<label class="form-label" for="filter_object_type">Objektart</label>
<select name="filter[object_type]" id="filter_object_type" class="form-control">
<option value="">Alle</option>
<option value="building" <?=(array_key_exists("object_type", $filter) && $filter["object_type"] == "building") ? "selected='selected'" : ""?>>Gebäude</option>
<option value="street" <?=(array_key_exists("object_type", $filter) && $filter["object_type"] == "street") ? "selected='selected'" : ""?>>Straße</option>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_network">Netzgebiet</label>
<select name="filter[network]" id="filter_network" class="form-control">
<option value="">Alle</option>
<?php
$networks = array_key_exists("project_id", $filter) && $filter["project_id"] ? ConstructionConsentNetwork::search(["constructionconsentproject_id" => $filter["project_id"]]) : ConstructionConsentNetwork::getAll();
$networkOptions = [];
foreach($networks as $network):
if (array_key_exists($network->adb_netzgebiet_id, $networkOptions)) continue;
$networkOptions[$network->adb_netzgebiet_id] = $network;?>
<option value="<?=$network->adb_netzgebiet_id?>" <?=(is_array($filter) && array_key_exists("network", $filter) && $network->adb_netzgebiet_id == $filter["network"]) ? "selected='selected'" : ""?>><?=$network->adb_netzgebiet->name?></option>
<?php endforeach;
?>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_address">Objektadresse</label>
<input type="text" class="form-control" name="filter[address]" id="filter_address" value="<?=(array_key_exists('address', $filter)) ? $filter['address'] : ""?>" />
</div>
</div>
<div class="row mt-2">
<div class="col">
<button type="submit" class="btn btn-primary"><i class="far fa-search fa-fw"></i> Filter anwenden</button>
<a class="btn btn-secondary" href="<?=self::getUrl("ConstructionConsent", "", ["resetFilter" => 1, "filter" => ["project_id" => (is_array($filter) && array_key_exists("project_id", $filter) ? $filter["project_id"] : "")]])?>"><i class="far fa-xmark fa-fw"></i> Filter zurücksetzen</a>
</div>
</div>
</form>
</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">
<div class="row">
<div class="col-12">
<div class="float-left">
<h4 class="header-title">Liste aller Zustimmmungserklärungen</h4>
</div>
<div class="float-right">
<a class="btn btn-primary" href="<?=self::getUrl("ConstructionConsent", "add", ["project_id" => (is_array($filter) && array_key_exists("project_id", $filter) ? $filter["project_id"] : "")])?>"><i class="fas fa-plus"></i> Neue Zustimmungserklärung anlegen</a>
</div>
</div>
</div>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<table class="table table-striped table-hover">
<tr>
<th>Name</th>
<th>Objekttyp</th>
<th>Objektadresse</th>
<th>GST-Nr.</th>
<th>Anfragestatus</th>
<th>Anfrageresultat</th>
<th></th>
</tr>
<?php foreach($items as $item): ?>
<tr>
<td><a href="<?=self::getUrl("ConstructionConsent","View", ["id" => $item->id])?>"><?=$item->name?></a></td>
<td><?=__($item->object_type)?></td>
<td>
<?php if($item->object_type == "street"): ?>
<?=$item->adb_strasse->name?>, <?=$item->adb_strasse->ortschaft->name?><br />
<?=$item->adb_strasse->gemeinde->name?>
<?php else: ?>
<?=$item->adb_hausnummer->strasse->name?>
<?=$item->adb_hausnummer->hausnummer?><?=($item->adb_hausnummer->stiege) ? "/".$item->adb_hausnummer->stiege : ""?><br />
<?=$item->adb_hausnummer->plz->plz?>
<?=$item->adb_hausnummer->ortschaft->name?><br />
<?=$item->adb_hausnummer->strasse->gemeinde->name?>
<?php endif; ?>
</td>
<td><?=$item->gst?></td>
<td><?=($item->status) ? __($item->status,"consent") : ""?></td>
<td>
<?php
// Determine the status based on the counts
$status_class = 'blue'; // Default to blue (all open)
if (isset($item->owner_result_counts['denied']) && $item->owner_result_counts['denied'] > 0) {
$status_class = 'red'; // Red if at least one denied
} elseif ((isset($item->owner_result_counts['unresolvable']) && $item->owner_result_counts['unresolvable'] > 0) ||
(isset($item->owner_result_counts['moved']) && $item->owner_result_counts['moved'] > 0)) {
$status_class = 'yellow'; // Yellow if at least one unresolvable or moved
} elseif (isset($item->owner_result_counts['accepted']) &&
$item->owner_result_counts['accepted'] === count($item->owners)) {
$status_class = 'green'; // Green if all accepted
}
?>
<div class="status-circle <?=$status_class?>"></div>
</td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("ConstructionConsent", "view", ["id" => $item->id])?>"><i class="far fa-eyes" title="Anzeigen"></i></a>
<?php if(!$item->result): ?>
<a href="<?=self::getUrl("ConstructionConsent", "edit", ["id" => $item->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a href="<?=self::getUrl("ConstructionConsent", "delete", ["id" => $item->id])?>" onclick="if(!confirm('Zustimmungserklärung wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
</div>
</div>
</div>
</div>
<style>
/* Styles for the status circle */
.status-circle {
width: 25px;
height: 25px;
border-radius: 50%;
display: inline-block;
}
.status-circle.red {
background-color: #d9534f; /* Red */
}
.status-circle.yellow {
background-color: #f0ad4e; /* Yellow */
}
.status-circle.green {
background-color: #5cb85c; /* Green */
}
.status-circle.blue {
background-color: #337ab7; /* Blue */
}
</style>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>