Added ADB Gwrgst table and auto EZ in ConstructionConsent
This commit is contained in:
@@ -90,13 +90,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group row">
|
|
||||||
<label class="col-lg-2 col-form-label" for="ez">Grundbuch Einlagezahl EZ</label>
|
|
||||||
<div class="col-lg-10">
|
|
||||||
<input type="text" class="form-control" name="ez" id="ez" value="<?=(isset($item)) ? $item->ez : ""?>" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="kg">KG</label>
|
<label class="col-lg-2 col-form-label" for="kg">KG</label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
@@ -118,6 +111,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-lg-2 col-form-label" for="ez">Grundbuch Einlagezahl EZ</label>
|
||||||
|
<div class="col-lg-10">
|
||||||
|
<input type="text" class="form-control" name="ez" id="ez" value="<?=(isset($item)) ? $item->ez : ""?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<div id="usage-container">
|
<div id="usage-container">
|
||||||
@@ -395,13 +395,24 @@
|
|||||||
$("#kg").change(updateGstnr);
|
$("#kg").change(updateGstnr);
|
||||||
$("#gst").change(updateGstnr);
|
$("#gst").change(updateGstnr);
|
||||||
|
|
||||||
function updateGstnr() {
|
async function updateGstnr() {
|
||||||
let kg = $("#kg").val();
|
let kg = $("#kg").val();
|
||||||
let gst = $("#gst").val();
|
let gst = $("#gst").val();
|
||||||
|
|
||||||
if(!kg || !gst) return;
|
if(!kg || !gst) return;
|
||||||
|
|
||||||
$("#gstnr").val(kg + gst);
|
$("#gstnr").val(kg + gst);
|
||||||
|
|
||||||
|
// update EZ
|
||||||
|
|
||||||
|
var response = await fetch('<?=self::getUrl("ConstructionConsent", "Api", ["do" => "getEz"])?>&kg=' + kg + '&gst=' + gst);
|
||||||
|
if (!response.ok) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var resp_json = await response.json();
|
||||||
|
if(resp_json.status == "OK" && resp_json.result.ez) {
|
||||||
|
$("#ez").val(resp_json.result.ez);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(window).bind("paste", (e) => {
|
$(window).bind("paste", (e) => {
|
||||||
|
|||||||
266
application/ADBGwrgst/ADBGwrgst.php
Normal file
266
application/ADBGwrgst/ADBGwrgst.php
Normal file
@@ -0,0 +1,266 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ADBGwrgst extends mfBaseModel {
|
||||||
|
protected $forcestr = ["gstnr", "g", "ba", "nu", "tind", "ind", "flaeche", "emz", "gfn", "gft", "kgez", "ez"];
|
||||||
|
|
||||||
|
protected function init() {
|
||||||
|
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||||
|
$this->table = "Gwrgst";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProperty($name) {
|
||||||
|
if($this->$name == null) {
|
||||||
|
|
||||||
|
if(!$this->id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$classname = ucfirst($name);
|
||||||
|
$idfield = $name."_id";
|
||||||
|
$this->$name = new $classname($this->$idfield);
|
||||||
|
|
||||||
|
if($this->$name->id) {
|
||||||
|
return $this->$name;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->$name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Static Model function
|
||||||
|
*/
|
||||||
|
|
||||||
|
/********************************
|
||||||
|
* Begin static Model functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static function create(Array $data) {
|
||||||
|
$model = new ADBGwrgst();
|
||||||
|
|
||||||
|
$table_fields = [
|
||||||
|
"kgnr", "gstnr", "g", "ba", "nu", "tind", "ind", "flaeche", "emz", "gfn", "gft", "kgez", "ez",
|
||||||
|
"create","edit"
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data as $field => $value) {
|
||||||
|
if(in_array($field, $table_fields)) {
|
||||||
|
$model->$field = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$me = new User();
|
||||||
|
$me->loadMe();
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAll() {
|
||||||
|
$items = [];
|
||||||
|
|
||||||
|
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||||
|
|
||||||
|
$res = $db->select("Gwrgst", "*", "1 = 1 ORDER BY id");
|
||||||
|
if($db->num_rows($res)) {
|
||||||
|
while($data = $db->fetch_object($res)) {
|
||||||
|
$items[] = new Gwrgst($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFirst($filter) {
|
||||||
|
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||||
|
|
||||||
|
$where = self::getSqlFilter($filter);
|
||||||
|
$sql = "SELECT Gwrgst.* FROM Gwrgst
|
||||||
|
WHERE $where
|
||||||
|
ORDER BY id
|
||||||
|
LIMIT 1";
|
||||||
|
|
||||||
|
mfLoghandler::singleton()->debug($sql);
|
||||||
|
|
||||||
|
$res = $db->query($sql);
|
||||||
|
if($db->num_rows($res)) {
|
||||||
|
$data = $db->fetch_object($res);
|
||||||
|
$item = new ADBGwrgst($data);
|
||||||
|
if($item->id) {
|
||||||
|
return $item;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function count($filter) {
|
||||||
|
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||||
|
|
||||||
|
$where = self::getSqlFilter($filter);
|
||||||
|
$sql = "SELECT COUNT(*) as cnt FROM Gwrgst
|
||||||
|
WHERE $where
|
||||||
|
ORDER BY 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 = "id ASC";
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||||
|
|
||||||
|
$where = self::getSqlFilter($filter);
|
||||||
|
$sql = "SELECT Gwrgst.* FROM Gwrgst
|
||||||
|
WHERE $where
|
||||||
|
GROUP BY Gwrgst.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 ADBGwrgst($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getSqlFilter($filter) {
|
||||||
|
$where = "1=1 ";
|
||||||
|
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||||
|
|
||||||
|
|
||||||
|
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("kgnr", $filter)) {
|
||||||
|
$kgnr = $db->escape($filter["kgnr"]);
|
||||||
|
if($kgnr) {
|
||||||
|
$where .= " AND `kgnr`='$kgnr'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("gstnr", $filter)) {
|
||||||
|
$gstnr = $db->escape($filter["gstnr"]);
|
||||||
|
if($gstnr) {
|
||||||
|
$where .= " AND `gstnr`='$gstnr'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("g", $filter)) {
|
||||||
|
$g = $db->escape($filter["g"]);
|
||||||
|
if($g) {
|
||||||
|
$where .= " AND `g`='$g'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("ba", $filter)) {
|
||||||
|
$ba = $db->escape($filter["ba"]);
|
||||||
|
if($ba) {
|
||||||
|
$where .= " AND `ba`='$ba'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("nu", $filter)) {
|
||||||
|
$nu = $db->escape($filter["nu"]);
|
||||||
|
if($nu) {
|
||||||
|
$where .= " AND `nu`='$nu'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("tind", $filter)) {
|
||||||
|
$tind = $db->escape($filter["tind"]);
|
||||||
|
if($tind) {
|
||||||
|
$where .= " AND `tind`='$tind'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("ind", $filter)) {
|
||||||
|
$ind = $db->escape($filter["ind"]);
|
||||||
|
if($ind) {
|
||||||
|
$where .= " AND `ind`='$ind'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("flaeche", $filter)) {
|
||||||
|
$flaeche = $db->escape($filter["flaeche"]);
|
||||||
|
if($flaeche) {
|
||||||
|
$where .= " AND `flaeche`='$flaeche'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("emz", $filter)) {
|
||||||
|
$emz = $db->escape($filter["emz"]);
|
||||||
|
if($emz) {
|
||||||
|
$where .= " AND `emz`='$emz'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("gfn", $filter)) {
|
||||||
|
$gfn = $db->escape($filter["gfn"]);
|
||||||
|
if($gfn) {
|
||||||
|
$where .= " AND `gfn`='$gfn'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("gft", $filter)) {
|
||||||
|
$gft = $db->escape($filter["gft"]);
|
||||||
|
if($gft) {
|
||||||
|
$where .= " AND `gft`='$gft'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("kgez", $filter)) {
|
||||||
|
$kgez = $db->escape($filter["kgez"]);
|
||||||
|
if($kgez) {
|
||||||
|
$where .= " AND `kgez`='$kgez'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("ez", $filter)) {
|
||||||
|
$ez = $db->escape($filter["ez"]);
|
||||||
|
if($ez) {
|
||||||
|
$where .= " AND `ez`='$ez'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(array_key_exists("add-where", $filter)) {
|
||||||
|
$where .= " ".$filter['add-where'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//var_dump($filter, $where);exit;
|
||||||
|
return $where;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -492,6 +492,9 @@ class ConstructionConsentController extends mfBaseController {
|
|||||||
case "deleteRimoPlan":
|
case "deleteRimoPlan":
|
||||||
$return = $this->deleteRimoPlanApi();
|
$return = $this->deleteRimoPlanApi();
|
||||||
break;
|
break;
|
||||||
|
case "getEz":
|
||||||
|
$return = $this->getEzApi();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$this->log->warn(__METHOD__ . ": Called API function '$do' does not exist");
|
$this->log->warn(__METHOD__ . ": Called API function '$do' does not exist");
|
||||||
$return = false;
|
$return = false;
|
||||||
@@ -506,6 +509,22 @@ class ConstructionConsentController extends mfBaseController {
|
|||||||
$this->returnJson($data);
|
$this->returnJson($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getEzApi() {
|
||||||
|
$kg = trim($this->request->kg);
|
||||||
|
$gst = trim($this->request->gst);
|
||||||
|
|
||||||
|
if(!$kg || !$gst) return false;
|
||||||
|
|
||||||
|
$ez = ADBGwrgst::getFirst(["kgnr" => $kg, "gstnr" => $gst]);
|
||||||
|
//var_dump($ez);exit;
|
||||||
|
if(!$ez) {
|
||||||
|
return ["ez" => ""];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ["ez" => $ez->ez];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private function findStreetApi() {
|
private function findStreetApi() {
|
||||||
$addresses = [];
|
$addresses = [];
|
||||||
$search = trim($this->request->q);
|
$search = trim($this->request->q);
|
||||||
|
|||||||
47
db/migrations/20250226154252_addressdb_create_gwrgst.php
Normal file
47
db/migrations/20250226154252_addressdb_create_gwrgst.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
final class AddressdbCreateGwrgst extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if($this->getEnvironment() == "thetool") {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getEnvironment() == "addressdb") {
|
||||||
|
$table = $this->table('Gwrgst');
|
||||||
|
$table->addColumn("kgnr", "integer", ["null" => false])
|
||||||
|
->addColumn("gstnr", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
->addColumn("g", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
->addColumn("ba", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
->addColumn("nu", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
->addColumn("tind", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
->addColumn("ind", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
->addColumn("flaeche", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
->addColumn("emz", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
->addColumn("gfn", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
->addColumn("gft", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
->addColumn("kgez", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
->addColumn("ez", "string", ["limit" => 255, "null" => true, "default" => null])
|
||||||
|
|
||||||
|
->addColumn("create", "integer", ["null" => false])
|
||||||
|
->addColumn("edit", "integer", ["null" => false])
|
||||||
|
|
||||||
|
->create();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
if($this->getEnvironment() == "thetool") {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getEnvironment() == "addressdb") {
|
||||||
|
$this->table("Gwrgst")->drop()->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user