diff --git a/Layout/default/Order/Index.php b/Layout/default/Order/Index.php index 09b91df56..a69ef62ed 100644 --- a/Layout/default/Order/Index.php +++ b/Layout/default/Order/Index.php @@ -558,6 +558,7 @@ + log->debug("blah: ".print_r($order->terminations[0]->workflowitems["customer_setup_date"]->value,true)); ?> " id="order-id?>"> id?> @@ -653,7 +654,7 @@
value->value_string) ? "active" : ""?>">Tiefbau: terminations[0]->workflowitems["bautermin"]->value->value_string) ? "".$order->terminations[0]->workflowitems["bautermin"]->value->value_string."" : "--.--.----"?>
value->value_string) ? "active" : ""?>">Leitungsbau Backbone: terminations[0]->workflowitems["backbone_setup_date"]->value->value_string) ? "".$order->terminations[0]->workflowitems["backbone_setup_date"]->value->value_string."" : "--.--.----"?>
-
value->value_string) ? "active" : ""?>">Leitungsbau Kunde: terminations[0]->workflowitems["customer_setup_date"]->value->value_string) ? "".$order->terminations[0]->workflowitems["customer_setup_date"]->value->value_string."" : "--.--.----"?>
+
">Leitungsbau Kunde: terminations[0]->getWorkflowvalue("customer_setup_date")) ? "".$order->terminations[0]->getWorkflowvalue("customer_setup_date")."" : "--.--.----"?>
">Versandtermin: shippingdate) ? "".date("d.m.Y", $order->shippingdate)."" : "--.--.----"?>
" id="order-install-date-id?>">Vorortinstallation: install_date) ? "".date("d.m.Y",$order->install_date)."" : "--.--.----"?>
diff --git a/application/Building/Building.php b/application/Building/Building.php index f8dbfc5a5..3b303bb68 100644 --- a/application/Building/Building.php +++ b/application/Building/Building.php @@ -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); } } diff --git a/application/Termination/Termination.php b/application/Termination/Termination.php index d81af0af7..d4a4da866 100644 --- a/application/Termination/Termination.php +++ b/application/Termination/Termination.php @@ -35,8 +35,9 @@ class Termination extends mfBaseModel { return $address; } + public function loadWorkflowItems() { - $item_ids = []; + //$this->log->debug("in loadWorkflowItems() - terminstaiton_id: ".$this->id); $term_wfitems = mfValuecache::singleton()->get("wfitems-term-active"); if(!$term_wfitems) { @@ -45,32 +46,28 @@ class Termination extends mfBaseModel { } foreach($term_wfitems as $item) { - $item->setObjectId($this->id); - $this->workflowitems[$item->name] = $item; mfValuecache::singleton()->set("wfTerm-name-".$item->name, $item); mfValuecache::singleton()->set("wfTerm-id-".$item->id, $item); - $item_ids[] = $item->id; + $item->setObjectId($this->id); + + $new_value = new Workflowvalue(); + $new_value->item_id = $item->id; + $new_value->object_id = $this->id; + //$this->log->debug("empty value has item_id: ".$new_value->item_id." - object_id: ".$new_value->object_id. ". Goes into cache as wfItemvalue-item-".$item->id."-object-".$this->id." value: ".$new_value->value_string); + + mfValuecache::singleton()->set("wfItemvalue-item-".$item->id."-object-".$this->id, $new_value); + $item->setValue($new_value); + $this->workflowitems[$item->name] = $item; } - foreach($item_ids as $id) { - mfValuecache::singleton()->set("wfItemvalue-item-".$id."-object-".$this->id, new Workflowvalue()); - } // get values $values = WorkflowvalueModel::search(["object_id" => $this->id]); - //var_dump($values);exit; + 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); - } } - /*if($this->id == 42) { - //var_dump(array_keys(mfValuecache::singleton()->getCache()));exit; - var_dump(mfValuecache::singleton()->get("wfItemvalue-item-20-object-42"));exit; - }*/ - } public function getWorkflowvalue($itemname, $type = false) { @@ -83,6 +80,7 @@ class Termination extends mfBaseModel { mfValuecache::singleton()->set("wfTerm-name-".$itemname, $item); mfValuecache::singleton()->set("wfTerm-id-".$item->id, $item); } + $item->setObjectId($this->id); switch($item->type) { case "string": @@ -116,9 +114,8 @@ class Termination extends mfBaseModel { $value_type = "string"; } - if(array_key_exists($itemname, $this->getProperty("workflowitems"))) { - //$this->log->debug(__FILE__.": $itemname => ".$this->getProperty("workflowitems")[$itemname]->value->{"value_$value_type"}); - return $this->getProperty("workflowitems")[$itemname]->value->{"value_$value_type"}; + if(array_key_exists($itemname, $this->workflowitems)) { + return $this->workflowitems[$itemname]->value->{"value_$value_type"}; } return null; @@ -142,7 +139,6 @@ class Termination extends mfBaseModel { $done = true; foreach($item_names as $name) { - //$this->log->debug(__FILE__.": (Termination ".$this->id.") $name => $type == '".$this->getWorkflowvalue($name)."' (ist: '".$this->getWorkflowvalue("ist_".$name)."')"); if(!strlen($this->getWorkflowvalue($name)) && !strlen($this->getWorkflowvalue("ist_".$name))) { $done = false; break; diff --git a/application/Workflowitem/Workflowitem.php b/application/Workflowitem/Workflowitem.php index f9d73b053..21e047227 100644 --- a/application/Workflowitem/Workflowitem.php +++ b/application/Workflowitem/Workflowitem.php @@ -12,6 +12,10 @@ class Workflowitem extends mfBaseModel { return true; } + public function unsetObjectId() { + $this->object_id = null; + } + public function setValue(Workflowvalue $value) { $this->value = $value; } @@ -22,6 +26,14 @@ class Workflowitem extends mfBaseModel { if($name == "value") { if(!$this->object_id) { $this->log->warn(__CLASS__."::getProperty('value'): Object ID not set"); + $this->log->debug("[Backtrace] ================"); + $this->log->debug("[Backtrace] START Backtrace"); + $bt = debug_backtrace(); + foreach($bt as $n => $b) { + $this->log->debug($n.") ".$b["file"]."(".$b['line']."): ".$b['class']."->".$b['function']."()" ); + } + $this->log->debug("[Backtrace] $sql"); + $this->log->debug("[Backtrace] END Backtrace"); return null; } $value = mfValuecache::singleton()->get("wfItemvalue-item-".$this->id."-object-".$this->object_id); diff --git a/application/Workflowvalue/Workflowvalue.php b/application/Workflowvalue/Workflowvalue.php index 3d0480e80..9184d4ffd 100644 --- a/application/Workflowvalue/Workflowvalue.php +++ b/application/Workflowvalue/Workflowvalue.php @@ -137,6 +137,8 @@ class Workflowvalue extends mfBaseModel { if(!$this->item) { $this->item = new Workflowitem($this->item_id); if($this->item->id) { + $item = $this->item; + $item->unsetObjectId(); mfValuecache::singleton()->set("wfItem-id-".$this->item->id, $this->item); } } diff --git a/application/Workflowvalue/WorkflowvalueModel.php b/application/Workflowvalue/WorkflowvalueModel.php index 05541f4bb..a066a4e13 100644 --- a/application/Workflowvalue/WorkflowvalueModel.php +++ b/application/Workflowvalue/WorkflowvalueModel.php @@ -94,7 +94,12 @@ class WorkflowvalueModel { $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); - $res = $db->select("Workflowvalue", "*", $where); + + $sql = "SELECT Workflowvalue.* FROM Workflowvalue + LEFT JOIN Workflowitem ON (Workflowitem.id = Workflowvalue.item_id) + WHERE $where"; + + $res = $db->query($sql); if($db->num_rows($res)) { while($data = $db->fetch_object($res)) { $items[] = new Workflowvalue($data); @@ -137,6 +142,16 @@ class WorkflowvalueModel { } } + if(array_key_exists("object_type", $filter)) { + $object_type = $filter["object_type"]; + if(strtolower($object_type) == "termination") { + $where .= " AND Workflowitem.object_type = 'Termination' "; + } + if(strtolower($object_type) == "building") { + $where .= " AND Workflowitem.object_type = 'Building' "; + } + } + //var_dump($filter, $where);exit;