ConstructionConsent Filter update

This commit is contained in:
Frank Schubert
2025-01-14 14:57:03 +01:00
parent fd88903963
commit ae7d565398
4 changed files with 58 additions and 20 deletions

View File

@@ -36,7 +36,7 @@
<div class="col-lg-10">
<select class="form-control" name="constructionconsentproject_id" id="constructionconsentproject_id">
<?php foreach(ConstructionConsentProject::getAll() as $project): ?>
<option value="<?=$project->id?>" <?=($item->constructionconsentproject_id == $project->id ? "selected='selected'" : "")?>><?=$project->name?></option>
<option value="<?=$project->id?>" <?=(isset($project_id) && $project_id == $project->id || isset($item) && $item->constructionconsentproject_id == $project->id) ? "selected='selected'" : ""?>><?=$project->name?></option>
<?php endforeach; ?>
</select>
</div>
@@ -46,8 +46,8 @@
<label class="col-lg-2 col-form-label" for="object_type">Objekttyp *</label>
<div class="col-lg-10">
<select class="form-control" name="object_type" id="object_type">
<option value="building" <?=($item->object_type == "building" ? "selected='selected'" : "")?>>Gebäude</option>
<option value="street" <?=($item->object_type == "street" ? "selected='selected'" : "")?>>Straße/Grunstück</option>
<option value="building" <?=(isset($item) && $item->object_type == "building" ? "selected='selected'" : "")?>>Gebäude</option>
<option value="street" <?=(isset($item) && $item->object_type == "street" ? "selected='selected'" : "")?>>Straße/Grunstück</option>
</select>
</div>
</div>
@@ -55,7 +55,7 @@
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="name">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="name" id="name" value="<?=$item->name?>" placeholder="z.B. Straße oder Adresse" />
<input type="text" class="form-control" name="name" id="name" value="<?=(isset($item)) ? $item->name : ""?>" placeholder="z.B. Straße oder Adresse" />
</div>
</div>
@@ -64,7 +64,7 @@
<label class="col-lg-2 col-form-label" for="adb_strasse_id">Straße *</label>
<div class="col-lg-10">
<select class="form-control" name="adb_strasse_id" id="adb_strasse_id">
<?php if($item->adb_strasse_id): ?>
<?php if(isset($item) && $item->adb_strasse_id): ?>
<option value="<?=$item->adb_strasse_id?>" selected="selected"><?=$item->adb_strasse->gemeinde->name?>, <?=$item->adb_strasse->name?></option>
<?php endif; ?>
</select>
@@ -76,28 +76,28 @@
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="ez">Grundbuch Einlagezahl EZ</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="ez" id="ez" value="<?=$item->ez?>" />
<input type="text" class="form-control" name="ez" id="ez" value="<?=(isset($item)) ? $item->ez : ""?>" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="kg">KG</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="kg" id="kg" value="<?=$item->kg?>" />
<input type="text" class="form-control" name="kg" id="kg" value="<?=(isset($item)) ? $item->kg : ""?>" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="gst">GST</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="gst" id="gst" value="<?=$item->gst?>" />
<input type="text" class="form-control" name="gst" id="gst" value="<?=(isset($item)) ? $item->gst : ""?>" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="gstnr">GSTNR</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="gstnr" id="gstnr" value="<?=$item->gstnr?>" />
<input type="text" class="form-control" name="gstnr" id="gstnr" value="<?=(isset($item)) ? $item->gstnr : ""?>" />
</div>
</div>
@@ -107,7 +107,7 @@
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="usage_length">Länge auf Grundstück (in m)</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="usage_length" id="usage_length" value="<?=$item->usage_length?>" />
<input type="text" class="form-control" name="usage_length" id="usage_length" value="<?=(isset($item)) ? $item->usage_length : ""?>" />
</div>
</div>
@@ -115,7 +115,7 @@
<div class="col-lg-2"></div>
<div class="col-lg-10">
<label>
<input type="checkbox" name="usage_pipe_on_plot" id="usage_pipe_on_plot" value="1" <?=($item->usage_pipe_on_plot ? "checked='checked'" : "")?> />
<input type="checkbox" name="usage_pipe_on_plot" id="usage_pipe_on_plot" value="1" <?=(isset($item) && $item->usage_pipe_on_plot ? "checked='checked'" : "")?> />
Verlegung von Rohren und Lichtwellenleitern am Grundstück
</label>
</div>
@@ -125,7 +125,7 @@
<div class="col-lg-2"></div>
<div class="col-lg-10">
<label>
<input type="checkbox" name="usage_pipe_in_building" id="usage_pipe_in_building" value="1" <?=($item->usage_pipe_in_building ? "checked='checked'" : "")?> />
<input type="checkbox" name="usage_pipe_in_building" id="usage_pipe_in_building" value="1" <?=(isset($item) && $item->usage_pipe_in_building ? "checked='checked'" : "")?> />
Verlegung von Rohren und Lichtwellenleitern in den darauf befindlichen Gebäuden
</label>
</div>
@@ -135,7 +135,7 @@
<div class="col-lg-2"></div>
<div class="col-lg-10">
<label>
<input type="checkbox" name="usage_manhole" id="usage_manhole" value="1" <?=($item->usage_manhole ? "checked='checked'" : "")?> />
<input type="checkbox" name="usage_manhole" id="usage_manhole" value="1" <?=(isset($item) && $item->usage_manhole ? "checked='checked'" : "")?> />
Errichtung eines Schachtes/einer Kabelmontagegrube und/oder eines LWL-Verteilschrankes/einer LWL-Abschlussbox
</label>
</div>
@@ -145,7 +145,7 @@
<div class="col-lg-2"></div>
<div class="col-lg-10">
<label>
<input type="checkbox" name="usage_owner" id="usage_owner" value="1" <?=($item->usage_owner ? "checked='checked'" : "")?> />
<input type="checkbox" name="usage_owner" id="usage_owner" value="1" <?=(isset($item) && $item->usage_owner ? "checked='checked'" : "")?> />
Die Nutzung der Liegenschaft seitens BB dient der Eigenversorgung der GE und/oder dessen Nutzer(in) und wird dieser entgeltlos zugestimmt
</label>
</div>
@@ -166,7 +166,7 @@
<div class="form-group row mt-3">
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
<div class="col-lg-10">
<textarea id="note" class="form-control" name="note" rows="5"><?=$project->note?></textarea>
<textarea id="note" class="form-control" name="note" rows="5"><?=(isset($item)) ? $item->note : ""?></textarea>
</div>
</div>
@@ -207,7 +207,14 @@
*/
$('#adb_strasse_id').select2({
ajax: {
url: '<?=self::getUrl("ConstructionConsent", "api", ["do" => "findStreet", "project_id" => $project->id])?>',
url: '<?=self::getUrl("ConstructionConsent", "api")?>',
data: (params) => {
return {
q: params.term,
do: "findStreet",
project_id: $("#constructionconsentproject_id :selected").val()
}
},
delay: 250,
dataType: 'json'
},
@@ -220,6 +227,11 @@
$('#new-address-toggle').show();
}
});
$("#constructionconsentproject_id").change(() => {
$("#adb_strasse_id").val("").change();
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -36,8 +36,8 @@ $pagination_entity_name = "Zustimmungserklärungen";
<label class="form-label" for="filter_project_id">Projekt</label>
<select name="filter[project_id]" id="filter_project_id" class="form-control">
<option></option>
<?php foreach(ConstructionConsentProject::getAll() as $project): ?>
<option value="<?=$project->id?>" <?=(is_array($filter) && array_key_exists("project_id", $filter) && $project->id == $filter["project_id"]) ? "selected='selected'" : ""?>><?=$project->name?></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>
@@ -62,7 +62,7 @@ $pagination_entity_name = "Zustimmungserklärungen";
<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])?>"><i class="far fa-xmark fa-fw"></i> Filter zurücksetzen</a>
<a class="btn btn-secondary" href="<?=self::getUrl("ConstructionConsent", "", ["resetFilter" => 1, "filter" => ["project_id" => $filter["project_id"]]])?>"><i class="far fa-xmark fa-fw"></i> Filter zurücksetzen</a>
</div>
</div>
</form>
@@ -80,7 +80,7 @@ $pagination_entity_name = "Zustimmungserklärungen";
<h4 class="header-title">Liste aller Zustimmmungserklärungen</h4>
</div>
<div class="float-right">
<a class="btn btn-primary" href="<?=self::getUrl("ConstructionConsent", "add")?>"><i class="fas fa-plus"></i> Neue Zustimmungserklärung anlegen</a>
<a class="btn btn-primary" href="<?=self::getUrl("ConstructionConsent", "add", ["project_id" => $filter["project_id"]])?>"><i class="fas fa-plus"></i> Neue Zustimmungserklärung anlegen</a>
</div>
</div>
</div>

View File

@@ -262,6 +262,20 @@ class ConstructionConsent extends mfBaseModel {
private static function getSqlFilter($filter) {
$where = "1=1 ";
if(array_key_exists("project_id", $filter)) {
$project_id = $filter['project_id'];
if(is_numeric($project_id)) {
$where .= " AND ConstructionConsent.constructionconsentproject_id=$project_id";
}
}
if(array_key_exists("constructionconsentproject_id", $filter)) {
$constructionconsentproject_id = $filter['constructionconsentproject_id'];
if(is_numeric($constructionconsentproject_id)) {
$where .= " AND ConstructionConsent.constructionconsentproject_id=$constructionconsentproject_id";
}
}
if(array_key_exists("adb_wohneinheit_id", $filter)) {
$adb_wohneinheit_id = $filter['adb_wohneinheit_id'];
if(is_numeric($adb_wohneinheit_id)) {

View File

@@ -75,6 +75,13 @@ class ConstructionConsentController extends mfBaseController {
$items = ConstructionConsent::search($filter);
$this->layout->set("items", $items);
if(array_key_exists("project_id", $filter) && $filter["project_id"]) {
$project = new ConstructionConsentProject($filter["project_id"]);
if($project->id) {
$this->layout()->set("project", $project);
}
}
}
private function getPreparedFilter($filter) : array
@@ -87,6 +94,8 @@ class ConstructionConsentController extends mfBaseController {
}
}
return $new_filter;
}
@@ -110,6 +119,9 @@ class ConstructionConsentController extends mfBaseController {
protected function addAction() : void {
$this->layout()->setTemplate("ConstructionConsent/Form");
if($this->request->project_id) {
$this->layout()->set("project_id", $this->request->project_id);
}
}
protected function editAction() : void {