diff --git a/module/metric/control.php b/module/metric/control.php index d4dc2cd920..9c18f3e234 100755 --- a/module/metric/control.php +++ b/module/metric/control.php @@ -81,7 +81,7 @@ class metric extends control list($groupHeader, $groupData) = $this->metric->getGroupTable($resultHeader, $resultData); $this->view->groupHeader = $groupHeader; $this->view->groupData = $groupData; - $this->view->dateType = $current ? $this->metric->getDateTypeByCode($current->code) : 'nodate'; + $this->view->dateType = $current ? $current->dateType : 'nodate'; $this->view->dateLabels = $this->metric->getDateLabels($this->view->dateType); $this->view->defaultDate = $this->metric->getDefaultDate($this->view->dateLabels); $this->view->tableWidth = $this->metricZen->getViewTableWidth($groupHeader); @@ -293,7 +293,7 @@ class metric extends control list($groupHeader, $groupData) = $this->metric->getGroupTable($resultHeader, $resultData); $this->view->groupHeader = $groupHeader; $this->view->groupData = $groupData; - $this->view->dateType = $this->metric->getDateTypeByCode($metric->code); + $this->view->dateType = $metric->dateType; $this->view->dateLabels = $this->metric->getDateLabels($this->view->dateType); $this->view->defaultDate = $this->metric->getDefaultDate($this->view->dateLabels); $this->view->tableWidth = $this->metricZen->getViewTableWidth($groupHeader); diff --git a/module/metric/model.php b/module/metric/model.php index cead609d4b..74d2431bee 100755 --- a/module/metric/model.php +++ b/module/metric/model.php @@ -454,6 +454,7 @@ class metricModel extends model $metric->collectConf = $oldMetric->collectConf; $metric->execTime = $oldMetric->execTime; } + if(empty($metric->dateType)) $metric->dateType = $this->getDateTypeByCode($metric->code); return $metric; } @@ -1962,8 +1963,14 @@ class metricModel extends model public function getDateTypeByCode(string $code) { + /* Get dateType form db first. */ + $dateType = $this->getByCode($code, 'dateType'); + if(!empty($dateType)) return $dateType; + + /* Get dateType from config second. */ if(isset($this->config->metric->dateType[$code])) return $this->config->metric->dateType[$code]; + /* At last, infer dateType by code. */ $dataFields = $this->getMetricRecordDateField($code); return $this->getDateType($dataFields); } diff --git a/module/screen/model.php b/module/screen/model.php index 47dd58663b..4044ee3ebf 100644 --- a/module/screen/model.php +++ b/module/screen/model.php @@ -190,7 +190,15 @@ class screenModel extends model $type = $component->chartConfig->package; $type = $this->getChartType($type); $table = $this->config->objectTables[$type]; - $chart = $this->dao->select('*')->from($table)->where('id')->eq($chartID)->fetch(); + + if($type == 'metric') + { + $chart = $this->loadModel('metric')->getByID($chartID); + } + else + { + $chart = $this->dao->select('*')->from($table)->where('id')->eq($chartID)->fetch(); + } if($type == 'metric') return $this->genMetricComponent($chart); return $this->genComponentData($chart, $type, $component); @@ -1770,7 +1778,7 @@ class screenModel extends model $this->loadModel('metric'); $isObjectMetric = $this->metric->isObjectMetric($resultHeader); - $dateType = $this->metric->getDateTypeByCode($metric->code); + $dateType = $metric->dateType; $filters = $this->processMetricFilter($filterParams, $dateType); @@ -1861,7 +1869,7 @@ class screenModel extends model $option = new stdclass(); $option->displayType = 'normal'; $option->cardType = 'A'; - $option->dateType = $this->metric->getDateTypeByCode($metric->code); + $option->dateType = $metric->dateType; $option->bgColor = '#26292EFF'; $option->border = array('color' => '#515458FF', 'width' => 1, 'radius' => 2); $option->scope = $metric->scope;