Files
thetool/Layout/default/ConstructionConsent/Index.php
2025-02-13 08:19:54 +00:00

223 lines
12 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-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 title="Grundstücksnummer">GST-Nr.</th>-->
<!-- <th title="Grundbuch Einlagezahl">EZ</th>-->
<!-- <th>Besitzer</th>-->
<!-- <th>Besitzer Adresse</th>-->
<!-- <th>Besitzer Kontakt</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>--><?php //=$item->ez?><!--</td>-->
<!-- <td>--><?php //=$item->owner_name?><!--</td>-->
<!-- <td>-->
<!-- --><?php //=$item->owner_street?><!--<br />-->
<!-- --><?php //=$item->owner_zip?><!-- --><?php //=$item->owner_city?><!--<br />-->
<!-- </td>-->
<!-- <td>-->
<!-- --><?php //if($item->phone): ?>
<!-- Tel: --><?php //=$item->phone?><!--<br />-->
<!-- --><?php //endif; ?>
<!-- --><?php //if($item->fax): ?>
<!-- Fax: --><?php //=$item->fax?><!--<br />-->
<!-- --><?php //endif; ?>
<!-- --><?php //if($item->email): ?>
<!-- Email: --><?php //=$item->email?>
<!-- --><?php //endif; ?>
<!-- </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>
<?php if($item->status == "new"): ?>
<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; ?>
<?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"); ?>