512 lines
18 KiB
PHP
512 lines
18 KiB
PHP
|
|
<?php
|
||
|
|
require_once 'classes/model/AdditionalTables.php';
|
||
|
|
|
||
|
|
//G::LoadClass('processMap');
|
||
|
|
|
||
|
|
class pmTablesProxy extends HttpProxyController
|
||
|
|
{
|
||
|
|
public function getList($params)
|
||
|
|
{
|
||
|
|
G::LoadClass('configuration');
|
||
|
|
$configurations = new Configurations();
|
||
|
|
|
||
|
|
// setting parameters
|
||
|
|
$config = $configurations->getConfiguration('additionalTablesList', 'pageSize','',$_SESSION['USER_LOGGED']);
|
||
|
|
$env = $configurations->getConfiguration('ENVIRONMENT_SETTINGS', '');
|
||
|
|
$limit_size = isset($config->pageSize) ? $config['pageSize'] : 20;
|
||
|
|
$start = isset($params->start) ? $params->start : 0;
|
||
|
|
$limit = isset($params->limit) ? $params->limit : $limit_size;
|
||
|
|
$filter = isset($params->textFilter) ? $params->textFilter : '';
|
||
|
|
$pro_uid = isset($params->pro_uid) ? $params->pro_uid : null;
|
||
|
|
|
||
|
|
//$process = $pro_uid == '' ? array('not_equal'=>$pro_uid) : array('equal'=>$pro_uid);
|
||
|
|
$process = null;
|
||
|
|
$addTables = AdditionalTables::getAll($start, $limit, $filter, $process);
|
||
|
|
|
||
|
|
return $addTables;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getProcessList()
|
||
|
|
{
|
||
|
|
require_once 'classes/model/Process.php';
|
||
|
|
|
||
|
|
$process = new Process();
|
||
|
|
return $process->getAll();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getDbConnectionsList()
|
||
|
|
{
|
||
|
|
G::LoadClass ( 'dbConnections');
|
||
|
|
$proUid = $_POST['PRO_UID'];
|
||
|
|
$dbConn = new DbConnections();
|
||
|
|
$dbConnections = $dbConn->getConnectionsProUid($proUid);
|
||
|
|
$defaultConnections = array (
|
||
|
|
array('DBS_UID'=>'workflow', 'DBS_NAME'=>'Workflow'),
|
||
|
|
array('DBS_UID'=>'rp', 'DBS_NAME'=>'REPORT')
|
||
|
|
);
|
||
|
|
|
||
|
|
$dbConnections = array_merge($defaultConnections, $dbConnections);
|
||
|
|
|
||
|
|
return $dbConnections;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function availableFieldsReportTables($params)
|
||
|
|
{
|
||
|
|
G::LoadClass('reportTables');
|
||
|
|
//G::LoadClass('xmlfield_InputPM');
|
||
|
|
|
||
|
|
$aFields['FIELDS'] = array();
|
||
|
|
$aFields['PRO_UID'] = $_POST['PRO_UID'];
|
||
|
|
|
||
|
|
if(isset($_POST['TYPE']) && $_POST['TYPE'] == 'GRID') {
|
||
|
|
$aProcessGridFields = Array();
|
||
|
|
if (isset($_POST['GRID_UID'])) {
|
||
|
|
global $G_FORM;
|
||
|
|
list($gridName, $gridId) = explode('-', $_POST['GRID_UID']);
|
||
|
|
|
||
|
|
// $G_FORM = new Form($_POST['PRO_UID'] . '/' . $gridId, PATH_DYNAFORM, SYS_LANG, false);
|
||
|
|
//$gridFields = $G_FORM->getVars(false);
|
||
|
|
$gridFields = getGridDynafields($_POST['PRO_UID'], $gridId);
|
||
|
|
|
||
|
|
foreach ($gridFields as $gfield) {
|
||
|
|
$aProcessGridFields[] = array(
|
||
|
|
'FIELD_UID' => $gfield['name'] . '-' . $gfield['type'],
|
||
|
|
'FIELD_NAME' => $gfield['name']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
$gridFields = getGridFields($aFields['PRO_UID']);
|
||
|
|
|
||
|
|
foreach ($gridFields as $gfield) {
|
||
|
|
$aProcessGridFields[] = array(
|
||
|
|
'FIELD_UID' => $gfield['name'] . '-' . $gfield['xmlform'],
|
||
|
|
'FIELD_NAME' => $gfield['name']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$resultList['processFields'] = $aProcessGridFields;
|
||
|
|
|
||
|
|
} else {
|
||
|
|
$aProcessFields = Array();
|
||
|
|
//$dynFields = getDynaformsVars($aFields['PRO_UID'], false);
|
||
|
|
$dynFields = getDynafields($aFields['PRO_UID']);
|
||
|
|
|
||
|
|
foreach ($dynFields as $dfield) {
|
||
|
|
$aProcessFields[] = array(
|
||
|
|
'FIELD_UID' => $dfield['name'] . '-' . $dfield['type'],
|
||
|
|
'FIELD_NAME' => $dfield['name']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
$resultList['processFields'] = $aProcessFields;
|
||
|
|
}
|
||
|
|
|
||
|
|
return $resultList;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function save()
|
||
|
|
{
|
||
|
|
require_once 'classes/model/AdditionalTables.php';
|
||
|
|
require_once 'classes/model/Fields.php';
|
||
|
|
try {
|
||
|
|
$data = $_POST;
|
||
|
|
$data['PRO_UID'] = trim($data['PRO_UID']);
|
||
|
|
$data['columns'] = G::json_decode($_POST['columns']); //decofing data columns
|
||
|
|
$isReportTable = $data['PRO_UID'] != '' ? true : false;
|
||
|
|
|
||
|
|
// Reserved Words
|
||
|
|
$aReservedWords = array(
|
||
|
|
'ALTER', 'CLOSE', 'COMMIT', 'CREATE', 'DECLARE',
|
||
|
|
'DELETE', 'DROP', 'FETCH', 'FUNCTION', 'GRANT',
|
||
|
|
'INDEX', 'INSERT', 'OPEN', 'REVOKE', 'ROLLBACK',
|
||
|
|
'SELECT', 'SYNONYM', 'TABLE', 'UPDATE', 'VIEW',
|
||
|
|
'APP_UID', 'ROW'
|
||
|
|
);
|
||
|
|
|
||
|
|
$oAdditionalTables = new AdditionalTables();
|
||
|
|
$oFields = new Fields();
|
||
|
|
|
||
|
|
// verify if exists.
|
||
|
|
$aNameTable = $oAdditionalTables->loadByName($data['REP_TAB_NAME']);
|
||
|
|
|
||
|
|
$repTabClassName = $oAdditionalTables->getPHPName($data['REP_TAB_NAME']);
|
||
|
|
|
||
|
|
$repTabData = array(
|
||
|
|
'ADD_TAB_UID' => $data['REP_TAB_UID'],
|
||
|
|
'ADD_TAB_NAME' => $data['REP_TAB_NAME'],
|
||
|
|
'ADD_TAB_CLASS_NAME' => $repTabClassName,
|
||
|
|
'ADD_TAB_DESCRIPTION' => $data['REP_TAB_DSC'],
|
||
|
|
'ADD_TAB_PLG_UID' => '',
|
||
|
|
'DBS_UID' => $data['REP_TAB_CONNECTION'],
|
||
|
|
'PRO_UID' => $data['PRO_UID'],
|
||
|
|
'ADD_TAB_TYPE' => $data['REP_TAB_TYPE'],
|
||
|
|
'ADD_TAB_GRID' => $data['REP_TAB_GRID']
|
||
|
|
);
|
||
|
|
|
||
|
|
$columns = $data['columns'];
|
||
|
|
|
||
|
|
if ($data['REP_TAB_UID'] == '') { //new report table
|
||
|
|
|
||
|
|
if ($isReportTable) { //setting default columns
|
||
|
|
$defaultColumns = $this->_getReportTableDefaultColumns($data['REP_TAB_TYPE']);
|
||
|
|
$columns = array_merge($defaultColumns, $columns);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** validations **/
|
||
|
|
if(is_array($aNameTable)) {
|
||
|
|
throw new Exception('The table "' . $data['REP_TAB_NAME'] . '" already exits.');
|
||
|
|
}
|
||
|
|
|
||
|
|
if (in_array(strtoupper($data['REP_TAB_NAME']), $aReservedWords) ) {
|
||
|
|
throw new Exception('Could not create the table with the name "' . $data['REP_TAB_NAME'] . '" because it is a reserved word.');
|
||
|
|
}
|
||
|
|
//create record
|
||
|
|
$addTabUid = $oAdditionalTables->create($repTabData);
|
||
|
|
|
||
|
|
} else { //editing report table
|
||
|
|
$addTabUid = $data['REP_TAB_UID'];
|
||
|
|
//loading old data before update
|
||
|
|
$addTabBeforeData = $oAdditionalTables->load($addTabUid, true);
|
||
|
|
//updating record
|
||
|
|
$oAdditionalTables->update($repTabData);
|
||
|
|
|
||
|
|
//removing old data fields references
|
||
|
|
$oCriteria = new Criteria('workflow');
|
||
|
|
$oCriteria->add(FieldsPeer::ADD_TAB_UID, $data['REP_TAB_UID']);
|
||
|
|
//$oCriteria->add(FieldsPeer::FLD_NAME, 'APP_UID', Criteria::NOT_EQUAL);
|
||
|
|
//$oCriteria->add(FieldsPeer::FLD_NAME, 'ROW', Criteria::NOT_EQUAL);
|
||
|
|
FieldsPeer::doDelete($oCriteria);
|
||
|
|
|
||
|
|
//getting old fieldnames
|
||
|
|
$oldFields = array();
|
||
|
|
foreach ($addTabBeforeData['FIELDS'] as $field) {
|
||
|
|
$oldFields[$field['FLD_UID']] = $field;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$aFields = array();
|
||
|
|
$fieldsList = array();
|
||
|
|
$editFieldsList = array();
|
||
|
|
|
||
|
|
foreach ($columns as $i => $column) {
|
||
|
|
//new feature, to reorder the columns
|
||
|
|
if (isset($oldFields[$column->uid])) { // the the field alreaday exists
|
||
|
|
if ($oldFields[$column->uid]['FLD_INDEX'] != $i) { // if its index has changed
|
||
|
|
$column->uid = ''; //set as new field,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$field = array(
|
||
|
|
'FLD_UID' => $column->uid,
|
||
|
|
'FLD_INDEX' => $i,
|
||
|
|
'ADD_TAB_UID' => $addTabUid,
|
||
|
|
'FLD_NAME' => $column->field_name,
|
||
|
|
'FLD_DESCRIPTION' => $column->field_label,
|
||
|
|
'FLD_TYPE' => $column->field_type,
|
||
|
|
'FLD_SIZE' => $column->field_size,
|
||
|
|
'FLD_NULL' => (isset($column->field_null) && $column->field_null ? 1 : 0),
|
||
|
|
'FLD_AUTO_INCREMENT' => 0,
|
||
|
|
'FLD_KEY' => (isset($column->field_key) && $column->field_key ? 1 : 0),
|
||
|
|
'FLD_FOREIGN_KEY' => 0,
|
||
|
|
'FLD_FOREIGN_KEY_TABLE' => '',
|
||
|
|
'FLD_DYN_NAME' => $column->field_dyn,
|
||
|
|
'FLD_DYN_UID' => $column->field_uid,
|
||
|
|
'FLD_FILTER' => (isset($column->field_filter) && $column->field_filter ? 1 : 0)
|
||
|
|
);
|
||
|
|
|
||
|
|
$fieldUid = $oFields->create($field);
|
||
|
|
$fieldsList[] = $field;
|
||
|
|
|
||
|
|
if($data['REP_TAB_UID'] == '') { //new
|
||
|
|
$aFields[] = array(
|
||
|
|
'sType' => $column->field_type,
|
||
|
|
'iSize' => $column->field_size,
|
||
|
|
'sFieldName' => $column->field_name,
|
||
|
|
'bNull' => (isset($column->field_null) ? $column->field_null : 1),
|
||
|
|
'bAI' => 0,
|
||
|
|
'bPrimaryKey' => (isset($column->field_key) ? $column->field_key : 0)
|
||
|
|
);
|
||
|
|
} else { //editing
|
||
|
|
$field['FLD_UID'] = $fieldUid;
|
||
|
|
$aFields[$fieldUid] = $field;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if ($data['REP_TAB_UID'] == '') { //create a new report table
|
||
|
|
$oAdditionalTables->createTable($data['REP_TAB_NAME'], $data['REP_TAB_CONNECTION'], $aFields);
|
||
|
|
} else { //editing
|
||
|
|
//print_R($aFields);
|
||
|
|
$oAdditionalTables->updateTable($data['REP_TAB_NAME'], $data['REP_TAB_CONNECTION'], $aFields, $oldFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
$oAdditionalTables->createPropelClasses($data['REP_TAB_NAME'], '', $fieldsList, $addTabUid, $data['REP_TAB_CONNECTION']);
|
||
|
|
|
||
|
|
if ($isReportTable) {
|
||
|
|
$oAdditionalTables->populateReportTable($data['REP_TAB_NAME'], $data['REP_TAB_CONNECTION'], $data['REP_TAB_TYPE'], $fieldsList, $data['PRO_UID'], $data['REP_TAB_GRID']);
|
||
|
|
}
|
||
|
|
|
||
|
|
$result->success = true;
|
||
|
|
} catch (Exception $e) {
|
||
|
|
$result->success = false;
|
||
|
|
$result->msg = $e->getMessage();
|
||
|
|
$result->trace = $e->getTraceAsString();
|
||
|
|
}
|
||
|
|
|
||
|
|
return $result;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function delete($httpData)
|
||
|
|
{
|
||
|
|
G::LoadClass('reportTables');
|
||
|
|
$rows = G::json_decode($_REQUEST['rows']);
|
||
|
|
$rp = new reportTables();
|
||
|
|
$at = new AdditionalTables();
|
||
|
|
|
||
|
|
try {
|
||
|
|
foreach ($rows as $row ) {
|
||
|
|
if($row->type == 'CLASSIC') {
|
||
|
|
$rp->deleteReportTable($row->id);
|
||
|
|
} else {
|
||
|
|
$at->deleteAll($row->id);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$result->success = true;
|
||
|
|
} catch(Exception $e) {
|
||
|
|
$result->success = false;
|
||
|
|
$result->msg = $e->getMessage();
|
||
|
|
}
|
||
|
|
|
||
|
|
return $result;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getData($httpData)
|
||
|
|
{
|
||
|
|
require_once 'classes/model/AdditionalTables.php';
|
||
|
|
|
||
|
|
G::LoadClass('configuration');
|
||
|
|
$co = new Configurations();
|
||
|
|
$config = $co->getConfiguration('additionalTablesData', 'pageSize','',$_SESSION['USER_LOGGED']);
|
||
|
|
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
|
||
|
|
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
|
||
|
|
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
|
||
|
|
|
||
|
|
$oAdditionalTables = new AdditionalTables();
|
||
|
|
$result = $oAdditionalTables->getAllData($httpData->id, $start, $limit);
|
||
|
|
|
||
|
|
return $result;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// protected functions
|
||
|
|
protected function _getReportTableDefaultColumns($type='NORMAL')
|
||
|
|
{
|
||
|
|
$defaultColumns = array();
|
||
|
|
$application = new stdClass(); //APPLICATION KEY
|
||
|
|
$application->uid = '';
|
||
|
|
$application->field_dyn = '';
|
||
|
|
$application->field_uid = '';
|
||
|
|
$application->field_name = 'APP_UID';
|
||
|
|
$application->field_label = 'APP_UID';
|
||
|
|
$application->field_type = 'VARCHAR';
|
||
|
|
$application->field_size = 32;
|
||
|
|
$application->field_dyn = '';
|
||
|
|
$application->field_key = 1;
|
||
|
|
$application->field_null = 0;
|
||
|
|
$application->field_filter = false;
|
||
|
|
array_push($defaultColumns, $application);
|
||
|
|
|
||
|
|
$application = new stdClass(); //APP_NUMBER
|
||
|
|
$application->uid = '';
|
||
|
|
$application->field_dyn = '';
|
||
|
|
$application->field_uid = '';
|
||
|
|
$application->field_name = 'APP_NUMBER';
|
||
|
|
$application->field_label = 'APP_NUMBER';
|
||
|
|
$application->field_type = 'INT';
|
||
|
|
$application->field_size = 11;
|
||
|
|
$application->field_dyn = '';
|
||
|
|
$application->field_key = 0;
|
||
|
|
$application->field_null = 0;
|
||
|
|
$application->field_filter = false;
|
||
|
|
array_push($defaultColumns, $application);
|
||
|
|
|
||
|
|
//if it is a grid report table
|
||
|
|
if ($type == 'GRID') { //GRID INDEX
|
||
|
|
$gridIndex = new stdClass();
|
||
|
|
$gridIndex->uid = '';
|
||
|
|
$gridIndex->field_dyn = '';
|
||
|
|
$gridIndex->field_uid = '';
|
||
|
|
$gridIndex->field_name = 'ROW';
|
||
|
|
$gridIndex->field_label = 'ROW';
|
||
|
|
$gridIndex->field_type = 'INT';
|
||
|
|
$gridIndex->field_size = '11';
|
||
|
|
$gridIndex->field_dyn = '';
|
||
|
|
$gridIndex->field_key = 1;
|
||
|
|
$gridIndex->field_null = 0;
|
||
|
|
$gridIndex->field_filter = false;
|
||
|
|
array_push($defaultColumns, $gridIndex);
|
||
|
|
}
|
||
|
|
|
||
|
|
return $defaultColumns;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
///
|
||
|
|
/**
|
||
|
|
* Translates a string with underscores into camel case (e.g. first_name -> firstName)
|
||
|
|
* @param string $str String in underscore format
|
||
|
|
* @param bool $capitalise_first_char If true, capitalise the first char in $str
|
||
|
|
* @return string $str translated into camel caps
|
||
|
|
*/
|
||
|
|
function to_camel_case($str, $capitalise_first_char = true) {
|
||
|
|
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';
|
||
|
|
$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;
|
||
|
|
}
|
||
|
|
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|