Merge branch 'fronkdev' into 'master'
Added RTR C10 reporting See merge request fronk/thetool!817
This commit is contained in:
@@ -32,25 +32,30 @@
|
||||
<div class="card-body">
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="object_type">Objekttyp *</label>
|
||||
<label class="col-lg-2 col-form-label" for="constructionconsentproject_id">Projekt *</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</option>
|
||||
<select class="form-control" name="constructionconsentproject_id" id="constructionconsentproject_id">
|
||||
<?php foreach(ConstructionConsentProject::getAll() as $project): ?>
|
||||
<option value="street" <?=($item->constructionconsentproject_id == $project->id ? "selected='selected'" : "")?>><?=$project->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="building-search">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="adb_hausnummer_id">Adresse/GST *</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="adb_hausnummer_id" id="adb_hausnummer_id">
|
||||
<?php if($item->adb_hausnummer_id): ?>
|
||||
<option value="<?=$item->adb_hausnummer_id?>" selected="selected"><?=$item->adb_hausnummer->plz->plz?> <?=$item->adb_hausnummer->strasse->ortschaft->name?>, <?=$item->adb_hausnummer->strasse->name?> <?=$item->adb_hausnummer->hausnummer?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<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>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -68,14 +73,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>
|
||||
@@ -85,7 +105,7 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('#adb_hausnummer_id').select2({
|
||||
/*$('#adb_hausnummer_id').select2({
|
||||
ajax: {
|
||||
url: '<?=self::getUrl("AddressDB", "api", ["do" => "findAddress", "include_gst" => 1])?>',
|
||||
delay: 250,
|
||||
@@ -102,6 +122,22 @@
|
||||
}
|
||||
|
||||
});
|
||||
*/
|
||||
$('#adb_strasse_id').select2({
|
||||
ajax: {
|
||||
url: '<?=self::getUrl("ConstructionConsent", "api", ["do" => "findStreet", "project_id" => $project->id])?>',
|
||||
delay: 250,
|
||||
dataType: 'json'
|
||||
},
|
||||
minimumInputLength: 2,
|
||||
placeholder: "Suche nach Straße",
|
||||
allowClear: true
|
||||
});
|
||||
$('#adb_strasse_id').on('select2:close', function(e) {
|
||||
if(!$('#adb_strasse_id').val()) {
|
||||
$('#new-address-toggle').show();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
|
||||
@@ -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">
|
||||
|
||||
131
Layout/default/ConstructionConsentProject/Form.php
Normal file
131
Layout/default/ConstructionConsentProject/Form.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||
<?php //var_dump($project);exit; ?>
|
||||
<!-- 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">
|
||||
|
||||
<h4>Projekt</h4>
|
||||
<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="email">Emailadresse *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="email" id="email" value="<?=$project->email?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="phone">Telefonnummer *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="phone" id="phone" value="<?=$project->phone?>" />
|
||||
</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>
|
||||
|
||||
|
||||
<h4 class="mt-3">Emailversand</h4>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="sender_name">Absendername *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="sender_name" id="sender_name" value="<?=$project->sender_name?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="sender_email">Absender Emailadresse *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="sender_email" id="sender_email" value="<?=$project->sender_email?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="sender_reply_to">Antworten an (Reply To)</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="sender_reply_to" id="sender_reply_toender_email" value="<?=$project->sender_reply_to?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="mt-3 mb-3" />
|
||||
|
||||
<div class="form-group row">
|
||||
<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"); ?>
|
||||
121
Layout/default/ConstructionConsentProject/Index.php
Normal file
121
Layout/default/ConstructionConsentProject/Index.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?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>Kontakt</th>
|
||||
<th>Email Absender</th>
|
||||
<th>Antwort an</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>
|
||||
<?=$project->email?><br />
|
||||
<?=$project->phone?>
|
||||
</td>
|
||||
<td><?=$project->sender_name?> <<?=$project->sender_email?>></td>
|
||||
<td><?=$project->sender_reply_to?></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"); ?>
|
||||
@@ -6,9 +6,15 @@ class Admin_RtrReporting {
|
||||
private $log;
|
||||
private $flash = [];
|
||||
private $systemowner_id = 1;
|
||||
private $energie_bb_id = 209;
|
||||
|
||||
private $netowner_is_systemowner = [
|
||||
1473,
|
||||
421,
|
||||
|
||||
];
|
||||
private $additional_owner_networks = [
|
||||
7 // mortantsch
|
||||
7, // mortantsch
|
||||
];
|
||||
private $ort_replace = [
|
||||
"St.Ruprecht/Raab" => "Sankt Ruprecht an der Raab",
|
||||
@@ -444,6 +450,95 @@ class Admin_RtrReporting {
|
||||
|
||||
}
|
||||
|
||||
protected function c10reportAction() {
|
||||
$data = [];
|
||||
|
||||
$systemowner = new Address($this->systemowner_id);
|
||||
$energie_bb = new Address($this->energie_bb_id);
|
||||
if(!$energie_bb->id) {
|
||||
return [
|
||||
"error" => "Energie BB id nicht gesetzt",
|
||||
"template" => "Admin/RtrReporting/Index",
|
||||
"redirect" => "",
|
||||
"templateVars" => []
|
||||
];
|
||||
}
|
||||
|
||||
foreach(ContractModel::searchActive([]) as $contract) {
|
||||
if(!is_array($contract->product->attributes) || !array_key_exists("rtr_tech_code", $contract->product->attributes) || !$contract->product->attributes["rtr_tech_code"]->value) continue;
|
||||
|
||||
$prov_id = false;
|
||||
$prod_code = $contract->product->attributes["rtr_tech_code"]->value;
|
||||
if(!$prod_code) continue;
|
||||
|
||||
if($contract->termination_id) {
|
||||
$network_id = $contract->termination->building->network_id;
|
||||
$netowner_id = $contract->termination->building->network->owner_id;
|
||||
|
||||
if(in_array($network_id, $this->additional_owner_networks)) {
|
||||
$netowner_id = $this->systemowner_id;
|
||||
}
|
||||
|
||||
if(in_array($netowner_id, $this->netowner_is_systemowner)) {
|
||||
$netowner_id = $this->systemowner_id;
|
||||
}
|
||||
|
||||
$netowner = new Address($netowner_id);
|
||||
|
||||
if($netowner->id && is_array($netowner->attributes) && array_key_exists("rtrcode", $netowner->attributes) && $netowner->attributes["rtrcode"]->value) {
|
||||
$prov_id = $netowner->attributes["rtrcode"]->value;
|
||||
}
|
||||
if(!$prov_id) {
|
||||
$this->log->debug(__METHOD__.": keine provider id trotz termination | netowner: $netowner_id ".$netowner->getCompanyOrName());
|
||||
}
|
||||
}
|
||||
|
||||
$prod_code_start = substr($prod_code, 0, 4);
|
||||
$prod_code_p = $prod_code_start."1";
|
||||
$prod_code_b = $prod_code_start."2";
|
||||
|
||||
if(!$prov_id) {
|
||||
if($prod_code_start == "1432") {
|
||||
// is OAN product
|
||||
$prov_id = $energie_bb->attributes["rtrcode"]->value;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$prov_id) {
|
||||
$prov_id = $systemowner->attributes["rtrcode"]->value;
|
||||
}
|
||||
|
||||
if(!array_key_exists($prov_id, $data)) {
|
||||
$data[$prov_id] = [];
|
||||
}
|
||||
|
||||
if(!in_array($prod_code_p, $data[$prov_id])) {
|
||||
$data[$prov_id][] = $prod_code_p;
|
||||
}
|
||||
if(!in_array($prod_code_b, $data[$prov_id])) {
|
||||
$data[$prov_id][] = $prod_code_b;
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($data);exit;
|
||||
|
||||
$csv_header = "partnernetz_id;code";
|
||||
$csv = $csv_header."\n";
|
||||
foreach($data as $prov_id => $prov) {
|
||||
foreach($prov as $prod_code) {
|
||||
$csv .= "$prov_id;";
|
||||
$csv .= "$prod_code";
|
||||
$csv .= "\n";
|
||||
}
|
||||
}
|
||||
|
||||
header("Content-type: text/csv; charset=utf-8");
|
||||
header('Content-disposition: attachment; filename="rtr-C10-report-'.date('Y-m-d_H-i-s').'.csv"');
|
||||
|
||||
echo $csv;
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
* 1042% = radio
|
||||
* 1431% = fiber
|
||||
|
||||
@@ -88,4 +88,160 @@ class ConstructionConsentController extends mfBaseController {
|
||||
$this->addAction();
|
||||
}
|
||||
|
||||
protected function apiAction() {
|
||||
if(!$this->me->is(["Admin","netowner"]) && !$this->me->can("Preorder")) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
$do = $this->request->do;
|
||||
$data = [];
|
||||
|
||||
switch($do) {
|
||||
case "findStreet":
|
||||
$return = $this->findStreetApi();
|
||||
break;
|
||||
default:
|
||||
$this->log->warn(__METHOD__ . ": Called API function '$do' does not exist");
|
||||
$return = false;
|
||||
}
|
||||
|
||||
if(!is_array($return) || !count($return)) {
|
||||
$data = ["status" => "error"];
|
||||
$this->returnJson($data);
|
||||
}
|
||||
$data['status'] = "OK";
|
||||
$data['result'] = $return;
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
private function findStreetApi() {
|
||||
$addresses = [];
|
||||
$search = trim($this->request->q);
|
||||
$project_id = $this->request->project_id;
|
||||
|
||||
$scluster_ids = [];
|
||||
|
||||
if($project_id) {
|
||||
$project = new ConstructionConsentProject($project_id);
|
||||
if(!$project->id) {
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode(["results" => []]);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach($project->adb_networks as $network) {
|
||||
$scluster_ids[] = $network->id;
|
||||
}
|
||||
} else {
|
||||
// get all salesclusters
|
||||
foreach(ADBNetzgebietModel::getAll() as $network) {
|
||||
$scluster_ids[] = $network->id;
|
||||
}
|
||||
}
|
||||
|
||||
$results = [];
|
||||
|
||||
$search_parts = explode(" ", $search);
|
||||
|
||||
$ort_search = $strasse_search = $plz_search = $hausnummer_search = $gst_search = [];
|
||||
|
||||
foreach($search_parts as $p) {
|
||||
$p = $this->db->escape(trim($p));
|
||||
if(!$p) continue;
|
||||
$ort_search[] = "ortschaft like '$p%'";
|
||||
$strasse_search[] = "strasse like '$p%'";
|
||||
$plz_search[] = "plz like '%$p%'";
|
||||
$hausnummer_search[] = "hausnummer like '%$p%'";
|
||||
$gst_search[] = "grund_nr like '%$p%'";
|
||||
}
|
||||
|
||||
$where = "1=1";
|
||||
if(count($scluster_ids)) {
|
||||
$where .= " AND netzgebiet_id IN (".implode(', ',$scluster_ids).")";
|
||||
}
|
||||
|
||||
/*if($include_gst) {
|
||||
$sql = "SELECT * FROM view_hausnummer WHERE $where AND ((".implode(" OR ", $ort_search).") OR (".implode(" OR ", $strasse_search).") OR (".implode(" OR ", $plz_search).") OR (".implode(" OR ", $hausnummer_search).") OR (".implode(" OR ", $gst_search).") ) ORDER BY strasse, LENGTH(hausnummer), hausnummer";
|
||||
} else {
|
||||
$sql = "SELECT * FROM view_hausnummer WHERE $where AND ((".implode(" OR ", $ort_search).") OR (".implode(" OR ", $strasse_search).") OR (".implode(" OR ", $plz_search).") OR (".implode(" OR ", $hausnummer_search).")) ORDER BY strasse, LENGTH(hausnummer), hausnummer";
|
||||
}*/
|
||||
|
||||
$sql = "SELECT strasse_id,plz,ortschaft,strasse FROM view_hausnummer
|
||||
WHERE $where
|
||||
AND ((".implode(" OR ", $ort_search).") OR (".implode(" OR ", $strasse_search).") OR (".implode(" OR ", $plz_search).") OR (".implode(" OR ", $hausnummer_search)."))
|
||||
GROUP BY plz,ortschaft,strasse,strasse_id
|
||||
ORDER BY strasse
|
||||
";
|
||||
|
||||
$this->log->debug($sql);
|
||||
|
||||
$adb = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$res = $adb->query($sql);
|
||||
$this->log->debug("done");
|
||||
|
||||
if(!$adb->num_rows($res)) {
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode(["results" => []]);
|
||||
exit;
|
||||
}
|
||||
|
||||
while($data = $adb->fetch_object($res)) {
|
||||
//$address_string = $data->plz." ".$data->ortschaft.", ".$data->strasse." ".$data->hausnummer;
|
||||
$address_string = $data->plz." ".$data->ortschaft.", ".$data->strasse;
|
||||
/*if($include_gst) {
|
||||
$address_string .= " | GST: ".$data->grund_nr;
|
||||
}*/
|
||||
$sort_key = $data->plz." ".$data->ortschaft." ".$data->strasse;
|
||||
|
||||
$address = [];
|
||||
$address['id'] = $data->strasse_id;
|
||||
$address["text"] = $address_string;
|
||||
$address['sort_key'] = $sort_key;
|
||||
$addresses[] = $address;
|
||||
}
|
||||
|
||||
|
||||
// sort results by most occurences of search strings
|
||||
$sort = [];
|
||||
foreach($addresses as $key => $address) {
|
||||
$includes_int = false;
|
||||
$count = 0;
|
||||
foreach($search_parts as $p) {
|
||||
$p = $this->db->escape(trim($p));
|
||||
if(!$p) continue;
|
||||
if(is_numeric(($p))) {
|
||||
$includes_int = true;
|
||||
if(substr_count(strtolower($address['text']), strtolower($p))) {
|
||||
$count++;
|
||||
}
|
||||
} else {
|
||||
$count += substr_count(strtolower($address['text']), strtolower($p));
|
||||
}
|
||||
}
|
||||
unset($address['sort_key']);
|
||||
//echo $address['text']." $p $count<br />\n";
|
||||
|
||||
if($includes_int && (($count + 1) - count($search_parts) ) < 1) {
|
||||
continue;
|
||||
}
|
||||
if(!array_key_exists($count, $sort)) {
|
||||
$sort[$count] = [];
|
||||
}
|
||||
$sort[$count][] = $address;
|
||||
}
|
||||
|
||||
ksort($sort, SORT_NUMERIC);
|
||||
$sort = array_reverse($sort, true);
|
||||
//var_dump($sort);exit;
|
||||
|
||||
foreach($sort as $res) {
|
||||
foreach($res as $a) {
|
||||
$results[] = $a;
|
||||
}
|
||||
}
|
||||
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode(["results" => $results]);
|
||||
exit;
|
||||
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
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", "sender_name", "sender_email", "sender_reply_to", "email", "phone", "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,186 @@
|
||||
<?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");
|
||||
|
||||
if ($this->request->resetFilter) {
|
||||
unset($_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter']);
|
||||
}
|
||||
|
||||
$filter = [];
|
||||
if (is_array($this->request->filter)) {
|
||||
$filter = $this->request->filter;
|
||||
$_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'] = $filter;
|
||||
} else {
|
||||
if (array_key_exists(MFAPPNAME . '-ConstructionConsentProject-filter', $_SESSION) && count($_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'])) {
|
||||
$filter = $_SESSION[MFAPPNAME . '-ConstructionConsentProject-filter'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $filter);
|
||||
$filter = $this->getPreparedFilter($filter);
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 25;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
if (is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
//var_dump($filter);exit;
|
||||
$pagination['maxItems'] = ConstructionConsentProject::count($filter);
|
||||
|
||||
$projects = ConstructionConsentProject::getAll();
|
||||
$this->layout()->set("projects", $projects);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
$new_filter = [];
|
||||
|
||||
|
||||
|
||||
if (is_array($filter) && count($filter)) {
|
||||
foreach ($filter as $name => $value) {
|
||||
$new_filter[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
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;
|
||||
$data["sender_name"] = $r->sender_name;
|
||||
$data["sender_email"] = $r->sender_email;
|
||||
$data["sender_reply_to"] = $r->sender_reply_to;
|
||||
$data["email"] = $r->email;
|
||||
$data["phone"] = $r->phone;
|
||||
$data["note"] = $r->note;
|
||||
|
||||
if($mode == "add") {
|
||||
$project = ConstructionConsentProject::create($data);
|
||||
} else {
|
||||
$project->update($data);
|
||||
}
|
||||
$this->layout()->set("project", $project);
|
||||
|
||||
if(!$r->name || !$r->sender_name || !$r->sender_email || !$r->email || !$r->phone) {
|
||||
$this->layout()->setFlash("Bitte alle erforderlichen Felder ausfüllen", "error");
|
||||
return $this->addAction();
|
||||
}
|
||||
if(!is_array($r->adb_netzgebiet_id) || !count($r->adb_netzgebiet_id)) {
|
||||
$this->layout()->setFlash("Bitte mindestens ein Netzgebiet auswählen", "error");
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
$netzgebiete = [];
|
||||
|
||||
if(!$project->save()) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
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);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
//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