CODE STYLE workflow/engine/methods/reportTables/

FILES:
edit.php
main.php
reportTables_Ajax.php
reportTables_Delete.php
reportTables_Edit.php
reportTables_Save.php
This commit is contained in:
jennylee
2012-10-17 12:35:18 -04:00
parent c1f29f8729
commit 2ba2258eea
6 changed files with 639 additions and 694 deletions

View File

@@ -1,80 +1,75 @@
<?php
$id = isset($_GET['id']) ? $_GET['id'] : false;
$id = isset( $_GET['id'] ) ? $_GET['id'] : false;
$table = false;
$oHeadPublisher =& headPublisher::getSingleton();
$oHeadPublisher = & headPublisher::getSingleton();
$oHeadPublisher->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' );

View File

@@ -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 <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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' );

File diff suppressed because it is too large Load Diff

View File

@@ -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 <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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 );
?>

View File

@@ -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 <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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' );
?>

View File

@@ -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 <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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'] );
?>