63 lines
1.5 KiB
PHP
63 lines
1.5 KiB
PHP
<?php
|
|
|
|
class RimoWorkorder extends mfBaseModel {
|
|
private $adb_wohneinheit;
|
|
private $termination;
|
|
|
|
public function afterSave() {
|
|
// 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 downloadAh() {
|
|
if(!$this->id) return false;
|
|
|
|
$ah = Rimoapi::getWorkorderAhReport($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;
|
|
}
|
|
} |