New Preorderstatus handling at import
This commit is contained in:
@@ -16,9 +16,47 @@ class ADBHausnummer extends mfBaseModel {
|
||||
}
|
||||
|
||||
public function afterSave() {
|
||||
if($this->netzgebiet_id && !$this->gps_long && !$this->gps_lat) {
|
||||
$this->getGpsCoords();
|
||||
}
|
||||
// prevent potential infinite loop
|
||||
$nesting_level = mfValuecache::singleton()->get("adbhausnummer-save-nesting-level-".$this->id);
|
||||
if(!$nesting_level) {
|
||||
$nesting_level = 1;
|
||||
} else {
|
||||
$nesting_level++;
|
||||
}
|
||||
mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$this->id, $nesting_level);
|
||||
|
||||
if($nesting_level > 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if($this->netzgebiet_id && !$this->gps_long && !$this->gps_lat) {
|
||||
$this->getGpsCoords();
|
||||
}
|
||||
|
||||
|
||||
// Statuschange from Rimo statuschange for all units
|
||||
foreach(ADBWohneinheitModel::search(["hausnummer_id" => $this->id]) as $wohneinheit) {
|
||||
AddressDB::handleRimoStatusUpdate($wohneinheit->id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function setNewStatusCode($new_status_code) {
|
||||
if(!$new_status_code) return false;
|
||||
|
||||
$this->log->debug(__METHOD__.": Want new Hausnummer (".$this->id.") Status ".$new_status_code);
|
||||
|
||||
$new_status = ADBStatusModel::getFirst(["code" => $new_status_code]);
|
||||
if(!$new_status) return false;
|
||||
|
||||
$old_status = $this->getProperty("status");
|
||||
if($old_status->code < $new_status->code) {
|
||||
$this->log->debug(__METHOD__.": Setting Hausnummer (".$this->id.") Status from ".$old_status->code." to ".$new_status->code);
|
||||
$this->status_id = $new_status->id;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function getGpsCoords() {
|
||||
|
||||
Reference in New Issue
Block a user