Files
thetool/application/RimoWorkorder/RimoWorkorder.php
2025-01-24 15:04:24 +01:00

73 lines
1.7 KiB
PHP

<?php
class RimoWorkorder extends mfBaseModel {
private $adb_wohneinheit;
private $termination;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
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 getAha() {
if(!$this->id) return false;
$ah = Rimoapi::getWorkorderAhaReport($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;
}
}