loadMe(); $data["edit_by"] = $me->id; } return $data; } public function afterSave() { $this->adb_wohneinheit = null; $this->termination = null; // prevent potential infinite loop $nesting_level = mfValuecache::singleton()->get("rimoworkorder-save-nesting-level-".$this->id); if(!$nesting_level) { $nesting_level = 1; } else { $nesting_level++; } mfValuecache::singleton()->set("rimoworkorder-save-nesting-level-".$this->id, $nesting_level); if($nesting_level > 1) { return true; } // Statuschange from Rimo statuschange for all units $wohneinheit = $this->getProperty("adb_wohneinheit"); if($wohneinheit) { AddressDB::handleRimoStatusUpdate($wohneinheit->id); } } public function getAha() { if(!$this->id) return false; if(!$this->adb_wohneinheit_id) return false; $preorder = PreorderModel::getFirstActive(["adb_wohneinheit_id" => $this->adb_wohneinheit_id]); $this->log->debug(__METHOD__.": Wohneinheit: ".$this->adb_wohneinheit_id); $this->log->debug(__METHOD__.": Preorder: ".$preorder->id); if(!$preorder) return false; $api_creds = $preorder->getNetownerRimoApiCredentials(); $this->log->debug(__METHOD__.": Rimo Api Creds: ".print_r($api_creds, true)); if(!$api_creds) return false; $apikey = $api_creds["prod"]["key"]; $ah = Rimoapi::getWorkorderAhaReport($apikey, $this->rimo_id); return $ah; } public function getProperty($name) { if($this->$name == null) { if(!$this->id) { return null; } if($name == "adb_wohneinheit") { $this->adb_wohneinheit = new ADBWohneinheit($this->adb_wohneinheit_id); return $this->adb_wohneinheit; } $classname = ucfirst($name); $idfield = $name."_id"; $this->$name = new $classname($this->$idfield); if($this->$name->id) { return $this->$name; } else { return null; } } return $this->$name; } }