Saving REport tables in Extjs
This commit is contained in:
@@ -8,7 +8,7 @@ try
|
|||||||
$rows = $oProcessMap->getExtReportTables($_GET['pid']);
|
$rows = $oProcessMap->getExtReportTables($_GET['pid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(isset($_GET['pid']) && $_GET['type'] == 'global')
|
else if(isset($_GET['pid']) && $_GET['type'] == 'NORMAL')
|
||||||
{
|
{
|
||||||
$aTheFields = array();
|
$aTheFields = array();
|
||||||
$aTheFields = getDynaformsVars($_GET['pid'], false);
|
$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 = array();
|
||||||
$aTheFields = getGridsVars($_GET['pid']);
|
$aTheFields = getGridsVars($_GET['pid']);
|
||||||
foreach ($aTheFields as $aField) {
|
foreach ($aTheFields as $aField) {
|
||||||
|
|||||||
@@ -25,42 +25,47 @@
|
|||||||
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']))
|
if(isset($_POST['form']))
|
||||||
$value= $_POST['form'];
|
$values = $_POST['form']; //For Old processmap
|
||||||
else
|
else
|
||||||
$value=$_POST;
|
{
|
||||||
|
$values = $_POST; //For extjs,since we are not using form
|
||||||
|
$values['FIELDS'] = explode(',',$_POST['FIELDS']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$oReportTable = new ReportTable();
|
$oReportTable = new ReportTable();
|
||||||
if (!isset($value['REP_TAB_CONNECTION'])) {
|
if (!isset($values['REP_TAB_CONNECTION'])) {
|
||||||
$value['REP_TAB_CONNECTION'] = 'report';
|
$values['REP_TAB_CONNECTION'] = 'report';
|
||||||
}
|
}
|
||||||
if ($value['REP_TAB_UID'] != '') {
|
if ($values['REP_TAB_UID'] != '') {
|
||||||
$aReportTable = $oReportTable->load($value['REP_TAB_UID']);
|
$aReportTable = $oReportTable->load($values['REP_TAB_UID']);
|
||||||
$sOldTableName = $aReportTable['REP_TAB_NAME'];
|
$sOldTableName = $aReportTable['REP_TAB_NAME'];
|
||||||
$sOldConnection = $aReportTable['REP_TAB_CONNECTION'];
|
$sOldConnection = $aReportTable['REP_TAB_CONNECTION'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sOldTableName = $value['REP_TAB_NAME'];
|
$sOldTableName = $values['REP_TAB_NAME'];
|
||||||
$sOldConnection = $value['REP_TAB_CONNECTION'];
|
$sOldConnection = $values['REP_TAB_CONNECTION'];
|
||||||
$oReportTable->create($value);
|
$oReportTable->create($values);
|
||||||
$value['REP_TAB_UID'] = $oReportTable->getRepTabUid();
|
$values['REP_TAB_UID'] = $oReportTable->getRepTabUid();
|
||||||
}
|
}
|
||||||
|
|
||||||
$oReportTable->update($value);
|
$oReportTable->update($values);
|
||||||
$oReportVar = new ReportVar();
|
$oReportVar = new ReportVar();
|
||||||
$oReportTables = new ReportTables();
|
$oReportTables = new ReportTables();
|
||||||
$oReportTables->deleteAllReportVars($value['REP_TAB_UID']);
|
$oReportTables->deleteAllReportVars($values['REP_TAB_UID']);
|
||||||
$aFields = array();
|
$aFields = array();
|
||||||
if ($value['REP_TAB_TYPE'] == 'GRID') {
|
if ($values['REP_TAB_TYPE'] == 'GRID') {
|
||||||
$aAux = explode('-', $value['REP_TAB_GRID']);
|
$aAux = explode('-', $values['REP_TAB_GRID']);
|
||||||
global $G_FORM;
|
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);
|
$aAux = $G_FORM->getVars(false);
|
||||||
foreach ($aAux as $aField) {
|
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);
|
$aField = explode('-', $sField);
|
||||||
switch ($aField[1]) {
|
switch ($aField[1]) {
|
||||||
case 'currency':
|
case 'currency':
|
||||||
@@ -86,13 +91,13 @@ foreach ($value['FIELDS'] as $sField) {
|
|||||||
$sType = 'char';
|
$sType = 'char';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$oReportVar->create(array('REP_TAB_UID' => $value['REP_TAB_UID'],
|
$oReportVar->create(array('REP_TAB_UID' => $values['REP_TAB_UID'],
|
||||||
'PRO_UID' => $value['PRO_UID'],
|
'PRO_UID' => $values['PRO_UID'],
|
||||||
'REP_VAR_NAME' => $aField[0],
|
'REP_VAR_NAME' => $aField[0],
|
||||||
'REP_VAR_TYPE' => $sType));
|
'REP_VAR_TYPE' => $sType));
|
||||||
$aFields[] = array('sFieldName' => $aField[0], 'sType' => $sType);
|
$aFields[] = array('sFieldName' => $aField[0], 'sType' => $sType);
|
||||||
}
|
}
|
||||||
$oReportTables->dropTable($sOldTableName, $sOldConnection);
|
$oReportTables->dropTable($sOldTableName, $sOldConnection);
|
||||||
$oReportTables->createTable($value['REP_TAB_NAME'], $value['REP_TAB_CONNECTION'], $value['REP_TAB_TYPE'], $aFields);
|
$oReportTables->createTable($values['REP_TAB_NAME'], $values['REP_TAB_CONNECTION'], $values['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->populateTable($values['REP_TAB_NAME'], $values['REP_TAB_CONNECTION'], $values['REP_TAB_TYPE'], $aFields, $values['PRO_UID'], $values['REP_TAB_GRID']);
|
||||||
?>
|
?>
|
||||||
@@ -2018,12 +2018,20 @@ ProcessOptions.prototype.addReportTable= function(_5625)
|
|||||||
name: 'REP_TAB_TITLE',
|
name: 'REP_TAB_TITLE',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'REP_TAB_UID',
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'FIELD_NAME',
|
name: 'FIELD_NAME',
|
||||||
type: 'string'
|
type: 'string'
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
var editor = new Ext.ux.grid.RowEditor({
|
||||||
|
saveText: 'Update'
|
||||||
|
});
|
||||||
|
|
||||||
var reportStore = new Ext.data.JsonStore({
|
var reportStore = new Ext.data.JsonStore({
|
||||||
root : 'data',
|
root : 'data',
|
||||||
totalProperty: 'totalCount',
|
totalProperty: 'totalCount',
|
||||||
@@ -2043,7 +2051,7 @@ ProcessOptions.prototype.addReportTable= function(_5625)
|
|||||||
id: 'REP_TAB_TITLE',
|
id: 'REP_TAB_TITLE',
|
||||||
header: 'Title',
|
header: 'Title',
|
||||||
dataIndex: 'REP_TAB_TITLE',
|
dataIndex: 'REP_TAB_TITLE',
|
||||||
width: 280,
|
width: 380,
|
||||||
editable: false,
|
editable: false,
|
||||||
editor: new Ext.form.TextField({
|
editor: new Ext.form.TextField({
|
||||||
//allowBlank: false
|
//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({
|
var tb = new Ext.Toolbar({
|
||||||
items: [btnAdd]
|
items: [btnAdd,btnRemove]
|
||||||
});
|
});
|
||||||
|
|
||||||
var reportGrid = new Ext.grid.GridPanel({
|
var reportGrid = new Ext.grid.GridPanel({
|
||||||
@@ -2076,20 +2115,20 @@ ProcessOptions.prototype.addReportTable= function(_5625)
|
|||||||
frame : false,
|
frame : false,
|
||||||
autoHeight :false,
|
autoHeight :false,
|
||||||
clicksToEdit: 1,
|
clicksToEdit: 1,
|
||||||
minHeight :400,
|
width :400,
|
||||||
height :400,
|
height :400,
|
||||||
layout : 'fit',
|
layout : 'fit',
|
||||||
cm : reportColumns,
|
cm : reportColumns,
|
||||||
stripeRows: true,
|
stripeRows: true,
|
||||||
tbar : tb
|
tbar: tb,
|
||||||
//viewConfig : {forceFit: true}
|
viewConfig: {forceFit: true}
|
||||||
});
|
});
|
||||||
|
|
||||||
var gridWindow = new Ext.Window({
|
var gridWindow = new Ext.Window({
|
||||||
title : 'Report Tables',
|
title : 'Report Tables',
|
||||||
collapsible : false,
|
collapsible : false,
|
||||||
maximizable : false,
|
maximizable : false,
|
||||||
width : 550,
|
width : 400,
|
||||||
defaults :{ autoScroll:true },
|
defaults :{ autoScroll:true },
|
||||||
height : 450,
|
height : 450,
|
||||||
minWidth : 200,
|
minWidth : 200,
|
||||||
@@ -2103,15 +2142,14 @@ ProcessOptions.prototype.addReportTable= function(_5625)
|
|||||||
gridWindow.show();
|
gridWindow.show();
|
||||||
|
|
||||||
var reportForm =new Ext.FormPanel({
|
var reportForm =new Ext.FormPanel({
|
||||||
// title:"Add new Database Source",
|
|
||||||
collapsible: false,
|
collapsible: false,
|
||||||
maximizable: true,
|
maximizable: true,
|
||||||
width:450,
|
width:450,
|
||||||
|
height:380,
|
||||||
frame:true,
|
frame:true,
|
||||||
plain: true,
|
plain: true,
|
||||||
bodyStyle: 'padding:5px;',
|
bodyStyle: 'padding:5px;',
|
||||||
buttonAlign: 'center',
|
buttonAlign: 'center',
|
||||||
|
|
||||||
items:[{
|
items:[{
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
fieldLabel: 'Title',
|
fieldLabel: 'Title',
|
||||||
@@ -2124,10 +2162,7 @@ var reportForm =new Ext.FormPanel({
|
|||||||
name: 'REP_TAB_NAME',
|
name: 'REP_TAB_NAME',
|
||||||
allowBlank: false
|
allowBlank: false
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
xtype: 'combo',
|
xtype: 'combo',
|
||||||
width: 150,
|
width: 150,
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
@@ -2137,18 +2172,17 @@ var reportForm =new Ext.FormPanel({
|
|||||||
forceSelection: true,
|
forceSelection: true,
|
||||||
name: 'REP_TAB_TYPE',
|
name: 'REP_TAB_TYPE',
|
||||||
displayField: 'name',
|
displayField: 'name',
|
||||||
//emptyText : 'Select Format',
|
|
||||||
valueField : 'value',
|
valueField : 'value',
|
||||||
value : 'global',
|
value : 'global',
|
||||||
store: new Ext.data.JsonStore({
|
store: new Ext.data.JsonStore({
|
||||||
fields : ['name', 'value'],
|
fields : ['name', 'value'],
|
||||||
data : [
|
data : [
|
||||||
{name : 'Global', value: 'global'},
|
{name : 'Global', value: 'NORMAL'},
|
||||||
{name : 'Grid', value: 'grid'}
|
{name : 'Grid', value: 'GRID'}
|
||||||
]}),
|
]}),
|
||||||
onSelect: function(record, index) {
|
onSelect: function(record, index) {
|
||||||
//Show-Hide Format Type Field
|
//Show-Hide Format Type Field
|
||||||
if(record.data.value == 'global')
|
if(record.data.value == 'NORMAL')
|
||||||
{
|
{
|
||||||
Ext.getCmp("fields").show();
|
Ext.getCmp("fields").show();
|
||||||
Ext.getCmp("gridfields").hide();
|
Ext.getCmp("gridfields").hide();
|
||||||
@@ -2173,7 +2207,7 @@ var reportForm =new Ext.FormPanel({
|
|||||||
hidden: false,
|
hidden: false,
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'multiselect',
|
xtype: 'multiselect',
|
||||||
width: 150,
|
width: 200,
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
editable:true,
|
editable:true,
|
||||||
fieldLabel: 'Fields',
|
fieldLabel: 'Fields',
|
||||||
@@ -2185,14 +2219,7 @@ var reportForm =new Ext.FormPanel({
|
|||||||
valueField: 'FIELD_NAME',
|
valueField: 'FIELD_NAME',
|
||||||
displayField: 'FIELD_NAME',
|
displayField: 'FIELD_NAME',
|
||||||
store: reportStore
|
store: reportStore
|
||||||
|
|
||||||
//text: 'clear',
|
|
||||||
|
|
||||||
}]
|
}]
|
||||||
//displayField: 'name',
|
|
||||||
//emptyText : 'Select Format',
|
|
||||||
// valueField : 'value',
|
|
||||||
// value : 'Select'
|
|
||||||
}, {
|
}, {
|
||||||
xtype: 'fieldset',
|
xtype: 'fieldset',
|
||||||
id: 'gridfields',
|
id: 'gridfields',
|
||||||
@@ -2202,47 +2229,27 @@ var reportForm =new Ext.FormPanel({
|
|||||||
xtype: 'combo',
|
xtype: 'combo',
|
||||||
width: 150,
|
width: 150,
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
// hidden: true,
|
|
||||||
editable:false,
|
editable:false,
|
||||||
fieldLabel: 'Grid Fields',
|
fieldLabel: 'Grid Fields',
|
||||||
triggerAction: 'all',
|
triggerAction: 'all',
|
||||||
forceSelection: true,
|
forceSelection: true,
|
||||||
//dataIndex : 'ENGINE',
|
|
||||||
displayField: 'name',
|
displayField: 'name',
|
||||||
valueField: 'value',
|
valueField: 'value',
|
||||||
name: 'DBS_ENCODE',
|
name: 'REP_TAB_GRID',
|
||||||
store: new Ext.data.JsonStore({
|
store: new Ext.data.JsonStore({
|
||||||
fields : ['name', 'value'],
|
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({
|
var formWindow = new Ext.Window({
|
||||||
title: 'New Report Table',
|
title: 'New Report Table',
|
||||||
collapsible: false,
|
collapsible: false,
|
||||||
maximizable: true,
|
maximizable: true,
|
||||||
width: 450,
|
width: 400,
|
||||||
//autoHeight: true,
|
//autoHeight: true,
|
||||||
height: 400,
|
height: 400,
|
||||||
//layout: 'fit',
|
//layout: 'fit',
|
||||||
@@ -2258,11 +2265,16 @@ var formWindow = new Ext.Window({
|
|||||||
var Title = getForm.REP_TAB_TITLE;
|
var Title = getForm.REP_TAB_TITLE;
|
||||||
var Name = getForm.REP_TAB_NAME;
|
var Name = getForm.REP_TAB_NAME;
|
||||||
var Type = getForm.REP_TAB_TYPE;
|
var Type = getForm.REP_TAB_TYPE;
|
||||||
|
if(Type == 'Global')
|
||||||
|
Type = 'NORMAL';
|
||||||
|
else
|
||||||
|
Type = 'GRID';
|
||||||
|
|
||||||
var Grid = getForm.REP_TAB_GRID;
|
var Grid = getForm.REP_TAB_GRID;
|
||||||
var Fields = getForm.FIELDS;
|
var Fields = getForm.FIELDS;
|
||||||
// var VariableName = getForm.REP_VAR_NAME;
|
// var VariableName = getForm.REP_VAR_NAME;
|
||||||
// var VariableType = getForm.REP_VAR_TYPE;
|
// var VariableType = getForm.REP_VAR_TYPE;
|
||||||
var Connection = getForm.REP_TAB_CONNECTION
|
// var Connection = getForm.REP_TAB_CONNECTION
|
||||||
|
|
||||||
|
|
||||||
Ext.Ajax.request({
|
Ext.Ajax.request({
|
||||||
@@ -2270,15 +2282,15 @@ var formWindow = new Ext.Window({
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
params:{
|
params:{
|
||||||
PRO_UID :pro_uid,
|
PRO_UID :pro_uid,
|
||||||
REP_TAB_UID :tableUID,
|
REP_TAB_UID :'',
|
||||||
REP_TAB_TITLE :Title,
|
REP_TAB_TITLE :Title,
|
||||||
REP_TAB_NAME :Name,
|
REP_TAB_NAME :Name,
|
||||||
REP_TAB_TYPE :Type ,
|
REP_TAB_TYPE :Type ,
|
||||||
REP_TAB_GRID :Grid,
|
REP_TAB_GRID :Grid,
|
||||||
FIELDS :Fields,
|
FIELDS :Fields
|
||||||
//REP_VAR_NAME : VariableName,
|
//REP_VAR_NAME : VariableName,
|
||||||
//REP_VAR_TYPE : VariableType,
|
//REP_VAR_TYPE : VariableType,
|
||||||
REP_TAB_CONNECTION: Connection
|
//REP_TAB_CONNECTION: Connection
|
||||||
|
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
|
|||||||
Reference in New Issue
Block a user