Fixed adding same homes every time import runs
This commit is contained in:
@@ -107,8 +107,10 @@ class AddressHelper
|
||||
}
|
||||
|
||||
$create_address_parts = false;
|
||||
$update_freigabe = false;
|
||||
if ($this->netzgebiet) {
|
||||
$create_address_parts = $this->netzgebiet->getOption("create_address_parts");
|
||||
$update_freigabe = $this->netzgebiet->getOption("update_freigabe");
|
||||
}
|
||||
|
||||
|
||||
@@ -323,7 +325,11 @@ class AddressHelper
|
||||
$hausnummer->rimo_fcp_name = $fcp_name;
|
||||
$hausnummer->save();
|
||||
}
|
||||
//$hausnummer->freigabe = $this->netzgebiet->default_freigabe;
|
||||
if($update_freigabe && $hausnummer->freigabe != $this->netzgebiet->default_freigabe) {
|
||||
$hausnummer->freigabe = $this->netzgebiet->default_freigabe;
|
||||
$hausnummer->save();
|
||||
}
|
||||
|
||||
|
||||
//echo ">>>>>>>>>>>>>>>>>>>\nupdating hausnummer:\n";
|
||||
//print_r($hausnummer);exit;
|
||||
|
||||
@@ -122,8 +122,8 @@ foreach($netowners as $apiOwner) {
|
||||
|
||||
$addressErrors = [];
|
||||
|
||||
if($cluster_rimo_id != "SDIRolloutRegion_97586867201_1711003389") {
|
||||
// stiftingtal
|
||||
if($cluster_rimo_id != "SDISalesCluster_29189625089_1679036889") {
|
||||
// lieboch
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -222,8 +222,10 @@ foreach($netowners as $apiOwner) {
|
||||
|
||||
$last_unit_num = 0;
|
||||
$existing_units = [];
|
||||
$existing_units_extref = [];
|
||||
foreach(\ADBWohneinheitModel::search(["hausnummer_id" => $hausnummer->id]) as $unit) {
|
||||
$existing_units[$unit->extref] = $unit;
|
||||
$existing_units[] = $unit;
|
||||
$existing_units_extref[$unit->extref] = $unit;
|
||||
if($last_unit_num < $unit->num) {
|
||||
$last_unit_num++;
|
||||
}
|
||||
@@ -259,8 +261,8 @@ foreach($netowners as $apiOwner) {
|
||||
|
||||
//echo "$home_rimo_id\n";continue;
|
||||
|
||||
if(array_key_exists($home_rimo_id, $existing_units)) {
|
||||
$unit = $existing_units[$home_rimo_id];
|
||||
if(array_key_exists($home_rimo_id, $existing_units_extref)) {
|
||||
$unit = $existing_units_extref[$home_rimo_id];
|
||||
} else {
|
||||
// find free home without rimo_id
|
||||
$unit = \ADBWohneinheitModel::getFirst(["hausnummer_id" => $hausnummer->id, "extref" => null]);
|
||||
|
||||
21
scripts/addressdb/recalculate_home_count.php
Normal file
21
scripts/addressdb/recalculate_home_count.php
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
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);
|
||||
|
||||
foreach(ADBNetzgebietModel::getAll() as $netzgebiet) {
|
||||
$home = ADBWohneinheitModel::getFirst(["netzgebiet_id" => $netzgebiet->id]);
|
||||
if(!$home) continue;
|
||||
|
||||
$home->save();
|
||||
}
|
||||
Reference in New Issue
Block a user