Fixed Termination and Building Workflowitem loading

This commit is contained in:
Frank Schubert
2022-02-17 21:34:53 +01:00
parent b63640e232
commit 08630e9942
6 changed files with 63 additions and 43 deletions

View File

@@ -80,13 +80,6 @@ class Building extends mfBaseModel {
}
public function loadWorkflowItems() {
/*foreach(WorkflowitemModel::search(["object_type" => "building", "active" => 1]) as $item) {
$item->setObjectId($this->id);
$this->workflowitems[$item->name] = $item;
mfValuecache::singleton()->set("wfBuilding-".$item->name, $item);
}*/
$item_ids = [];
$building_wfitems = mfValuecache::singleton()->get("wfitems-building-active");
@@ -96,26 +89,27 @@ class Building extends mfBaseModel {
}
foreach($building_wfitems as $item) {
$item->setObjectId($this->id);
$this->workflowitems[$item->name] = $item;
mfValuecache::singleton()->set("wfBuilding-name-".$item->name, $item);
mfValuecache::singleton()->set("wfBuilding-id-".$item->id, $item);
$item_ids[] = $item->id;
}
foreach($item_ids as $id) {
mfValuecache::singleton()->set("wfItemvalue-item-".$id."-object-".$this->id, new Workflowvalue());
$item->setObjectId($this->id);
$new_value = new Workflowvalue();
$new_value->item_id = $item->id;
$new_value->object_id = $this->id;
mfValuecache::singleton()->set("wfItemvalue-item-".$item->id."-object-".$this->id, $new_value);
$item->setValue($new_value);
$this->workflowitems[$item->name] = $item;
}
// get values
$values = WorkflowvalueModel::search(["object_id" => $this->id]);
//var_dump($values);exit;
$values = WorkflowvalueModel::search(["object_id" => $this->id, "object_type" => "building"]);
foreach($values as $value) {
if(array_key_exists($value->item->name, $this->workflowitems)) {
//var_dump($value);exit;
$this->workflowitems[$value->item->name]->setValue($value);
mfValuecache::singleton()->set("wfItemvalue-item-".$value->item_id."-object-".$this->id, $value);
}
$this->log->debug(print_r($value->item, true));
$this->workflowitems[$value->item->name]->setValue($value);
mfValuecache::singleton()->set("wfItemvalue-item-".$value->item_id."-object-".$this->id, $value);
}
}