Saving REport tables in Extjs

This commit is contained in:
safan
2011-01-03 14:44:06 +00:00
parent 2b521ce65d
commit 99e5f70665
3 changed files with 149 additions and 132 deletions

View File

@@ -8,7 +8,7 @@ try
$rows = $oProcessMap->getExtReportTables($_GET['pid']);
}
else if(isset($_GET['pid']) && $_GET['type'] == 'global')
else if(isset($_GET['pid']) && $_GET['type'] == 'NORMAL')
{
$aTheFields = array();
$aTheFields = getDynaformsVars($_GET['pid'], false);
@@ -18,7 +18,7 @@ try
}
}
else if(isset($_GET['pid']) && $_GET['type'] == 'grid'){
else if(isset($_GET['pid']) && $_GET['type'] == 'GRID'){
$aTheFields = array();
$aTheFields = getGridsVars($_GET['pid']);
foreach ($aTheFields as $aField) {

View File

@@ -25,42 +25,47 @@
if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response;
G::LoadClass('reportTables');
if(isset($_POST['form']))
$value= $_POST['form'];
else
$value=$_POST;
$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($value['REP_TAB_CONNECTION'])) {
$value['REP_TAB_CONNECTION'] = 'report';
if (!isset($values['REP_TAB_CONNECTION'])) {
$values['REP_TAB_CONNECTION'] = 'report';
}
if ($value['REP_TAB_UID'] != '') {
$aReportTable = $oReportTable->load($value['REP_TAB_UID']);
if ($values['REP_TAB_UID'] != '') {
$aReportTable = $oReportTable->load($values['REP_TAB_UID']);
$sOldTableName = $aReportTable['REP_TAB_NAME'];
$sOldConnection = $aReportTable['REP_TAB_CONNECTION'];
}
else {
$sOldTableName = $value['REP_TAB_NAME'];
$sOldConnection = $value['REP_TAB_CONNECTION'];
$oReportTable->create($value);
$value['REP_TAB_UID'] = $oReportTable->getRepTabUid();
$sOldTableName = $values['REP_TAB_NAME'];
$sOldConnection = $values['REP_TAB_CONNECTION'];
$oReportTable->create($values);
$values['REP_TAB_UID'] = $oReportTable->getRepTabUid();
}
$oReportTable->update($value);
$oReportTable->update($values);
$oReportVar = new ReportVar();
$oReportTables = new ReportTables();
$oReportTables->deleteAllReportVars($value['REP_TAB_UID']);
$oReportTables->deleteAllReportVars($values['REP_TAB_UID']);
$aFields = array();
if ($value['REP_TAB_TYPE'] == 'GRID') {
$aAux = explode('-', $value['REP_TAB_GRID']);
if ($values['REP_TAB_TYPE'] == 'GRID') {
$aAux = explode('-', $values['REP_TAB_GRID']);
global $G_FORM;
$G_FORM = new Form($value['PRO_UID'] . '/' . $aAux[1], PATH_DYNAFORM, SYS_LANG, false);
$G_FORM = new Form($values['PRO_UID'] . '/' . $aAux[1], PATH_DYNAFORM, SYS_LANG, false);
$aAux = $G_FORM->getVars(false);
foreach ($aAux as $aField) {
$value['FIELDS'][] = $aField['sName'] . '-' . $aField['sType'];
$values['FIELDS'][] = $aField['sName'] . '-' . $aField['sType'];
}
}
foreach ($value['FIELDS'] as $sField) {
foreach ($values['FIELDS'] as $sField) {
$aField = explode('-', $sField);
switch ($aField[1]) {
case 'currency':
@@ -86,13 +91,13 @@ foreach ($value['FIELDS'] as $sField) {
$sType = 'char';
break;
}
$oReportVar->create(array('REP_TAB_UID' => $value['REP_TAB_UID'],
'PRO_UID' => $value['PRO_UID'],
$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($value['REP_TAB_NAME'], $value['REP_TAB_CONNECTION'], $value['REP_TAB_TYPE'], $aFields);
$oReportTables->populateTable($value['REP_TAB_NAME'], $value['REP_TAB_CONNECTION'], $value['REP_TAB_TYPE'], $aFields, $value['PRO_UID'], $value['REP_TAB_GRID']);
$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']);
?>

View File

@@ -2018,12 +2018,20 @@ ProcessOptions.prototype.addReportTable= function(_5625)
name: 'REP_TAB_TITLE',
type: 'string'
},
{
name: 'REP_TAB_UID',
type: 'string'
},
{
name: 'FIELD_NAME',
type: 'string'
}
]);
var editor = new Ext.ux.grid.RowEditor({
saveText: 'Update'
});
var reportStore = new Ext.data.JsonStore({
root : 'data',
totalProperty: 'totalCount',
@@ -2043,7 +2051,7 @@ ProcessOptions.prototype.addReportTable= function(_5625)
id: 'REP_TAB_TITLE',
header: 'Title',
dataIndex: 'REP_TAB_TITLE',
width: 280,
width: 380,
editable: false,
editor: new Ext.form.TextField({
//allowBlank: false
@@ -2061,10 +2069,41 @@ ProcessOptions.prototype.addReportTable= function(_5625)
}
});
var btnRemove = new Ext.Button({
id: 'btnAdd',
text: 'Delete Report Table',
iconCls: 'application_add',
handler: function () {
editor.stopEditing();
var s = reportGrid.getSelectionModel().getSelections();
for(var i = 0, r; r = s[i]; i++){
//if REP_TAB_UID is properly defined (i.e. set to valid value) then only delete the row
//else its a BLANK ROW for which Ajax should not be called.
if(r.data.REP_TAB_UID != "")
{
Ext.Ajax.request({
url : '../reportTables/reportTables_Delete.php',
method: 'POST',
params: {
REP_TAB_UID : r.data.REP_TAB_UID
},
success: function(response) {
Ext.MessageBox.alert ('Status','Report Table has been removed successfully.');
//Secondly deleting from Grid
reportGrid.remove(r);
//Reloading store after deleting report table
reportGrid.reload();
}
});
}
}
}
});
var tb = new Ext.Toolbar({
items: [btnAdd]
items: [btnAdd,btnRemove]
});
var reportGrid = new Ext.grid.GridPanel({
@@ -2076,20 +2115,20 @@ ProcessOptions.prototype.addReportTable= function(_5625)
frame : false,
autoHeight :false,
clicksToEdit: 1,
minHeight :400,
width :400,
height :400,
layout : 'fit',
cm : reportColumns,
stripeRows : true,
tbar : tb
//viewConfig : {forceFit: true}
stripeRows: true,
tbar: tb,
viewConfig: {forceFit: true}
});
var gridWindow = new Ext.Window({
title : 'Report Tables',
collapsible : false,
maximizable : false,
width : 550,
width : 400,
defaults :{ autoScroll:true },
height : 450,
minWidth : 200,
@@ -2103,15 +2142,14 @@ ProcessOptions.prototype.addReportTable= function(_5625)
gridWindow.show();
var reportForm =new Ext.FormPanel({
// title:"Add new Database Source",
collapsible: false,
maximizable: true,
width:450,
height:380,
frame:true,
plain: true,
bodyStyle: 'padding:5px;',
buttonAlign: 'center',
items:[{
xtype: 'textfield',
fieldLabel: 'Title',
@@ -2124,10 +2162,7 @@ var reportForm =new Ext.FormPanel({
name: 'REP_TAB_NAME',
allowBlank: false
},
{
xtype: 'combo',
width: 150,
mode: 'local',
@@ -2137,18 +2172,17 @@ var reportForm =new Ext.FormPanel({
forceSelection: true,
name: 'REP_TAB_TYPE',
displayField: 'name',
//emptyText : 'Select Format',
valueField : 'value',
value : 'global',
store: new Ext.data.JsonStore({
fields : ['name', 'value'],
data : [
{name : 'Global', value: 'global'},
{name : 'Grid', value: 'grid'}
{name : 'Global', value: 'NORMAL'},
{name : 'Grid', value: 'GRID'}
]}),
onSelect: function(record, index) {
//Show-Hide Format Type Field
if(record.data.value == 'global')
if(record.data.value == 'NORMAL')
{
Ext.getCmp("fields").show();
Ext.getCmp("gridfields").hide();
@@ -2173,7 +2207,7 @@ var reportForm =new Ext.FormPanel({
hidden: false,
items: [{
xtype: 'multiselect',
width: 150,
width: 200,
mode: 'local',
editable:true,
fieldLabel: 'Fields',
@@ -2185,14 +2219,7 @@ var reportForm =new Ext.FormPanel({
valueField: 'FIELD_NAME',
displayField: 'FIELD_NAME',
store: reportStore
//text: 'clear',
}]
//displayField: 'name',
//emptyText : 'Select Format',
// valueField : 'value',
// value : 'Select'
}, {
xtype: 'fieldset',
id: 'gridfields',
@@ -2202,47 +2229,27 @@ var reportForm =new Ext.FormPanel({
xtype: 'combo',
width: 150,
mode: 'local',
// hidden: true,
editable:false,
fieldLabel: 'Grid Fields',
triggerAction: 'all',
forceSelection: true,
//dataIndex : 'ENGINE',
displayField: 'name',
valueField: 'value',
name: 'DBS_ENCODE',
name: 'REP_TAB_GRID',
store: new Ext.data.JsonStore({
fields : ['name', 'value'],
data : [
]})
data : []
})
}]
}
]
})
var gridWindow = new Ext.Window({
title: 'New Report Table',
collapsible: false,
maximizable: true,
width: 450,
//autoHeight: true,
height: 400,
//layout: 'fit',
plain: true,
bodyStyle: 'padding:5px;',
buttonAlign: 'center',
items: reportGrid
});
gridWindow.show();
var formWindow = new Ext.Window({
title: 'New Report Table',
collapsible: false,
maximizable: true,
width: 450,
width: 400,
//autoHeight: true,
height: 400,
//layout: 'fit',
@@ -2258,11 +2265,16 @@ var formWindow = new Ext.Window({
var Title = getForm.REP_TAB_TITLE;
var Name = getForm.REP_TAB_NAME;
var Type = getForm.REP_TAB_TYPE;
if(Type == 'Global')
Type = 'NORMAL';
else
Type = 'GRID';
var Grid = getForm.REP_TAB_GRID;
var Fields = getForm.FIELDS;
// var VariableName = getForm.REP_VAR_NAME;
// var VariableType = getForm.REP_VAR_TYPE;
var Connection = getForm.REP_TAB_CONNECTION
// var Connection = getForm.REP_TAB_CONNECTION
Ext.Ajax.request({
@@ -2270,15 +2282,15 @@ var formWindow = new Ext.Window({
method: 'POST',
params:{
PRO_UID :pro_uid,
REP_TAB_UID :tableUID,
REP_TAB_UID :'',
REP_TAB_TITLE :Title,
REP_TAB_NAME :Name,
REP_TAB_TYPE :Type ,
REP_TAB_GRID :Grid,
FIELDS :Fields,
FIELDS :Fields
//REP_VAR_NAME : VariableName,
//REP_VAR_TYPE : VariableType,
REP_TAB_CONNECTION: Connection
//REP_TAB_CONNECTION: Connection
},
success: function(response) {