* Add processFieldSettings to solve pivot design and view diff.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
$config->dataview = new stdclass();
|
||||
$config->dataview->create = new stdclass();
|
||||
$config->dataview->create->requiredFields = 'name,code,group';
|
||||
|
||||
$config->dataview->edit = new stdclass();
|
||||
$config->dataview->edit->requiredFields = 'name,group';
|
||||
|
||||
$config->dataview->groupChild['product'] = array('story' => 'story,storyestimate,storyreview,storyspec,storystage');
|
||||
$config->dataview->groupChild['project'] = array('measure' => 'measqueue,measrecords,meastemplate', 'projectContent' => 'programactivity,programoutput,programprocess,programreport,projectcase,projectproduct,projectspec,projectstory', 'review' => 'review,reviewissue,reviewlist,reviewresult');
|
||||
$config->dataview->groupChild['company'] = array('user' => 'user,usercontact,usergroup,userquery,usertpl,userview');
|
||||
|
||||
$config->dataview->columnTypes = new stdclass();
|
||||
$config->dataview->columnTypes->TINY = 'number';
|
||||
$config->dataview->columnTypes->SHORT = 'number';
|
||||
$config->dataview->columnTypes->LONG = 'number';
|
||||
$config->dataview->columnTypes->FLOAT = 'number';
|
||||
$config->dataview->columnTypes->DOUBLE = 'number';
|
||||
$config->dataview->columnTypes->TIMESTAMP = 'string';
|
||||
$config->dataview->columnTypes->LONGLONG = 'string';
|
||||
$config->dataview->columnTypes->INT24 = 'number';
|
||||
$config->dataview->columnTypes->DATE = 'date';
|
||||
$config->dataview->columnTypes->TIME = 'string';
|
||||
$config->dataview->columnTypes->DATETIME = 'date';
|
||||
$config->dataview->columnTypes->YEAR = 'date';
|
||||
$config->dataview->columnTypes->ENUM = 'string';
|
||||
$config->dataview->columnTypes->SET = 'string';
|
||||
$config->dataview->columnTypes->TINYBLOB = 'string';
|
||||
$config->dataview->columnTypes->MEDIUMBLOB = 'string';
|
||||
$config->dataview->columnTypes->LONG_BLOB = 'string';
|
||||
$config->dataview->columnTypes->BLOB = 'string';
|
||||
$config->dataview->columnTypes->VAR_STRING = 'string';
|
||||
$config->dataview->columnTypes->STRING = 'string';
|
||||
$config->dataview->columnTypes->NULL = 'null';
|
||||
$config->dataview->columnTypes->NEWDATE = 'date';
|
||||
$config->dataview->columnTypes->INTERVAL = 'string';
|
||||
$config->dataview->columnTypes->GEOMETRY = 'string';
|
||||
$config->dataview->columnTypes->NEWDECIMAL = 'number';
|
||||
File diff suppressed because it is too large
Load Diff
@@ -260,9 +260,9 @@ class pivot extends control
|
||||
* @return string
|
||||
*/
|
||||
public function ajaxGetSysOptions($type, $object = '', $field = '')
|
||||
{
|
||||
{
|
||||
$sql = isset($_POST['sql']) ? $_POST['sql'] : '';
|
||||
$filters = isset($_POST['filters']) ? $_POST['filters'] : '';
|
||||
$filters = isset($_POST['filters']) ? $_POST['filters'] : '';
|
||||
|
||||
$sql = $this->loadModel('chart')->parseSqlVars($sql, $filters);
|
||||
$options = $this->pivot->getSysOptions($type, $object, $field, $sql);
|
||||
@@ -270,18 +270,18 @@ class pivot extends control
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get pivot table.
|
||||
*
|
||||
* Ajax get pivot table.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetPivot()
|
||||
{
|
||||
{
|
||||
$post = fixer::input('post')->skipSpecial('settings,filters,sql,langs')->get();
|
||||
|
||||
$pivotID = $post->id;
|
||||
$settings = $post->settings;
|
||||
$filters = isset($_POST['searchFilters']) ? $_POST['searchFilters'] : (isset($_POST['filters']) ? $post->filters : array());
|
||||
$filters = isset($_POST['searchFilters']) ? $_POST['searchFilters'] : (isset($_POST['filters']) ? $post->filters : array());
|
||||
$filterType = 'result';
|
||||
|
||||
$pivot = $this->pivot->getById($pivotID);
|
||||
|
||||
@@ -196,11 +196,103 @@ class pivotModel extends model
|
||||
}
|
||||
$pivots[$index]->used = $this->screen->checkIFChartInUse($pivot->id, 'pivot', $screenList);
|
||||
}
|
||||
|
||||
if($isObject) $pivots[$index] = $this->processFieldSettings($pivots[$index]);
|
||||
}
|
||||
|
||||
return $isObject ? reset($pivots) : $pivots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process pivot field settings, function like dataview/js/basequery.js getFieldSettings().
|
||||
*
|
||||
* @param object $pivot
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processFieldSettings($pivot)
|
||||
{
|
||||
$this->loadModel('chart');
|
||||
$this->loadModel('dataview');
|
||||
|
||||
$sql = isset($pivot->sql) ? $pivot->sql : '';
|
||||
$filters = isset($pivot->filters) ? $pivot->filters : array();
|
||||
$recPerPage = 20;
|
||||
$pageID = 1;
|
||||
|
||||
if(!empty($filters))
|
||||
{
|
||||
foreach($filters as $index => $filter)
|
||||
{
|
||||
if(empty($filter['default'])) continue;
|
||||
|
||||
$filters[$index]['default'] = $this->processDateVar($filter['default']);
|
||||
}
|
||||
}
|
||||
$querySQL = $this->chart->parseSqlVars($sql, $filters);
|
||||
|
||||
$columns = $this->dataview->getColumns($querySQL);
|
||||
$columnFields = array();
|
||||
foreach($columns as $column => $type) $columnFields[$column] = $column;
|
||||
|
||||
$tableAndFields = $this->chart->getTables($querySQL);
|
||||
$tables = $tableAndFields['tables'];
|
||||
$fields = $tableAndFields['fields'];
|
||||
$querySQL = $tableAndFields['sql'];
|
||||
|
||||
$moduleNames = array();
|
||||
if($tables) $moduleNames = $this->dataview->getModuleNames($tables);
|
||||
|
||||
list($fieldPairs, $relatedObject) = $this->dataview->mergeFields($columnFields, $fields, $moduleNames);
|
||||
|
||||
/* Use fieldPairs, columns, relatedObject, objectFields refresh pivot fieldSettings .*/
|
||||
|
||||
$fieldSettings = $pivot->fieldSettings;
|
||||
$objectFields = array();
|
||||
foreach($this->lang->dataview->objects as $object => $objectName) $objectFields[$object] = $this->dataview->getTypeOptions($object);
|
||||
|
||||
$fieldSettingsNew = new stdclass();
|
||||
|
||||
foreach($fieldPairs as $index => $field)
|
||||
{
|
||||
$defaultType = $columns->$index;
|
||||
$defaultObject = $relatedObject[$index];
|
||||
|
||||
if(!empty($objectFields) and isset($objectFields[$defaultObject]) and isset($objectFields[$defaultObject][$index])) $defaultType = $objectFields[$defaultObject][$index]['type'] == 'object' ? 'string' : $objectFields[$defaultObject][$index]['type'];
|
||||
|
||||
if(!isset($fieldSettings->$index))
|
||||
{
|
||||
$fieldItem = new stdclass();
|
||||
$fieldItem->name = $field;
|
||||
$fieldItem->object = $defaultObject;
|
||||
$fieldItem->field = $index;
|
||||
$fieldItem->type = $defaultType;
|
||||
|
||||
$fieldSettingsNew[$index] = $fieldItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!isset($fieldSettings->$index->object) or strlen($fieldSettings->$index->object) == 0) $fieldSettings->$index->object = $defaultObject;
|
||||
|
||||
if(!isset($fieldSettings->$index->field) or strlen($fieldSettings->$index->field) == 0)
|
||||
{
|
||||
$fieldSettings->$index->field = $index;
|
||||
$fieldSettings->$index->object = $defaultObject;
|
||||
$fieldSettings->$index->type = 'string';
|
||||
}
|
||||
|
||||
$object = $fieldSettings->$index->object;
|
||||
$type = $fieldSettings->$index->type;
|
||||
if($object == $defaultObject && $type != $defaultType) $fieldSettings->$index->type = $defaultType;
|
||||
|
||||
$fieldSettingsNew->$index = $fieldSettings->$index;
|
||||
}
|
||||
}
|
||||
$pivot->fieldSettings = $fieldSettingsNew;
|
||||
|
||||
return $pivot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute percent of every item.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user