Changes for Preorder:
- Added OAID to Hausnummer and Wohneinheit - Added format parameter to /addressdb/findAddress - Added additional fields to /addressdb/findAddress - Updated api doc yaml - Updated addressdb import scripts for Liezen
This commit is contained in:
@@ -37,6 +37,40 @@ class ADBHausnummer extends mfBaseModel {
|
||||
return $data;
|
||||
}*/
|
||||
|
||||
public function getNewOAID() {
|
||||
if(!$this->plz_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cc = "AT";
|
||||
$zip = $this->getProperty("plz")->plz;
|
||||
|
||||
for($try = 16; $try > 0; $try--) {
|
||||
$rnd[0] = random_int(0, 255);
|
||||
$rnd[1] = random_int(0, 255);
|
||||
$rnd[2] = random_int(0, 255);
|
||||
$rnd[3] = random_int(0, 255);
|
||||
|
||||
$code = "$cc-$zip-";
|
||||
foreach($rnd as $r) {
|
||||
$code .= str_pad(dechex($r), 2, "0", STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
if(ADBHausnummerModel::search(['oaid' => $code])) {
|
||||
$this->log->warn(__FILE__."::getNewObjectCode: New Code already in use. Trying again for a maximum of $try times.");
|
||||
} else {
|
||||
// code is unique
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($try == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user