BUG 7835 "PMTables Importing issue" SOLVED

This commit is contained in:
Erik Amaru Ortiz
2011-10-12 19:05:14 -04:00
parent 5b5699dcf5
commit c00514f237
5 changed files with 144 additions and 76 deletions

View File

@@ -83,7 +83,7 @@ class PmTable
{
$this->dataSource = self::resolveDbSource($dbsUid);
switch ($dbsUid) {
switch ($this->dataSource) {
case 'workflow':
$this->dbConfig->adapter= DB_ADAPTER;
$this->dbConfig->host = DB_HOST;
@@ -193,10 +193,6 @@ class PmTable
return true;
}
if ($this->dataSource == '' || $this->dataSource == 'wf' || !$this->dataSource) {
$this->dataSource = 'workflow';
}
$this->schemaFilename = 'schema.xml';
$this->baseDir = PATH_DB . SYS_SYS . PATH_SEP;
$this->targetDir = $this->baseDir . 'pmt-propel' . PATH_SEP . $this->dataSource . PATH_SEP;

View File

@@ -725,7 +725,7 @@ class pmTablesProxy extends HttpProxyController
$fileContent = file_get_contents($PUBLIC_ROOT_PATH.$filename);
if(strpos($fileContent, '-----== ProcessMaker Open Source Private Tables ==-----') === false) {
throw new Exception('ID_PMTABLE_INVALID_FILE');
throw new Exception(G::loadTranslation('ID_PMTABLE_INVALID_FILE'));
}
$fp = fopen($PUBLIC_ROOT_PATH.$filename, "rb");
@@ -862,6 +862,12 @@ class pmTablesProxy extends HttpProxyController
$uid = fread($fp, $fsUid);
$fsData = intval(fread($fp, 9));
$schema = fread($fp, $fsData);
$contentSchema = unserialize($schema);
$additionalTable = new additionalTables();
$table = $additionalTable->loadByName($tableNameMap[$contentSchema['ADD_TAB_NAME']]);
if ($table['PRO_UID'] != '') { // is a report table, try populate it
$additionalTable->populateReportTable($table['ADD_TAB_NAME'], pmTable::resolveDbSource($table['DBS_UID']), $table['ADD_TAB_TYPE'], $table['PRO_UID'], $table['ADD_TAB_GRID']);
}
break;
case '@DATA':
@@ -880,7 +886,6 @@ class pmTablesProxy extends HttpProxyController
if ($table !== false) {
if (!$isReport) {
//////////data
if (count($contentData) > 0) {
foreach ($contentData as $row) {
$data = new StdClass();
@@ -892,10 +897,6 @@ class pmTablesProxy extends HttpProxyController
}
}
}
////////////
}
else { // is a report table
$oAdditionalTables->populateReportTable($tablename, $table['DBS_UID'], $table['ADD_TAB_TYPE'], $table['PRO_UID'], $table['ADD_TAB_GRID']);
}
}
}
@@ -1207,6 +1208,29 @@ class pmTablesProxy extends HttpProxyController
}
}
public function genDataReport($httpData)
{
G::loadClass('pmTable');
require_once 'classes/model/AdditionalTables.php';
$result->message = '';
$result->success = true;
$additionalTables = new AdditionalTables();
$table = $additionalTables->load($httpData->id);
if ($table['PRO_UID'] != '') {
$additionalTables->populateReportTable(
$table['ADD_TAB_NAME'],
pmTable::resolveDbSource($table['DBS_UID']),
$table['ADD_TAB_TYPE'],
$table['PRO_UID'],
$table['ADD_TAB_GRID']
);
$result->message = 'generated for table '.$table['ADD_TAB_NAME'];
}
return $result;
}
/**
* Get report table default columns
* @param $type

View File

@@ -57,6 +57,14 @@ Ext.onReady(function(){
handler : ExportPMTableCSV
});
genDataReportButton = new Ext.Action({
text: 'Regenerate Data Report',
iconCls: 'silk-add',
icon: '/images/database-tool.png',
handler: genDataReport,
disabled: false
});
backButton = new Ext.Action({
text : _('ID_BACK'),
icon : '/images/back-icon.png',
@@ -64,8 +72,7 @@ Ext.onReady(function(){
});
contextMenu = new Ext.menu.Menu({
items : [ editButton,
deleteButton ]
items : [ editButton, deleteButton ]
});
//This loop loads columns and fields to store and column model
@@ -147,6 +154,8 @@ Ext.onReady(function(){
smodel = new Ext.grid.CheckboxSelectionModel({
listeners:{
selectionchange : function(sm){
if (isReport) return;
var count_rows = sm.getCount();
switch(count_rows){
case 0:
@@ -154,10 +163,9 @@ Ext.onReady(function(){
deleteButton.disable();
break;
case 1:
if (!isReport) {
editButton.enable();
deleteButton.enable();
}
break;
default:
editButton.disable();
@@ -274,6 +282,21 @@ Ext.onReady(function(){
items: ['-',_('ID_PAGE_SIZE')+':',comboPageSize]
});
if (!isReport) {
tbar = [
newButton,
'-',
editButton,
deleteButton,
'-',
importButton,
exportButton
];
}
else
tbar = [genDataReportButton];
infoGridConfig = {
region: 'center',
layout: 'fit',
@@ -294,15 +317,7 @@ Ext.onReady(function(){
loadMask: true,
cm: cmodel,
sm: smodel,
tbar:[
newButton,
'-',
editButton,
deleteButton,
'-',
importButton,
exportButton
],
tbar: tbar,
bbar: bbarpaging
}
@@ -313,6 +328,7 @@ Ext.onReady(function(){
infoGrid = new Ext.grid.GridPanel(infoGridConfig);
if (!isReport) {
infoGrid.on('rowcontextmenu',
function (grid, rowIndex, evt) {
var sm = grid.getSelectionModel();
@@ -323,6 +339,7 @@ Ext.onReady(function(){
infoGrid.on('contextmenu', function(evt){evt.preventDefault();}, this);
infoGrid.addListener('rowcontextmenu',onMessageContextMenu, this);
}
viewport = new Ext.Viewport({
layout: 'fit',
@@ -651,3 +668,19 @@ UpdatePageConfig = function(pageSize){
params: {action:'updatePageSizeData', size: pageSize}
});
};
genDataReport = function()
{
Ext.Ajax.request({
url: '../pmTablesProxy/genDataReport',
params: {id: tableDef.ADD_TAB_UID},
success: function(resp){
response = Ext.util.JSON.decode(resp.responseText);
PMExt.notify(_('ID_UPDATE'), response.message)
Ext.getCmp('infoGrid').store.reload();
},
failure: function(obj, resp){
PMExt.error( _('ID_ERROR'), resp.result.message);
}
});
}

View File

@@ -15,6 +15,7 @@ var smodel;
var rowsSelected;
var importOption;
var externalOption;
var currentSelectedRow = -1;
Ext.onReady(function(){
///Keyboard Events
@@ -199,13 +200,25 @@ Ext.onReady(function(){
{name : 'PRO_UID'},
{name : 'NUM_ROWS'}
]
})
}),
listeners: {
load: function(a,b){
if (currentSelectedRow != '') {
Ext.getCmp('infoGrid').getSelectionModel().selectRow(currentSelectedRow);
Ext.getCmp('infoGrid').fireEvent('rowclick', Ext.getCmp('infoGrid'), currentSelectedRow)
}
}
}
});
smodel = new Ext.grid.CheckboxSelectionModel({
listeners:{
selectionchange: function(sm){
if (sm.last !== false) {
var count_rows = sm.getCount();
//var isReport = sm.getSelected().get('PRO_UID') != '';
currentSelectedRow = sm.last;
switch(count_rows){
case 0:
editButton.disable();
@@ -226,6 +239,8 @@ Ext.onReady(function(){
dataButton.disable();
break;
}
}
}
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B