* Add bi getScopeOption.
This commit is contained in:
+24
-43
@@ -22,6 +22,7 @@ class chartModel extends model
|
||||
{
|
||||
parent::__construct($appName);
|
||||
$this->loadBIDAO();
|
||||
$this->loadModel('bi');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,7 +255,7 @@ class chartModel extends model
|
||||
}
|
||||
|
||||
$indicator = array();
|
||||
$optionList = $this->getFieldOptions($fields[$group]['type'], $fields[$group]['object'], $fields[$group]['field']);
|
||||
$optionList = $this->getSysOptions($fields[$group]['type'], $fields[$group]['object'], $fields[$group]['field']);
|
||||
foreach($xLabels as $xLabel)
|
||||
{
|
||||
$labelName = isset($optionList[$xLabel]) ? $optionList[$xLabel] : $xLabel;
|
||||
@@ -293,7 +294,7 @@ class chartModel extends model
|
||||
if(empty($date)) arsort($stat);
|
||||
|
||||
$seriesData = array();
|
||||
$optionList = $this->getFieldOptions($fields[$group]['type'], $fields[$group]['object'], $fields[$group]['field']);
|
||||
$optionList = $this->getSysOptions($fields[$group]['type'], $fields[$group]['object'], $fields[$group]['field']);
|
||||
foreach($stat as $name => $value)
|
||||
{
|
||||
if(empty($value)) continue;
|
||||
@@ -345,7 +346,7 @@ class chartModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
$optionList = $this->getFieldOptions($fields[$group]['type'], $fields[$group]['object'], $fields[$group]['field']);
|
||||
$optionList = $this->getSysOptions($fields[$group]['type'], $fields[$group]['object'], $fields[$group]['field']);
|
||||
foreach($xLabels as $index => $xLabel) $xLabels[$index] = isset($optionList[$xLabel]) ? $optionList[$xLabel] : $xLabel;
|
||||
|
||||
$series = array();
|
||||
@@ -388,7 +389,7 @@ class chartModel extends model
|
||||
$yDatas[] = $data;
|
||||
}
|
||||
|
||||
$optionList = $this->getFieldOptions($fields[$group]['type'], $fields[$group]['object'], $fields[$group]['field']);
|
||||
$optionList = $this->getSysOptions($fields[$group]['type'], $fields[$group]['object'], $fields[$group]['field']);
|
||||
foreach($xLabels as $index => $xLabel) $xLabels[$index] = isset($optionList[$xLabel]) ? $optionList[$xLabel] : $xLabel;
|
||||
|
||||
$series = array();
|
||||
@@ -521,61 +522,41 @@ class chartModel extends model
|
||||
* @param string $object
|
||||
* @param string $field
|
||||
* @param string $sql
|
||||
* @param string $saveAs
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getFieldOptions(string $type, string $object = '', string $field = '', string $sql = ''): array
|
||||
public function getSysOptions(string $type, string $object = '', string $field = '', string $sql = '', string $saveAs = ''): array
|
||||
{
|
||||
if(in_array($type, array('user', 'product', 'project', 'execution', 'dept'))) return $this->bi->getScopeOptions($type);
|
||||
if(!$field) return array();
|
||||
|
||||
$options = array();
|
||||
switch($type)
|
||||
{
|
||||
case 'user':
|
||||
$options = $this->loadModel('user')->getPairs();
|
||||
break;
|
||||
case 'product':
|
||||
$options = $this->loadModel('product')->getPairs();
|
||||
break;
|
||||
case 'project':
|
||||
$options = $this->loadModel('project')->getPairsByProgram();
|
||||
break;
|
||||
case 'execution':
|
||||
$options = $this->loadModel('execution')->getPairs();
|
||||
break;
|
||||
case 'dept':
|
||||
$options = $this->loadModel('dept')->getOptionMenu(0);
|
||||
break;
|
||||
case 'option':
|
||||
if($field)
|
||||
{
|
||||
$path = $this->app->getModuleRoot() . 'dataview' . DS . 'table' . DS . "$object.php";
|
||||
if(is_file($path))
|
||||
{
|
||||
include $path;
|
||||
$options = $schema->fields[$field]['options'];
|
||||
}
|
||||
}
|
||||
$options = $this->bi->getDataviewOptions($object, $field);
|
||||
break;
|
||||
case 'object':
|
||||
if($field)
|
||||
{
|
||||
$table = zget($this->config->objectTables, $object, '');
|
||||
if($table) $options = $this->dao->select("id, {$field}")->from($table)->fetchPairs();
|
||||
}
|
||||
$options = $this->bi->getObjectOptions($object, $field);
|
||||
break;
|
||||
default:
|
||||
if($field and $sql)
|
||||
case 'string':
|
||||
case 'number':
|
||||
if($sql)
|
||||
{
|
||||
$cols = $this->dbh->query($sql)->fetchAll();
|
||||
foreach($cols as $col)
|
||||
{
|
||||
$data = $col->$field;
|
||||
$options[$data] = $data;
|
||||
}
|
||||
$keyField = $field;
|
||||
$valueField = $saveAs ? $saveAs : $field;
|
||||
$options = $this->bi->getOptionsFromSql($sql, $keyField, $valueField);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $options;
|
||||
if($sql and $saveAs and in_array($type, array('user', 'product', 'project', 'execution', 'dept', 'option', 'object')))
|
||||
{
|
||||
$options = $this->bi->getOptionsFromSql($sql, $field, $saveAs);
|
||||
}
|
||||
|
||||
return array_filter($options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user