From c00514f237e6733d6d809aa23ca278cc03ab30b0 Mon Sep 17 00:00:00 2001 From: Erik Amaru Ortiz Date: Wed, 12 Oct 2011 19:05:14 -0400 Subject: [PATCH] BUG 7835 "PMTables Importing issue" SOLVED --- workflow/engine/classes/class.pmTable.php | 6 +- workflow/engine/controllers/pmTablesProxy.php | 38 ++++-- workflow/engine/templates/pmTables/data.js | 119 +++++++++++------- workflow/engine/templates/pmTables/list.js | 57 +++++---- workflow/public_html/images/database-tool.png | Bin 0 -> 495 bytes 5 files changed, 144 insertions(+), 76 deletions(-) create mode 100644 workflow/public_html/images/database-tool.png diff --git a/workflow/engine/classes/class.pmTable.php b/workflow/engine/classes/class.pmTable.php index 011c24750..d65ccc560 100755 --- a/workflow/engine/classes/class.pmTable.php +++ b/workflow/engine/classes/class.pmTable.php @@ -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; @@ -192,10 +192,6 @@ class PmTable if (is_object($this->dom)) { 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; diff --git a/workflow/engine/controllers/pmTablesProxy.php b/workflow/engine/controllers/pmTablesProxy.php index 4accc3fd6..e32ed53b0 100755 --- a/workflow/engine/controllers/pmTablesProxy.php +++ b/workflow/engine/controllers/pmTablesProxy.php @@ -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': @@ -877,10 +883,9 @@ class pmTablesProxy extends HttpProxyController $oAdditionalTables = new AdditionalTables(); $table = $oAdditionalTables->loadByName($tableName); $isReport = $table['PRO_UID'] !== '' ? true : false; - + 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 diff --git a/workflow/engine/templates/pmTables/data.js b/workflow/engine/templates/pmTables/data.js index f8cf1f0be..ea4c45bf2 100755 --- a/workflow/engine/templates/pmTables/data.js +++ b/workflow/engine/templates/pmTables/data.js @@ -56,6 +56,14 @@ Ext.onReady(function(){ icon : '/images/export.png', 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'), @@ -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 @@ -144,29 +151,30 @@ Ext.onReady(function(){ } - smodel = new Ext.grid.CheckboxSelectionModel({ - listeners:{ - selectionchange : function(sm){ - var count_rows = sm.getCount(); - switch(count_rows){ - case 0: - editButton.disable(); - deleteButton.disable(); - break; - case 1: - if (!isReport) { + smodel = new Ext.grid.CheckboxSelectionModel({ + listeners:{ + selectionchange : function(sm){ + if (isReport) return; + + var count_rows = sm.getCount(); + switch(count_rows){ + case 0: + editButton.disable(); + deleteButton.disable(); + break; + case 1: editButton.enable(); deleteButton.enable(); - } - break; - default: - editButton.disable(); - //deleteButton.disable(); - break; - } - } - } - }); + + break; + default: + editButton.disable(); + //deleteButton.disable(); + break; + } + } + } + }); //row editor for table columns grid if (!isReport) { @@ -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,16 +328,18 @@ Ext.onReady(function(){ infoGrid = new Ext.grid.GridPanel(infoGridConfig); - infoGrid.on('rowcontextmenu', - function (grid, rowIndex, evt) { - var sm = grid.getSelectionModel(); - sm.selectRow(rowIndex, sm.isSelected(rowIndex)); - }, - this - ); - - infoGrid.on('contextmenu', function(evt){evt.preventDefault();}, this); - infoGrid.addListener('rowcontextmenu',onMessageContextMenu, this); + if (!isReport) { + infoGrid.on('rowcontextmenu', + function (grid, rowIndex, evt) { + var sm = grid.getSelectionModel(); + sm.selectRow(rowIndex, sm.isSelected(rowIndex)); + }, + this + ); + + infoGrid.on('contextmenu', function(evt){evt.preventDefault();}, this); + infoGrid.addListener('rowcontextmenu',onMessageContextMenu, this); + } viewport = new Ext.Viewport({ layout: 'fit', @@ -650,4 +667,20 @@ UpdatePageConfig = function(pageSize){ url: 'additionalTablesAjax', params: {action:'updatePageSizeData', size: pageSize} }); -}; \ No newline at end of file +}; + +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); + } + }); +} \ No newline at end of file diff --git a/workflow/engine/templates/pmTables/list.js b/workflow/engine/templates/pmTables/list.js index 8ca0d74cb..ebc3fb4ec 100755 --- a/workflow/engine/templates/pmTables/list.js +++ b/workflow/engine/templates/pmTables/list.js @@ -15,6 +15,7 @@ var smodel; var rowsSelected; var importOption; var externalOption; +var currentSelectedRow = -1; Ext.onReady(function(){ ///Keyboard Events @@ -199,32 +200,46 @@ 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){ - var count_rows = sm.getCount(); - switch(count_rows){ - case 0: - editButton.disable(); - deleteButton.disable(); - exportButton.disable(); - dataButton.disable(); - break; - case 1: - editButton.enable(); - deleteButton.enable(); - exportButton.enable(); - dataButton.enable(); - break; - default: - editButton.disable(); - deleteButton.enable(); - exportButton.enable(); - dataButton.disable(); - break; + 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(); + deleteButton.disable(); + exportButton.disable(); + dataButton.disable(); + break; + case 1: + editButton.enable(); + deleteButton.enable(); + exportButton.enable(); + dataButton.enable(); + break; + default: + editButton.disable(); + deleteButton.enable(); + exportButton.enable(); + dataButton.disable(); + break; + } + } } } diff --git a/workflow/public_html/images/database-tool.png b/workflow/public_html/images/database-tool.png new file mode 100644 index 0000000000000000000000000000000000000000..654abe5b94f20badcd509253df91033c2474fded GIT binary patch literal 495 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1Ig0|7oEt_-mZ zEfePc|NsBx4PWwjA2L|BUJ;$^ZWu7~B|s|M~mq#ryNu?+Y*H z+JExW{ikof{rJ_;HSO~4$AA9*d-LJ*&tJc@OX?mxef{Fihimtqeg68rwqx?|KY#oV zs#i4ie)#%;@Ht{drcVuaC;* z@AX#v=@zpmT&hoj<}qPD5cOq4=Rxaog)rv&oDRV(h2r-O4=g4w zmk20+yYuj2_n9+|Ry2xS-m^L^va!7T|H>QstMBpqoO){80CXmUr>mdKI;Vst0DVH( AAOHXW literal 0 HcmV?d00001