BUG 0000 PM tables - Import invalid files validation and improved catch errors
This commit is contained in:
@@ -209,7 +209,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
}
|
||||
|
||||
/** validations **/
|
||||
if(in_array($data['REP_TAB_NAME'], $reservedWords) || (isset($httpData->forceUid) && $httpData->forceUid )) {
|
||||
if (is_array($oAdditionalTables->loadByName($data['REP_TAB_NAME']))) {
|
||||
throw new Exception('The table "' . $data['REP_TAB_NAME'] . '" already exits.');
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
}
|
||||
|
||||
$result->success = true;
|
||||
$result->msg = $buildResult;
|
||||
$result->message = $result->msg = $buildResult;
|
||||
} catch (Exception $e) {
|
||||
$buildResult = ob_get_contents();
|
||||
ob_end_clean();
|
||||
@@ -298,11 +298,11 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
// if it is a propel exception message
|
||||
if (preg_match('/(.*)\s\[(.*):\s(.*)\]\s\[(.*):\s(.*)\]/', $e->getMessage(), $match)) {
|
||||
$result->msg = $match[3];
|
||||
$result->message = $result->msg = $match[3];
|
||||
$result->type = ucfirst($pmTable->getDbConfig()->adapter);
|
||||
}
|
||||
else {
|
||||
$result->msg = $e->getMessage();
|
||||
$result->message = $result->msg = $e->getMessage();
|
||||
$result->type = G::loadTranslation('ID_EXCEPTION');
|
||||
}
|
||||
|
||||
@@ -749,7 +749,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
$result = $this->save($tableData, $alterTable);
|
||||
|
||||
if (!$result->success) {
|
||||
$errors .= $errors . "\n\n";
|
||||
$errors .= $result->message . "\n\n";
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -806,31 +806,31 @@ class pmTablesProxy extends HttpProxyController
|
||||
}
|
||||
|
||||
if ($errors == '') {
|
||||
$result->success = true;
|
||||
$msg = 'File Imported "'.$filename.'" Successfully';
|
||||
$result->type = 0;
|
||||
}
|
||||
else {
|
||||
$result->success = false;
|
||||
$result->errorType = 'warning';
|
||||
$msg = 'File Imported "'.$filename.'" but with errors' . "\n\n" . $errors;
|
||||
$result->type = 1;
|
||||
}
|
||||
|
||||
$result->success = true;
|
||||
$result->message = $msg;
|
||||
|
||||
}
|
||||
catch(Exception $e) {
|
||||
$result->type = 2;
|
||||
$result->errorType = 'error';
|
||||
$result->buildResult = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$result->success = false;
|
||||
|
||||
// if it is a propel exception message
|
||||
if (preg_match('/(.*)\s\[(.*):\s(.*)\]\s\[(.*):\s(.*)\]/', $e->getMessage(), $match)) {
|
||||
$result->msg = $match[3];
|
||||
$result->message = $match[3];
|
||||
$result->type = ucfirst($pmTable->getDbConfig()->adapter);
|
||||
}
|
||||
else {
|
||||
$result->msg = $e->getMessage();
|
||||
$result->message = $e->getMessage();
|
||||
$result->type = G::loadTranslation('ID_EXCEPTION');
|
||||
}
|
||||
|
||||
|
||||
@@ -490,21 +490,46 @@ ImportPMTable = function(){
|
||||
url: 'pmTablesProxy/import',
|
||||
waitMsg: 'Uploading file...',
|
||||
success: function(o, resp){
|
||||
console.log(o);
|
||||
console.log(resp.response.responseText);
|
||||
var result = Ext.util.JSON.decode(resp.response.responseText);
|
||||
|
||||
if (result.success) {
|
||||
PMExt.notify('IMPORT RESULT', result.message);
|
||||
}
|
||||
else {
|
||||
win = new Ext.Window({
|
||||
applyTo:'hello-win',
|
||||
layout:'fit',
|
||||
width:500,
|
||||
height:300,
|
||||
closeAction:'hide',
|
||||
plain: true,
|
||||
html: '<h3>Importing Error</h3>'+ result.message,
|
||||
items: [],
|
||||
|
||||
buttons: [{
|
||||
text: 'Close',
|
||||
handler: function(){
|
||||
win.hide();
|
||||
}
|
||||
}]
|
||||
});
|
||||
win.show(this);
|
||||
}
|
||||
|
||||
w.close();
|
||||
infoGrid.store.reload();
|
||||
|
||||
PMExt.notify('IMPORT RESULT', resp.result.message);
|
||||
},
|
||||
failure: function(o, resp){
|
||||
w.close();
|
||||
//alert('ERROR "'+resp.result.msg+'"');
|
||||
Ext.MessageBox.show({title: '', msg: resp.result.msg, buttons:
|
||||
Ext.MessageBox.OK, animEl: 'mb9', fn: function(){}, icon:
|
||||
Ext.MessageBox.ERROR});
|
||||
//setTimeout(function(){Ext.MessageBox.hide(); }, 2000);
|
||||
infoGrid.store.reload();
|
||||
|
||||
var result = Ext.util.JSON.decode(resp.response.responseText);
|
||||
if (result.errorType == 'warning') {
|
||||
PMExt.warning(_('ID_WARNING'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
else {
|
||||
PMExt.error(_('ID_ERROR'), result.message.replace(/\n/g,' <br>'));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user