BUG 0000 Report tables ver2 (improvements to pmtables data edit)

improvements and unification with PMTables
This commit is contained in:
Erik Amaru Ortiz
2011-07-11 18:06:32 -04:00
parent 645a465652
commit 7ca0a99a75
14 changed files with 453 additions and 286 deletions

View File

@@ -689,7 +689,7 @@ class AdditionalTables extends BaseAdditionalTables {
$aData['className'] = $sClassName; $aData['className'] = $sClassName;
$aData['connection'] = $connection; $aData['connection'] = $connection;
$aData['GUID'] = $sAddTabUid; $aData['GUID'] = $sAddTabUid;
$aData['firstColumn'] = strtoupper($aFields[1]['FLD_NAME']); $aData['firstColumn'] = strtoupper($aFields[0]['FLD_NAME']);
$aData['totalColumns'] = count($aFields); $aData['totalColumns'] = count($aFields);
$aData['useIdGenerator'] = 'false'; $aData['useIdGenerator'] = 'false';
$oTP1 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'Table.tpl'); $oTP1 = new TemplatePower(PATH_TPL . 'additionalTables' . PATH_SEP . 'Table.tpl');
@@ -1170,8 +1170,7 @@ var additionalTablesDataDelete = function(sUID, sKeys) {
$sClassPeerName = $sClassName . 'Peer'; $sClassPeerName = $sClassName . 'Peer';
$con = Propel::getConnection($aData['DBS_UID']); $con = Propel::getConnection($aData['DBS_UID']);
$oCriteria = new Criteria($aData['DBS_UID']); $oCriteria = new Criteria($aData['DBS_UID']);
var_dump($aData['DBS_UID']);
print_r($oCriteria);
//eval('$oCriteria->addSelectColumn(' . $sClassPeerName . '::PM_UNIQUE_ID);'); //eval('$oCriteria->addSelectColumn(' . $sClassPeerName . '::PM_UNIQUE_ID);');
eval('$oCriteria->addSelectColumn("\'1\' AS DUMMY");'); eval('$oCriteria->addSelectColumn("\'1\' AS DUMMY");');
foreach ($aData['FIELDS'] as $aField) { foreach ($aData['FIELDS'] as $aField) {
@@ -1221,7 +1220,8 @@ var additionalTablesDataDelete = function(sUID, sKeys) {
} }
$oCriteriaCount = clone $oCriteria; $oCriteriaCount = clone $oCriteria;
$count = $sClassPeerName::doCount($oCriteria); //$count = $sClassPeerName::doCount($oCriteria);
eval('$count = '.$sClassPeerName.'::doCount($oCriteria);');
if (isset($limit)) { if (isset($limit)) {
$oCriteria->setLimit($limit); $oCriteria->setLimit($limit);
@@ -1229,7 +1229,8 @@ var additionalTablesDataDelete = function(sUID, sKeys) {
if (isset($start)) { if (isset($start)) {
$oCriteria->setOffset($start); $oCriteria->setOffset($start);
} }
$rs = $sClassPeerName::doSelectRS($oCriteria); //$rs = $sClassPeerName::doSelectRS($oCriteria);
eval('$rs = '.$sClassPeerName.'::doSelectRS($oCriteria);');
$rs->setFetchmode (ResultSet::FETCHMODE_ASSOC); $rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
$rows = Array(); $rows = Array();

View File

@@ -1,9 +1,22 @@
<?php <?php
/**
* pmTables controller
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
* @inherits Controller
* @access public
*/
class pmTables extends Controller class pmTables extends Controller
{ {
public $debug = true; /**
* @param boolean debug
*/
public $debug = FALSE;
/**
* getting default list
* @param string $httpData->PRO_UID (opional)
*/
public function index($httpData) public function index($httpData)
{ {
global $RBAC; global $RBAC;
@@ -26,11 +39,18 @@ class pmTables extends Controller
G::RenderPage('publish', 'extJs'); G::RenderPage('publish', 'extJs');
} }
/**
* edit pmtable
* @param string $httpData->id
*/
public function edit($httpData) public function edit($httpData)
{ {
$addTabUid = isset($_GET['id']) ? $_GET['id'] : false; require_once PATH_CONTROLLERS . 'pmTablesProxy.php';
$addTabUid = isset($httpData->id) ? $httpData->id : false;
$table = false; $table = false;
$repTabPluginPermissions = false; $repTabPluginPermissions = false;
$additionalTables = new AdditionalTables();
$additionalTables = new AdditionalTables();
if ($addTabUid !== false) { // if is a edit request if ($addTabUid !== false) { // if is a edit request
require_once 'classes/model/AdditionalTables.php'; require_once 'classes/model/AdditionalTables.php';
@@ -38,7 +58,6 @@ class pmTables extends Controller
$tableFields = array(); $tableFields = array();
$fieldsList = array(); $fieldsList = array();
$additionalTables = new AdditionalTables();
$table = $additionalTables->load($addTabUid, true); $table = $additionalTables->load($addTabUid, true);
// list the case fields // list the case fields
@@ -52,7 +71,7 @@ class pmTables extends Controller
//list dynaform fields //list dynaform fields
switch ($table['ADD_TAB_TYPE']) { switch ($table['ADD_TAB_TYPE']) {
case 'NORMAL': case 'NORMAL':
$fields = $this->_getDynafields($table['PRO_UID']); $fields = pmTablesProxy::_getDynafields($table['PRO_UID']);
foreach ($fields as $field) { foreach ($fields as $field) {
//select to not assigned fields for available grid //select to not assigned fields for available grid
@@ -73,7 +92,7 @@ class pmTables extends Controller
// $G_FORM = new Form($table['PRO_UID'] . '/' . $gridId, PATH_DYNAFORM, SYS_LANG, false); // $G_FORM = new Form($table['PRO_UID'] . '/' . $gridId, PATH_DYNAFORM, SYS_LANG, false);
// $gridFields = $G_FORM->getVars(false); // $gridFields = $G_FORM->getVars(false);
$fieldsList = array(); $fieldsList = array();
$gridFields = $this->_getGridDynafields($table['PRO_UID'], $gridId); $gridFields = pmTablesProxy::_getGridDynafields($table['PRO_UID'], $gridId);
foreach ($gridFields as $gfield) { foreach ($gridFields as $gfield) {
if (!in_array($gfield['name'], $tableFields)) { if (!in_array($gfield['name'], $tableFields)) {
$fieldsList[] = array( $fieldsList[] = array(
@@ -105,6 +124,10 @@ class pmTables extends Controller
G::RenderPage('publish', 'extJs'); G::RenderPage('publish', 'extJs');
} }
/**
* show pmTable data list
* @param string $httpData->id
*/
function data($httpData) function data($httpData)
{ {
require_once 'classes/model/AdditionalTables.php'; require_once 'classes/model/AdditionalTables.php';
@@ -119,7 +142,12 @@ class pmTables extends Controller
/** /**
* protected functions * - protected functions (non-callable from controller outside) -
*/
/**
* Get simple report plugin definition
* @param $type
*/ */
protected function _getSimpleReportPluginDef() protected function _getSimpleReportPluginDef()
{ {
@@ -140,104 +168,5 @@ class pmTables extends Controller
return $repTabPluginPermissions; return $repTabPluginPermissions;
} }
protected function _getDynafields($proUid, $type = 'xmlform')
{
require_once 'classes/model/Dynaform.php';
$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);
$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', 'checkbox', 'radiogroup', 'yesno');
while ($aRow = $oDataset->getRow()) {
if (file_exists(PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml')) {
$G_FORM = new Form($aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG);
if ($G_FORM->type == 'xmlform' || $G_FORM->type == '') {
foreach($G_FORM->fields as $fieldName => $fieldNode) {
if (!in_array($fieldNode->type, $excludeFieldsList) && !in_array($fieldName, $fieldsNames)) {
$fields[] = array('name' => $fieldName, 'type' => $fieldNode->type, 'label'=> $fieldNode->label);
$fieldsNames[] = $fieldName;
if (in_array($fieldNode->type, $labelFieldsTypeList) && !in_array($fieldName.'_label', $fieldsNames)) {
$fields[] = array('name' => $fieldName . '_label', 'type' => $fieldNode->type, 'label'=>$fieldNode->label . '_label');
$fieldsNames[] = $fieldName;
}
}
}
}
}
$oDataset->next();
}
return $fields;
}
protected function _getGridDynafields($proUid, $gridId)
{
$fields = array();
$fieldsNames = array();
$excludeFieldsList = array('title', 'subtitle', 'link', 'file', 'button', 'reset', 'submit',
'listbox', 'checkgroup', 'grid', 'javascript');
$labelFieldsTypeList = array('dropdown', 'checkbox', 'radiogroup', 'yesno');
$G_FORM = new Form($proUid . '/' . $gridId, PATH_DYNAFORM, SYS_LANG, false);
if ($G_FORM->type == 'grid') {
foreach($G_FORM->fields as $fieldName => $fieldNode) {
if (!in_array($fieldNode->type, $excludeFieldsList) && !in_array($fieldName, $fieldsNames)) {
$fields[] = array('name' => $fieldName, 'type' => $fieldNode->type, 'label'=> $fieldNode->label);
$fieldsNames[] = $fieldName;
if (in_array($fieldNode->type, $labelFieldsTypeList) && !in_array($fieldName.'_label', $fieldsNames)) {
$fields[] = array('name' => $fieldName . '_label', 'type' => $fieldNode->type, 'label'=>$fieldNode->label . '_label');
$fieldsNames[] = $fieldName;
}
}
}
}
return $fields;
}
protected function _getGridFields($proUid)
{
$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);
$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;
}
}
}
}
$oDataset->next();
}
return $aFields;
}
} }

View File

@@ -1,31 +1,72 @@
<?php <?php
require_once 'classes/model/AdditionalTables.php'; /**
* pmTablesProxy
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
* @inherits HttpProxyController
* @access public
*/
//G::LoadClass('processMap'); require_once 'classes/model/AdditionalTables.php';
class pmTablesProxy extends HttpProxyController class pmTablesProxy extends HttpProxyController
{ {
public function getList($params)
/**
* get pmtables list
* @param string $httpData->start
* @param string $httpData->limit
* @param string $httpData->textFilter
*/
public function getList($httpData)
{ {
G::LoadClass('configuration'); G::LoadClass('configuration');
G::LoadClass('processMap');
$configurations = new Configurations(); $configurations = new Configurations();
$processMap = new processMap();
// setting parameters // setting parameters
$config = $configurations->getConfiguration('additionalTablesList', 'pageSize','',$_SESSION['USER_LOGGED']); $config = $configurations->getConfiguration('additionalTablesList', 'pageSize','',$_SESSION['USER_LOGGED']);
$env = $configurations->getConfiguration('ENVIRONMENT_SETTINGS', ''); $env = $configurations->getConfiguration('ENVIRONMENT_SETTINGS', '');
$limit_size = isset($config->pageSize) ? $config['pageSize'] : 20; $limit_size = isset($config->pageSize) ? $config['pageSize'] : 20;
$start = isset($params->start) ? $params->start : 0; $start = isset($httpData->start) ? $httpData->start : 0;
$limit = isset($params->limit) ? $params->limit : $limit_size; $limit = isset($httpData->limit) ? $httpData->limit : $limit_size;
$filter = isset($params->textFilter) ? $params->textFilter : ''; $filter = isset($httpData->textFilter) ? $httpData->textFilter : '';
$pro_uid = isset($params->pro_uid) ? $params->pro_uid : null; $pro_uid = isset($httpData->pro_uid) ? $httpData->pro_uid : null;
//$process = $pro_uid == '' ? array('not_equal'=>$pro_uid) : array('equal'=>$pro_uid); if ($pro_uid !== null) {
$process = null; $process = $pro_uid == '' ? array('not_equal'=>$pro_uid) : array('equal'=>$pro_uid);
$addTables = AdditionalTables::getAll($start, $limit, $filter, $process); $addTables = AdditionalTables::getAll($start, $limit, $filter, $process);
$c = $processMap->getReportTablesCriteria($pro_uid);
$oDataset = RoutePeer::doSelectRS($c);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$reportTablesOldList = array();
while($oDataset->next()) {
$reportTablesOldList[] = $oDataset->getRow();
}
$addTables['count'] += count($reportTablesOldList);
foreach ($reportTablesOldList as $i => $oldRepTab) {
$addTables['rows'][] = array(
'ADD_TAB_UID' => $oldRepTab['REP_TAB_UID'],
'PRO_UID' => $oldRepTab['PRO_UID'],
'ADD_TAB_DESCRIPTION' => $oldRepTab['REP_TAB_TITLE'],
'ADD_TAB_NAME' => $oldRepTab['REP_TAB_NAME'],
'ADD_TAB_TYPE' => $oldRepTab['REP_TAB_TYPE'],
'TYPE' => 'CLASSIC'
);
}
}
else {
$addTables = AdditionalTables::getAll($start, $limit, $filter);
}
return $addTables; return $addTables;
} }
/**
* get processesList
*/
public function getProcessList() public function getProcessList()
{ {
require_once 'classes/model/Process.php'; require_once 'classes/model/Process.php';
@@ -34,6 +75,9 @@ class pmTablesProxy extends HttpProxyController
return $process->getAll(); return $process->getAll();
} }
/**
* get database connection list
*/
public function getDbConnectionsList() public function getDbConnectionsList()
{ {
G::LoadClass ( 'dbConnections'); G::LoadClass ( 'dbConnections');
@@ -50,23 +94,26 @@ class pmTablesProxy extends HttpProxyController
return $dbConnections; return $dbConnections;
} }
public function availableFieldsReportTables($params) /**
* get dynaform fields
* @param string $httpData->PRO_UID
* @param string $httpData->TYPE
* @param string $httpData->GRID_UID
*/
public function getDynafields($httpData)
{ {
G::LoadClass('reportTables'); G::LoadClass('reportTables');
//G::LoadClass('xmlfield_InputPM');
$aFields['FIELDS'] = array(); $aFields['FIELDS'] = array();
$aFields['PRO_UID'] = $_POST['PRO_UID']; $aFields['PRO_UID'] = $httpData->PRO_UID;
if(isset($_POST['TYPE']) && $_POST['TYPE'] == 'GRID') { if(isset($httpData->TYPE) && $httpData->TYPE == 'GRID') {
$aProcessGridFields = Array(); $aProcessGridFields = Array();
if (isset($_POST['GRID_UID'])) { if (isset($httpData->GRID_UID)) {
global $G_FORM; global $G_FORM;
list($gridName, $gridId) = explode('-', $_POST['GRID_UID']); list($gridName, $gridId) = explode('-', $httpData->GRID_UID);
// $G_FORM = new Form($_POST['PRO_UID'] . '/' . $gridId, PATH_DYNAFORM, SYS_LANG, false); $gridFields = $this->_getGridDynafields($httpData->PRO_UID, $gridId);
//$gridFields = $G_FORM->getVars(false);
$gridFields = getGridDynafields($_POST['PRO_UID'], $gridId);
foreach ($gridFields as $gfield) { foreach ($gridFields as $gfield) {
$aProcessGridFields[] = array( $aProcessGridFields[] = array(
@@ -75,7 +122,7 @@ class pmTablesProxy extends HttpProxyController
); );
} }
} else { } else {
$gridFields = getGridFields($aFields['PRO_UID']); $gridFields = $this->_getGridFields($aFields['PRO_UID']);
foreach ($gridFields as $gfield) { foreach ($gridFields as $gfield) {
$aProcessGridFields[] = array( $aProcessGridFields[] = array(
@@ -88,8 +135,7 @@ class pmTablesProxy extends HttpProxyController
} else { } else {
$aProcessFields = Array(); $aProcessFields = Array();
//$dynFields = getDynaformsVars($aFields['PRO_UID'], false); $dynFields = $this->_getDynafields($aFields['PRO_UID']);
$dynFields = getDynafields($aFields['PRO_UID']);
foreach ($dynFields as $dfield) { foreach ($dynFields as $dfield) {
$aProcessFields[] = array( $aProcessFields[] = array(
@@ -103,6 +149,9 @@ class pmTablesProxy extends HttpProxyController
return $resultList; return $resultList;
} }
/**
* save pm table
*/
public function save() public function save()
{ {
require_once 'classes/model/AdditionalTables.php'; require_once 'classes/model/AdditionalTables.php';
@@ -253,10 +302,14 @@ class pmTablesProxy extends HttpProxyController
return $result; return $result;
} }
/**
* delete pm table
* @param string $httpData->rows
*/
public function delete($httpData) public function delete($httpData)
{ {
G::LoadClass('reportTables'); G::LoadClass('reportTables');
$rows = G::json_decode($_REQUEST['rows']); $rows = G::json_decode($httpData->rows);
$rp = new reportTables(); $rp = new reportTables();
$at = new AdditionalTables(); $at = new AdditionalTables();
@@ -277,7 +330,13 @@ class pmTablesProxy extends HttpProxyController
return $result; return $result;
} }
public function getData($httpData) /**
* get pm tables data
* @param string $httpData->id
* @param string $httpData->start
* @param string $httpData->limit
*/
public function dataView($httpData)
{ {
require_once 'classes/model/AdditionalTables.php'; require_once 'classes/model/AdditionalTables.php';
@@ -285,17 +344,100 @@ class pmTablesProxy extends HttpProxyController
$co = new Configurations(); $co = new Configurations();
$config = $co->getConfiguration('additionalTablesData', 'pageSize','',$_SESSION['USER_LOGGED']); $config = $co->getConfiguration('additionalTablesData', 'pageSize','',$_SESSION['USER_LOGGED']);
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20; $limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0; $start = isset($httpData->start) ? $httpData->start : 0;
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size; $limit = isset($httpData->limit) ? $httpData->limit : $limit_size;
$oAdditionalTables = new AdditionalTables(); $oAdditionalTables = new AdditionalTables();
$table = $oAdditionalTables->load($httpData->id, true);
$result = $oAdditionalTables->getAllData($httpData->id, $start, $limit); $result = $oAdditionalTables->getAllData($httpData->id, $start, $limit);
$keys = array();
foreach ($table['FIELDS'] as $field) {
if ($field['FLD_KEY'] == '1') {
$keys[] = $field['FLD_NAME'];
}
}
foreach ($result['rows'] as $i => $row) {
$indexes = array();
foreach ($keys as $key) {
$indexes[] = $row[$key];
}
$result['rows'][$i]['__index__'] = implode('-', $indexes);
}
return $result; return $result;
} }
/**
* create pm tables record
* @param string $httpData->id
* @param string $httpData->start
* @param string $httpData->limit
*/
public function dataCreate($httpData)
{
require_once 'classes/model/AdditionalTables.php';
$oAdditionalTables = new AdditionalTables();
$table = $oAdditionalTables->load($httpData->id, true);
$className = $table['ADD_TAB_CLASS_NAME'];
$sClassPeerName = $className . 'Peer';
// protected functions $rows = G::json_decode($httpData->rows);
if (is_array($rows)) {
}
else { //then is object
}
print_R($row);
//$sClassPeerName::retrieveByPk();
}
/**
* update pm tables record
* @param string $httpData->id
* @param string $httpData->start
* @param string $httpData->limit
*/
public function dataUpdate($httpData)
{
require_once 'classes/model/AdditionalTables.php';
$oAdditionalTables = new AdditionalTables();
$table = $oAdditionalTables->load($httpData->id, true);
$className = $table['ADD_TAB_CLASS_NAME'];
$slassPeerName = $className . 'Peer';
$rows = G::json_decode($httpData->rows);
print_R($rows);
if (is_array($rows)) {
}
else { //then is object
$keys = explode('-', $rows->__index__);
foreach ($keys as $key) {
$params .= is_numeric($key) ? $key : "'$key'";
}
$obj = null;
var_dump('$obj = $classPeerName::retrieveByPk('.implode(',', $params).')');
eval('$obj = $classPeerName::retrieveByPk('.implode(',', $params).')');
var_dump($obj);
}
//$sClassPeerName::retrieveByPk();
}
/**
* - protected functions (non callable from controller outside) -
*/
/**
* Get report table default columns
* @param $type
*/
protected function _getReportTableDefaultColumns($type='NORMAL') protected function _getReportTableDefaultColumns($type='NORMAL')
{ {
$defaultColumns = array(); $defaultColumns = array();
@@ -346,27 +488,13 @@ class pmTablesProxy extends HttpProxyController
return $defaultColumns; return $defaultColumns;
} }
}
///
/** /**
* Translates a string with underscores into camel case (e.g. first_name -> firstName) * Get all dynaform fields from a process (without grid fields)
* @param string $str String in underscore format * @param $proUid
* @param bool $capitalise_first_char If true, capitalise the first char in $str * @param $type [values:xmlform/grid]
* @return string $str translated into camel caps
*/ */
function to_camel_case($str, $capitalise_first_char = true) { function _getDynafields($proUid, $type = 'xmlform')
if($capitalise_first_char) {
$str[0] = strtoupper($str[0]);
}
$func = create_function('$c', 'return strtoupper($c[1]);');
return preg_replace_callback('/_([a-z])/', $func, $str);
}
function getDynafields($proUid, $type = 'xmlform')
{ {
require_once 'classes/model/Dynaform.php'; require_once 'classes/model/Dynaform.php';
$fields = array(); $fields = array();
@@ -409,7 +537,12 @@ class pmTablesProxy extends HttpProxyController
return $fields; return $fields;
} }
function getGridDynafields($proUid, $gridId) /**
* Get all dynaform grid fields from a process
* @param $proUid
* @param $gridId
*/
function _getGridDynafields($proUid, $gridId)
{ {
$fields = array(); $fields = array();
$fieldsNames = array(); $fieldsNames = array();
@@ -437,7 +570,11 @@ class pmTablesProxy extends HttpProxyController
return $fields; return $fields;
} }
function getGridFields($proUid) /**
* Get all dynaform fields inside all grids from a process
* @param $proUid
*/
function _getGridFields($proUid)
{ {
$aFields = array(); $aFields = array();
$aFieldsNames = array(); $aFieldsNames = array();
@@ -464,49 +601,6 @@ class pmTablesProxy extends HttpProxyController
} }
return $aFields; return $aFields;
} }
function getAllFields($filepath, $includeTypes=array(), $excludeTypes=array())
{
$G_FORM = new Form($filepath, PATH_DYNAFORM, SYS_LANG);
$fields = array();
$fieldsNames = array();
$labelFieldsTypeList = array('dropdown', 'checkbox', 'radiogroup', 'yesno');
if ($G_FORM->type == 'xmlform' || $G_FORM->type == '') {
foreach($G_FORM->fields as $fieldName => $fieldNode) {
if (!in_array($fieldNode->type, $excludeTypes)) {
continue;
}
if (count($includeTypes) > 0) {
if (in_array($fieldNode->type, $includeTypes) && !in_array($fieldName, $fieldsNames)) {
$fields[] = array('name' => $fieldName, 'type' => $fieldNode->type, 'label'=> $fieldNode->label);
$fieldsNames[] = $fieldName;
if (in_array($fieldNode->type, $labelFieldsTypeList) && !in_array($fieldName.'_label', $fieldsNames)) {
$fields[] = array('name' => $fieldName . '_label', 'type' => $fieldNode->type, 'label'=>$fieldNode->label . '_label');
$fieldsNames[] = $fieldName;
}
}
continue;
}
if (!in_array($fieldName, $fieldsNames)) {
$fields[] = array('name' => $fieldName, 'type' => $fieldNode->type, 'label'=> $fieldNode->label);
$fieldsNames[] = $fieldName;
if (in_array($fieldNode->type, $labelFieldsTypeList) && !in_array($fieldName.'_label', $fieldsNames)) {
$fields[] = array('name' => $fieldName . '_label', 'type' => $fieldNode->type, 'label'=>$fieldNode->label . '_label');
$fieldsNames[] = $fieldName;
}
}
}
}
return $fields;
} }

View File

@@ -1,3 +1,7 @@
/**
* Handle PMtables Data
* @author Erik A. O. <erik@colosa.com>
*/
var newButton; var newButton;
var editButton; var editButton;
@@ -43,7 +47,7 @@ Ext.onReady(function(){
backButton = new Ext.Action({ backButton = new Ext.Action({
text: _('ID_BACK'), text: _('ID_BACK'),
iconCls: 'button_menu_ext ss_sprite ss_arrow_redo', icon: '/images/back-icon.png',
handler: BackPMList handler: BackPMList
}); });
@@ -54,6 +58,15 @@ Ext.onReady(function(){
//This loop loads columns and fields to store and column model //This loop loads columns and fields to store and column model
_columns = new Array(); _columns = new Array();
_fields = new Array(); _fields = new Array();
_idProperty = '__index__';
//default generated id
_columns.push({
id: _idProperty,
hidden: true
});
_fields.push({name: _idProperty});
if (tableDef.FIELDS.length !== 0) { if (tableDef.FIELDS.length !== 0) {
for (i in tableDef.FIELDS) { for (i in tableDef.FIELDS) {
@@ -61,10 +74,18 @@ Ext.onReady(function(){
id: tableDef.FIELDS[i].FLD_NAME, id: tableDef.FIELDS[i].FLD_NAME,
header: tableDef.FIELDS[i].FLD_DESCRIPTION, header: tableDef.FIELDS[i].FLD_DESCRIPTION,
dataIndex: tableDef.FIELDS[i].FLD_NAME, dataIndex: tableDef.FIELDS[i].FLD_NAME,
width: 40 width: 40,
editor:{
xtype: 'textfield',
allowBlank: true
}
}); });
_fields.push({name: tableDef.FIELDS[i].FLD_NAME}); _fields.push({name: tableDef.FIELDS[i].FLD_NAME});
if(_idProperty == '' && tableDef.FIELDS[i].FLD_KEY) {
_idProperty = tableDef.FIELDS[i].FLD_NAME;
}
} }
} }
@@ -90,17 +111,49 @@ Ext.onReady(function(){
// } // }
// }); // });
store = new Ext.data.GroupingStore({ //row editor for table columns grid
proxy : new Ext.data.HttpProxy({ editor = new Ext.ux.grid.RowEditor({
url: '../pmTablesProxy/getData?id=' + tableDef.ADD_TAB_UID saveText: _("ID_UPDATE")
}),
reader : new Ext.data.JsonReader({
root: 'rows',
totalProperty: 'count',
fields : _fields
})
}); });
var proxy = new Ext.data.HttpProxy({
//url: '../pmTablesProxy/getData?id=' + tableDef.ADD_TAB_UID
api: {
read : '../pmTablesProxy/dataView?id=' + tableDef.ADD_TAB_UID,
create : '../pmTablesProxy/dataCreate?id=' + tableDef.ADD_TAB_UID,
update : '../pmTablesProxy/dataUpdate?id=' + tableDef.ADD_TAB_UID,
destroy: '../pmTablesProxy/dataDestroy?id=' + tableDef.ADD_TAB_UID
},
baseParams : {id: tableDef.ADD_TAB_UID},
})
// The new DataWriter component.
var writer = new Ext.data.JsonWriter({
encode: true,
writeAllFields: false
});
var reader = new Ext.data.JsonReader({
root : 'rows',
idProperty : 'id',
fields : _fields,
idProperty : _idProperty,
totalProperty: 'count'
})
store = new Ext.data.GroupingStore({
proxy : proxy,
reader : reader,
writer : writer, // <-- plug a DataWriter into the store just as you would a Reader
autoSave: true // <-- false would delay executing create, update, destroy requests until specifically told to do so with some [save] buton.
});
// load the store immeditately
//store.load();
//store.on('update', store._update, store);
cmodel = new Ext.grid.ColumnModel({ cmodel = new Ext.grid.ColumnModel({
defaults: { defaults: {
width: 50, width: 50,
@@ -163,11 +216,12 @@ Ext.onReady(function(){
}, },
store: store, store: store,
cm: cmodel, cm: cmodel,
plugins: [editor],
//sm: smodel, //sm: smodel,
tbar:[newButton,'-',editButton, deleteButton,'-',importButton,{xtype: 'tbfill' }, backButton], tbar:[newButton,'-',editButton, deleteButton,'-',importButton,{xtype: 'tbfill' }, backButton],
bbar: bbarpaging, bbar: bbarpaging,
listeners: { listeners: {
rowdblclick: EditPMTableRow, //rowdblclick: EditPMTableRow,
render: function(){ render: function(){
this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')}); this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')});
} }
@@ -261,7 +315,8 @@ ImportPMTableCSV = function(){
//Load PM Table List //Load PM Table List
BackPMList = function(){ BackPMList = function(){
location.href = 'additionalTablesList'; //location.href = 'additionalTablesList';
history.back();
}; };
//Gets UIDs from a array of rows //Gets UIDs from a array of rows

View File

@@ -1,5 +1,5 @@
/** /**
* Report tables Edit * PM tables Edit
* @author Erik A. O. <erik@colosa.com> * @author Erik A. O. <erik@colosa.com>
*/ */
@@ -25,7 +25,7 @@ Ext.onReady(function(){
// store for available fields grid // store for available fields grid
storeA = new Ext.data.GroupingStore( { storeA = new Ext.data.GroupingStore( {
proxy : new Ext.data.HttpProxy({ proxy : new Ext.data.HttpProxy({
url: '../pmTablesProxy/availableFieldsReportTables' url: '../pmTablesProxy/getDynafields'
}), }),
reader : new Ext.data.JsonReader( { reader : new Ext.data.JsonReader( {
root: 'processFields', root: 'processFields',
@@ -100,8 +100,20 @@ Ext.onReady(function(){
listeners:{ listeners:{
selectionchange: function(sm){ selectionchange: function(sm){
switch(sm.getCount()){ switch(sm.getCount()){
case 0: Ext.getCmp('removeButton').disable(); break; case 0:
default: Ext.getCmp('removeButton').enable(); break; //Ext.getCmp('removeButton').disable();
Ext.getCmp('editColumn').disable();
Ext.getCmp('removeColumn').disable();
break;
case 1:
Ext.getCmp('editColumn').enable();
Ext.getCmp('removeColumn').enable();
break;
default:
//Ext.getCmp('removeButton').enable();
Ext.getCmp('editColumn').disable();
Ext.getCmp('removeColumn').enable();
break;
} }
} }
} }
@@ -290,9 +302,21 @@ Ext.onReady(function(){
plugins: [editor, checkColumn], plugins: [editor, checkColumn],
tbar: [ tbar: [
{ {
icon: '/images/addcolumn.jpg', icon: '/images/add-row-after.png',
text: _("ID_ADD_COLUMN"), text: _("ID_ADD_FIELD"),
handler: addColumn handler: addColumn
}, {
id: 'editColumn',
icon: '/images/edit-row.png',
text: _("ID_EDIT_FIELD"),
disabled: true,
handler: editColumn
}, {
id: 'removeColumn',
icon: '/images/delete-row.png',
text: _("ID_REMOVE_FIELD"),
disabled: true,
handler: removeColumn
} }
], ],
listeners: { listeners: {
@@ -524,7 +548,7 @@ Ext.onReady(function(){
region : 'north', region : 'north',
labelWidth : 120, labelWidth : 120,
labelAlign :'right', labelAlign :'right',
title : 'New Report Table', title : 'New PM Table',
bodyStyle :'padding:10px', bodyStyle :'padding:10px',
frame : true, frame : true,
height : 120, height : 120,
@@ -541,16 +565,18 @@ Ext.onReady(function(){
southPanel = new Ext.FormPanel({ southPanel = new Ext.FormPanel({
region: 'south', region: 'south',
buttons:[ { buttons:[
{
text: TABLE === false ? _("ID_CREATE") : _("ID_UPDATE"), text: TABLE === false ? _("ID_CREATE") : _("ID_UPDATE"),
handler: createReportTable handler: createReportTable
}, { }, {
text:_("ID_CANCEL"), text:_("ID_CANCEL"),
handler: function() { handler: function() {
proParam = PRO_UID !== false ? '?PRO_UID='+PRO_UID : ''; proParam = PRO_UID !== false ? '?PRO_UID='+PRO_UID : '';
//location.href = '../pmTables' + proParam; //history.back(); location.href = '../pmTables' + proParam; //history.back();
} }
}] }
]
}); });
var viewport = new Ext.Viewport({ var viewport = new Ext.Viewport({
@@ -608,8 +634,13 @@ function createReportTable()
return false; return false;
} }
if (row.data['field_type'] == '') {
PMExt.error(_('ID_ERROR'), 'Set a field type for <b>'+row.data['field_name']+'</b> please.');
return false;
}
// validate field size for varchar & int column types // validate field size for varchar & int column types
if(row.data['field_type'] == 'VARCHAR' || row.data['field_type'] == 'INT') { if ((row.data['field_type'] == 'VARCHAR' || row.data['field_type'] == 'INT') && row.data['field_size'] == '') {
PMExt.error(_('ID_ERROR'), 'Set a field size for '+row.data['field_name']+' ('+row.data['field_type']+') please.'); PMExt.error(_('ID_ERROR'), 'Set a field size for '+row.data['field_name']+' ('+row.data['field_type']+') please.');
return false; return false;
} }
@@ -678,6 +709,24 @@ function addColumn() {
editor.startEditing(length); editor.startEditing(length);
} }
function editColumn()
{
var row = Ext.getCmp('assignedGrid').getSelectionModel().getSelected();
var selIndex = store.indexOfId(row.id);
editor.stopEditing();
assignedGrid.getView().refresh();
assignedGrid.getSelectionModel().selectRow(selIndex);
editor.startEditing(selIndex);
}
function removeColumn()
{
PMExt.confirm(_('ID_CONFIRM'), _('ID_CONFIRM_REMOVE_FIELD'), function(){
var records = Ext.getCmp('assignedGrid').getSelectionModel().getSelections();
Ext.each(records, Ext.getCmp('assignedGrid').store.remove, Ext.getCmp('assignedGrid').store);
});
}
////ASSIGNBUTON FUNCTIONALITY ////ASSIGNBUTON FUNCTIONALITY
AssignFieldsAction = function(){ AssignFieldsAction = function(){

View File

@@ -25,7 +25,7 @@ Ext.onReady(function(){
// store for available fields grid // store for available fields grid
storeA = new Ext.data.GroupingStore( { storeA = new Ext.data.GroupingStore( {
proxy : new Ext.data.HttpProxy({ proxy : new Ext.data.HttpProxy({
url: '../pmTablesProxy/availableFieldsReportTables' url: '../pmTablesProxy/getDynafields'
}), }),
reader : new Ext.data.JsonReader( { reader : new Ext.data.JsonReader( {
root: 'processFields', root: 'processFields',
@@ -100,8 +100,21 @@ Ext.onReady(function(){
listeners:{ listeners:{
selectionchange: function(sm){ selectionchange: function(sm){
switch(sm.getCount()){ switch(sm.getCount()){
case 0: Ext.getCmp('removeButton').disable(); break; case 0:
default: Ext.getCmp('removeButton').enable(); break; Ext.getCmp('removeButton').disable();
Ext.getCmp('removeColumn').disable();
break;
case 1:
var record = Ext.getCmp('assignedGrid').getSelectionModel().getSelected();
if (record.data.field_dyn == '' && record.data.field_name != 'APP_UID' && record.data.field_name != 'APP_NUMBER' && record.data.field_name != 'ROW') {
Ext.getCmp('removeColumn').enable();
}
break;
default:
Ext.getCmp('removeButton').enable();
Ext.getCmp('removeColumn').disable();
break;
} }
} }
} }
@@ -273,11 +286,19 @@ Ext.onReady(function(){
sm : sm, sm : sm,
store : store, store : store,
plugins : [editor, checkColumn], plugins : [editor, checkColumn],
tbar : [{ tbar : [
icon: '/images/addcolumn.jpg', {
text: _("ID_ADD_CUSTOM_COLUMN"), icon: '/images/add-row-after.png',
text: _("ID_ADD_FIELD"),
handler: addColumn handler: addColumn
}], }, {
id: 'removeColumn',
icon: '/images/delete-row.png',
text: _("ID_REMOVE_FIELD"),
disabled: true,
handler: removeColumn
}
],
listeners: { listeners: {
render: function(grid) { render: function(grid) {
var ddrow = new Ext.dd.DropTarget(grid.getView().mainBody, { var ddrow = new Ext.dd.DropTarget(grid.getView().mainBody, {
@@ -780,7 +801,7 @@ function createReportTable()
} }
// validate field size for varchar & int column types // validate field size for varchar & int column types
if(row.data['field_type'] == 'VARCHAR' || row.data['field_type'] == 'INT') { if ((row.data['field_type'] == 'VARCHAR' || row.data['field_type'] == 'INT') && row.data['field_size'] == '') {
PMExt.error(_('ID_ERROR'), 'Set a field size for '+row.data['field_name']+' ('+row.data['field_type']+') please.'); PMExt.error(_('ID_ERROR'), 'Set a field size for '+row.data['field_name']+' ('+row.data['field_type']+') please.');
return false; return false;
} }
@@ -792,11 +813,6 @@ function createReportTable()
columns.push(row.data); columns.push(row.data);
} }
if (!hasSomePrimaryKey) {
PMExt.error(_('ID_ERROR'), 'You need set one column at least as Primary Key.');
return;
}
Ext.Ajax.request({ Ext.Ajax.request({
url: '../pmTablesProxy/save', url: '../pmTablesProxy/save',
params: { params: {
@@ -850,6 +866,14 @@ function addColumn()
editor.startEditing(length); editor.startEditing(length);
} }
function removeColumn()
{
PMExt.confirm(_('ID_CONFIRM'), _('ID_CONFIRM_REMOVE_FIELD'), function(){
var records = Ext.getCmp('assignedGrid').getSelectionModel().getSelections();
Ext.each(records, Ext.getCmp('assignedGrid').store.remove, Ext.getCmp('assignedGrid').store);
});
}
////ASSIGNBUTON FUNCTIONALITY ////ASSIGNBUTON FUNCTIONALITY
AssignFieldsAction = function(){ AssignFieldsAction = function(){
records = Ext.getCmp('availableGrid').getSelectionModel().getSelections(); records = Ext.getCmp('availableGrid').getSelectionModel().getSelections();
@@ -955,7 +979,7 @@ loadFieldNormal = function(){
Ext.getCmp('availableGrid').store.removeAll(); Ext.getCmp('availableGrid').store.removeAll();
Ext.getCmp('availableGrid').store.load({ Ext.getCmp('availableGrid').store.load({
params: { params: {
action: "availableFieldsReportTables", action: "getDynafields",
PRO_UID: PRO_UID !== false ? PRO_UID : Ext.getCmp('PROCESS').getValue() PRO_UID: PRO_UID !== false ? PRO_UID : Ext.getCmp('PROCESS').getValue()
} }
}); });
@@ -968,7 +992,7 @@ loadFieldsGrids = function(){
available.store.load({ available.store.load({
params: { params: {
action: "availableFieldsReportTables", action: "getDynafields",
PRO_UID: PRO_UID !== false ? PRO_UID : Ext.getCmp('PROCESS').getValue(), PRO_UID: PRO_UID !== false ? PRO_UID : Ext.getCmp('PROCESS').getValue(),
TYPE: 'GRID', TYPE: 'GRID',
GRID_UID: Ext.getCmp('REP_TAB_GRID').getValue() GRID_UID: Ext.getCmp('REP_TAB_GRID').getValue()

View File

@@ -36,11 +36,7 @@ Ext.onReady(function(){
pageSize = parseInt(CONFIG.pageSize); pageSize = parseInt(CONFIG.pageSize);
newButton = new Ext.Action({ var newMenuOptions = [
text: _('ID_NEW'),
iconCls: 'button_menu_ext ss_sprite ss_add',
menu: [
{ {
text: 'New Table', text: 'New Table',
handler: newPMTable handler: newPMTable
@@ -48,19 +44,32 @@ Ext.onReady(function(){
text: 'New Report Table', text: 'New Report Table',
handler: NewReportTable handler: NewReportTable
} }
] ];
if (PRO_UID !== false) {
newMenuOptions.push({
text: 'New Report Table (Old Version)',
handler: NewReportTableOld
});
}
newButton = new Ext.Action({
text: _('ID_NEW'),
icon: '/images/add-table.png',
menu: newMenuOptions
}); });
editButton = new Ext.Action({ editButton = new Ext.Action({
text: _('ID_EDIT'), text: _('ID_EDIT'),
icon: '/images/icon-edit.png', icon: '/images/edit-table.png',
handler: EditPMTable, handler: EditPMTable,
disabled: true disabled: true
}); });
deleteButton = new Ext.Action({ deleteButton = new Ext.Action({
text: _('ID_DELETE'), text: _('ID_DELETE'),
iconCls: 'button_menu_ext ss_sprite ss_delete', icon: '/images/delete-table.png',
handler: DeletePMTable, handler: DeletePMTable,
disabled: true disabled: true
}); });
@@ -149,9 +158,10 @@ Ext.onReady(function(){
comboPageSize.setValue(pageSize); comboPageSize.setValue(pageSize);
store = new Ext.data.GroupingStore( { store = new Ext.data.GroupingStore( {
proxy : new Ext.data.HttpProxy({ proxy : new Ext.data.HttpProxy({
url: 'pmTablesProxy/getList' url: 'pmTablesProxy/getList' + (PRO_UID? '?pro_uid='+PRO_UID: '')
}), }),
reader : new Ext.data.JsonReader( { reader : new Ext.data.JsonReader( {
root: 'rows', root: 'rows',
@@ -315,14 +325,19 @@ DoNothing = function(){};
//Load New PM Table Forms //Load New PM Table Forms
NewReportTable = function(){ NewReportTable = function(){
//location.href = 'additionalTablesNew';
if(PRO_UID !== false) if(PRO_UID !== false)
location.href = 'pmTables/edit?PRO_UID='+PRO_UID+'&tableType=report'; location.href = 'pmTables/edit?PRO_UID='+PRO_UID+'&tableType=report';
else else
location.href = 'pmTables/edit?tableType=report'; location.href = 'pmTables/edit?tableType=report';
}; };
NewReportTableOld = function(){
//location.href = 'reportTables/edit?PRO_UID='+PRO_UID+'&tableType=report';
//parent.reportTables2();
//parent.Pm.data.render.buildingBlocks.injector('reportTables2');
location.href = 'reportTables/reportTables_Edit?PRO_UID='+PRO_UID;
};
newPMTable = function(){ newPMTable = function(){
location.href = 'pmTables/edit?tableType=table'; location.href = 'pmTables/edit?tableType=table';
}; };
@@ -336,7 +351,7 @@ EditPMTable = function(){
location.href = 'pmTables/edit?id='+row.data.ADD_TAB_UID+'&tableType=' + tableType + proParam; location.href = 'pmTables/edit?id='+row.data.ADD_TAB_UID+'&tableType=' + tableType + proParam;
} }
else { //edit old report table else { //edit old report table
location.href = '../reportTables/reportTables_Edit?REP_TAB_UID='+row.data.ADD_TAB_UID location.href = 'reportTables/reportTables_Edit?REP_TAB_UID='+row.data.ADD_TAB_UID
} }
}; };

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B