Merge branch 'fronkdev' into 'master'
Fronkdev See merge request fronk/thetool!71
This commit is contained in:
@@ -96,6 +96,9 @@
|
||||
<label class="col-lg-2 col-form-label" for="netzgebiet_id">Netzgebiet *</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="netzgebiet_id" id="netzgebiet_id">
|
||||
<?php if($me->is("Admin")): ?>
|
||||
<option value=""></option>
|
||||
<?php endif; ?>
|
||||
<?php foreach($my_adb_networks as $fnet): ?>
|
||||
<?php if(is_array($save_data) && array_key_exists("netzgebiet_id", $save_data) && $save_data['netzgebiet_id']): ?>
|
||||
<option value="<?=$fnet->id?>" <?=($save_data['netzgebiet_id'] == $fnet->id) ? "selected='selected'" : ""?>><?=$fnet->name?></option>
|
||||
|
||||
@@ -3,7 +3,7 @@ ob_end_flush();
|
||||
header("Content-type: text/csv");
|
||||
header('Content-disposition: attachment; filename="preorder-export-'.date('Y-m-d_H-i-s').'.csv"');
|
||||
?>
|
||||
Kampagne;Netzgebiet ID;Netzgebiet;Extref;Bestellcode;OAID;Bestelltyp;Status;Anschlusstyp;GWR Adresscode;Anschluss Strasse;Anschluss Hausnummer;Anschluss PLZ;Anschluss Ort;Anschluss Wohneinheit;GPS Breite;GPS Länge;Anzahl Anschlüsse;Kunde Firma;Kunde UID;Kunde Vorname;Kunde Nachname;Kunde Strasse;Kunde PLZ;Kunde Ort;Kunde Telefon;Kunde Email;Partner;Addon Lehrverrohrung Grundstück;Addon Hausverkabelung;BEP festgelegt;Starterpaket erhalten;Erstellt;Letzte Bearbeitung
|
||||
Kampagne;Netzgebiet ID;Netzgebiet;Extref;Bestellcode;OAID;Bestelltyp;Status;Anschlusstyp;GWR Adresscode;RW;HW;Anschluss Strasse;Anschluss Hausnummer;Anschluss PLZ;Anschluss Ort;Anschluss Wohneinheit;GPS Breite;GPS Länge;Anzahl Anschlüsse;Kunde Firma;Kunde UID;Kunde Vorname;Kunde Nachname;Kunde Strasse;Kunde PLZ;Kunde Ort;Kunde Telefon;Kunde Email;Partner;Addon Lehrverrohrung Grundstück;Addon Hausverkabelung;BEP festgelegt;Starterpaket erhalten;Erstellt;Letzte Bearbeitung
|
||||
<?php
|
||||
$line = 0;
|
||||
|
||||
@@ -57,9 +57,9 @@ while($data = mysqli_fetch_object($res)):
|
||||
if($data->uid == "string") $data->uid = "";
|
||||
|
||||
?>
|
||||
"<?=$campaign->name?>";"<?=$netzgebiet->extref?>";"<?=$netzgebiet->name?>";"<?=$data->extref?>";"<?=$data->ucode?>";"<?=$wohneinheit->oaid?>";"<?=__($data->type,"preorder")?>";"<?=$status->name?>";"<?=__($data->connection_type,"preorder")?>";"<?=$hausnummer->adrcd?>";"<?=$strasse->name?>";"<?=$hausnummer->hausnummer?>";"<?=$plz->plz?>";"<?=$ortschaft->name?>";"<?=$unit_data?>";"<?=$hausnummer->gps_lat?>";"<?=$hausnummer->gps_long?>";<?=$data->connection_count?>;"<?=$data->company?>";"<?=$data->uid?>";"<?=$data->firstname?>";"<?=$data->lastname?>";"<?=$data->street?>";"<?=$data->zip?>";"<?=$data->city?>";"<?=$data->phone?>";"<?=$data->email?>";"<?=$partner->getCompanyOrName()?>";<?=$addon_property?>;<?=$addon_inhouse?>;<?=($bep) ? "1" : "0"?>;<?=($inhouse) ? "1" : "0"?>;"<?=date("Y-m-d H:i:s",$data->create)?>";"<?=date("Y-m-d H:i:s",$data->edit)?>"
|
||||
"<?=$campaign->name?>";"<?=$netzgebiet->extref?>";"<?=$netzgebiet->name?>";"<?=$data->extref?>";"<?=$data->ucode?>";"<?=$wohneinheit->oaid?>";"<?=__($data->type,"preorder")?>";"<?=$status->name?>";"<?=__($data->connection_type,"preorder")?>";"<?=$hausnummer->adrcd?>";"<?=$hausnummer->rw?>";"<?=$hausnummer->hw?>";"<?=$strasse->name?>";"<?=$hausnummer->hausnummer?>";"<?=$plz->plz?>";"<?=$ortschaft->name?>";"<?=$unit_data?>";"<?=$hausnummer->gps_lat?>";"<?=$hausnummer->gps_long?>";<?=$data->connection_count?>;"<?=$data->company?>";"<?=$data->uid?>";"<?=$data->firstname?>";"<?=$data->lastname?>";"<?=$data->street?>";"<?=$data->zip?>";"<?=$data->city?>";"<?=$data->phone?>";"<?=$data->email?>";"<?=$partner->getCompanyOrName()?>";<?=$addon_property?>;<?=$addon_inhouse?>;<?=($bep) ? "1" : "0"?>;<?=($inhouse) ? "1" : "0"?>;"<?=date("Y-m-d H:i:s",$data->create)?>";"<?=date("Y-m-d H:i:s",$data->edit)?>"
|
||||
<?php
|
||||
$i++;
|
||||
$line++;
|
||||
if($line % 1000 === 0) {
|
||||
flush();
|
||||
}
|
||||
|
||||
@@ -14,31 +14,33 @@ class ADBHausnummer extends mfBaseModel {
|
||||
$this->table = "Hausnummer";
|
||||
}
|
||||
|
||||
/*
|
||||
public static function parseAddresszusatz($text) {
|
||||
$zusatz = "";
|
||||
|
||||
$text = trim($text);
|
||||
if(!$text) return $data;
|
||||
$text = " ".$text;
|
||||
|
||||
$m = [];
|
||||
if(preg_match('/((?:gesch(?:ae|ä)ft|betrieb und wohnungen|paketlogistik|cafe|pavillon|pfarrheim|[^ ]*haus|[^ ]*geb(?:ae|ä)ude|[^ ]*halle)(?:\s+[a-z0-9]+)?)/i', $text, $m)) {
|
||||
$zusatz = $m[1];
|
||||
$text = str_replace($m[0], "", $text);
|
||||
public function afterSave() {
|
||||
if($this->netzgebiet_id && !$this->gps_long && !$this->gps_lat) {
|
||||
$this->getGpsCoords();
|
||||
}
|
||||
}
|
||||
|
||||
private function getGpsCoords() {
|
||||
$search = [
|
||||
'country' => "AT",
|
||||
'city' => $this->getProperty("strasse")->gemeinde->name,
|
||||
'zip' => $this->getProperty("plz")->plz,
|
||||
'street' => $this->getProperty("strasse")->name
|
||||
];
|
||||
if(!$search['country'] || !$search['city'] || !$search['zip'] || !$search['street']) {
|
||||
$this->log->warning(__METHOD__.": Unable to retrieve GPS Coordinates. Search key missing (hausnummer_id: ".$this->id.")");
|
||||
return false;
|
||||
}
|
||||
|
||||
$coords = Gmaps_Geocoding::getCoords($search);
|
||||
|
||||
|
||||
$text = trim(preg_replace('/\s{2,}/', "", $text));
|
||||
|
||||
if($text) {
|
||||
$data['zusatz'] = $text;
|
||||
if(is_array($coords) && count($coords) == 2 && $coords[0] && $coords[1]) {
|
||||
$this->gps_lat = str_replace(",",".",$coords[0]);
|
||||
$this->gps_long = str_replace(",",".",$coords[1]);
|
||||
$this->save();
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getAddress() {
|
||||
$address = "[".$this->getProperty("strasse")->gemeinde->name."]";
|
||||
|
||||
@@ -58,53 +58,11 @@ class AddressDB {
|
||||
left join `".FRONKDB_DBNAME."`.`Address` as tbl_address on (tbl_address.`id` = tbl_preorder.partner_id)
|
||||
";
|
||||
|
||||
/*public static $wohneinheit_query = "select `Netzgebiet`.`id` AS `netzgebiet_id`,
|
||||
`Netzgebiet`.`name` AS `netzgebiet`,
|
||||
`Netzgebiet`.`extref` AS `netzgebiet_extref`,
|
||||
`Gemeinde`.`id` AS `gemeinde_id`,
|
||||
`Gemeinde`.`kennziffer` AS `gemeinde_kennziffer`,
|
||||
`Gemeinde`.`code` AS `gemeinde_code`,
|
||||
`Gemeinde`.`name` AS `gemeinde`,
|
||||
`Ortschaft`.`id` AS `ortschaft_id`,
|
||||
`Ortschaft`.`kennziffer` AS `ortschaft_kennziffer`,
|
||||
`Ortschaft`.`name` AS `ortschaft`,
|
||||
`Plz`.`plz` AS `plz`,
|
||||
`Strasse`.`id` AS `strasse_id`,
|
||||
`Strasse`.`kennziffer` AS `strasse_kennziffer`,
|
||||
`Strasse`.`name` AS `strasse`,
|
||||
`Hausnummer`.`id` AS `hausnummer_id`,
|
||||
`Hausnummer`.`oaid` AS `hausnummer_oaid`,
|
||||
`Hausnummer`.`hausnummer` AS `hausnummer`,
|
||||
`Hausnummer`.`extref` AS `hausnummer_extref`,
|
||||
`Hausnummer`.`grund_nr` AS `grund_nr`,
|
||||
`Hausnummer`.`gps_lat` AS `gps_lat`,
|
||||
`Hausnummer`.`gps_long` AS `gps_long`,
|
||||
`Hausnummer`.`rollout` AS `rollout`,
|
||||
`Hausnummer`.`rollout_info` AS `rollout_info`,
|
||||
`Hausnummer`.`freigabe` AS `freigabe`,
|
||||
`Wohneinheit`.`id` AS `wohneinheit_id`,
|
||||
`Wohneinheit`.`oaid` AS `wohneinheit_oaid`,
|
||||
`Wohneinheit`.`extref` AS `wohneinheit_extref`,
|
||||
`Wohneinheit`.`num` AS `num`,
|
||||
`Wohneinheit`.`block` AS `block`,
|
||||
`Wohneinheit`.`stiege` AS `stiege`,
|
||||
`Wohneinheit`.`stock` AS `stock`,
|
||||
`Wohneinheit`.`tuer` AS `tuer`,
|
||||
`Wohneinheit`.`bezeichner` AS `bezeichner`,
|
||||
`Wohneinheit`.`zusatz` AS `zusatz` from `Hausnummer`
|
||||
left join `Netzgebiet` on (`Hausnummer`.`netzgebiet_id` = `Netzgebiet`.`id`)
|
||||
left join `Plz` on (`Plz`.`id` = `Hausnummer`.`plz_id`)
|
||||
left join `Strasse` on (`Strasse`.`id` = `Hausnummer`.`strasse_id`)
|
||||
left join `Ortschaft` on (`Ortschaft`.`id` = `Hausnummer`.`ortschaft_id`)
|
||||
left join `Gemeinde` on (`Gemeinde`.`id` = `Strasse`.`gemeinde_id`)
|
||||
left join `Wohneinheit` on (`Wohneinheit`.`hausnummer_id` = `Hausnummer`.`id`)";
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$this->log = mfLoghandler::singleton();
|
||||
}
|
||||
|
||||
|
||||
public function import($input) {
|
||||
$path = __DIR__."/Importer/";
|
||||
$dir = opendir($path);
|
||||
@@ -130,6 +88,7 @@ class AddressDB {
|
||||
*/
|
||||
|
||||
public function createUpdateHausnummer($data) {
|
||||
$netzgebiet_id = 0;
|
||||
$netzgebiet = null;
|
||||
$gemeinde = null;
|
||||
$ortschaft = null;
|
||||
@@ -139,10 +98,6 @@ class AddressDB {
|
||||
|
||||
//var_dump($data);exit;
|
||||
|
||||
if(!array_key_exists("netzgebiet_id", $data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach(["gemeinde", "ortschaft", "strasse", "plz"] as $field) {
|
||||
$classname = "ADB".ucfirst($field);
|
||||
$idfield = $field."_id";
|
||||
@@ -153,13 +108,16 @@ class AddressDB {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$netzgebiet = new ADBNetzgebiet($data['netzgebiet_id']);
|
||||
if(!$netzgebiet->id) {
|
||||
$this->log->debug(__CLASS__."::".__METHOD__.": Missing netzgebiet_id");
|
||||
return false;
|
||||
if(array_key_exists("netzgebiet_id", $data) && $data['netzgebiet_id']) {
|
||||
$netzgebiet_id = $data['netzgebiet_id'];
|
||||
$netzgebiet = new ADBNetzgebiet($data['netzgebiet_id']);
|
||||
if(!$netzgebiet->id) {
|
||||
$this->log->debug(__CLASS__."::".__METHOD__.": Missing netzgebiet_id");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!$gemeinde) {
|
||||
// dont allow creating Gemeinden
|
||||
$this->log->debug(__CLASS__."::".__METHOD__.": Missing Gemeinde");
|
||||
@@ -253,7 +211,7 @@ class AddressDB {
|
||||
//$hausnummer_data['oaid'] = (array_key_exists("oaid", $data) && $data['oaid']) ? $data['oaid'] : null;
|
||||
$hausnummer_data['adrcd'] = ($data['adrcd']) ? $data['adrcd'] : null;
|
||||
$hausnummer_data['extref'] = ($data['extref']) ? $data['extref'] : null;
|
||||
$hausnummer_data['netzgebiet_id'] = $netzgebiet->id;
|
||||
$hausnummer_data['netzgebiet_id'] = $netzgebiet_id;
|
||||
$hausnummer_data['ortschaft_id'] = $ortschaft->id;
|
||||
$hausnummer_data['plz_id'] = $plz->id;
|
||||
$hausnummer_data['strasse_id'] = $strasse->id;
|
||||
|
||||
@@ -243,7 +243,10 @@ class AddressDBController extends mfBaseController {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$required = ['netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde'];
|
||||
$required = ['strasse','hausnummer','plz','ortschaft','gemeinde'];
|
||||
if(!$this->me->is("Admin")) {
|
||||
$required[] = "netzgebiet_id";
|
||||
}
|
||||
foreach(['adrcd','extref','netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde','grund_nr','gdaeigenschaft','meridian','rw','hw','gps_lat','gps_long','unit_count'] as $field) {
|
||||
if(in_array($field, $required)) {
|
||||
if(!trim($r->$field)) {
|
||||
|
||||
Reference in New Issue
Block a user