Homes update premstaetten nord

This commit is contained in:
Frank Schubert
2023-06-12 12:34:49 +02:00
parent 81dfd78529
commit 01e8360f2f
2 changed files with 1879 additions and 2 deletions

View File

@@ -13,7 +13,7 @@ require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
$me = new User(1);
$filename = __DIR__."/import/SDIHome__Homes_ PremNord_20230526.csv";
$filename = __DIR__."/import/SDIHome__Homes_PremNord_20230609.csv";
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$log = mfLoghandler::singleton();
@@ -115,13 +115,14 @@ while($csv = fgetcsv($input, 0, ";")) {
$wohneinheit = ADBWohneinheitModel::create($wohneinheit_data);
$wohneinheit->save();
//echo "+ ".$wohneinheit->extref."\n";
} else {
$wohneinheit = ADBWohneinheitModel::getFirst(['hausnummer_id' => $hausnummer->id, "extref" => $wohneinheit_extref]);
if($wohneinheit) continue; // unit with extref exists so continue
if($hausnummer_extref == "25012281") {
$zusatz = "Haus ".(ceil($num / 12))." Top $num";
echo "$num: $zusatz\n";
//echo "$num: $zusatz\n";
$wohneinheit = ADBWohneinheitModel::getFirst(['hausnummer_id' => $hausnummer->id, "zusatz" => $zusatz]);
if(!$wohneinheit) {
echo "top not found\n";
@@ -158,6 +159,7 @@ while($csv = fgetcsv($input, 0, ";")) {
if(!$wohneinheit->extref) {
$wohneinheit->extref = $wohneinheit_extref;
//var_dump("UPDATE UNIT",$wohneinheit);exit;
//echo "u ".$wohneinheit->extref."\n";
$wohneinheit->save();
//exit;
}
@@ -167,6 +169,8 @@ while($csv = fgetcsv($input, 0, ";")) {
}
echo "\n";
function getLastWohneinheit($hausnummer_id) {
global $db;
$sql = "SELECT * FROM Wohneinheit WHERE hausnummer_id = $hausnummer_id ORDER BY num DESC LIMIT 1";

File diff suppressed because it is too large Load Diff