BUG 7835 "Error con los reportables" Solved!
This commit is contained in:
@@ -347,3 +347,8 @@ String.prototype.trim = function() {
|
||||
return this.replace(/^\s+|\s+get/g,"");
|
||||
//return Ext.util.Format.trim(this);
|
||||
}
|
||||
|
||||
String.prototype.nl2br = function () {
|
||||
return this.replace(/\n/g,'<br />');
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ class PmTable
|
||||
$this->prepare($loadSchema);
|
||||
$this->phingbuildModel();
|
||||
$this->phingbuildSql();
|
||||
$this->upgradeDatabaseFor($this->dataSource, $tablesList);
|
||||
//$this->upgradeDatabaseFor($this->dataSource, $tablesList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,7 +349,12 @@ class PmTable
|
||||
$stmt = $con->createStatement();
|
||||
|
||||
if (is_object($con)) {
|
||||
$stmt->executeQuery("DROP TABLE {$tableName}");
|
||||
try {
|
||||
$stmt->executeQuery("DROP TABLE {$tableName}");
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw new Exception("Phisical table '$tableName' does not exist!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,12 +472,13 @@ class PmTable
|
||||
|
||||
}
|
||||
|
||||
public function upgradeDatabaseFor($dataSource, $tablesList)
|
||||
public function upgradeDatabaseFor($dataSource, $tablesList = array())
|
||||
{
|
||||
$con = Propel::getConnection($dataSource);
|
||||
$stmt = $con->createStatement();
|
||||
$lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql');
|
||||
$previous = NULL;
|
||||
$errors = '';
|
||||
|
||||
foreach ($lines as $j => $line) {
|
||||
$line = trim($line); // Remove comments from the script
|
||||
@@ -509,17 +515,27 @@ class PmTable
|
||||
$line = substr($line, 0, strrpos($line, ";"));
|
||||
|
||||
// execute
|
||||
if (stripos($line, 'CREATE TABLE') !== false || stripos($line, 'DROP TABLE') !== false) {
|
||||
$isCreate = stripos($line, 'CREATE TABLE') !== false;
|
||||
$isDrop = stripos($line, 'DROP TABLE') !== false;
|
||||
|
||||
if ($isCreate || $isDrop) {
|
||||
if (preg_match('/TABLE\s[\'\"\`]+(\w+)[\'\"\`]+/i', $line, $match)) {
|
||||
if (in_array($match[1], $tablesList)) {
|
||||
//error_log($line);
|
||||
$stmt->executeQuery($line);
|
||||
try {
|
||||
$stmt->executeQuery($line);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
$errors .= $e->getMessage() . "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2273,6 +2273,7 @@ class processMap {
|
||||
$oCriteria->addSelectColumn(ReportTablePeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(ReportTablePeer::REP_TAB_NAME);
|
||||
$oCriteria->addSelectColumn(ReportTablePeer::REP_TAB_TYPE);
|
||||
$oCriteria->addSelectColumn(ReportTablePeer::REP_TAB_CONNECTION);
|
||||
// $oCriteria->addAsColumn ( 'REP_TAB_TITLE', 'C.CON_VALUE' );
|
||||
$oCriteria->addAsColumn('REP_TAB_TITLE', "CASE WHEN C.CON_VALUE IS NULL THEN (SELECT DISTINCT MAX(A.CON_VALUE) FROM CONTENT A WHERE A.CON_ID = REPORT_TABLE.REP_TAB_UID ) ELSE C.CON_VALUE END ");
|
||||
$oCriteria->addAlias('C', 'CONTENT');
|
||||
|
||||
@@ -27,26 +27,22 @@ class AdditionalTables extends BaseAdditionalTables {
|
||||
* Function load
|
||||
* access public
|
||||
*/
|
||||
public function load($sUID, $bFields = false) {
|
||||
try {
|
||||
$oAdditionalTables = AdditionalTablesPeer::retrieveByPK($sUID);
|
||||
if (!is_null($oAdditionalTables)) {
|
||||
$aFields = $oAdditionalTables->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
public function load($sUID, $bFields = false)
|
||||
{
|
||||
$oAdditionalTables = AdditionalTablesPeer::retrieveByPK($sUID);
|
||||
|
||||
if ($bFields) {
|
||||
$aFields['FIELDS'] = $this->getFields();
|
||||
}
|
||||
if (is_null($oAdditionalTables)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $aFields;
|
||||
}
|
||||
else {
|
||||
throw(new Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
$aFields = $oAdditionalTables->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
if ($bFields) {
|
||||
$aFields['FIELDS'] = $this->getFields();
|
||||
}
|
||||
|
||||
return $aFields;
|
||||
}
|
||||
|
||||
public function getFields()
|
||||
@@ -709,6 +705,7 @@ class AdditionalTables extends BaseAdditionalTables {
|
||||
$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_TYPE);
|
||||
$oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_TAG);
|
||||
$oCriteria->addSelectColumn(AdditionalTablesPeer::PRO_UID);
|
||||
$oCriteria->addSelectColumn(AdditionalTablesPeer::DBS_UID);
|
||||
|
||||
if (isset($process)) {
|
||||
foreach ($process as $key => $pro_uid) {
|
||||
|
||||
@@ -54,6 +54,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
$addTables['rows'][] = array(
|
||||
'ADD_TAB_UID' => $oldRepTab['REP_TAB_UID'],
|
||||
'PRO_UID' => $oldRepTab['PRO_UID'],
|
||||
'DBS_UID' => ($oldRepTab['REP_TAB_CONNECTION']=='wf'? 'workflow' : 'rp'),
|
||||
'ADD_TAB_DESCRIPTION' => $oldRepTab['REP_TAB_TITLE'],
|
||||
'ADD_TAB_NAME' => $oldRepTab['REP_TAB_NAME'],
|
||||
'ADD_TAB_TYPE' => $oldRepTab['REP_TAB_TYPE'],
|
||||
@@ -65,6 +66,19 @@ class pmTablesProxy extends HttpProxyController
|
||||
$addTables = AdditionalTables::getAll($start, $limit, $filter);
|
||||
}
|
||||
|
||||
foreach ($addTables['rows'] as $i => $table) {
|
||||
$con = Propel::getConnection($table['DBS_UID']);
|
||||
$stmt = $con->createStatement();
|
||||
$rs = $stmt->executeQuery('SELECT COUNT(*) AS NUM_ROWS from ' . $table['ADD_TAB_NAME']);
|
||||
if ($rs->next()) {
|
||||
$r = $rs->getRow();
|
||||
$addTables['rows'][$i]['NUM_ROWS'] = $r['NUM_ROWS'];
|
||||
}
|
||||
else {
|
||||
$addTables['rows'][$i]['NUM_ROWS'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $addTables;
|
||||
}
|
||||
|
||||
@@ -223,6 +237,13 @@ class pmTablesProxy extends HttpProxyController
|
||||
case 'INT': $columns[$i]->field_type = 'INTEGER'; break;
|
||||
case 'TEXT': $columns[$i]->field_type = 'LONGVARCHAR'; break;
|
||||
}
|
||||
|
||||
// VALIDATIONS
|
||||
if ($columns[$i]->field_autoincrement) {
|
||||
if ($columns[$i]->field_type !== 'INTEGER') {
|
||||
$columns[$i]->field_autoincrement = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
G::loadClass('pmTable');
|
||||
@@ -291,7 +312,8 @@ class pmTablesProxy extends HttpProxyController
|
||||
$result->success = true;
|
||||
$result->message = $result->msg = $buildResult;
|
||||
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$buildResult = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$result->success = false;
|
||||
@@ -319,24 +341,46 @@ class pmTablesProxy extends HttpProxyController
|
||||
public function delete($httpData)
|
||||
{
|
||||
$rows = G::json_decode(stripslashes($httpData->rows));
|
||||
$errors = '';
|
||||
$count = 0;
|
||||
|
||||
foreach ($rows as $row ) {
|
||||
try {
|
||||
$at = new AdditionalTables();
|
||||
$table = $at->load($row->id);
|
||||
|
||||
if (!isset($table)) {
|
||||
throw new Exception("Table does not exist... skipped!\n");
|
||||
}
|
||||
|
||||
try {
|
||||
foreach ($rows as $row ) {
|
||||
if($row->type == 'CLASSIC') {
|
||||
G::LoadClass('reportTables');
|
||||
$rp = new reportTables();
|
||||
$rp->deleteReportTable($row->id);
|
||||
} else {
|
||||
$at = new AdditionalTables();
|
||||
$at->deleteAll($row->id);
|
||||
$count++;
|
||||
}
|
||||
else {
|
||||
$at->deleteAll($row->id);
|
||||
$count++;
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$tableName = isset($table['ADD_TAB_NAME']) ? $table['ADD_TAB_NAME'] : $row->id;
|
||||
$errors .= $e->getMessage() . "\n";
|
||||
continue;
|
||||
}
|
||||
$result->success = true;
|
||||
} catch(Exception $e) {
|
||||
$result->success = true; // if the table does not exist just skip it and don't show messages for it
|
||||
$result->msg = $e->getMessage();
|
||||
}
|
||||
|
||||
if ($errors == '') {
|
||||
$result->success = true;
|
||||
$result->message = "$count tables removed Successfully.";
|
||||
}
|
||||
else {
|
||||
$result->success = false;
|
||||
$result->message = "$count tables removed but with errors.\n$errors" ;
|
||||
}
|
||||
|
||||
$result->errors = $errors;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -655,7 +699,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
try {
|
||||
$errors = '';
|
||||
ob_start();
|
||||
|
||||
$overWrite = isset($_POST['form']['OVERWRITE'])? true: false;
|
||||
|
||||
//save the file
|
||||
@@ -679,10 +723,11 @@ class pmTablesProxy extends HttpProxyController
|
||||
throw new Exception('ID_PMTABLE_INVALID_FILE');
|
||||
}
|
||||
|
||||
$fp = fopen($PUBLIC_ROOT_PATH.$filename, "rb");
|
||||
$fsData = intval(fread($fp, 9)); //reading the metadata
|
||||
$sType = fread($fp, $fsData); //reading string $oData
|
||||
$fp = fopen($PUBLIC_ROOT_PATH.$filename, "rb");
|
||||
$fsData = intval(fread($fp, 9)); //reading the metadata
|
||||
$sType = fread($fp, $fsData);
|
||||
|
||||
// first create the tables structures
|
||||
while (!feof($fp)) {
|
||||
switch($sType) {
|
||||
case '@META':
|
||||
@@ -696,13 +741,12 @@ class pmTablesProxy extends HttpProxyController
|
||||
$fsData = intval(fread($fp, 9));
|
||||
$schema = fread($fp, $fsData);
|
||||
$contentSchema = unserialize($schema);
|
||||
|
||||
$additionalTable = new additionalTables();
|
||||
$tableExists = $additionalTable->loadByName($contentSchema['ADD_TAB_NAME']);
|
||||
$tableNameMap[$contentSchema['ADD_TAB_NAME']] = $contentSchema['ADD_TAB_NAME'];
|
||||
|
||||
if ($overWrite) {
|
||||
if($tableExists !== false) {
|
||||
if ($tableExists !== false) {
|
||||
$additionalTable->deleteAll($tableExists['ADD_TAB_UID']);
|
||||
}
|
||||
}
|
||||
@@ -754,19 +798,67 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
//save the table
|
||||
$alterTable = false;
|
||||
if (!isset($processQueue[$contentSchema['DBS_UID']])) {
|
||||
$processQueue[$contentSchema['DBS_UID']] = array();
|
||||
}
|
||||
$processQueueTables[] = $contentSchema['ADD_TAB_NAME'];
|
||||
|
||||
$result = $this->save($tableData, $alterTable);
|
||||
|
||||
if (!$result->success) {
|
||||
$errors .= $result->message . "\n\n";
|
||||
if ($result->success) {
|
||||
$processQueueTables[$contentSchema['DBS_UID']][] = $contentSchema['ADD_TAB_NAME'];
|
||||
}
|
||||
else {
|
||||
$errors .= 'Error creating table: '.$tableData->REP_TAB_NAME.'-> '.$result->message . "\n\n";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case '@DATA':
|
||||
$fstName = intval(fread($fp, 9));
|
||||
$tableName = fread($fp, $fstName);
|
||||
$fsData = intval(fread($fp, 9));
|
||||
if ($fsData > 0) $data = fread($fp, $fsData);
|
||||
break;
|
||||
}
|
||||
|
||||
$fsData = intval(fread($fp, 9)); //reading the metadata
|
||||
if($fsData > 0){ // reading next block type
|
||||
$sType = fread($fp, $fsData);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
G::loadClass('pmTable');
|
||||
|
||||
foreach ($processQueueTables as $dbsUid => $tables) {
|
||||
$pmTable = new pmTable();
|
||||
ob_start();
|
||||
$pmTable->buildModelFor($dbsUid, $tables);
|
||||
$buildResult = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$errors .= $pmTable->upgradeDatabaseFor($pmTable->getDataSource(), $tables);
|
||||
}
|
||||
|
||||
$fp = fopen($PUBLIC_ROOT_PATH.$filename, "rb");
|
||||
$fsData = intval(fread($fp, 9));
|
||||
$sType = fread($fp, $fsData);
|
||||
// data processing
|
||||
|
||||
while (!feof($fp)) {
|
||||
|
||||
switch($sType) {
|
||||
case '@META':
|
||||
$fsData = intval(fread($fp, 9));
|
||||
$METADATA = fread($fp, $fsData);
|
||||
break;
|
||||
|
||||
case '@SCHEMA':
|
||||
$fsUid = intval(fread($fp, 9));
|
||||
$uid = fread($fp, $fsUid);
|
||||
$fsData = intval(fread($fp, 9));
|
||||
$schema = fread($fp, $fsData);
|
||||
break;
|
||||
|
||||
case '@DATA':
|
||||
$fstName = intval(fread($fp, 9));
|
||||
$tableName = fread($fp, $fstName);
|
||||
@@ -779,9 +871,24 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
$oAdditionalTables = new AdditionalTables();
|
||||
$table = $oAdditionalTables->loadByName($tableName);
|
||||
$isReport = $table['PRO_UID'] !== '' ? true : false;
|
||||
|
||||
if ($table !== false) {
|
||||
$processQueue[$contentSchema['DBS_UID']][] = array('id'=>$table[0]['ADD_TAB_UID'], 'records'=>$contentData);
|
||||
if (!$isReport) {
|
||||
//////////data
|
||||
if (count($contentData) > 0) {
|
||||
foreach ($contentData as $row) {
|
||||
$data = new StdClass();
|
||||
$data->id = $table['ADD_TAB_UID'];
|
||||
$data->rows = base64_encode(serialize($row));
|
||||
$res = $this->dataCreate($data , 'base64');
|
||||
}
|
||||
}
|
||||
////////////
|
||||
}
|
||||
else { // is a report table
|
||||
$oAdditionalTables->populateReportTable($tablename, $table['DBS_UID'], $table['ADD_TAB_TYPE'], $table['PRO_UID'], $table['ADD_TAB_GRID']);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -797,37 +904,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
}
|
||||
|
||||
////////////
|
||||
G::loadClass('pmTable');
|
||||
|
||||
foreach ($processQueue as $dbsUid => $tableData) {
|
||||
|
||||
$pmTable = new pmTable();
|
||||
$pmTable->buildModelFor($dbsUid, $processQueueTables);
|
||||
$buildResult = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if (count($tableData) > 0) {
|
||||
foreach ($tableData as $rows) {
|
||||
foreach ($rows['records'] as $row) {
|
||||
$data = new StdClass();
|
||||
$data->id = $rows['id'];
|
||||
$data->rows = base64_encode(serialize($row));
|
||||
$this->dataCreate($data , 'base64');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$additionalTable = new AdditionalTables();
|
||||
|
||||
foreach ($processQueueTables as $tablename) {
|
||||
$table = $additionalTable->loadByName($tablename);
|
||||
$isReport = $table['PRO_UID'] !== '' ? true : false;
|
||||
|
||||
if ($table && $isReport) {
|
||||
$oAdditionalTables->populateReportTable($tablename, $table['DBS_UID'], $table['ADD_TAB_TYPE'], $table['PRO_UID'], $table['ADD_TAB_GRID']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($errors == '') {
|
||||
$result->success = true;
|
||||
|
||||
@@ -122,7 +122,7 @@ Ext.onReady(function(){
|
||||
header : tableDef.FIELDS[i].FLD_DESCRIPTION,
|
||||
dataIndex : tableDef.FIELDS[i].FLD_NAME,
|
||||
width : 40,
|
||||
align : columnAlign,
|
||||
align : 'right',
|
||||
renderer : columnRenderer
|
||||
};
|
||||
if (tableDef.FIELDS[i].FLD_AUTO_INCREMENT != 1) {
|
||||
@@ -282,7 +282,7 @@ Ext.onReady(function(){
|
||||
id: 'infoGrid',
|
||||
height:1000,
|
||||
autoWidth : true,
|
||||
title : _('ID_PM_TABLE') + " : " + tableDef.ADD_TAB_NAME,
|
||||
//title : _('ID_PM_TABLE') + " : " + tableDef.ADD_TAB_NAME,
|
||||
stateful : true,
|
||||
stateId : 'grid',
|
||||
enableColumnResize: true,
|
||||
@@ -296,15 +296,15 @@ Ext.onReady(function(){
|
||||
loadMask: true,
|
||||
cm: cmodel,
|
||||
sm: smodel,
|
||||
tbar:[ newButton,
|
||||
'-',
|
||||
editButton,
|
||||
deleteButton,
|
||||
'-',
|
||||
importButton,
|
||||
exportButton,
|
||||
{xtype: 'tbfill'},
|
||||
backButton ],
|
||||
tbar:[
|
||||
newButton,
|
||||
'-',
|
||||
editButton,
|
||||
deleteButton,
|
||||
'-',
|
||||
importButton,
|
||||
exportButton
|
||||
],
|
||||
bbar: bbarpaging
|
||||
}
|
||||
|
||||
|
||||
@@ -197,6 +197,7 @@ Ext.onReady(function(){
|
||||
{name : 'ADD_TAB_TYPE'},
|
||||
{name : 'ADD_TAB_TAG'},
|
||||
{name : 'PRO_UID'},
|
||||
{name : 'NUM_ROWS'}
|
||||
]
|
||||
})
|
||||
});
|
||||
@@ -216,7 +217,10 @@ Ext.onReady(function(){
|
||||
editButton.enable();
|
||||
deleteButton.enable();
|
||||
exportButton.enable();
|
||||
dataButton.enable();
|
||||
row = sm.getSelected();
|
||||
if (row.data.NUM_ROWS > 0) {
|
||||
dataButton.enable();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
editButton.disable();
|
||||
@@ -253,6 +257,8 @@ Ext.onReady(function(){
|
||||
return '<span style="color:'+color+'">'+value+'</span> ';
|
||||
}});
|
||||
|
||||
cmodelColumns.push({header: 'Records', dataIndex: 'NUM_ROWS', width: 90, align:'left'});
|
||||
|
||||
if (PRO_UID === false) {
|
||||
cmodelColumns.push({header: _('ID_PROCESS'), dataIndex: 'PRO_TITLE', width: 180, align:'left'});
|
||||
}
|
||||
@@ -421,15 +427,16 @@ DeletePMTable = function() {
|
||||
},
|
||||
success: function(resp){
|
||||
result = Ext.util.JSON.decode(resp.responseText);
|
||||
Ext.getCmp('infoGrid').getStore().reload();
|
||||
if (result.success) {
|
||||
Ext.getCmp('infoGrid').getStore().reload();
|
||||
PMExt.notify(_("ID_DELETION_SUCCESSFULLY"), _("ID_ALL_RECORDS_DELETED_SUCESSFULLY"));
|
||||
} else {
|
||||
Ext.Msg.alert( _('ID_ERROR'), result.msg);
|
||||
PMExt.error( _('ID_ERROR'), result.message.nl2br());
|
||||
}
|
||||
},
|
||||
failure: function(obj, resp){
|
||||
Ext.Msg.alert( _('ID_ERROR'), resp.result.msg);
|
||||
Ext.getCmp('infoGrid').getStore().reload();
|
||||
Ext.Msg.alert( _('ID_ERROR'), resp.result.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -573,9 +580,32 @@ ExportPMTable = function(){
|
||||
};
|
||||
|
||||
//Load PM TAble Data
|
||||
PMTableData = function(){
|
||||
PMTableData = function()
|
||||
{
|
||||
var row = Ext.getCmp('infoGrid').getSelectionModel().getSelected();
|
||||
location.href = 'pmTables/data?id='+row.get('ADD_TAB_UID');
|
||||
//location.href = 'pmTables/data?id='+row.get('ADD_TAB_UID');
|
||||
if (row.get('TYPE') != '') {
|
||||
PMExt.info(_('ID_INFO'), _('ID_DATA_LIST_NOT_AVAILABLE_FOR_OLDVER'));
|
||||
return;
|
||||
}
|
||||
|
||||
win = new Ext.Window({
|
||||
layout:'fit',
|
||||
width:700,
|
||||
title: _('ID_PM_TABLE') +': '+ row.get('ADD_TAB_NAME'),
|
||||
height:500,
|
||||
modal: true,
|
||||
maximizable: true,
|
||||
constrain: true,
|
||||
//closeAction:'hide',
|
||||
plain: true,
|
||||
items: [{
|
||||
xtype:"iframepanel",
|
||||
defaultSrc : 'pmTables/data?id='+row.get('ADD_TAB_UID')+'&type='+row.get('TYPE'),
|
||||
loadMask:{msg: _('ID_LOADING')}
|
||||
}]
|
||||
});
|
||||
win.show();
|
||||
};
|
||||
|
||||
//Gets UIDs from a array of rows
|
||||
|
||||
Reference in New Issue
Block a user