diff --git a/workflow/engine/methods/reportTables/edit.php b/workflow/engine/methods/reportTables/edit.php
index 195fac4f4..93dd9ceb8 100755
--- a/workflow/engine/methods/reportTables/edit.php
+++ b/workflow/engine/methods/reportTables/edit.php
@@ -1,80 +1,75 @@
addExtJsScript('reportTables/edit', true );
-$oHeadPublisher->assign('ADD_TAB_UID', $id);
+$oHeadPublisher->addExtJsScript( 'reportTables/edit', true );
+$oHeadPublisher->assign( 'ADD_TAB_UID', $id );
if ($id) { // if is a edit request
- require_once 'classes/model/AdditionalTables.php';
- require_once 'classes/model/Fields.php';
- G::LoadClass('xmlfield_InputPM');
+ require_once 'classes/model/AdditionalTables.php';
+ require_once 'classes/model/Fields.php';
+ G::LoadClass( 'xmlfield_InputPM' );
- $additionalTables = new AdditionalTables();
- $table = $additionalTables->load($id, true);
- $tableFields = array();
- $fieldsList = array();
+ $additionalTables = new AdditionalTables();
+ $table = $additionalTables->load( $id, true );
+ $tableFields = array ();
+ $fieldsList = array ();
- // list the case fields
- foreach ($table['FIELDS'] as $i=>$field) {
- /*if ($field['FLD_NAME'] == 'APP_UID' || $field['FLD_NAME'] == 'APP_NUMBER' || $field['FLD_NAME'] == 'ROW') {
+ // list the case fields
+ foreach ($table['FIELDS'] as $i => $field) {
+ /*if ($field['FLD_NAME'] == 'APP_UID' || $field['FLD_NAME'] == 'APP_NUMBER' || $field['FLD_NAME'] == 'ROW') {
unset($table['FIELDS'][$i]);
continue;
}*/
- array_push($tableFields, $field['FLD_DYN_NAME']);
- }
-
- //list dynaform fields
- if ($table['ADD_TAB_TYPE'] == 'NORMAL') {
- $fields = getDynaformsVars($table['PRO_UID'], false);
- foreach ($fields as $field) {
- //select to not assigned fields for available grid
- if (!in_array($field['sName'], $tableFields)) {
- $fieldsList[] = array(
- 'FIELD_UID' => $field['sName'] . '-' . $field['sType'],
- 'FIELD_NAME' => $field['sName']
- );
- }
+ array_push( $tableFields, $field['FLD_DYN_NAME'] );
}
- } else {
- 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);
-
- foreach ($gridFields as $gfield) {
- if (!in_array($gfield['sName'], $tableFields)) {
- $fieldsList[] = array(
- 'FIELD_UID' => $gfield['sName'] . '-' . $gfield['sType'],
- 'FIELD_NAME' => $gfield['sName']
- );
- }
- }
- }
- $oHeadPublisher->assign('avFieldsList', $fieldsList);
+ //list dynaform fields
+ if ($table['ADD_TAB_TYPE'] == 'NORMAL') {
+ $fields = getDynaformsVars( $table['PRO_UID'], false );
+ foreach ($fields as $field) {
+ //select to not assigned fields for available grid
+ if (! in_array( $field['sName'], $tableFields )) {
+ $fieldsList[] = array ('FIELD_UID' => $field['sName'] . '-' . $field['sType'],'FIELD_NAME' => $field['sName']
+ );
+ }
+ }
+ } else {
+ 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 );
+
+ foreach ($gridFields as $gfield) {
+ if (! in_array( $gfield['sName'], $tableFields )) {
+ $fieldsList[] = array ('FIELD_UID' => $gfield['sName'] . '-' . $gfield['sType'],'FIELD_NAME' => $gfield['sName']
+ );
+ }
+ }
+ }
+
+ $oHeadPublisher->assign( 'avFieldsList', $fieldsList );
}
$repTabPluginPermissions = false;
global $G_TMP_MENU;
$oMenu = new Menu();
-$oMenu->load('setup');
+$oMenu->load( 'setup' );
-foreach( $oMenu->Options as $i=>$option) {
- if ($oMenu->Types[$i] == 'private' && $oMenu->Id[$i] == 'PLUGIN_REPTAB_PERMISSIONS') {
- $repTabPluginPermissions = array();
- $repTabPluginPermissions['label'] = $oMenu->Labels[$i];
- $repTabPluginPermissions['fn'] = $oMenu->Options[$i];
- break;
- }
+foreach ($oMenu->Options as $i => $option) {
+ if ($oMenu->Types[$i] == 'private' && $oMenu->Id[$i] == 'PLUGIN_REPTAB_PERMISSIONS') {
+ $repTabPluginPermissions = array ();
+ $repTabPluginPermissions['label'] = $oMenu->Labels[$i];
+ $repTabPluginPermissions['fn'] = $oMenu->Options[$i];
+ break;
+ }
}
-$oHeadPublisher->assign('_plugin_permissions', $repTabPluginPermissions);
+$oHeadPublisher->assign( '_plugin_permissions', $repTabPluginPermissions );
-$oHeadPublisher->assign('PRO_UID', isset($_GET['PRO_UID'])? $_GET['PRO_UID'] : false);
-$oHeadPublisher->assign('TABLE', $table);
+$oHeadPublisher->assign( 'PRO_UID', isset( $_GET['PRO_UID'] ) ? $_GET['PRO_UID'] : false );
+$oHeadPublisher->assign( 'TABLE', $table );
-
-G::RenderPage('publish', 'extJs');
+G::RenderPage( 'publish', 'extJs' );
diff --git a/workflow/engine/methods/reportTables/main.php b/workflow/engine/methods/reportTables/main.php
index 33f2578f9..99863c77a 100755
--- a/workflow/engine/methods/reportTables/main.php
+++ b/workflow/engine/methods/reportTables/main.php
@@ -12,48 +12,47 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
- *
*/
global $RBAC;
-$RBAC->requirePermissions('PM_SETUP_ADVANCE');
-$G_PUBLISH = new Publisher;
+$RBAC->requirePermissions( 'PM_SETUP_ADVANCE' );
+$G_PUBLISH = new Publisher();
-G::LoadClass('configuration');
+G::LoadClass( 'configuration' );
$c = new Configurations();
-$configPage = $c->getConfiguration('additionalTablesList', 'pageSize','',$_SESSION['USER_LOGGED']);
-$Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20;
+$configPage = $c->getConfiguration( 'additionalTablesList', 'pageSize', '', $_SESSION['USER_LOGGED'] );
+$Config['pageSize'] = isset( $configPage['pageSize'] ) ? $configPage['pageSize'] : 20;
-$oHeadPublisher =& headPublisher::getSingleton();
+$oHeadPublisher = & headPublisher::getSingleton();
$repTabPluginPermissions = false;
global $G_TMP_MENU;
$oMenu = new Menu();
-$oMenu->load('setup');
+$oMenu->load( 'setup' );
$simpleREportsPlugin = false;
-foreach( $oMenu->Options as $i=>$option) {
- if ($oMenu->Types[$i] == 'private' && $oMenu->Id[$i] == 'PLUGIN_REPTAB_PERMISSIONS') {
- $simpleREportsPlugin = array();
- $simpleREportsPlugin['label'] = $oMenu->Labels[$i];
- $simpleREportsPlugin['fn'] = $oMenu->Options[$i];
- break;
- }
+foreach ($oMenu->Options as $i => $option) {
+ if ($oMenu->Types[$i] == 'private' && $oMenu->Id[$i] == 'PLUGIN_REPTAB_PERMISSIONS') {
+ $simpleREportsPlugin = array ();
+ $simpleREportsPlugin['label'] = $oMenu->Labels[$i];
+ $simpleREportsPlugin['fn'] = $oMenu->Options[$i];
+ break;
+ }
}
-$oHeadPublisher->assign('_PLUGIN_SIMPLEREPORTS', $simpleREportsPlugin);
+$oHeadPublisher->assign( '_PLUGIN_SIMPLEREPORTS', $simpleREportsPlugin );
-$oHeadPublisher->addExtJsScript('reportTables/main', true); //adding a javascript file .js
-$oHeadPublisher->addContent('reportTables/main'); //adding a html file .html.
-$oHeadPublisher->assign('FORMATS',$c->getFormats());
-$oHeadPublisher->assign('CONFIG', $Config);
-$oHeadPublisher->assign('PRO_UID', isset($_GET['PRO_UID'])? $_GET['PRO_UID'] : false);
-G::RenderPage('publish', 'extJs');
+$oHeadPublisher->addExtJsScript( 'reportTables/main', true ); //adding a javascript file .js
+$oHeadPublisher->addContent( 'reportTables/main' ); //adding a html file .html.
+$oHeadPublisher->assign( 'FORMATS', $c->getFormats() );
+$oHeadPublisher->assign( 'CONFIG', $Config );
+$oHeadPublisher->assign( 'PRO_UID', isset( $_GET['PRO_UID'] ) ? $_GET['PRO_UID'] : false );
+G::RenderPage( 'publish', 'extJs' );
diff --git a/workflow/engine/methods/reportTables/reportTables_Ajax.php b/workflow/engine/methods/reportTables/reportTables_Ajax.php
index b647899a9..8659b501d 100755
--- a/workflow/engine/methods/reportTables/reportTables_Ajax.php
+++ b/workflow/engine/methods/reportTables/reportTables_Ajax.php
@@ -12,551 +12,509 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
- *
*/
-G::LoadClass('case');
+G::LoadClass( 'case' );
$action = $_REQUEST['action'];
-unset($_POST['action']);
+unset( $_POST['action'] );
-switch($action) {
+switch ($action) {
- case 'availableFieldsReportTables':
- G::LoadClass('reportTables');
- G::LoadClass('xmlfield_InputPM');
+ case 'availableFieldsReportTables':
+ G::LoadClass( 'reportTables' );
+ G::LoadClass( 'xmlfield_InputPM' );
- $aFields['FIELDS'] = array();
- $aFields['PRO_UID'] = $_POST['PRO_UID'];
+ $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']);
+ 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);
+ // $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']
- );
+ 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;
}
- } else {
- $gridFields = getGridFields($aFields['PRO_UID']);
- foreach ($gridFields as $gfield) {
- $aProcessGridFields[] = array(
- 'FIELD_UID' => $gfield['name'] . '-' . $gfield['xmlform'],
- 'FIELD_NAME' => $gfield['name']
- );
+ echo G::json_encode( $resultList );
+
+ break;
+
+ case 'fieldsList':
+
+ G::LoadClass( 'reportTables' );
+ G::LoadClass( 'xmlfield_InputPM' );
+ $aFields['FIELDS'] = array ();
+ $oReportTable = new ReportTable();
+ $aFields = $oReportTable->load( $_POST['REP_TAB_UID'] );
+ $aTheFields = getDynaformsVars( $aFields['PRO_UID'], false );
+ $oReportTables = new ReportTables();
+ $aVars = $oReportTables->getTableVars( $_POST['REP_TAB_UID'] );
+ $aFields['FIELDS'] = array ();
+
+ foreach ($aTheFields as $aField) {
+ if (in_array( $aField['sName'], $aVars )) {
+
+ $aResultFields[] = array ('FIELD_UID' => $aField['sName'] . '-' . $aField['sType'],'FIELD_NAME' => $aField['sName'],'FIELD_DYNAFORM' => $aField['sName']
+ );
+ }
}
- }
- $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;
- }
-
- echo G::json_encode($resultList);
-
- break;
-
-
-
- case 'fieldsList':
-
- G::LoadClass('reportTables');
- G::LoadClass('xmlfield_InputPM');
- $aFields['FIELDS'] = array();
- $oReportTable = new ReportTable();
- $aFields = $oReportTable->load($_POST['REP_TAB_UID']);
- $aTheFields = getDynaformsVars($aFields['PRO_UID'], false);
- $oReportTables = new ReportTables();
- $aVars = $oReportTables->getTableVars($_POST['REP_TAB_UID']);
- $aFields['FIELDS'] = array();
-
- foreach ($aTheFields as $aField) {
- if (in_array($aField['sName'], $aVars)) {
-
- $aResultFields[] = array('FIELD_UID' => $aField['sName'] . '-' . $aField['sType'],
- 'FIELD_NAME' => $aField['sName'],
- 'FIELD_DYNAFORM' => $aField['sName']);
- }
- }
-
-
- $result->success = true;
- $result->data=$aResultFields;
- echo G::json_encode($result);
- break;
+ $result->success = true;
+ $result->data = $aResultFields;
+ echo G::json_encode( $result );
+ break;
case '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')
- );
+ 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'
+ )
+ );
- echo G::json_encode(array_merge($defaultConnections, $dbConnections));
+ echo G::json_encode( array_merge( $defaultConnections, $dbConnections ) );
- break;
+ break;
case 'getProcessList':
- require_once 'classes/model/Process.php';
-
- $process = new Process();
- echo G::json_encode($process->getAll());
- break;
+ require_once 'classes/model/Process.php';
+ $process = new Process();
+ echo G::json_encode( $process->getAll() );
+ break;
case 'save':
- require_once 'classes/model/AdditionalTables.php';
- require_once 'classes/model/Fields.php';
- try {
- $data = $_POST;
- $data['columns'] = G::json_decode($_POST['columns']); //decofing data columns
-
- // 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 = to_camel_case($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
- //setting default columns
- $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 = 1;
- $application->field_null =0;
- $application->field_filter = false;
- array_push($defaultColumns, $application);
-
- //if it is a grid report table
- if ($data['REP_TAB_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_null = 0;
- $gridIndex->field_filter = false;
- array_push($defaultColumns, $gridIndex);
- }
-
- $columns = array_merge($defaultColumns, $columns);
+ require_once 'classes/model/AdditionalTables.php';
+ require_once 'classes/model/Fields.php';
+ try {
+ $data = $_POST;
+ $data['columns'] = G::json_decode( $_POST['columns'] ); //decofing data 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) {
- //if ($field['FLD_NAME'] == 'APP_UID' || $field['FLD_NAME'] == 'ROW') continue;
- $oldFields[$field['FLD_UID']] = $field;
- }
- }
-
- $aFields = array();
- $fieldsList = array();
- $editFieldsList = array();
-
- foreach ($columns as $i => $column) {
- $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),
- 'FLD_AUTO_INCREMENT' => 0,
- 'FLD_KEY' => (isset($column->field_key) ? $column->field_key : 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)
+ // 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'
);
- } 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 = new AdditionalTables();
+ $oFields = new Fields();
+
+ // verify if exists.
+ $aNameTable = $oAdditionalTables->loadByName( $data['REP_TAB_NAME'] );
+
+ $repTabClassName = to_camel_case( $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
+ //setting default columns
+ $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 = 1;
+ $application->field_null = 0;
+ $application->field_filter = false;
+ array_push( $defaultColumns, $application );
+
+ //if it is a grid report table
+ if ($data['REP_TAB_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_null = 0;
+ $gridIndex->field_filter = false;
+ array_push( $defaultColumns, $gridIndex );
+ }
+
+ $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) {
+ //if ($field['FLD_NAME'] == 'APP_UID' || $field['FLD_NAME'] == 'ROW') continue;
+ $oldFields[$field['FLD_UID']] = $field;
+ }
+ }
+
+ $aFields = array ();
+ $fieldsList = array ();
+ $editFieldsList = array ();
+
+ foreach ($columns as $i => $column) {
+ $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),'FLD_AUTO_INCREMENT' => 0,'FLD_KEY' => (isset( $column->field_key ) ? $column->field_key : 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'], $repTabClassName, $fieldsList, $addTabUid );
+
+ $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();
}
- $oAdditionalTables->createPropelClasses($data['REP_TAB_NAME'], $repTabClassName, $fieldsList, $addTabUid);
-
- $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();
- }
-
- echo G::json_encode($result);
- break;
+ echo G::json_encode( $result );
+ break;
case 'delete':
- require_once 'classes/model/AdditionalTables.php';
- 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);
- }
+ require_once 'classes/model/AdditionalTables.php';
+ 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();
}
- $result->success = true;
- } catch(Exception $e) {
- $result->success = false;
- $result->msg = $e->getMessage();
- }
- echo G::json_encode($result);
- break;
+ echo G::json_encode( $result );
+ break;
case 'list':
- require_once 'classes/model/AdditionalTables.php';
- G::LoadClass('configuration');
- G::LoadClass('processMap');
- $configigurations = new Configurations();
- $oProcessMap = new processMap();
-
- $config = $configigurations->getConfiguration('additionalTablesList', 'pageSize','',$_SESSION['USER_LOGGED']);
- $env = $configigurations->getConfiguration('ENVIRONMENT_SETTINGS', '');
- $limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
- $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
- $limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
- $filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
- $pro_uid = isset($_REQUEST['pro_uid']) ? $_REQUEST['pro_uid'] : '';
+ require_once 'classes/model/AdditionalTables.php';
+ G::LoadClass( 'configuration' );
+ G::LoadClass( 'processMap' );
+ $configigurations = new Configurations();
+ $oProcessMap = new processMap();
- $process = $pro_uid == '' ? array('not_equal'=>$pro_uid) : array('equal'=>$pro_uid);
- $addTab = AdditionalTables::getAll($start, $limit, $filter, $process);
+ $config = $configigurations->getConfiguration( 'additionalTablesList', 'pageSize', '', $_SESSION['USER_LOGGED'] );
+ $env = $configigurations->getConfiguration( 'ENVIRONMENT_SETTINGS', '' );
+ $limit_size = isset( $config['pageSize'] ) ? $config['pageSize'] : 20;
+ $start = isset( $_REQUEST['start'] ) ? $_REQUEST['start'] : 0;
+ $limit = isset( $_REQUEST['limit'] ) ? $_REQUEST['limit'] : $limit_size;
+ $filter = isset( $_REQUEST['textFilter'] ) ? $_REQUEST['textFilter'] : '';
+ $pro_uid = isset( $_REQUEST['pro_uid'] ) ? $_REQUEST['pro_uid'] : '';
+
+ $process = $pro_uid == '' ? array ('not_equal' => $pro_uid
+ ) : array ('equal' => $pro_uid
+ );
+ $addTab = AdditionalTables::getAll( $start, $limit, $filter, $process );
+
+ if ($pro_uid != '') {
+ $c = $oProcessMap->getReportTablesCriteria( $pro_uid );
+ $oDataset = RoutePeer::doSelectRS( $c );
+ $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $reportTablesOldList = array ();
+ while ($oDataset->next()) {
+ $reportTablesOldList[] = $oDataset->getRow();
+ }
+ $addTab['count'] += count( $reportTablesOldList );
+
+ foreach ($reportTablesOldList as $i => $oldRepTab) {
+ $addTab['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'
+ );
+ }
- if ($pro_uid != '') {
- $c = $oProcessMap->getReportTablesCriteria($pro_uid);
- $oDataset = RoutePeer::doSelectRS($c);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $reportTablesOldList = array();
- while($oDataset->next()) {
- $reportTablesOldList[] = $oDataset->getRow();
}
- $addTab['count'] += count($reportTablesOldList);
-
- foreach ($reportTablesOldList as $i => $oldRepTab) {
- $addTab['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'
- );
- }
-
- }
-
- echo G::json_encode($addTab);
- break;
+
+ echo G::json_encode( $addTab );
+ break;
case 'updateTag':
- require_once 'classes/model/AdditionalTables.php';
- $oAdditionalTables = new AdditionalTables();
- $uid = $_REQUEST['ADD_TAB_UID'];
- $value = $_REQUEST['value'];
+ require_once 'classes/model/AdditionalTables.php';
+ $oAdditionalTables = new AdditionalTables();
+ $uid = $_REQUEST['ADD_TAB_UID'];
+ $value = $_REQUEST['value'];
- $repTabData = array(
- 'ADD_TAB_UID' => $uid,
- 'ADD_TAB_TAG' => $value
- );
- $oAdditionalTables->update($repTabData);
- break;
+ $repTabData = array ('ADD_TAB_UID' => $uid,'ADD_TAB_TAG' => $value
+ );
+ $oAdditionalTables->update( $repTabData );
+ break;
+}
+
+/**
+ * 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;
}
-
- /**
- * 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;
- }
-
-
-
\ No newline at end of file
diff --git a/workflow/engine/methods/reportTables/reportTables_Delete.php b/workflow/engine/methods/reportTables/reportTables_Delete.php
index 553553e53..4aa0058eb 100755
--- a/workflow/engine/methods/reportTables/reportTables_Delete.php
+++ b/workflow/engine/methods/reportTables/reportTables_Delete.php
@@ -12,26 +12,26 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
- *
*/
-if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response;
-G::LoadClass('reportTables');
-try{
+if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1)
+ return $RBAC_Response;
+G::LoadClass( 'reportTables' );
+try {
$oReportTables = new ReportTables();
- $oReportTables->deleteReportTable($_POST['REP_TAB_UID']);
+ $oReportTables->deleteReportTable( $_POST['REP_TAB_UID'] );
$result->success = true;
- $result->msg = G::LoadTranslation('ID_REPORTTABLE_REMOVED');
+ $result->msg = G::LoadTranslation( 'ID_REPORTTABLE_REMOVED' );
} catch (Exception $e) {
$result->success = false;
$result->msg = $e->getMessage();
- }
-print G::json_encode($result);
+}
+print G::json_encode( $result );
?>
diff --git a/workflow/engine/methods/reportTables/reportTables_Edit.php b/workflow/engine/methods/reportTables/reportTables_Edit.php
index 53ab181ec..764548157 100755
--- a/workflow/engine/methods/reportTables/reportTables_Edit.php
+++ b/workflow/engine/methods/reportTables/reportTables_Edit.php
@@ -12,53 +12,50 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
- *
*/
-if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response;
-G::LoadClass('reportTables');
-G::LoadClass('xmlfield_InputPM');
-$aFields['FIELDS'] = array();
-if (isset($_GET['REP_TAB_UID']))
-{
- $oReportTable = new ReportTable();
- $aFields = $oReportTable->load($_GET['REP_TAB_UID']);
- $aTheFields = getDynaformsVars($aFields['PRO_UID'], false);
- $oReportTables = new ReportTables();
- $aVars = $oReportTables->getTableVars($_GET['REP_TAB_UID']);
- $aFields['FIELDS'] = array();
- foreach ($aTheFields as $aField) {
- if (in_array($aField['sName'], $aVars)) {
- $aFields['FIELDS'][] = $aField['sName'] . '-' . $aField['sType'];
+if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1)
+ return $RBAC_Response;
+G::LoadClass( 'reportTables' );
+G::LoadClass( 'xmlfield_InputPM' );
+$aFields['FIELDS'] = array ();
+if (isset( $_GET['REP_TAB_UID'] )) {
+ $oReportTable = new ReportTable();
+ $aFields = $oReportTable->load( $_GET['REP_TAB_UID'] );
+ $aTheFields = getDynaformsVars( $aFields['PRO_UID'], false );
+ $oReportTables = new ReportTables();
+ $aVars = $oReportTables->getTableVars( $_GET['REP_TAB_UID'] );
+ $aFields['FIELDS'] = array ();
+ foreach ($aTheFields as $aField) {
+ if (in_array( $aField['sName'], $aVars )) {
+ $aFields['FIELDS'][] = $aField['sName'] . '-' . $aField['sType'];
+ }
}
- }
+} else {
+ $aFields['PRO_UID'] = $_GET['PRO_UID'];
+ $aFields['FIELDS'] = array ();
+ $aTheFields = getDynaformsVars( $aFields['PRO_UID'], false );
}
-else
-{
- $aFields['PRO_UID'] = $_GET['PRO_UID'];
- $aFields['FIELDS'] = array();
- $aTheFields = getDynaformsVars($aFields['PRO_UID'], false);
-}
-$aProcessFields[] = array('FIELD_UID' => 'char',
- 'FIELD_NAME' => 'char');
-$aTheFields = getDynaformsVars($aFields['PRO_UID'], false);
+$aProcessFields[] = array ('FIELD_UID' => 'char','FIELD_NAME' => 'char'
+);
+$aTheFields = getDynaformsVars( $aFields['PRO_UID'], false );
foreach ($aTheFields as $aField) {
- $aProcessFields[] = array('FIELD_UID' => $aField['sName'] . '-' . $aField['sType'],
- 'FIELD_NAME' => $aField['sName']);
+ $aProcessFields[] = array ('FIELD_UID' => $aField['sName'] . '-' . $aField['sType'],'FIELD_NAME' => $aField['sName']
+ );
}
-$aProcessGridFields[] = array('FIELD_UID' => 'char',
- 'FIELD_NAME' => 'char');
-$aTheFields = getGridsVars($aFields['PRO_UID']);
+$aProcessGridFields[] = array ('FIELD_UID' => 'char','FIELD_NAME' => 'char'
+);
+$aTheFields = getGridsVars( $aFields['PRO_UID'] );
foreach ($aTheFields as $aField) {
- $aProcessGridFields[] = array('FIELD_UID' => $aField['sName'] . '-' . $aField['sXmlForm'],
- 'FIELD_NAME' => $aField['sName']);
+ $aProcessGridFields[] = array ('FIELD_UID' => $aField['sName'] . '-' . $aField['sXmlForm'],'FIELD_NAME' => $aField['sName']
+ );
}
global $_DBArray;
$_DBArray['processFields'] = $aProcessFields;
@@ -67,6 +64,6 @@ $_SESSION['_DBArray'] = $_DBArray;
$aFields['LANG'] = SYS_LANG;
$G_PUBLISH = new Publisher();
-$G_PUBLISH->AddContent('xmlform', 'xmlform', 'reportTables/reportTables_Edit', '', $aFields, '../reportTables/reportTables_Save');
-G::RenderPage('publish', 'blank');
+$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'reportTables/reportTables_Edit', '', $aFields, '../reportTables/reportTables_Save' );
+G::RenderPage( 'publish', 'blank' );
?>
\ No newline at end of file
diff --git a/workflow/engine/methods/reportTables/reportTables_Save.php b/workflow/engine/methods/reportTables/reportTables_Save.php
index 44bda3f53..44d83396d 100755
--- a/workflow/engine/methods/reportTables/reportTables_Save.php
+++ b/workflow/engine/methods/reportTables/reportTables_Save.php
@@ -12,92 +12,88 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
- *
*/
-if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response;
+if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1)
+ return $RBAC_Response;
-G::LoadClass('reportTables');
+G::LoadClass( 'reportTables' );
-if(isset($_POST['form']))
- $values = $_POST['form']; //For Old processmap
-else
-{
- $values = $_POST; //For extjs,since we are not using form
- $values['FIELDS'] = explode(',',$_POST['FIELDS']);
+if (isset( $_POST['form'] ))
+ $values = $_POST['form']; //For Old processmap
+else {
+ $values = $_POST; //For extjs,since we are not using form
+ $values['FIELDS'] = explode( ',', $_POST['FIELDS'] );
}
-
$oReportTable = new ReportTable();
-if (!isset($values['REP_TAB_CONNECTION'])) {
- $values['REP_TAB_CONNECTION'] = 'report';
+if (! isset( $values['REP_TAB_CONNECTION'] )) {
+ $values['REP_TAB_CONNECTION'] = 'report';
}
if ($values['REP_TAB_UID'] != '') {
- $aReportTable = $oReportTable->load($values['REP_TAB_UID']);
- $sOldTableName = $aReportTable['REP_TAB_NAME'];
- $sOldConnection = $aReportTable['REP_TAB_CONNECTION'];
-}
-else {
- $sOldTableName = $values['REP_TAB_NAME'];
- $sOldConnection = $values['REP_TAB_CONNECTION'];
- $oReportTable->create($values);
- $values['REP_TAB_UID'] = $oReportTable->getRepTabUid();
+ $aReportTable = $oReportTable->load( $values['REP_TAB_UID'] );
+ $sOldTableName = $aReportTable['REP_TAB_NAME'];
+ $sOldConnection = $aReportTable['REP_TAB_CONNECTION'];
+} else {
+ $sOldTableName = $values['REP_TAB_NAME'];
+ $sOldConnection = $values['REP_TAB_CONNECTION'];
+ $oReportTable->create( $values );
+ $values['REP_TAB_UID'] = $oReportTable->getRepTabUid();
}
-$oReportTable->update($values);
+$oReportTable->update( $values );
$oReportVar = new ReportVar();
$oReportTables = new ReportTables();
-$oReportTables->deleteAllReportVars($values['REP_TAB_UID']);
-$aFields = array();
+$oReportTables->deleteAllReportVars( $values['REP_TAB_UID'] );
+$aFields = array ();
if ($values['REP_TAB_TYPE'] == 'GRID') {
- $aAux = explode('-', $values['REP_TAB_GRID']);
- global $G_FORM;
- $G_FORM = new Form($values['PRO_UID'] . '/' . $aAux[1], PATH_DYNAFORM, SYS_LANG, false);
- $aAux = $G_FORM->getVars(false);
- foreach ($aAux as $aField) {
- $values['FIELDS'][] = $aField['sName'] . '-' . $aField['sType'];
- }
+ $aAux = explode( '-', $values['REP_TAB_GRID'] );
+ global $G_FORM;
+ $G_FORM = new Form( $values['PRO_UID'] . '/' . $aAux[1], PATH_DYNAFORM, SYS_LANG, false );
+ $aAux = $G_FORM->getVars( false );
+ foreach ($aAux as $aField) {
+ $values['FIELDS'][] = $aField['sName'] . '-' . $aField['sType'];
+ }
}
foreach ($values['FIELDS'] as $sField) {
- $aField = explode('-', $sField);
- switch ($aField[1]) {
- case 'currency':
- case 'percentage':
- $sType = 'number';
- break;
- case 'text':
- case 'password':
- case 'dropdown':
- case 'yesno':
- case 'checkbox':
- case 'radiogroup':
- case 'hidden':
- $sType = 'char';
- break;
- case 'textarea':
- $sType = 'text';
- break;
- case 'date':
- $sType = 'date';
- break;
- default:
- $sType = 'char';
- break;
- }
- $oReportVar->create(array('REP_TAB_UID' => $values['REP_TAB_UID'],
- 'PRO_UID' => $values['PRO_UID'],
- 'REP_VAR_NAME' => $aField[0],
- 'REP_VAR_TYPE' => $sType));
- $aFields[] = array('sFieldName' => $aField[0], 'sType' => $sType);
+ $aField = explode( '-', $sField );
+ switch ($aField[1]) {
+ case 'currency':
+ case 'percentage':
+ $sType = 'number';
+ break;
+ case 'text':
+ case 'password':
+ case 'dropdown':
+ case 'yesno':
+ case 'checkbox':
+ case 'radiogroup':
+ case 'hidden':
+ $sType = 'char';
+ break;
+ case 'textarea':
+ $sType = 'text';
+ break;
+ case 'date':
+ $sType = 'date';
+ break;
+ default:
+ $sType = 'char';
+ break;
+ }
+ $oReportVar->create( array ('REP_TAB_UID' => $values['REP_TAB_UID'],'PRO_UID' => $values['PRO_UID'],'REP_VAR_NAME' => $aField[0],'REP_VAR_TYPE' => $sType
+ ) );
+ $aFields[] = array ('sFieldName' => $aField[0],'sType' => $sType
+ );
}
-$oReportTables->dropTable($sOldTableName, $sOldConnection);
-$oReportTables->createTable($values['REP_TAB_NAME'], $values['REP_TAB_CONNECTION'], $values['REP_TAB_TYPE'], $aFields);
-$oReportTables->populateTable($values['REP_TAB_NAME'], $values['REP_TAB_CONNECTION'], $values['REP_TAB_TYPE'], $aFields, $values['PRO_UID'], $values['REP_TAB_GRID']);
+$oReportTables->dropTable( $sOldTableName, $sOldConnection );
+$oReportTables->createTable( $values['REP_TAB_NAME'], $values['REP_TAB_CONNECTION'], $values['REP_TAB_TYPE'], $aFields );
+$oReportTables->populateTable( $values['REP_TAB_NAME'], $values['REP_TAB_CONNECTION'], $values['REP_TAB_TYPE'], $aFields, $values['PRO_UID'], $values['REP_TAB_GRID'] );
?>