Added creater/editer to Address/View

This commit is contained in:
Frank Schubert
2024-07-09 22:35:07 +02:00
parent ac0430f5a4
commit 43e28847a4
2 changed files with 48 additions and 11 deletions

View File

@@ -158,6 +158,15 @@
</tr><tr>
<th>RTR Code</th>
<td><?=(is_array($address->attributes) && array_key_exists("rtrcode", $address->attributes)) ? $address->attributes['rtrcode']->value : ""?></td>
</tr><tr>
<th></th>
<td></td>
</tr><tr>
<th>Erstellt</th>
<td class="text-monospace"><?=date("d.m.Y H:i:s", $address->create)?> (<?=$address->creator->name?>)</td>
</tr><tr>
<th>Letzte Bearbeitung</th>
<td class="text-monospace"><?=date("d.m.Y H:i:s", $address->edit)?> (<?=$address->editor->name?>)</td>
</tr>
</table>

View File

@@ -17,6 +17,8 @@ class Address extends mfBaseModel {
private $active_contracts;
private $phoneparts;
private $creator;
private $editor;
protected function afterSave() {
// prevent potential infinite loop
@@ -648,11 +650,37 @@ class Address extends mfBaseModel {
return $this->links_to;
}
if($name == "creator") {
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($this->creator === null) {
$this->creator = new User($this->create_by);
if($this->creator->id) {
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
}
}
return $this->creator;
}
if($name == "editor") {
$this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
if($this->editor === null) {
$this->editor = new User($this->edit_by);
if($this->editor->id) {
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
}
}
return $this->editor;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
if(!$this->$name) {
$this->$name = new $classname($this->$idfield);
}
if($this->$name->id) {
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
return $this->$name;
} else {
return null;