Merge branch 'fronkdev' into 'master'
Added User flag employee_number See merge request fronk/thetool!156
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
<div class="row col-12">
|
||||
<div><a href="<?=self::getUrl("Admin", "ivtImportMatchProducts")?>">IVT Produkte zu thetool Produkte matchen</a></div>
|
||||
</div>
|
||||
<div class="row col-12">
|
||||
<div class="row col-12 mt-2">
|
||||
<div><a href="<?=self::getUrl("Admin", "ivtDownloadActiveProducts")?>">Produkte in Verwendung herunterladen</a></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -51,11 +51,15 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row col-12">
|
||||
<div><a href="<?=self::getUrl("Admin", "ivtAdminImport")?>" class="text-danger">IVT Contracts importieren</a></div>
|
||||
<div><a href="<?=self::getUrl("Admin", "ivtContractImport")?>" class="text-danger">IVT Contracts importieren</a></div>
|
||||
</div>
|
||||
<div class="row col-12 mt-2">
|
||||
<div><a href="<?=self::getUrl("Admin", "ivtCreditImport")?>" class="text-danger">IVT Gutschriften importieren</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
79
Layout/default/Admin/IvtCreditImport.php
Normal file
79
Layout/default/Admin/IvtCreditImport.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
|
||||
type="text/css"/>
|
||||
<!-- 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("Admin")?>">Admin</a></li>
|
||||
<li class="breadcrumb-item active">IVT Contract Import</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">IVT Import</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
|
||||
<div class="card border-top-primary">
|
||||
<div class="card-body">
|
||||
|
||||
<table id="datatable" class="table table-sm table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Kunde</th>
|
||||
<th>IVT Produkt</th>
|
||||
<th>Produkt</th>
|
||||
<th>Preis Setup</th>
|
||||
<th>Preis</th>
|
||||
<th>Rech. Interval</th>
|
||||
<th>Aktion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($data['contracts'] as $d): ?>
|
||||
<tr>
|
||||
<td><?=$d["customer"]->getCompanyOrName()?></td>
|
||||
<td><?=$d["ivtproduct"]->name?></td>
|
||||
<td><?=$d["product"]->name?></td>
|
||||
<td><?=$d["contract"]->price_setup?></td>
|
||||
<td><?=$d["contract"]->price?></td>
|
||||
<td>
|
||||
<?=$d["contract"]->billing_period?> (<?=($d["contract"]->billing_period == 1) ? "Monatlich" : ""?><?=($d["contract"]->billing_period == 12) ? "Jährlich" : ""?><?=($d["contract"]->billing_period == 24) ? "Zweijährlich" : ""?><?=($d["contract"]->billing_period == 36) ? "Dreijährlich" : ""?>)
|
||||
</td>
|
||||
<td><?=$d["action"]?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div>
|
||||
<a href="<?=self::getUrl("Admin", "ivtAdminImport", ["doit" => 1])?>"><button class="btn btn-primary" id="doitbutton"><i class="far fa-fw fa-exclamation-circle"></i> Jetzt importieren</button></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?= date('U') ?>"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#doitbutton").click(function() {
|
||||
$("#doitbutton").text("Bitte warten...");
|
||||
$("#doitbutton").prop("disabled", true);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
@@ -68,6 +68,10 @@
|
||||
<option value="true" <?=(isset($user) && $user->is("employee")) ? "selected='selected'" : ""?>>Yes</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group <?=(!$user->is("employee")) ? "hidden" : ""?>" id="employee-number-container">
|
||||
<label for="employee_number"><span class="text-warning font-weight-bold font-16">X</span><span class="text-primary font-weight-bold">inon</span> Mitarbeiternummer:</label>
|
||||
<input type="text" id="employee_number" name="employee_number" class="form-control" value="<?=(new WorkerFlag($user->id, "employee_number"))->value()?>" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="technician">Techniker:</label>
|
||||
<select name="technician" id="technician" class="form-control">
|
||||
@@ -299,6 +303,13 @@
|
||||
}
|
||||
});
|
||||
|
||||
$("#employee").change(function() {
|
||||
if($("#employee").val() == "true") {
|
||||
$("#employee-number-container").show(400);
|
||||
} else {
|
||||
$("#employee-number-container").hide(400);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -209,6 +209,12 @@ class ADBHausnummerModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("rimo_id", $filter)) {
|
||||
$rimo_id = FronkDB::singleton()->escape($filter['rimo_id']);
|
||||
if($rimo_id) {
|
||||
$where .= " AND Hausnummer.rimo_id = '$rimo_id'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("plz", $filter)) {
|
||||
$plz = FronkDB::singleton()->escape($filter['plz']);
|
||||
|
||||
@@ -6,8 +6,6 @@ class ADBStrasseModel {
|
||||
public $kennziffer;
|
||||
public $name;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
|
||||
@@ -150,20 +150,20 @@ class AdminController extends mfBaseController {
|
||||
$this->layout()->set("products", $products);
|
||||
}
|
||||
|
||||
protected function ivtAdminImportAction() {
|
||||
protected function ivtContractImportAction() {
|
||||
exit;
|
||||
$doit = false;
|
||||
if($this->request->doit == 1) {
|
||||
$doit = true;
|
||||
}
|
||||
|
||||
require_once(realpath(dirname(__FILE__)."/functions")."/IvtAdminImport.php");
|
||||
require_once(realpath(dirname(__FILE__)."/functions")."/IvtContractImport.php");
|
||||
|
||||
if(class_exists("Admin_IvtAdminImport")) {
|
||||
$import = new Admin_IvtAdminImport($this->request);
|
||||
if(class_exists("Admin_IvtContractImport")) {
|
||||
$import = new Admin_IvtContractImport($this->request);
|
||||
$data = $import->run($doit);
|
||||
|
||||
$this->layout()->setTemplate("Admin/IvtAdminImport");
|
||||
$this->layout()->setTemplate("Admin/IvtContractImport");
|
||||
$this->layout()->set("data", $data);
|
||||
|
||||
if($doit) {
|
||||
@@ -173,4 +173,26 @@ class AdminController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
protected function ivtCreditImportAction() {
|
||||
$doit = false;
|
||||
if($this->request->doit == 1) {
|
||||
$doit = true;
|
||||
}
|
||||
|
||||
require_once(realpath(dirname(__FILE__)."/functions")."/IvtCreditImport.php");
|
||||
|
||||
if(class_exists("Admin_IvtCreditImport")) {
|
||||
$import = new Admin_IvtCreditImport($this->request);
|
||||
$data = $import->run($doit);
|
||||
|
||||
$this->layout()->setTemplate("Admin/IvtCreditImport");
|
||||
$this->layout()->set("data", $data);
|
||||
|
||||
if($doit) {
|
||||
$this->layout()->setFlash((count($data['contracts']) - $data['ignore'])." Gutschriften aus IVT importiert!", "success");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Admin_IvtAdminImport {
|
||||
class Admin_IvtContractImport {
|
||||
private $request;
|
||||
|
||||
public function __construct($request) {
|
||||
26
application/Admin/functions/IvtCreditImport.php
Normal file
26
application/Admin/functions/IvtCreditImport.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
class Admin_IvtCreditImport {
|
||||
private $request;
|
||||
|
||||
public function __construct($request) {
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function run($doit = false) {
|
||||
$i = 0;
|
||||
foreach(IvtCustomerCreditingModel::getAll() as $cust_cred) {
|
||||
if($i<200) {$i++; continue;}
|
||||
var_dump($cust_cred);
|
||||
var_dump($cust_cred->netowner);
|
||||
var_dump($cust_cred->customer);
|
||||
var_dump($cust_cred->crediting_product);
|
||||
exit;
|
||||
|
||||
if(!$cust_cred->customer) continue;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
74
application/IvtCreditingProduct/IvtCreditingProduct.php
Normal file
74
application/IvtCreditingProduct/IvtCreditingProduct.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
class IvtCreditingProduct extends mfBaseModel {
|
||||
protected $forcestr = [];
|
||||
|
||||
/**
|
||||
* Takes ID or DB row as arguments
|
||||
* @param id or table row $_
|
||||
*/
|
||||
public function __construct($_=NULL) {
|
||||
$this->log = mfLoghandler::singleton();
|
||||
$this->data = new stdClass();
|
||||
$this->table = "crediting_products";
|
||||
|
||||
$this->db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
if(is_numeric($_)) {
|
||||
$this->fetch($_);
|
||||
} elseif(is_object($_)) {
|
||||
$this->load($_);
|
||||
}
|
||||
}
|
||||
|
||||
public function save() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "product") {
|
||||
$ivtproduct = new IvtProduct($this->pid);
|
||||
if($ivtproduct->id) {
|
||||
$this->ivtproduct = $ivtproduct;
|
||||
}
|
||||
return $this->ivtproduct;
|
||||
}
|
||||
|
||||
if($name == "customer") {
|
||||
$ivtcustomer = new IvtCustomer($this->cid);
|
||||
if($ivtcustomer->id) {
|
||||
$this->ivtcustomer = $ivtcustomer;
|
||||
}
|
||||
return $this->ivtcustomer;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
public function __debugInfo() {
|
||||
$vars = get_object_vars($this);
|
||||
if(is_object($vars['db'])) $vars['db'] = "object(FronkDB)";
|
||||
if(is_object($vars['log'])) $vars['log'] = 'object(mfLoghandler)';
|
||||
return $vars;
|
||||
}
|
||||
|
||||
}
|
||||
105
application/IvtCreditingProduct/IvtCreditingProductModel.php
Normal file
105
application/IvtCreditingProduct/IvtCreditingProductModel.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
class IvtCreditingProductModel {
|
||||
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$res = $db->select("crediting_products", "*");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new IvtCreditingProduct($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function getFirst($filter = []) {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("crediting_products", "*", "$where LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new IvtCreditingProduct($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) cnt FROM crediting_products WHERE $where";
|
||||
|
||||
$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(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM crediting_products WHERE $where";
|
||||
|
||||
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($count)) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new IvtCreditingProduct($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
/*
|
||||
if(array_key_exists("cid", $filter)) {
|
||||
$cid = $filter['cid'];
|
||||
if(is_numeric($cid)) {
|
||||
$where .= " AND cid=$cid";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("pid", $filter)) {
|
||||
$pid = $filter['pid'];
|
||||
if(is_numeric($pid)) {
|
||||
$where .= " AND pid=$pid";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("sid", $filter)) {
|
||||
$sid = $filter['sid'];
|
||||
if(is_numeric($sid)) {
|
||||
$where .= " AND sid=$sid";
|
||||
}
|
||||
}
|
||||
*/
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
94
application/IvtCustomerCrediting/IvtCustomerCrediting.php
Normal file
94
application/IvtCustomerCrediting/IvtCustomerCrediting.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
class IvtCustomerCrediting extends mfBaseModel {
|
||||
private $netowner;
|
||||
private $customer;
|
||||
private $crediting_product;
|
||||
|
||||
|
||||
public function __construct($_=NULL) {
|
||||
$this->log = mfLoghandler::singleton();
|
||||
$this->data = new stdClass();
|
||||
$this->table = "customer_crediting";
|
||||
|
||||
$this->db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
if(is_numeric($_)) {
|
||||
$this->fetch($_);
|
||||
} elseif(is_object($_)) {
|
||||
$this->load($_);
|
||||
}
|
||||
}
|
||||
|
||||
public function save() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private function getCustomerId() {
|
||||
$customer_id = false;
|
||||
|
||||
$m = [];
|
||||
if(preg_match('/(\d+)\s*$/', $this->comment, $m)) {
|
||||
$customer_id = $m[1];
|
||||
}
|
||||
if(!$customer_id) {
|
||||
$this->log->warn(__METHOD__.": Cannot extract customer id from comment");
|
||||
}
|
||||
return $customer_id;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "crediting_product") {
|
||||
$cred_prod = new IvtCreditingProduct($this->cred_id);
|
||||
if($cred_prod->id) {
|
||||
$this->crediting_product = $cred_prod;
|
||||
}
|
||||
return $this->crediting_product;
|
||||
}
|
||||
|
||||
if($name == "netowner") {
|
||||
$netowner = new IvtCustomer($this->cust_id);
|
||||
if($netowner->id) {
|
||||
$this->netowner = $netowner;
|
||||
}
|
||||
return $this->netowner;
|
||||
}
|
||||
|
||||
if($name == "customer") {
|
||||
$customer_id = $this->getCustomerId();
|
||||
$customer = new IvtCustomer($customer_id);
|
||||
if($customer->id) {
|
||||
$this->customer = $customer;
|
||||
}
|
||||
return $this->customer;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
public function __debugInfo() {
|
||||
$vars = get_object_vars($this);
|
||||
if(is_object($vars['db'])) $vars['db'] = "object(FronkDB)";
|
||||
if(is_object($vars['log'])) $vars['log'] = 'object(mfLoghandler)';
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
107
application/IvtCustomerCrediting/IvtCustomerCreditingModel.php
Normal file
107
application/IvtCustomerCrediting/IvtCustomerCreditingModel.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
class IvtCustomerCreditingModel {
|
||||
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$res = $db->select("customer_crediting", "*", "1=1 ORDER BY id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new IvtCustomerCrediting($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function getFirst($filter = []) {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("customer_crediting", "*", "$where ORDER BY id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new IvtCustomerCrediting($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) cnt FROM customer_crediting WHERE $where ORDER by id";
|
||||
|
||||
$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(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM customer_crediting WHERE $where ORDER by cid,pid,sid,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($count)) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new IvtCustomerCrediting($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
/*
|
||||
if(array_key_exists("status_id", $filter)) {
|
||||
$status_id = $filter['status_id'];
|
||||
if(is_numeric($status_id)) {
|
||||
$where .= " AND IvtCustomerCrediting.status_id=$status_id";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("street", $filter)) {
|
||||
$street = FronkDB::singleton()->escape($filter["street"]);
|
||||
if($street) {
|
||||
$where .= " AND street like '%$street%'";
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if(array_key_exists("cust_id", $filter)) {
|
||||
$cust_id = $filter['cust_id'];
|
||||
if(is_numeric($cust_id)) {
|
||||
$where .= " AND cust_id=$cust_id";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -250,6 +250,15 @@ class UserController extends mfBaseController
|
||||
}
|
||||
|
||||
|
||||
// employee number
|
||||
$enum = new WorkerFlag($user->id, "employee_number");
|
||||
if($r->employee_number && $user->permissions->employee == "true") {
|
||||
$enum->value($r->employee_number);
|
||||
$enum->save();
|
||||
} else {
|
||||
$enum->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Benutzer gespeichert.", "success");
|
||||
|
||||
31
db/migrations/20240108200100_hausnummer_add_index_rimoid.php
Normal file
31
db/migrations/20240108200100_hausnummer_add_index_rimoid.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class HausnummerAddIndexRimoid extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
$table = $this->table("Hausnummer");
|
||||
$table->addIndex("rimo_id", ["limit" => 18]);
|
||||
$table->update();
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace ADBRimoImport\ADBAddressHelper\Network;
|
||||
|
||||
/*
|
||||
* Netzgebiet
|
||||
* Premstätten Süd
|
||||
*/
|
||||
class Network_60670_1 {
|
||||
|
||||
public function checkAddress($data) {
|
||||
/*
|
||||
* array keys are a reference their original variables and must be manipulated directly
|
||||
*/
|
||||
|
||||
// dererence input array keys into copies
|
||||
foreach(["strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$$var = $data[$var];
|
||||
}
|
||||
|
||||
if($strasse_name == "Bierbaumerstrasse") $strasse_name = "Bierbaumer Strasse";
|
||||
if($ort_name == "Oberpremstaetten") $ort_name = "Oberpremstätten";
|
||||
|
||||
|
||||
// put new values back into original pointer
|
||||
foreach(["strasse_name", "hausnummer_name", "addresszusatz", "gem_kz", "gem_name", "ort_name", "plz_name"] as $var) {
|
||||
$data[$var] = $$var;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
278
scripts/adb-rimo-import/ADBAddressHelper/address_helper.php
Normal file
278
scripts/adb-rimo-import/ADBAddressHelper/address_helper.php
Normal file
@@ -0,0 +1,278 @@
|
||||
<?php
|
||||
|
||||
namespace ADBRimoImport\ADBAddressHelper;
|
||||
|
||||
class AddressHelper {
|
||||
private $log;
|
||||
private $db;
|
||||
private $netzgebiet;
|
||||
private $NetworkHelper;
|
||||
|
||||
public function __construct($dependencies = []) {
|
||||
foreach(["log", "db", "netzgebiet"] as $type) {
|
||||
if(array_key_exists($type, $dependencies)) {
|
||||
$this->$type = $dependencies[$type];
|
||||
}
|
||||
}
|
||||
|
||||
// load network helper
|
||||
if($this->netzgebiet && $this->netzgebiet->extref) {
|
||||
// get netzgebiet extref and make classname
|
||||
$network_extref = $this->netzgebiet->extref;
|
||||
$network_id = preg_replace('/[^a-zA-Z0-9]/', '_', $network_extref);
|
||||
$network_helper_name = "ADBRimoImport\\ADBAddressHelper\\Network\\Network_$network_id";
|
||||
|
||||
// find network helper class
|
||||
$network_helper_dir = __DIR__."/Network";
|
||||
$network_helper_filename = "Network-$network_extref";
|
||||
|
||||
$dir = opendir($network_helper_dir);
|
||||
while($filename = readdir($dir)) {
|
||||
if(preg_match('/^'.$network_helper_filename.'-/', $filename)) {
|
||||
require_once($network_helper_dir."/$filename");
|
||||
}
|
||||
}
|
||||
|
||||
$network_helper = new $network_helper_name();
|
||||
$this->NetworkHelper = $network_helper;
|
||||
} else {
|
||||
die("Netzgebiet hat keine extref (".$this->netzgebiet->id.": ".$this->netzgebiet->name.")");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function splitStreetHausnummer($strasse_hausnummer) {
|
||||
$strasse_name = "";
|
||||
$hausnummer_name = "";
|
||||
$addresszusatz = "";
|
||||
|
||||
$m = [];
|
||||
if(preg_match('/^(\D+)\s+(\d+[a-z0-9\/&#._-]*)(?:\s+((?:gesch(?:ae|ä)ft|werkstatt|betrieb und wohnungen|stg|paketlogistik|cafe|pavillon|pfarrheim|[^ ]*haus|[^ ]*geb(?:ae|ä)ude|[^ ]*halle|[^ ]*schule|Öhlmühle)(?:\s+[a-z0-9]+)?))?/i', $strasse_hausnummer, $m)) {
|
||||
$strasse_name = trim($m[1]);
|
||||
$hausnummer_name = trim($m[2]);
|
||||
if(array_key_exists(3, $m)) {
|
||||
$addresszusatz = trim($m[3]);
|
||||
}
|
||||
} elseif(preg_match('/^(.+)\s+(\d+[a-z0-9\/&#._-]*)(.+)?/i', $strasse_hausnummer, $m)) {
|
||||
$strasse_name = trim($m[1]);
|
||||
$hausnummer_name = trim($m[2]);
|
||||
if(array_key_exists(3, $m)) {
|
||||
$addresszusatz = trim($m[3]);
|
||||
}
|
||||
} elseif(preg_match('/^(.+)/i', $strasse_hausnummer, $m)) {
|
||||
// ignore GST objects
|
||||
return false;
|
||||
$strasse_name = trim($m[1]);
|
||||
}
|
||||
|
||||
return [$strasse_name, $hausnummer_name, $addresszusatz];
|
||||
}
|
||||
|
||||
public function findAddressFromRimoBuilding($building) {
|
||||
$hausnummer = false;
|
||||
|
||||
echo "===================================\n";
|
||||
|
||||
$rimo_id = trim($building->id);
|
||||
|
||||
if(!$rimo_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$name = trim($building->name);
|
||||
|
||||
$strasse_hausnummer = trim($building->address->name);
|
||||
[$strasse_name, $hausnummer_name, $addresszusatz] = $this->splitStreetHausnummer($strasse_hausnummer);
|
||||
$strasse_name = $this->db->escape($strasse_name);
|
||||
$hausnummer_name = $this->db->escape($hausnummer_name);
|
||||
$addresszusatz = $this->db->escape($addresszusatz);
|
||||
|
||||
$gem_kz = $this->db->escape(trim($building->municipality->name));
|
||||
$gem_name = $this->db->escape(trim($building->municipality->userLabel));
|
||||
|
||||
$ort_name = $this->db->escape(trim($building->address->city));
|
||||
$plz_name = $this->db->escape(trim($building->address->zipCode));
|
||||
|
||||
$lat = $building->address->latitude;
|
||||
$long = $building->address->longitude;
|
||||
$unit_count = $building->homesCount;
|
||||
$lot_num = $building->address->lotNumber;
|
||||
$fcp_name = false;
|
||||
|
||||
$addr_dbg_str = "strasse: $strasse_name | hausnummer: $hausnummer_name | zusatz: $addresszusatz | gemkz: $gem_kz | gem_name: $gem_name | ort_name: $ort_name | plz_name: $plz_name";
|
||||
echo "$addr_dbg_str\n";
|
||||
|
||||
// pass variables by ref, so they can be manipulated directly
|
||||
$this->NetworkHelper->checkAddress([
|
||||
"strasse_name" => &$strasse_name,
|
||||
"hausnummer_name" => &$hausnummer_name,
|
||||
"addresszusatz" => &$addresszusatz,
|
||||
"gem_kz" => &$gem_kz,
|
||||
"gem_name" => &$gem_name,
|
||||
"ort_name" => &$ort_name,
|
||||
"plz_name" => &$plz_name
|
||||
]);
|
||||
|
||||
|
||||
$gemeinde = \ADBGemeindeModel::getFirst(["kennziffer" => $gem_kz]);
|
||||
if(!$gemeinde) {
|
||||
$this->log->warning("[WW] ($addr_dbg_str) Gemeinde nicht gefunden");
|
||||
echo "Gemeinde $gem_name $gem_kz nicht gefunden\n";
|
||||
return false;
|
||||
}
|
||||
$gemeinde_id = $gemeinde->id;
|
||||
|
||||
$adrcd = false;
|
||||
$adr = trim($building->foreignId2);
|
||||
$adr_parts = explode("-", $adr);
|
||||
if(count($adr_parts)) {
|
||||
$adrcd = $adr_parts[0];
|
||||
}
|
||||
|
||||
$hausnummer = \ADBHausnummerModel::getFirst(["rimo_id" => $rimo_id]);
|
||||
|
||||
if($hausnummer) {
|
||||
echo "found hausnummer from rimo_id $rimo_id\n";
|
||||
}
|
||||
|
||||
if($adrcd && !$hausnummer) {
|
||||
// get Hausnummer to update
|
||||
$hausnummer = \ADBHausnummerModel::getFirst(['adrcd' => $adrcd]);
|
||||
if(!$hausnummer) {
|
||||
//echo "Hausnummer adrcd $adrcd not found\n";
|
||||
} else {
|
||||
echo "found hausnummer from adrcd $adrcd\n";
|
||||
//echo "Hausnummer adrcd $adrcd gefunden!\n";
|
||||
}
|
||||
}
|
||||
|
||||
if(!$hausnummer) {
|
||||
$hausnummer = $this->findHausnummerByStreet($strasse_name, $hausnummer_name, $gemeinde_id);
|
||||
if(!$hausnummer) {
|
||||
// hausnummer anlegen
|
||||
|
||||
$strasse = \ADBStrasseModel::getFirst(["gemeinde_id" => $gemeinde_id, "name" => $strasse_name]);
|
||||
//if(!$strasse) die("Strasse $strasse_name (gemeinde_id $gemeinde_id; gem_kz $gem_kz) nicht gefunden\n");
|
||||
if(!$strasse) {
|
||||
$strasse = $this->createStreet($gemeinde_id, $strasse_name);
|
||||
echo "[EE] Konnte Strasse $strasse_name in Gemeinde $gemeinde_id nicht anlegen\n";
|
||||
if(!$strasse) return false;
|
||||
}
|
||||
|
||||
$plz = \ADBPlzModel::getFirst(["gemeinde_id" => $gemeinde_id, "plz" => $plz_name]);
|
||||
if(!$plz) die("PLZ $plz_name nicht gefunden\n");
|
||||
|
||||
$ortschaft = \ADBOrtschaftModel::getFirst(["gemeinde_id" => $gemeinde_id, "name" => $ort_name]);
|
||||
if(!$ortschaft) die("$strasse_hausnummer: ortschaft $ort_name nicht gefunden\n");
|
||||
|
||||
$hausnummer_data = [
|
||||
"netzgebiet_id" => $this->netzgebiet->id,
|
||||
"adrcd" => ($adrcd) ? $adrcd : null,
|
||||
"extref" => $name,
|
||||
"ortschaft_id" => $ortschaft->id,
|
||||
"plz_id" => $plz->id,
|
||||
"strasse_id" => $strasse->id,
|
||||
"hausnummer" => $hausnummer_name,
|
||||
"zusatz" => ($addresszusatz) ? $addresszusatz : null,
|
||||
"grund_nr" => ($lot_num) ? $lot_num : null,
|
||||
"gps_lat" => $lat,
|
||||
"gps_long" => $long,
|
||||
"unit_count" => ($unit_count) ? $unit_count : 1,
|
||||
"freigabe" => $this->netzgebiet->default_freigabe,
|
||||
"rimo_id" => $rimo_id,
|
||||
"rimo_fcp_name" => ($fcp_name) ? $fcp_name : null
|
||||
];
|
||||
$hausnummer = \ADBHausnummerModel::create($hausnummer_data);
|
||||
//var_dump($hausnummer);exit;
|
||||
//echo "----------------------\ncreating hausnummer:\n";
|
||||
//print_r($hausnummer);
|
||||
$hausnummer->save();
|
||||
}
|
||||
}
|
||||
|
||||
// update hausnummer
|
||||
if($hausnummer->netzgebiet_id != $this->netzgebiet->id) {
|
||||
$hausnummer->netzgebiet_id = $this->netzgebiet->id;
|
||||
//$hausnummer->save();
|
||||
}
|
||||
if($hausnummer->extref != $this->netzgebiet->extref) {
|
||||
$hausnummer->extref = $this->netzgebiet->extref;
|
||||
//$hausnummer->save();
|
||||
}
|
||||
if($lat && $long) {
|
||||
$hausnummer->gps_lat = (float)$lat;
|
||||
$hausnummer->gps_long = (float)$long;
|
||||
}
|
||||
if($rimo_id) $hausnummer->rimo_id = $rimo_id;
|
||||
if($fcp_name) $hausnummer->rimo_fcp_name = $fcp_name;
|
||||
//$hausnummer->freigabe = $this->netzgebiet->default_freigabe;
|
||||
$hausnummer->save();
|
||||
//echo ">>>>>>>>>>>>>>>>>>>\nupdating hausnummer:";
|
||||
//print_r($hausnummer);exit;
|
||||
return $hausnummer;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function findHausnummerByStreet($strasse_name, $hausnummer_name, $gemeinde_id) {
|
||||
$strasse_search = [$strasse_name];
|
||||
|
||||
if(strpos($strasse_name, ' ') !== false) $strasse_search[] = str_replace(' ', '-', $strasse_name);
|
||||
if(strpos($strasse_name, '-') !== false) $strasse_search[] = str_replace('-', ' ', $strasse_name);
|
||||
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '. ', $strasse_name);
|
||||
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '.-', $strasse_name);
|
||||
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.', $strasse_name);
|
||||
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.-', $strasse_name);
|
||||
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '.', $strasse_name);
|
||||
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '. ', $strasse_name);
|
||||
|
||||
foreach($strasse_search as $search) {
|
||||
if(strpos($search, 'ß') !== false) $strasse_search[] = str_replace('ß', 'ss', $search);
|
||||
if(strpos($search, 'ä') !== false) $strasse_search[] = str_replace('ä', 'ae', $search);
|
||||
if(strpos($search, 'ö') !== false) $strasse_search[] = str_replace('ö', 'oe', $search);
|
||||
if(strpos($search, 'ü') !== false) $strasse_search[] = str_replace('ü', 'ue', $search);
|
||||
|
||||
if(strpos($search, 'ss') !== false) $strasse_search[] = str_replace('ss', 'ß', $search);
|
||||
if(strpos($search, 'ae') !== false) $strasse_search[] = str_replace('ae', 'ä', $search);
|
||||
if(strpos($search, 'oe') !== false) $strasse_search[] = str_replace('oe', 'ö', $search);
|
||||
if(strpos($search, 'ue') !== false) $strasse_search[] = str_replace('ue', 'ü', $search);
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM view_hausnummer WHERE gemeinde_id = $gemeinde_id AND strasse IN ('". implode("', '", $strasse_search)."') AND hausnummer='$hausnummer_name'";
|
||||
//echo "$sql\n";
|
||||
/*if(preg_match('/^Tobelbader/i',$strasse_name)) {
|
||||
echo "$sql\n";
|
||||
}*/
|
||||
$res = $this->db->query($sql);
|
||||
|
||||
if($this->db->num_rows($res)) {
|
||||
// get Hausnummer to update
|
||||
//echo "Hausnummer per Suche gefunden\n";
|
||||
$data = $this->db->fetch_object($res);
|
||||
return new \ADBHausnummer($data->hausnummer_id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function createStreet($gemeinde_id, $strasse_name) {
|
||||
if(!$gemeinde_id || !$strasse_name) return null;
|
||||
|
||||
$strasse = \ADBStrasseModel::create([
|
||||
"gemeinde_id" => $gemeinde_id,
|
||||
"name" => $strasse_name
|
||||
]);
|
||||
|
||||
if(!$strasse->save()) {
|
||||
return null;
|
||||
}
|
||||
return $strasse;
|
||||
|
||||
}
|
||||
|
||||
public function createHausnummer($hausnummer_data = []) {
|
||||
$hausnummer = \ADBHausnummerModel::create($hausnummer_data);
|
||||
//var_dump($hausnummer);exit;
|
||||
return $hausnummer->save();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
namespace ADBRimoImport;
|
||||
use ADBRimoImport\ADBAddressHelper;
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../config/config.php");
|
||||
require("../../config/config.php");
|
||||
require("ADBAddressHelper/address_helper.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
@@ -11,13 +15,13 @@ require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
$me = new \User(1);
|
||||
|
||||
define("INTERNAL_USER_ID", $me->id);
|
||||
define("INTERNAL_USER_USERNAME", $me->username);
|
||||
|
||||
$mainlog = mfLoghandler::singleton();
|
||||
$log = new mfLog_File();
|
||||
$mainlog = \mfLoghandler::singleton();
|
||||
$log = new \mfLog_File();
|
||||
$log->init(BASEDIR."/var/log/rimo-import.log");
|
||||
|
||||
$apiOwner = "estmk";
|
||||
@@ -53,6 +57,9 @@ $ctxOptsGet = [
|
||||
]
|
||||
];
|
||||
|
||||
$adb = \FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
|
||||
/*
|
||||
* Get RIMO Sales Clusters
|
||||
*/
|
||||
@@ -73,58 +80,72 @@ if($responseText === false) {
|
||||
$clustersResponse = json_decode($responseText);
|
||||
//var_dump($clustersResponse);
|
||||
//exit;
|
||||
if(is_object($clustersResponse) && property_exists($clustersResponse, "item") && is_array($clustersResponse->item) && count($clustersResponse->item)) {
|
||||
|
||||
foreach($clustersResponse->item as $cluster) {
|
||||
$cluster_rimo_id = $cluster->id;
|
||||
echo "$cluster_rimo_id | name: ".$cluster->name."; label: ".$cluster->userLabel."\n";
|
||||
if(!is_object($clustersResponse) || !property_exists($clustersResponse, "item") || !is_array($clustersResponse->item) || !count($clustersResponse->item)) {
|
||||
die("Invalid GetClusters Response\n");
|
||||
}
|
||||
|
||||
foreach($clustersResponse->item as $cluster) {
|
||||
$cluster_rimo_id = $cluster->id;
|
||||
echo "$cluster_rimo_id | name: ".$cluster->name."; label: ".$cluster->userLabel."\n";
|
||||
//continue;
|
||||
$adb_netzgebiet = \ADBNetzgebietModel::getFirst(['rimo_id' => $cluster_rimo_id]);
|
||||
if(!$adb_netzgebiet) {
|
||||
echo "Kein Netzgebiet für Salescluster $cluster_rimo_id (".$cluster->name.")\n";
|
||||
continue;
|
||||
$adb_netzgebiet = ADBNetzgebietModel::getFirst(['rimo_id' => $cluster_rimo_id]);
|
||||
if(!$adb_netzgebiet) {
|
||||
echo "Kein Netzgebiet für Salescluster $cluster_rimo_id (".$cluster->name.")\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get Buildings per SalesCluster
|
||||
*/
|
||||
$params = $baseParams;
|
||||
$params["clusterId"] = $cluster_rimo_id;
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$req_url = $epGetBuildings."?".$qs;
|
||||
$req_ctx = stream_context_create($ctxOptsGet);
|
||||
|
||||
echo $req_url."\n";
|
||||
$responseText = file_get_contents($req_url, false, $req_ctx);
|
||||
|
||||
if($responseText === false) {
|
||||
echo "Error fetching Buildings in cluster $cluster_rimo_id (".$cluster->name.")\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$buildingsResponse = json_decode($responseText);
|
||||
|
||||
if(is_object($buildingsResponse) && property_exists($buildingsResponse, "item") && is_array($buildingsResponse->item) && count($buildingsResponse->item)) {
|
||||
foreach($buildingsResponse->item as $building) {
|
||||
//var_dump($building);
|
||||
if($building->buildingType && $building->buildingType->userLabel != "Greenfield") {
|
||||
//var_dump($building);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if($building->buildingType && $building->buildingType->userLabel != "Greenfield" && $building->homesCount > 0 && property_exists($building->homes, "item") && is_array($building->homes->item) && count($building->homes->item)) {
|
||||
print_r($building);exit;
|
||||
foreach($building->homes->item as $home) {
|
||||
|
||||
//vaR_dump($home->ftus->item);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$AddressHelper = new ADBAddressHelper\AddressHelper(["log" => $log, "db" => $adb, "netzgebiet" => $adb_netzgebiet]);
|
||||
|
||||
/*
|
||||
* Get Buildings per SalesCluster
|
||||
*/
|
||||
$params = $baseParams;
|
||||
$params["clusterId"] = $cluster_rimo_id;
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$req_url = $epGetBuildings."?".$qs;
|
||||
$req_ctx = stream_context_create($ctxOptsGet);
|
||||
|
||||
echo $req_url."\n";
|
||||
$responseText = file_get_contents($req_url, false, $req_ctx);
|
||||
|
||||
if($responseText === false) {
|
||||
echo "Error fetching Buildings in cluster $cluster_rimo_id (".$cluster->name.")\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$buildingsResponse = json_decode($responseText);
|
||||
|
||||
if(is_object($buildingsResponse) && property_exists($buildingsResponse, "item") && is_array($buildingsResponse->item) && count($buildingsResponse->item)) {
|
||||
foreach($buildingsResponse->item as $building) {
|
||||
//var_dump($building);
|
||||
if($building->buildingType && $building->buildingType->userLabel != "Greenfield") {
|
||||
//var_dump($building);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
// ignore buildings without units
|
||||
if(!$building->plannedTU) {
|
||||
continue;
|
||||
}
|
||||
if($building->buildingType && $building->buildingType->userLabel != "Greenfield" && $building->homesCount > 0 && property_exists($building->homes, "item") && is_array($building->homes->item) && count($building->homes->item)) {
|
||||
//print_r($building);exit;
|
||||
|
||||
$rimo_building_id = $building->id;
|
||||
$hausnummer = $AddressHelper->findAddressFromRimoBuilding($building);
|
||||
if(!$hausnummer) {
|
||||
echo "Adresse nicht gefunden: $rimo_building_id\n";
|
||||
}
|
||||
|
||||
/*foreach($building->homes->item as $home) {
|
||||
var_dump($home->ftus->item);exit;
|
||||
}*/
|
||||
//exit;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//echo $response;
|
||||
echo "\n";
|
||||
Reference in New Issue
Block a user