BUG 0000 PM tables ver 2. (performance improvements)
This commit is contained in:
@@ -330,6 +330,9 @@ class Form extends XmlForm
|
||||
$values["{$k}_label"] .= ($i != 0 ? '|': '') . $v->options[$value];
|
||||
} else {
|
||||
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
|
||||
if(trim($query) == '') {
|
||||
continue;
|
||||
}
|
||||
//we do the query to the external connection and we've got the label
|
||||
$con = Propel::getConnection($this->fields[$k]->sqlConnection!=""?$this->fields[$k]->sqlConnection:"workflow");//use default connection workflow if connection is not defined. Same as Dynaforms
|
||||
|
||||
@@ -361,6 +364,9 @@ class Form extends XmlForm
|
||||
$values["{$k}_label"] = $newValues["{$k}_label"] = $v->options[$newValues[$k]];
|
||||
} else {
|
||||
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
|
||||
if(trim($query) == '') {
|
||||
continue;
|
||||
}
|
||||
//we do the query to the external connection and we've got the label
|
||||
$con = Propel::getConnection($this->fields[$k]->sqlConnection!=""?$this->fields[$k]->sqlConnection:"workflow");
|
||||
$stmt = $con->prepareStatement($query);
|
||||
|
||||
@@ -37,6 +37,14 @@ class pmTables extends Controller
|
||||
|
||||
$this->setJSVar('_PLUGIN_SIMPLEREPORTS', $this->_getSimpleReportPluginDef());
|
||||
|
||||
if (isset($_SESSION['_cache_pmtables'])) {
|
||||
unset($_SESSION['_cache_pmtables']);
|
||||
}
|
||||
|
||||
if (isset($_SESSION['ADD_TAB_UID'])) {
|
||||
unset($_SESSION['ADD_TAB_UID']);
|
||||
}
|
||||
|
||||
//render content
|
||||
G::RenderPage('publish', 'extJs');
|
||||
}
|
||||
@@ -52,66 +60,21 @@ class pmTables extends Controller
|
||||
$table = false;
|
||||
$repTabPluginPermissions = false;
|
||||
$additionalTables = new AdditionalTables();
|
||||
$additionalTables = new AdditionalTables();
|
||||
|
||||
if ($addTabUid !== false) { // if is a edit request
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
require_once 'classes/model/Fields.php';
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
$tableFields = array();
|
||||
$fieldsList = array();
|
||||
|
||||
$table = $additionalTables->load($addTabUid, true);
|
||||
|
||||
// list the case fields
|
||||
foreach ($table['FIELDS'] as $i=>$field) {
|
||||
$table['FIELDS'][$i]['FLD_KEY'] = $field['FLD_KEY'] == '1' ? TRUE: FALSE;
|
||||
$table['FIELDS'][$i]['FLD_NULL'] = $field['FLD_NULL'] == '1' ? TRUE: FALSE;
|
||||
$table['FIELDS'][$i]['FLD_FILTER'] = $field['FLD_FILTER'] == '1' ? TRUE: FALSE;
|
||||
array_push($tableFields, $field['FLD_DYN_NAME']);
|
||||
}
|
||||
$_SESSION['ADD_TAB_UID'] = $addTabUid;
|
||||
|
||||
//list dynaform fields
|
||||
switch ($table['ADD_TAB_TYPE']) {
|
||||
case 'NORMAL':
|
||||
$fields = pmTablesProxy::_getDynafields($table['PRO_UID']);
|
||||
|
||||
foreach ($fields as $field) {
|
||||
//select to not assigned fields for available grid
|
||||
if (!in_array($field['name'], $tableFields)) {
|
||||
$fieldsList[] = array(
|
||||
'FIELD_UID' => $field['name'] . '-' . $field['type'],
|
||||
'FIELD_NAME' => $field['name']
|
||||
);
|
||||
}
|
||||
}
|
||||
sort($fieldsList);
|
||||
$this->setJSVar('avFieldsList', $fieldsList);
|
||||
$repTabPluginPermissions = $this->_getSimpleReportPluginDef();
|
||||
$this->setJSVar('_plugin_permissions', $repTabPluginPermissions);
|
||||
break;
|
||||
|
||||
case 'GRID':
|
||||
list($gridName, $gridId) = explode('-', $table['ADD_TAB_GRID']);
|
||||
// $G_FORM = new Form($table['PRO_UID'] . '/' . $gridId, PATH_DYNAFORM, SYS_LANG, false);
|
||||
// $gridFields = $G_FORM->getVars(false);
|
||||
$fieldsList = array();
|
||||
$gridFields = pmTablesProxy::_getGridDynafields($table['PRO_UID'], $gridId);
|
||||
foreach ($gridFields as $gfield) {
|
||||
if (!in_array($gfield['name'], $tableFields)) {
|
||||
$fieldsList[] = array(
|
||||
'FIELD_UID' => $gfield['name'] . '-' . $gfield['type'],
|
||||
'FIELD_NAME' => $gfield['name']
|
||||
);
|
||||
}
|
||||
}
|
||||
sort($fieldsList);
|
||||
$this->setJSVar('avFieldsList', $fieldsList);
|
||||
$repTabPluginPermissions = $this->_getSimpleReportPluginDef();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
protected $className;
|
||||
protected $classPeerName;
|
||||
protected $dynUid;
|
||||
|
||||
/**
|
||||
* get pmtables list
|
||||
@@ -109,49 +110,68 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
$aFields['FIELDS'] = array();
|
||||
$aFields['PRO_UID'] = $httpData->PRO_UID;
|
||||
$dynFields = array();
|
||||
|
||||
if(isset($httpData->TYPE) && $httpData->TYPE == 'GRID') {
|
||||
$aProcessGridFields = Array();
|
||||
if (isset($httpData->GRID_UID)) {
|
||||
global $G_FORM;
|
||||
list($gridName, $gridId) = explode('-', $httpData->GRID_UID);
|
||||
$this->dynUid = $gridId;
|
||||
|
||||
$gridFields = $this->_getGridDynafields($httpData->PRO_UID, $gridId);
|
||||
|
||||
foreach ($gridFields as $gfield) {
|
||||
$aProcessGridFields[] = array(
|
||||
'FIELD_UID' => $gfield['name'] . '-' . $gfield['type'],
|
||||
'FIELD_NAME' => $gfield['name']
|
||||
);
|
||||
$httpData->textFilter = isset($httpData->textFilter) ? $httpData->textFilter : null;
|
||||
$dynFields = $this->_getDynafields($aFields['PRO_UID'], 'grid', $httpData->start, $httpData->limit, $httpData->textFilter);
|
||||
}
|
||||
else {
|
||||
if (isset($_SESSION['_cache_pmtables'])) {
|
||||
unset($_SESSION['_cache_pmtables']);
|
||||
}
|
||||
} else {
|
||||
$gridFields = $this->_getGridFields($aFields['PRO_UID']);
|
||||
|
||||
foreach ($gridFields as $gfield) {
|
||||
$aProcessGridFields[] = array(
|
||||
$dynFields[] = array(
|
||||
'FIELD_UID' => $gfield['name'] . '-' . $gfield['xmlform'],
|
||||
'FIELD_NAME' => $gfield['name']
|
||||
);
|
||||
}
|
||||
}
|
||||
$resultList = $aProcessGridFields;
|
||||
|
||||
} else {
|
||||
$aProcessFields = Array();
|
||||
$dynFields = $this->_getDynafields($aFields['PRO_UID']);
|
||||
|
||||
foreach ($dynFields as $dfield) {
|
||||
$aProcessFields[] = array(
|
||||
'FIELD_UID' => $dfield['name'] . '-' . $dfield['type'],
|
||||
'FIELD_NAME' => $dfield['name']
|
||||
);
|
||||
}
|
||||
$resultList = $aProcessFields;
|
||||
}
|
||||
else {
|
||||
$httpData->textFilter = isset($httpData->textFilter) ? $httpData->textFilter : null;
|
||||
$dynFields = $this->_getDynafields($aFields['PRO_UID'], 'xmlform', $httpData->start, $httpData->limit, $httpData->textFilter);
|
||||
}
|
||||
|
||||
sort($resultList);
|
||||
return $dynFields;
|
||||
}
|
||||
|
||||
return array('processFields'=>$resultList);
|
||||
public function updateAvDynafields($httpData)
|
||||
{
|
||||
$indexes = explode(',', $httpData->indexes);
|
||||
$fields = array();
|
||||
$httpData->isset = $httpData->isset=='true'? true: false;
|
||||
|
||||
if (isset($_SESSION['_cache_pmtables']) && $_SESSION['_cache_pmtables']['pro_uid']== $httpData->PRO_UID) {
|
||||
foreach ($indexes as $i) {
|
||||
if (is_numeric($i)) {
|
||||
if (isset($_SESSION['_cache_pmtables']['rows'][$i])) {
|
||||
$_SESSION['_cache_pmtables']['rows'][$i]['_isset'] = $httpData->isset;
|
||||
if ($httpData->isset) {
|
||||
$_SESSION['_cache_pmtables']['count']++;
|
||||
} else {
|
||||
$_SESSION['_cache_pmtables']['count']--;
|
||||
}
|
||||
|
||||
$fields[] = $_SESSION['_cache_pmtables']['rows'][$i]['FIELD_NAME'];
|
||||
}
|
||||
} else {
|
||||
|
||||
$index = $_SESSION['_cache_pmtables']['indexes'][$i];
|
||||
$_SESSION['_cache_pmtables']['rows'][$index]['_isset'] = $httpData->isset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -813,7 +833,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
* @param $proUid
|
||||
* @param $type [values:xmlform/grid]
|
||||
*/
|
||||
function _getDynafields($proUid, $type = 'xmlform')
|
||||
function _getDynafields2($proUid, $type = 'xmlform')
|
||||
{
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
$fields = array();
|
||||
@@ -856,6 +876,122 @@ class pmTablesProxy extends HttpProxyController
|
||||
return $fields;
|
||||
}
|
||||
|
||||
function _getDynafields($proUid, $type = 'xmlform', $start=null, $limit=null, $filter=null)
|
||||
{
|
||||
$cache = 1;
|
||||
if (!isset($_SESSION['_cache_pmtables']) || (isset($_SESSION['_cache_pmtables']) && $_SESSION['_cache_pmtables']['pro_uid'] != $proUid)) {
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
$cache = 0;
|
||||
$fields = array();
|
||||
$fieldsNames = array();
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(DynaformPeer::DYN_FILENAME);
|
||||
$oCriteria->add(DynaformPeer::PRO_UID, $proUid);
|
||||
$oCriteria->add(DynaformPeer::DYN_TYPE, $type);
|
||||
|
||||
|
||||
if (isset($this->dynUid)) {
|
||||
$oCriteria->add(DynaformPeer::DYN_UID, $this->dynUid);
|
||||
}
|
||||
|
||||
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
$excludeFieldsList = array('title', 'subtitle', 'link', 'file', 'button', 'reset', 'submit',
|
||||
'listbox', 'checkgroup', 'grid', 'javascript');
|
||||
|
||||
$labelFieldsTypeList = array('dropdown', 'radiogroup');
|
||||
G::loadSystem('dynaformhandler');
|
||||
$index = 0;
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
if (file_exists(PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml')) {
|
||||
$dynaformHandler = new dynaformHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME']. '.xml');
|
||||
$nodeFieldsList = $dynaformHandler->getFields();
|
||||
|
||||
foreach($nodeFieldsList as $node) {
|
||||
$arrayNode = $dynaformHandler->getArray($node);
|
||||
$fieldName = $arrayNode['__nodeName__'];
|
||||
$fieldType = $arrayNode['type'];
|
||||
|
||||
if (!in_array($fieldType, $excludeFieldsList) && !in_array($fieldName, $fieldsNames)) {
|
||||
$fields[] = array(
|
||||
'FIELD_UID' => $fieldName . '-' . $fieldType,
|
||||
'FIELD_NAME' => $fieldName,
|
||||
'_index' => $index++,
|
||||
'_isset' => true
|
||||
);
|
||||
$fieldsNames[] = $fieldName;
|
||||
|
||||
if (in_array($fieldType, $labelFieldsTypeList) && !in_array($fieldName . '_label', $fieldsNames)) {
|
||||
$fields[] = array(
|
||||
'FIELD_UID' => $fieldName . '_label' . '-' . $fieldType,
|
||||
'FIELD_NAME' => $fieldName . '_label',
|
||||
'_index' => $index++,
|
||||
'_isset' => true
|
||||
);
|
||||
$fieldsNames[] = $fieldName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
sort($fields);
|
||||
|
||||
// if is a editing
|
||||
$fieldsEdit = array();
|
||||
if (isset($_SESSION['ADD_TAB_UID'])) {
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
|
||||
$additionalTables = new AdditionalTables();
|
||||
$table = $additionalTables->load($_SESSION['ADD_TAB_UID'], true);
|
||||
|
||||
foreach ($table['FIELDS'] as $i=>$field) {
|
||||
array_push($fieldsEdit, $field['FLD_DYN_NAME']);
|
||||
}
|
||||
}//end editing
|
||||
|
||||
foreach($fields as $i => $field) {
|
||||
$fields[$i]['_index'] = $i;
|
||||
$indexes[$field['FIELD_NAME']] = $i;
|
||||
|
||||
if(in_array($field['FIELD_NAME'], $fieldsEdit)) {
|
||||
$fields[$i]['_isset'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
$_SESSION['_cache_pmtables']['pro_uid'] = $proUid;
|
||||
$_SESSION['_cache_pmtables']['rows'] = $fields;
|
||||
$_SESSION['_cache_pmtables']['count'] = count($fields);
|
||||
$_SESSION['_cache_pmtables']['indexes'] = $indexes;
|
||||
} //end reload
|
||||
|
||||
$fields = array();
|
||||
$tmp = array();
|
||||
|
||||
foreach ($_SESSION['_cache_pmtables']['rows'] as $i => $row) {
|
||||
if (isset($filter) && $filter != '') {
|
||||
if ($row['_isset'] && stripos($row['FIELD_NAME'], $filter) !== false) {
|
||||
$tmp[] = $row;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($row['_isset']) {
|
||||
$tmp[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fields = array_slice($tmp, $start, $limit);
|
||||
|
||||
return array('cache'=>$cache, 'count'=>count($tmp), 'rows'=>$fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all dynaform grid fields from a process
|
||||
* @param $proUid
|
||||
@@ -895,27 +1031,38 @@ class pmTablesProxy extends HttpProxyController
|
||||
*/
|
||||
function _getGridFields($proUid)
|
||||
{
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
G::loadSystem('dynaformhandler');
|
||||
$aFields = array();
|
||||
$aFieldsNames = array();
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(DynaformPeer::DYN_FILENAME);
|
||||
$oCriteria->add(DynaformPeer::PRO_UID, $proUid);
|
||||
$oCriteria->add(DynaformPeer::DYN_TYPE, 'xmlform');
|
||||
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$G_FORM = new Form($aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG);
|
||||
if ($G_FORM->type == 'xmlform') {
|
||||
foreach($G_FORM->fields as $k => $v) {
|
||||
if ($v->type == 'grid') {
|
||||
if (!in_array($k, $aFieldsNames)) {
|
||||
$aFields[] = array('name' => $k, 'xmlform' => str_replace($proUid . '/', '', $v->xmlGrid));
|
||||
$aFieldsNames[] = $k;
|
||||
}
|
||||
//$G_FORM = new Form($aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG);
|
||||
$dynaformHandler = new dynaformHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME']. '.xml');
|
||||
$nodeFieldsList = $dynaformHandler->getFields();
|
||||
|
||||
foreach($nodeFieldsList as $node) {
|
||||
$arrayNode = $dynaformHandler->getArray($node);
|
||||
$fieldName = $arrayNode['__nodeName__'];
|
||||
$fieldType = $arrayNode['type'];
|
||||
|
||||
if ($fieldType == 'grid') {
|
||||
|
||||
if (!in_array($fieldName, $aFieldsNames)) {
|
||||
$aFields[] = array('name' => $fieldName, 'xmlform' => str_replace($proUid . '/', '', $arrayNode['xmlgrid']));
|
||||
$aFieldsNames[] = $fieldName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oDataset->next();
|
||||
}
|
||||
return $aFields;
|
||||
|
||||
@@ -2,6 +2,7 @@ var PROCESSMAP_STEP_EDIT = false;
|
||||
var PROCESSMAP_USER_EDIT = false;
|
||||
|
||||
var processmapOutputsPanel;
|
||||
var _client = getClientWindowSize();
|
||||
|
||||
var processmap=function(){
|
||||
this.data={
|
||||
@@ -23,8 +24,8 @@ var processmap=function(){
|
||||
Hx = 460;
|
||||
|
||||
if(lanzado=='reportTables'){
|
||||
Wx = 800;
|
||||
Hx = 600;
|
||||
Wx = _client.width-20; //900;
|
||||
Hx = _client.height-15; //600;
|
||||
}
|
||||
|
||||
var bbk = {
|
||||
@@ -163,8 +164,8 @@ var processmap=function(){
|
||||
iframe.setAttribute('id','reportTablesIframe');
|
||||
iframe.src = '../pmTables?PRO_UID=' + this.options.uid;
|
||||
iframe.style.border='0px';
|
||||
iframe.style.width='786px';
|
||||
iframe.style.height='564px';
|
||||
iframe.style.width=_client.width-36;//'886px';
|
||||
iframe.style.height=_client.height-60;//'564px';
|
||||
panel.addContent(iframe);
|
||||
}.extend(this),
|
||||
dynaforms:function(){
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user