PM-874
No se puede importar Report Tables en los procesos Se aumentaron validaciones varias, segun se especifica en el comentario en jira
This commit is contained in:
@@ -751,9 +751,11 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
} else {
|
||||
// grids
|
||||
foreach ($caseData[$dKey] as $dIndex => $dRow) {
|
||||
foreach ($dRow as $k => $v) {
|
||||
if (trim($v) === '') {
|
||||
$caseData[$dKey][$dIndex][$k] = null;
|
||||
if (!is_array($dRow)) {
|
||||
foreach ($dRow as $k => $v) {
|
||||
if (trim($v) === '') {
|
||||
$caseData[$dKey][$dIndex][$k] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -915,17 +915,32 @@ class pmTablesProxy extends HttpProxyController
|
||||
*/
|
||||
public function import ($httpData)
|
||||
{
|
||||
if (isset( $_POST["form"]["TYPE_TABLE"] ) && ! empty( $_POST["form"]["TYPE_TABLE"] )) {
|
||||
if($_POST["form"]["TYPE_TABLE"] == 'admin') {
|
||||
$fromAdmin = true;
|
||||
} else {
|
||||
$fromAdmin = false;
|
||||
}
|
||||
}
|
||||
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
try {
|
||||
$result = new stdClass();
|
||||
$errors = '';
|
||||
$fromConfirm = false;
|
||||
|
||||
$overWrite = isset( $_POST['form']['OVERWRITE'] ) ? true : false;
|
||||
|
||||
if (isset( $_POST["form"]["FROM_CONFIRM"] ) && ! empty( $_POST["form"]["FROM_CONFIRM"] )) {
|
||||
$fromConfirm = $_POST["form"]["FROM_CONFIRM"];
|
||||
$_FILES['form'] = $_SESSION['FILES_FORM'];
|
||||
}
|
||||
|
||||
//save the file
|
||||
if ($_FILES['form']['error']['FILENAME'] !== 0) {
|
||||
throw new Exception( G::loadTranslation( 'ID_PMTABLE_UPLOADING_FILE_PROBLEM' ) );
|
||||
}
|
||||
$_SESSION['FILES_FORM'] = $_FILES['form'];
|
||||
|
||||
$oAdditionalTables = new AdditionalTables();
|
||||
$tableNameMap = array ();
|
||||
@@ -935,7 +950,10 @@ class pmTablesProxy extends HttpProxyController
|
||||
$PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP;
|
||||
$filename = $_FILES['form']['name']['FILENAME'];
|
||||
$tempName = $_FILES['form']['tmp_name']['FILENAME'];
|
||||
G::uploadFile( $tempName, $PUBLIC_ROOT_PATH, $filename );
|
||||
|
||||
if(!$fromConfirm) {
|
||||
G::uploadFile( $tempName, $PUBLIC_ROOT_PATH, $filename );
|
||||
}
|
||||
|
||||
$fileContent = file_get_contents( $PUBLIC_ROOT_PATH . $filename );
|
||||
|
||||
@@ -947,6 +965,17 @@ class pmTablesProxy extends HttpProxyController
|
||||
$fsData = intval( fread( $fp, 9 ) ); //reading the metadata
|
||||
$sType = fread( $fp, $fsData );
|
||||
|
||||
$pmTables = $this->getList('');
|
||||
$proUids = Array();
|
||||
if($pmTables['count']) {
|
||||
$pmTables = $pmTables['rows'];
|
||||
foreach($pmTables as $val) {
|
||||
if($val['PRO_UID'] != '') {
|
||||
$proUids[] = $val['PRO_UID'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// first create the tables structures
|
||||
|
||||
while (! feof( $fp )) {
|
||||
@@ -965,6 +994,43 @@ class pmTablesProxy extends HttpProxyController
|
||||
$tableExists = $additionalTable->loadByName( $contentSchema['ADD_TAB_NAME'] );
|
||||
$tableNameMap[$contentSchema['ADD_TAB_NAME']] = $contentSchema['ADD_TAB_NAME'];
|
||||
|
||||
$tableData = new stdClass();
|
||||
if (isset( $_POST["form"]["PRO_UID"] ) && ! empty( $_POST["form"]["PRO_UID"] )) {
|
||||
$tableData->PRO_UID = $_POST["form"]["PRO_UID"];
|
||||
} else {
|
||||
$tableData->PRO_UID = isset( $contentSchema["PRO_UID"] ) ? $contentSchema["PRO_UID"] : "";
|
||||
}
|
||||
|
||||
if($fromAdmin) { /*from admin tab*/
|
||||
if ($tableExists !== false && !$fromConfirm) {
|
||||
$validationType = 1;
|
||||
throw new Exception( G::loadTranslation( 'ID_OVERWRITE_PMTABLE' ) );
|
||||
}
|
||||
if(!in_array($tableData->PRO_UID, $proUids)) {
|
||||
$validationType = 2;
|
||||
throw new Exception( G::loadTranslation( 'ID_NO_RELATED_PROCESS' ) );
|
||||
}
|
||||
} else { /*from designer tab*/
|
||||
if ($tableExists !== false && !$fromConfirm) {
|
||||
$validationType = 1;
|
||||
throw new Exception( G::loadTranslation( 'ID_OVERWRITE_PMTABLE' ) );
|
||||
}
|
||||
if (isset( $_SESSION['PROCESS'] ) && !empty( $_SESSION['PROCESS'] )) {
|
||||
if($_SESSION['PROCESS'] != $tableData->PRO_UID) {
|
||||
if(!in_array($tableData->PRO_UID, $proUids)) {
|
||||
$validationType = 2;
|
||||
if($fromConfirm == $validationType) {
|
||||
throw new Exception( G::loadTranslation( 'ID_OVERWRITE_RELATED_PROCESS' ) );
|
||||
} else {
|
||||
$tableData->PRO_UID = $_SESSION['PROCESS'];
|
||||
}
|
||||
} else {
|
||||
$validationType = 3;
|
||||
throw new Exception( G::loadTranslation( 'ID_ALREADY_RELATED_TABLE ' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($overWrite) {
|
||||
if ($tableExists !== false) {
|
||||
$additionalTable->deleteAll( $tableExists['ADD_TAB_UID'] );
|
||||
@@ -995,18 +1061,11 @@ class pmTablesProxy extends HttpProxyController
|
||||
$columns[] = $column;
|
||||
}
|
||||
|
||||
$tableData = new stdClass();
|
||||
$tableData->REP_TAB_UID = $contentSchema['ADD_TAB_UID'];
|
||||
$tableData->REP_TAB_NAME = $contentSchema['ADD_TAB_NAME'];
|
||||
$tableData->REP_TAB_DSC = $contentSchema['ADD_TAB_DESCRIPTION'];
|
||||
$tableData->REP_TAB_CONNECTION = $contentSchema['DBS_UID'];
|
||||
|
||||
if (isset( $_POST["form"]["PRO_UID"] ) && ! empty( $_POST["form"]["PRO_UID"] )) {
|
||||
$tableData->PRO_UID = $_POST["form"]["PRO_UID"];
|
||||
} else {
|
||||
$tableData->PRO_UID = isset( $contentSchema["PRO_UID"] ) ? $contentSchema["PRO_UID"] : "";
|
||||
}
|
||||
|
||||
$tableData->REP_TAB_TYPE = isset( $contentSchema['ADD_TAB_TYPE'] ) ? $contentSchema['ADD_TAB_TYPE'] : '';
|
||||
$tableData->REP_TAB_GRID = isset( $contentSchema['ADD_TAB_GRID'] ) ? $contentSchema['ADD_TAB_GRID'] : '';
|
||||
$tableData->columns = G::json_encode( $columns );
|
||||
@@ -1147,6 +1206,8 @@ class pmTablesProxy extends HttpProxyController
|
||||
$result->message = $msg;
|
||||
} catch (Exception $e) {
|
||||
$result = new stdClass();
|
||||
$result->fromAdmin = $fromAdmin;
|
||||
$result->validationType = $validationType;
|
||||
$result->errorType = 'error';
|
||||
$result->buildResult = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
@@ -561,6 +561,10 @@ ImportPMTable = function(){
|
||||
fieldLabel: '',
|
||||
boxLabel: _('ID_OVERWRITE_EXIST'), // 'Overwrite if exists?',
|
||||
name: 'form[OVERWRITE]'
|
||||
}, {
|
||||
xtype: 'hidden',
|
||||
name: 'form[TYPE_TABLE]',
|
||||
value: (PRO_UID? 'designer' : 'admin')
|
||||
}],
|
||||
buttons: [{
|
||||
id: 'importPMTableButtonUpload',
|
||||
@@ -613,7 +617,131 @@ ImportPMTable = function(){
|
||||
PMExt.warning(_('ID_WARNING'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
else {
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
if(result.fromAdmin) { /*from admin tab*/
|
||||
if(result.validationType == 1) {
|
||||
Ext.MessageBox.confirm('Confirmation', result.message.replace(/\n/g,' <br>'), function(btn, text){
|
||||
if (btn == 'yes'){
|
||||
Ext.Ajax.request({
|
||||
url: 'pmTablesProxy/import',
|
||||
params: {
|
||||
'form[FROM_CONFIRM]':'overWrite',
|
||||
'form[TYPE_TABLE]':(PRO_UID? 'designer' : 'admin'),
|
||||
'form[OVERWRITE]':true
|
||||
},
|
||||
success: function(resp){
|
||||
var result = Ext.util.JSON.decode(resp.responseText);
|
||||
if (result.success) {
|
||||
PMExt.notify(_('ID_IMPORT_RESULT'), result.message);
|
||||
} else {
|
||||
if(result.validationType == 2) {
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
}
|
||||
},
|
||||
failure: function(obj, resp){
|
||||
var result = Ext.util.JSON.decode(resp.responseText);
|
||||
if(result.validationType == 2) {
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
}
|
||||
});
|
||||
Ext.getCmp('infoGrid').getStore().reload();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
} else { /*from designer tab*/
|
||||
if(result.validationType == 1) {
|
||||
Ext.MessageBox.confirm('Confirmation', result.message.replace(/\n/g,' <br>'), function(btn, text){
|
||||
if (btn == 'yes'){
|
||||
Ext.Ajax.request({
|
||||
url: 'pmTablesProxy/import',
|
||||
params: {
|
||||
'form[FROM_CONFIRM]':'2',
|
||||
'form[TYPE_TABLE]':(PRO_UID? 'designer' : 'admin'),
|
||||
'form[OVERWRITE]':true
|
||||
},
|
||||
success: function(resp){
|
||||
var result = Ext.util.JSON.decode(resp.responseText);
|
||||
if (result.success) {
|
||||
PMExt.notify(_('ID_IMPORT_RESULT'), result.message);
|
||||
} else {
|
||||
if(result.validationType == 2) {
|
||||
Ext.MessageBox.confirm('Confirmation', result.message.replace(/\n/g,' <br>'), function(btn, text){
|
||||
if (btn == 'yes'){
|
||||
Ext.Ajax.request({
|
||||
url: 'pmTablesProxy/import',
|
||||
params: {
|
||||
'form[FROM_CONFIRM]':'overWrite',
|
||||
'form[TYPE_TABLE]':(PRO_UID? 'designer' : 'admin'),
|
||||
'form[OVERWRITE]':true
|
||||
},
|
||||
success: function(resp){
|
||||
var result = Ext.util.JSON.decode(resp.responseText);
|
||||
if (result.success) {
|
||||
PMExt.notify(_('ID_IMPORT_RESULT'), result.message);
|
||||
} else {
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
},
|
||||
failure: function(obj, resp){
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
});
|
||||
Ext.getCmp('infoGrid').getStore().reload();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
}
|
||||
},
|
||||
failure: function(obj, resp){
|
||||
var result = Ext.util.JSON.decode(resp.responseText);
|
||||
if(result.validationType == 2) {
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
}
|
||||
});
|
||||
Ext.getCmp('infoGrid').getStore().reload();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if(result.validationType == 2) {
|
||||
Ext.MessageBox.confirm('Confirmation', result.message.replace(/\n/g,' <br>'), function(btn, text){
|
||||
if (btn == 'yes'){
|
||||
Ext.Ajax.request({
|
||||
url: 'pmTablesProxy/import',
|
||||
params: {
|
||||
'form[FROM_CONFIRM]':'overWrite',
|
||||
'form[TYPE_TABLE]':(PRO_UID? 'designer' : 'admin'),
|
||||
'form[OVERWRITE]':true
|
||||
},
|
||||
success: function(resp){
|
||||
var result = Ext.util.JSON.decode(resp.responseText);
|
||||
if (result.success) {
|
||||
PMExt.notify(_('ID_IMPORT_RESULT'), result.message);
|
||||
} else {
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
},
|
||||
failure: function(obj, resp){
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
});
|
||||
Ext.getCmp('infoGrid').getStore().reload();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user