WIP 2024-12-12 ConstructionConsent
This commit is contained in:
@@ -68,14 +68,29 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="ez">Grundbuch Einlagezahl</label>
|
||||
<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?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2"></label>
|
||||
<div class="col-lg-10">
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -31,6 +31,17 @@ $pagination_entity_name = "Zustimmungserklärungen";
|
||||
|
||||
<form method="get" action="<?=self::getUrl("ConstructionConsent")?>">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-2">
|
||||
<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(ConstructionConsentNetwork::getAll() as $ccn): ?>
|
||||
<option value="<?=$ccn->id?>" <?=(is_array($filter) && array_key_exists("project_id", $filter) && $ccn->id == $filter["project_id"]) ? "selected='selected'" : ""?>><?=$ccn->adb_netzgebiet->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">
|
||||
@@ -59,9 +70,21 @@ $pagination_entity_name = "Zustimmungserklärungen";
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($me->is("Admin")): ?>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<a href="<?=self::getUrl("ConstructionConsentProject")?>" class="btn btn-success">Projekte bearbeiten</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="float-left">
|
||||
|
||||
90
Layout/default/ConstructionConsentProject/Form.php
Normal file
90
Layout/default/ConstructionConsentProject/Form.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?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ärungsprojekte</a></li>
|
||||
<li class="breadcrumb-item active"><?= ($Action == "add") ? "neu" : "bearbeiten" ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Zustimmungserklärung</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card bg-light">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2">
|
||||
<?= ($Action == "add") ? "Neues " : "" ?>Zustimmungserklärungsprojekt <?= ($Action == "edit") ? "bearbeiten " : "" ?>
|
||||
</h4>
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?= self::getUrl("ConstructionConsentProject", "save") ?>">
|
||||
<input type="hidden" name="id" value="<?=isset($project) ? $project->id : ""?>"/>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="name">Projektname *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="name" id="name" value="<?=$project->name?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="adb_network_id">Netzgebiete *</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control select2" name="adb_netzgebiet_id[]" id="adb_netzgebiet_id" multiple="multiple">
|
||||
<?php foreach(ADBNetzgebietModel::getAll() as $net): ?>
|
||||
<option value="<?=$net->id?>" <?=(is_array($project->adb_networks) && array_key_exists($net->id, $project->adb_networks)) ? "selected='selected'" : ""?> ><?=$net->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2"></label>
|
||||
<div class="col-lg-10">
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(".select2").select2({
|
||||
allowClear: true,
|
||||
placeholder: "",
|
||||
closeOnSelect: false
|
||||
});
|
||||
|
||||
$('#adb_hausnummer_id').on('select2:close', function(e) {
|
||||
if(!$('#adb_hausnummer_id').val()) {
|
||||
$('#new-address-toggle').show();
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
|
||||
112
Layout/default/ConstructionConsentProject/Index.php
Normal file
112
Layout/default/ConstructionConsentProject/Index.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
$pagination_baseurl = $this->getUrl($Mod,"Index");
|
||||
$pagination_baseurl_params = ["filter" => $filter];
|
||||
$pagination_entity_name = "Zustimmungserklärungsprojekte";
|
||||
?>
|
||||
<?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("ConstructionConsent")?>">Zustimmmungserklärungen</a></li>
|
||||
<li class="breadcrumb-item active">Projekte</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">
|
||||
<a href="<?=self::getUrl("ConstructionConsent")?>" class="btn btn-outline-secondary"><i class="fas fa-fw fa-arrow-left"></i> Zurück zu Zustimmungserklärungen</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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-1">
|
||||
<label class="form-label" for="filter_name">Name</label>
|
||||
<input type="text" class="form-control" name="filter[name]" id="filter_name" value="<?=(is_array($filter) && array_key_exists('name', $filter)) ? $filter['name'] : ""?>" />
|
||||
</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])?>"><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ärungsprojekte</h4>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary" href="<?=self::getUrl("ConstructionConsentProject", "add")?>"><i class="fas fa-plus"></i> Neue Zustimmungserklärungsprojekt erstellen</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>Projektname</th>
|
||||
<th>Netzgebiete</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($projects as $project): ?>
|
||||
<tr>
|
||||
<td><?=$project->name?></td>
|
||||
<td>
|
||||
<?php if(is_array($project->networks) && count($project->networks)): ?>
|
||||
<ul>
|
||||
<?php foreach($project->networks as $network): ?>
|
||||
<li><?=$network->adb_netzgebiet->name?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("ConstructionConsentProject", "edit", ["id" => $project->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
</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>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
180
application/ConstructionConsentFile/ConstructionConsentFile.php
Normal file
180
application/ConstructionConsentFile/ConstructionConsentFile.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
class ConstructionConsentFile extends mfBaseModel {
|
||||
private $file;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "creator") {
|
||||
$user = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($user) {
|
||||
$this->creator = $user;
|
||||
return $this->creator;
|
||||
}
|
||||
$this->creator = new User($this->create_by);
|
||||
if($this->creator->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
|
||||
}
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
if($name == "editor") {
|
||||
$this->editor = new User($this->edit_by);
|
||||
return $this->editor;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||
if(!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
/********************************
|
||||
* Begin static Model functions
|
||||
*/
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ConstructionConsentFile();
|
||||
|
||||
$table_fields = [
|
||||
"constructionconsent_id", "file_id", "filename",
|
||||
"create_by","edit_by","create","edit"
|
||||
];
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(in_array($field, $table_fields)) {
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ConstructionConsentFile", "*", "1 = 1 ORDER BY file_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ConstructionConsentFile($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst($filter = []) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ConstructionConsentFile", "*", "$where ORDER BY file_id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ConstructionConsentFile($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM `ConstructionConsentFile`
|
||||
WHERE $where
|
||||
";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit=false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
|
||||
$sql = "SELECT ConstructionConsentFile.* FROM `ConstructionConsentFile`
|
||||
WHERE $where
|
||||
ORDER BY file_id
|
||||
";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ConstructionConsentFile($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("mailtemplate_id", $filter)) {
|
||||
$mailtemplate_id = $filter['mailtemplate_id'];
|
||||
if(is_numeric($mailtemplate_id)) {
|
||||
$where .= " AND ConstructionConsentFile.`mailtemplate_id` = $mailtemplate_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("file_id", $filter)) {
|
||||
$file_id = $filter['file_id'];
|
||||
if(is_numeric($file_id)) {
|
||||
$where .= " AND ConstructionConsentFile.`file_id` = $file_id";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
class ConstructionConsentJournal extends mfBaseModel {
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||
if(!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
/********************************
|
||||
* Begin static Model functions
|
||||
*/
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ConstructionConsentJournal();
|
||||
|
||||
$table_fields = [
|
||||
"constructionconsent_id", "type", "value", "text",
|
||||
"create_by","edit_by","create","edit"
|
||||
];
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(in_array($field, $table_fields)) {
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ConstructionConsentJournal", "*", "1 = 1 ORDER BY `create`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ConstructionConsentJournal($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ConstructionConsentJournal
|
||||
WHERE $where
|
||||
ORDER BY `create` LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ConstructionConsentJournal($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM ConstructionConsentJournal
|
||||
WHERE $where";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false, $order = false) {
|
||||
//var_dump($filter);exit;
|
||||
$items = [];
|
||||
|
||||
if(!$order) {
|
||||
$order = "`create` ASC";
|
||||
}
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ConstructionConsentJournal
|
||||
WHERE $where
|
||||
ORDER BY $order";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new ConstructionConsentJournal($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
if(array_key_exists("constructionconsent_id", $filter)) {
|
||||
$constructionconsent_id = $filter['constructionconsent_id'];
|
||||
if(is_numeric($constructionconsent_id)) {
|
||||
$where .= " AND constructionconsent_id=$constructionconsent_id";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
$where .= " ".$filter['add-where'];
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
class ConstructionConsentNetwork extends mfBaseModel {
|
||||
private $adb_netzgebiet;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "adb_netzgebiet") {
|
||||
$netzgebiet = new ADBNetzgebiet($this->adb_netzgebiet_id);
|
||||
if(!$netzgebiet->id) {
|
||||
return null;
|
||||
}
|
||||
$this->adb_netzgebiet = $netzgebiet;
|
||||
return $this->adb_netzgebiet;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||
if(!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
/********************************
|
||||
* Begin static Model functions
|
||||
*/
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ConstructionConsentNetwork();
|
||||
|
||||
$table_fields = [
|
||||
"constructionconsentproject_id", "adb_netzgebiet_id",
|
||||
"create_by","edit_by","create","edit"
|
||||
];
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(in_array($field, $table_fields)) {
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ConstructionConsentNetwork", "*", "1 = 1 ORDER BY adb_netzgebiet_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ConstructionConsentNetwork($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT ConstructionConsentNetwork.* FROM ConstructionConsentNetwork
|
||||
WHERE $where
|
||||
ORDER BY adb_netzgebiet_id
|
||||
LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ConstructionConsentNetwork($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM ConstructionConsentNetwork
|
||||
WHERE $where
|
||||
ORDER BY adb_netzgebiet_id
|
||||
";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false, $order = false) {
|
||||
//var_dump($filter);exit;
|
||||
$items = [];
|
||||
|
||||
if(!$order) {
|
||||
$order = "adb_netzgebiet_id ASC";
|
||||
}
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT ConstructionConsentNetwork.* FROM ConstructionConsentNetwork
|
||||
WHERE $where
|
||||
GROUP BY ConstructionConsentNetwork.id
|
||||
ORDER BY $order";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new ConstructionConsentNetwork($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("constructionconsentproject_id", $filter)) {
|
||||
$constructionconsentproject_id = $filter["constructionconsentproject_id"];
|
||||
if(is_numeric($constructionconsentproject_id)) {
|
||||
$where .= " AND constructionconsentproject_id='$constructionconsentproject_id'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("adb_netzgebiet_id", $filter)) {
|
||||
$adb_netzgebiet_id = $filter["adb_netzgebiet_id"];
|
||||
if(is_numeric($adb_netzgebiet_id)) {
|
||||
$where .= " AND adb_netzgebiet_id='$adb_netzgebiet_id'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
$where .= " ".$filter['add-where'];
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
class ConstructionConsentOwner extends mfBaseModel {
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||
if(!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
/********************************
|
||||
* Begin static Model functions
|
||||
*/
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ConstructionConsentOwner();
|
||||
|
||||
$table_fields = [
|
||||
"constructionconsent_id", "owner_name", "owner_street", "owner_zip", "owner_city", "owner_country", "owner_phone",
|
||||
"owner_fax", "owner_email", "status", "result", "create_by","edit_by","create","edit"
|
||||
];
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(in_array($field, $table_fields)) {
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ConstructionConsentOwner", "*", "1 = 1 ORDER BY owner_name");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ConstructionConsentOwner($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ConstructionConsentOwner
|
||||
WHERE $where
|
||||
ORDER BY adb_hausnummer_id LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ConstructionConsentOwner($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM ConstructionConsentOwner
|
||||
WHERE $where";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false, $order = false) {
|
||||
//var_dump($filter);exit;
|
||||
$items = [];
|
||||
|
||||
if(!$order) {
|
||||
$order = "owner_name ASC";
|
||||
}
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ConstructionConsentOwner
|
||||
WHERE $where
|
||||
ORDER BY $order";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new ConstructionConsentOwner($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
if(array_key_exists("constructionconsent_id", $filter)) {
|
||||
$constructionconsent_id = $filter['constructionconsent_id'];
|
||||
if(is_numeric($constructionconsent_id)) {
|
||||
$where .= " AND constructionconsent_id=$constructionconsent_id";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
$where .= " ".$filter['add-where'];
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
class ConstructionConsentProject extends mfBaseModel {
|
||||
private $consents;
|
||||
private $networks;
|
||||
private $adb_networks;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "consents") {
|
||||
$consents = ConstructionConsent::search(["constructionconsentproject_id" => $this->id]);
|
||||
if(!$consents) {
|
||||
return [];
|
||||
|
||||
}
|
||||
$this->consents = $consents;
|
||||
return $this->consents;
|
||||
}
|
||||
|
||||
if($name == "networks") {
|
||||
$networks = ConstructionConsentNetwork::search(["constructionconsentproject_id" => $this->id]);
|
||||
if(!$networks) {
|
||||
return [];
|
||||
}
|
||||
foreach($networks as $network) {
|
||||
$this->networks[$network->id] = $network;
|
||||
}
|
||||
return $this->networks;
|
||||
}
|
||||
|
||||
if($name == "adb_networks") {
|
||||
$networks = ConstructionConsentNetwork::search(["constructionconsentproject_id" => $this->id]);
|
||||
if(!$networks) {
|
||||
return [];
|
||||
}
|
||||
foreach($networks as $network) {
|
||||
$this->networks[$network->adb_netzgebiet->id] = $network->adb_netzgebiet_id;
|
||||
}
|
||||
return $this->networks;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
|
||||
if(!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
/********************************
|
||||
* Begin static Model functions
|
||||
*/
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new ConstructionConsentProject();
|
||||
|
||||
$table_fields = [
|
||||
"name", "note",
|
||||
"create_by","edit_by","create","edit"
|
||||
];
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(in_array($field, $table_fields)) {
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("ConstructionConsentProject", "*", "1 = 1 ORDER BY name");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ConstructionConsentProject($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT ConstructionConsentProject.* FROM ConstructionConsentProject
|
||||
LEFT JOIN ConstructionConsentNetwork ON (ConstructionConsentNetwork.constructionconsentproject_id = ConstructionConsentNetwork.id)
|
||||
WHERE $where
|
||||
GROUP BY ConstructionConsentProject.id
|
||||
ORDER BY name
|
||||
LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ConstructionConsentProject($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM ConstructionConsentProject
|
||||
LEFT JOIN ConstructionConsentNetwork ON (ConstructionConsentNetwork.constructionconsentproject_id = ConstructionConsentNetwork.id)
|
||||
WHERE $where
|
||||
GROUP BY ConstructionConsentProject.id
|
||||
";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false, $order = false) {
|
||||
//var_dump($filter);exit;
|
||||
$items = [];
|
||||
|
||||
if(!$order) {
|
||||
$order = "name ASC";
|
||||
}
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT ConstructionConsentProject.* FROM ConstructionConsentProject
|
||||
LEFT JOIN ConstructionConsentNetwork ON (ConstructionConsentNetwork.constructionconsentproject_id = ConstructionConsentNetwork.id)
|
||||
WHERE $where
|
||||
GROUP BY ConstructionConsentProject.id
|
||||
ORDER BY $order";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new ConstructionConsentProject($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter["name"]);
|
||||
if($name) {
|
||||
$where .= " AND name='$name'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
$where .= " ".$filter['add-where'];
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
class ConstructionConsentProjectController extends mfBaseController {
|
||||
|
||||
protected function init() : void
|
||||
{
|
||||
$this->needlogin = true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction() : void {
|
||||
$this->layout()->setTemplate("ConstructionConsentProject/Index");
|
||||
|
||||
$projects = ConstructionConsentProject::getAll();
|
||||
$this->layout()->set("projects", $projects);
|
||||
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("ConstructionConsentProject/Form");
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
$id = $this->request->id;
|
||||
if(!$id || $id < 1) {
|
||||
$this->layout()->setFlash("Projekt nicht gefunden", "error");
|
||||
$this->redirect("ConstructionConsentProject");
|
||||
}
|
||||
|
||||
$project = new ConstructionConsentProject($id);
|
||||
if(!$project->id) {
|
||||
$this->layout()->setFlash("Projekt nicht gefunden", "error");
|
||||
$this->redirect("ConstructionConsentProject");
|
||||
}
|
||||
|
||||
$this->layout()->set("project", $project);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
if(!$this->me->is("Admin")) {
|
||||
$this->redirect("ConstructionConsent");
|
||||
}
|
||||
|
||||
$r = $this->request;
|
||||
//var_dump($r->get());exit;
|
||||
$id = $r->id;
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$project = new ConstructionConsentProject($id);
|
||||
if(!$project->id) {
|
||||
$this->layout()->setFlash("Zustimmungserklärungsprojekt nicht gefunden", "error");
|
||||
$this->redirect("ConstructionConsentProject");
|
||||
}
|
||||
} else {
|
||||
$id = false;
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data["name"] = $r->name;
|
||||
|
||||
if(!$r->name) {
|
||||
$this->layout()->setFlash("Bitte alle erforderlichen Felder ausfüllen", "error");
|
||||
$this->redirect("ConstructionConsentProject");
|
||||
}
|
||||
if(!is_array($r->adb_netzgebiet_id) || !count($r->adb_netzgebiet_id)) {
|
||||
$this->layout()->setFlash("Bitte alle erforderlichen Felder ausfüllen", "error");
|
||||
$this->redirect("ConstructionConsentProject");
|
||||
}
|
||||
|
||||
$netzgebiete = [];
|
||||
|
||||
foreach($r->adb_netzgebiet_id as $netzgebiet_id) {
|
||||
$netzgebiet = new ADBNetzgebiet($netzgebiet_id);
|
||||
if(!$netzgebiet->id) continue;
|
||||
|
||||
$netzgebiete[] = $netzgebiet_id;
|
||||
}
|
||||
|
||||
if($mode == "add") {
|
||||
$project = ConstructionConsentProject::create($data);
|
||||
} else {
|
||||
$project->update($data);
|
||||
}
|
||||
|
||||
if(!$project->save()) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
if($mode == "add") {
|
||||
$this->redirect("ConstructionConsentProject", "add");
|
||||
} else {
|
||||
$this->redirect("ConstructionConsentProject", "edit", ["id" => $project->id]);
|
||||
}
|
||||
}
|
||||
|
||||
//save networks
|
||||
foreach($netzgebiete as $netzgebiet_id) {
|
||||
$ccn = ConstructionConsentNetwork::getFirst(["constructionconsentproject_id" => $project->id, "adb_netzgebiet_id" => $netzgebiet_id]);
|
||||
if(!$ccn) {
|
||||
$ccn = ConstructionConsentNetwork::create([
|
||||
"constructionconsentproject_id" => $project->id,
|
||||
"adb_netzgebiet_id" => $netzgebiet_id
|
||||
]);
|
||||
$ccn->save();
|
||||
}
|
||||
}
|
||||
|
||||
foreach(ConstructionConsentNetwork::search(["constructionconsentproject_id" => $project->id]) as $ccn) {
|
||||
if(!in_array($ccn->adb_netzgebiet_id, $netzgebiete)) {
|
||||
$ccn->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Zustimmungserklärungsprojekt erfolgreich gespeichert", "success");
|
||||
$this->redirect("ConstructionConsentProject");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreateConstructionConsentProject extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$ccp = $this->table("ConstructionConsentProject");
|
||||
$ccp->addColumn("name", "string", ["null" => false, "limit" => 255]);
|
||||
$ccp->addColumn("sender_name", "string", ["null" => false, "limit" => 64]);
|
||||
$ccp->addColumn("sender_email", "string", ["null" => false, "limit" => 64]);
|
||||
$ccp->addColumn("sender_reply_to", "string", ["null" => false, "limit" => 64]);
|
||||
$ccp->addColumn("email", "string", ["null" => false, "limit" => 64]);
|
||||
$ccp->addColumn("phone", "string", ["null" => false, "limit" => 64]);
|
||||
$ccp->addColumn("note", "text", ["null" => true, "default" => null]);
|
||||
$ccp->addColumn("create_by", "integer", ["null" => false]);
|
||||
$ccp->addColumn("edit_by", "integer", ["null" => false]);
|
||||
$ccp->addColumn("create", "integer", ["null" => false]);
|
||||
$ccp->addColumn("edit", "integer", ["null" => false]);
|
||||
$ccp->create();
|
||||
|
||||
$ccn = $this->table("ConstructionConsentNetwork");
|
||||
$ccn->addColumn("constructionconsentproject_id", "integer", ["null" => false]);
|
||||
$ccn->addColumn("adb_netzgebiet_id", "integer", ["null" => false]);
|
||||
$ccn->addColumn("create_by", "integer", ["null" => false]);
|
||||
$ccn->addColumn("edit_by", "integer", ["null" => false]);
|
||||
$ccn->addColumn("create", "integer", ["null" => false]);
|
||||
$ccn->addColumn("edit", "integer", ["null" => false]);
|
||||
$ccn->create();
|
||||
|
||||
$cc = $this->table("ConstructionConsent");
|
||||
$cc->addColumn("constructionconsentproject_id", "integer", ["null" => false, "after" => "id"]);
|
||||
$cc->addColumn("name", "string", ["null" => true, "default" => null, "limit" => 255, "after" => "object_type"]);
|
||||
$cc->addColumn("kg", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "ez"]);
|
||||
$cc->addColumn("gst", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "kg"]);
|
||||
$cc->addColumn("gstnr", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "gst"]);
|
||||
$cc->addColumn("usage_length", "string", ["null" => true, "default" => null, "limit" => 32, "after" => "gstnr"]);
|
||||
$cc->addColumn("usage_pipe_on_plot", "integer", ["null" => false, "default" => 0, "after" => "usage_length"]);
|
||||
$cc->addColumn("usage_pipe_in_building", "integer", ["null" => false, "default" => 0, "after" => "usage_pipe_on_plot"]);
|
||||
$cc->addColumn("usage_manhole", "integer", ["null" => false, "default" => 0, "after" => "usage_pipe_in_building"]);
|
||||
$cc->addColumn("usage_owner", "integer", ["null" => false, "default" => 0, "after" => "usage_manhole"]);
|
||||
$cc->addColumn("result_text", "text", ["null" => true, "default" => null, "after" => "result"]);
|
||||
$cc->addColumn("note", "text", ["null" => true, "default" => null, "after" => "result_text"]);
|
||||
$cc->removeColumn("owner_name");
|
||||
$cc->removeColumn("owner_street");
|
||||
$cc->removeColumn("owner_zip");
|
||||
$cc->removeColumn("owner_city");
|
||||
$cc->removeColumn("owner_country");
|
||||
$cc->removeColumn("owner_phone");
|
||||
$cc->removeColumn("owner_fax");
|
||||
$cc->removeColumn("owner_email");
|
||||
$cc->update();
|
||||
|
||||
$cco = $this->table("ConstructionConsentOwner");
|
||||
$cco->addColumn("constructionconsent_id", "integer", ["null" => false]);
|
||||
$cco->addColumn("owner_name", "string", ["null" => true, "default" => null, "limit" => "255"]);
|
||||
$cco->addColumn("owner_street", "string", ["null" => true, "default" => null, "limit" => "64"]);
|
||||
$cco->addColumn("owner_zip", "string", ["null" => true, "default" => null, "limit" => "32"]);
|
||||
$cco->addColumn("owner_city", "string", ["null" => true, "default" => null, "limit" => "64"]);
|
||||
$cco->addColumn("owner_country", "string", ["null" => true, "default" => null, "limit" => "64"]);
|
||||
$cco->addColumn("owner_phone", "string", ["null" => true, "default" => null, "limit" => "64"]);
|
||||
$cco->addColumn("owner_fax", "string", ["null" => true, "default" => null, "limit" => "64"]);
|
||||
$cco->addColumn("owner_email", "string", ["null" => true, "default" => null, "limit" => "64"]);
|
||||
$cco->addColumn("status", "enum", ["null" => false, "default" => "new", "values" => "new,requested,answered"]);
|
||||
$cco->addColumn("result", "enum", ["null" => true, "default" => null, "values" => "success,failure"]);
|
||||
$cco->addColumn("create_by", "integer", ["null" => false]);
|
||||
$cco->addColumn("edit_by", "integer", ["null" => false]);
|
||||
$cco->addColumn("create", "integer", ["null" => false]);
|
||||
$cco->addColumn("edit", "integer", ["null" => false]);
|
||||
$cco->create();
|
||||
|
||||
$ccj = $this->table("ConstructionConsentJournal");
|
||||
$ccj->addColumn("constructionconsent_id", "integer", ["null" => false]);
|
||||
$ccj->addColumn("type", "string", ["null" => false]);
|
||||
$ccj->addColumn("value", "string", ["null" => false, "limit" => 64]);
|
||||
$ccj->addColumn("text", "string", ["null" => false, "limit" => 64]);
|
||||
$ccj->addColumn("create_by", "integer", ["null" => false]);
|
||||
$ccj->addColumn("edit_by", "integer", ["null" => false]);
|
||||
$ccj->addColumn("create", "integer", ["null" => false]);
|
||||
$ccj->addColumn("edit", "integer", ["null" => false]);
|
||||
$ccj->create();
|
||||
|
||||
$ccf = $this->table("ConstructionConsentFile");
|
||||
$ccf->addColumn("constructionconsent_id", "integer", ["null" => false]);
|
||||
$ccf->addColumn("file_id", "integer", ["null" => false]);
|
||||
$ccf->addColumn("filename", "string", ["null" => false]);
|
||||
$ccf->addColumn("create_by", "integer", ["null" => false]);
|
||||
$ccf->addColumn("edit_by", "integer", ["null" => false]);
|
||||
$ccf->addColumn("create", "integer", ["null" => false]);
|
||||
$ccf->addColumn("edit", "integer", ["null" => false]);
|
||||
$ccf->create();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$this->table("ConstructionConsentFile")->drop()->save();
|
||||
$this->table("ConstructionConsentJournal")->drop()->save();
|
||||
$this->table("ConstructionConsentOwner")->drop()->save();
|
||||
$this->table("ConstructionConsentNetwork")->drop()->save();
|
||||
$this->table("ConstructionConsentProject")->drop()->save();
|
||||
|
||||
$cc = $this->table("ConstructionConsent");
|
||||
$cc->removeColumn("constructionconsentproject_id");
|
||||
$cc->removeColumn("name");
|
||||
$cc->removeColumn("kg");
|
||||
$cc->removeColumn("gst");
|
||||
$cc->removeColumn("gstnr");
|
||||
$cc->removeColumn("usage_length");
|
||||
$cc->removeColumn("usage_pipe_on_plot");
|
||||
$cc->removeColumn("usage_pipe_in_building");
|
||||
$cc->removeColumn("usage_manhole");
|
||||
$cc->removeColumn("usage_owner");
|
||||
$cc->removeColumn("result_text");
|
||||
$cc->removeColumn("note");
|
||||
|
||||
$cc->addColumn("owner_name", "string", ["null" => true, "default" => null, "limit" => "255", "after" => "ez"]);
|
||||
$cc->addColumn("owner_street", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_name"]);
|
||||
$cc->addColumn("owner_zip", "string", ["null" => true, "default" => null, "limit" => "32", "after" => "owner_street"]);
|
||||
$cc->addColumn("owner_city", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_zip"]);
|
||||
$cc->addColumn("owner_country", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_city"]);
|
||||
$cc->addColumn("owner_phone", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_country"]);
|
||||
$cc->addColumn("owner_fax", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_phone"]);
|
||||
$cc->addColumn("owner_email", "string", ["null" => true, "default" => null, "limit" => "64", "after" => "owner_fax"]);
|
||||
|
||||
$cc->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user