BUG 0000 PM TABLES - importing issue
- fixed the problem when multiples tables are selected to import
This commit is contained in:
@@ -1061,15 +1061,17 @@ class AdditionalTables extends BaseAdditionalTables {
|
|||||||
FieldsPeer::doDelete($oCriteria);
|
FieldsPeer::doDelete($oCriteria);
|
||||||
|
|
||||||
//deleting table
|
//deleting table
|
||||||
if ( isset($aData['DBS_UID']) && $aData['DBS_UID'] != 'wf' && $aData['DBS_UID'] != '') {
|
if ($aData['DBS_UID'] == 'wf' || $aData['DBS_UID'] == 'workflow' || $aData['DBS_UID'] == '' || $aData['DBS_UID'] == '0' || !$aData['DBS_UID']) {
|
||||||
$con = Propel::getConnection($aData['DBS_UID']);
|
|
||||||
$stmt = $con->createStatement();
|
|
||||||
$stmt->executeQuery('DROP TABLE '.$aData['ADD_TAB_NAME']);
|
|
||||||
} else {
|
|
||||||
G::LoadSystem('database_' . strtolower(DB_ADAPTER));
|
G::LoadSystem('database_' . strtolower(DB_ADAPTER));
|
||||||
$oDataBase = new database(DB_ADAPTER, DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
$oDataBase = new database(DB_ADAPTER, DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||||
$oDataBase->iFetchType = MYSQL_NUM;
|
$oDataBase->iFetchType = MYSQL_NUM;
|
||||||
$oDataBase->executeQuery($oDataBase->generateDropTableSQL($aData['ADD_TAB_NAME']));
|
$oDataBase->executeQuery($oDataBase->generateDropTableSQL($aData['ADD_TAB_NAME']));
|
||||||
|
} else {
|
||||||
|
$con = Propel::getConnection($aData['DBS_UID']);
|
||||||
|
if (is_object($con)) {
|
||||||
|
$stmt = $con->createStatement();
|
||||||
|
$stmt->executeQuery('DROP TABLE '.$aData['ADD_TAB_NAME']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1216,9 +1218,12 @@ var additionalTablesDataDelete = function(sUID, sKeys) {
|
|||||||
$con = Propel::getConnection($aData['DBS_UID']);
|
$con = Propel::getConnection($aData['DBS_UID']);
|
||||||
$oCriteria = new Criteria($aData['DBS_UID']);
|
$oCriteria = new Criteria($aData['DBS_UID']);
|
||||||
|
|
||||||
eval('$oCriteria->addSelectColumn("\'1\' AS DUMMY");');
|
//eval('$oCriteria->addSelectColumn("\'1\' AS DUMMY");');
|
||||||
foreach ($aData['FIELDS'] as $aField) {
|
foreach ($aData['FIELDS'] as $aField) {
|
||||||
eval('$oCriteria->addSelectColumn(' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ');');
|
eval('$oCriteria->addSelectColumn(' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ');');
|
||||||
|
if ($aField['FLD_KEY'] == '1') {
|
||||||
|
eval('$oCriteria->addAscendingOrderByColumn(' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ');');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$oCriteriaCount = clone $oCriteria;
|
$oCriteriaCount = clone $oCriteria;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class pmTables extends Controller
|
|||||||
$Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20;
|
$Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20;
|
||||||
|
|
||||||
$this->includeExtJS('pmTables/list', $this->debug);
|
$this->includeExtJS('pmTables/list', $this->debug);
|
||||||
|
$this->includeExtJS('pmTables/export', $this->debug);
|
||||||
$this->setView('pmTables/list');
|
$this->setView('pmTables/list');
|
||||||
|
|
||||||
//assigning js variables
|
//assigning js variables
|
||||||
@@ -123,6 +124,16 @@ class pmTables extends Controller
|
|||||||
G::RenderPage('publish', 'extJs');
|
G::RenderPage('publish', 'extJs');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function streamExported($httpData)
|
||||||
|
{
|
||||||
|
$PUBLIC_ROOT_PATH = PATH_DATA.'sites'.PATH_SEP.SYS_SYS.PATH_SEP.'public'.PATH_SEP;
|
||||||
|
$sFileName = $httpData->f;
|
||||||
|
|
||||||
|
$realPath = $PUBLIC_ROOT_PATH . $sFileName;
|
||||||
|
G::streamFile ( $realPath, true );
|
||||||
|
unlink($realPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* - protected functions (non-callable from controller outside) -
|
* - protected functions (non-callable from controller outside) -
|
||||||
|
|||||||
@@ -403,6 +403,8 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
*/
|
*/
|
||||||
public function dataCreate($httpData)
|
public function dataCreate($httpData)
|
||||||
{
|
{
|
||||||
|
$rows = G::json_decode($httpData->rows);
|
||||||
|
|
||||||
require_once 'classes/model/AdditionalTables.php';
|
require_once 'classes/model/AdditionalTables.php';
|
||||||
$oAdditionalTables = new AdditionalTables();
|
$oAdditionalTables = new AdditionalTables();
|
||||||
$table = $oAdditionalTables->load($httpData->id, true);
|
$table = $oAdditionalTables->load($httpData->id, true);
|
||||||
@@ -415,33 +417,63 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
}
|
}
|
||||||
|
|
||||||
require_once $sPath . $this->className . '.php';
|
require_once $sPath . $this->className . '.php';
|
||||||
$rows = G::json_decode($httpData->rows);
|
$toSave = false;
|
||||||
|
|
||||||
|
if (is_array($rows)) { //multiple
|
||||||
|
$c = $cs = 0;
|
||||||
|
foreach ($rows as $i => $row) {
|
||||||
|
$fieldsCount = 0;
|
||||||
eval('$obj = new ' .$this->className. '();');
|
eval('$obj = new ' .$this->className. '();');
|
||||||
if (is_array($rows)) {
|
|
||||||
foreach ($rows as $row) {
|
|
||||||
foreach ($row as $key => $value) {
|
foreach ($row as $key => $value) {
|
||||||
$action = 'set' . AdditionalTables::getPHPName($key);
|
$action = 'set' . AdditionalTables::getPHPName($key);
|
||||||
$res = $obj->$action($value);
|
$obj->$action($value);
|
||||||
|
$fieldsCount++;
|
||||||
|
$toSave = true;
|
||||||
}
|
}
|
||||||
$this->success = $res ? true: false;
|
if ($fieldsCount != 0) {
|
||||||
|
$c++;
|
||||||
|
if ($obj->save() > 0) {
|
||||||
|
$cs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($toSave) {
|
||||||
|
$result->success = $cs == $c ? true: false;
|
||||||
|
$result->message = 'Saved #' . $c . ' records successfully';
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
|
$result->success = false;
|
||||||
|
$result->message = 'Nothing to do';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { //single
|
||||||
|
eval('$obj = new ' .$this->className. '();');
|
||||||
foreach ($rows as $key => $value) {
|
foreach ($rows as $key => $value) {
|
||||||
$action = 'set' . AdditionalTables::getPHPName($key);
|
$action = 'set' . AdditionalTables::getPHPName($key);
|
||||||
$obj->$action($value);
|
$obj->$action($value);
|
||||||
|
$toSave = true;
|
||||||
}
|
}
|
||||||
|
if ($toSave) {
|
||||||
if ($obj->save() > 0) {
|
if ($obj->save() > 0) {
|
||||||
$this->success = true;
|
$rows->__index__ = 5;
|
||||||
|
$result->success = true;
|
||||||
|
$result->message = 'Record saved successfully';
|
||||||
|
$result->data = (array) $rows;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->success = false;
|
$result->success = false;
|
||||||
|
$result->message = 'Error Updating records';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$result->success = true;
|
||||||
|
$result->data = array('__index__'=>1132);
|
||||||
|
$result->message = 'Nothing to do';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
$this->message = $this->success ? 'Saved Successfully' : 'Error Updating record';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -509,9 +541,7 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
public function import($httpData)
|
public function import($httpData)
|
||||||
{
|
{
|
||||||
require_once 'classes/model/AdditionalTables.php';
|
require_once 'classes/model/AdditionalTables.php';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$overWrite = isset($_POST['form']['OVERWRITE'])? true: false;
|
$overWrite = isset($_POST['form']['OVERWRITE'])? true: false;
|
||||||
|
|
||||||
//save the file
|
//save the file
|
||||||
@@ -524,7 +554,13 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
|
|
||||||
$fileContent = file_get_contents($PUBLIC_ROOT_PATH.$filename);
|
$fileContent = file_get_contents($PUBLIC_ROOT_PATH.$filename);
|
||||||
|
|
||||||
if(strpos($fileContent, '-----== ProcessMaker Open Source Private Tables ==-----') !== false){
|
if(strpos($fileContent, '-----== ProcessMaker Open Source Private Tables ==-----') === false) {
|
||||||
|
$this->success = false;
|
||||||
|
$this->message = 'INVALID_FILE';
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$oMap = new aTablesMap();
|
$oMap = new aTablesMap();
|
||||||
|
|
||||||
$fp = fopen($PUBLIC_ROOT_PATH.$filename, "rb");
|
$fp = fopen($PUBLIC_ROOT_PATH.$filename, "rb");
|
||||||
@@ -541,7 +577,6 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
case '@META':
|
case '@META':
|
||||||
$fsData = intval(fread($fp, 9));
|
$fsData = intval(fread($fp, 9));
|
||||||
$METADATA = fread($fp, $fsData);
|
$METADATA = fread($fp, $fsData);
|
||||||
//print_r($METADATA);
|
|
||||||
break;
|
break;
|
||||||
case '@SCHEMA':
|
case '@SCHEMA':
|
||||||
$fsUid = intval(fread($fp, 9));
|
$fsUid = intval(fread($fp, 9));
|
||||||
@@ -550,7 +585,7 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
$fsData = intval(fread($fp, 9));
|
$fsData = intval(fread($fp, 9));
|
||||||
$schema = fread($fp, $fsData);
|
$schema = fread($fp, $fsData);
|
||||||
$contentSchema = unserialize($schema);
|
$contentSchema = unserialize($schema);
|
||||||
//print_r($contentSchema);
|
//var_dump($overWrite); print_r($contentSchema); continue;
|
||||||
|
|
||||||
if($overWrite){
|
if($overWrite){
|
||||||
$aTable = new additionalTables();
|
$aTable = new additionalTables();
|
||||||
@@ -578,6 +613,11 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validating invalid bds_uid in old tables definition -> mapped to workflow
|
||||||
|
if (!$contentSchema['DBS_UID'] || $contentSchema['DBS_UID'] == '0') {
|
||||||
|
$contentSchema['DBS_UID'] = 'workflow';
|
||||||
|
}
|
||||||
|
|
||||||
$sAddTabUid = $oAdditionalTables->create(
|
$sAddTabUid = $oAdditionalTables->create(
|
||||||
array(
|
array(
|
||||||
'ADD_TAB_UID' => $contentSchema['ADD_TAB_UID'],
|
'ADD_TAB_UID' => $contentSchema['ADD_TAB_UID'],
|
||||||
@@ -636,7 +676,12 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
$fstName = intval(fread($fp, 9));
|
$fstName = intval(fread($fp, 9));
|
||||||
$tName = fread($fp, $fstName);
|
$tName = fread($fp, $fstName);
|
||||||
$fsData = intval(fread($fp, 9));
|
$fsData = intval(fread($fp, 9));
|
||||||
$contentData = unserialize(fread($fp, $fsData));
|
|
||||||
|
if ($fsData > 0) {
|
||||||
|
$data = fread($fp, $fsData);
|
||||||
|
$contentData = unserialize($data);
|
||||||
|
|
||||||
|
//var_dump($data); print_r($contentData); continue;
|
||||||
|
|
||||||
$tName = $oMap->route($tName);
|
$tName = $oMap->route($tName);
|
||||||
|
|
||||||
@@ -649,6 +694,7 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
$oAdditionalTables->saveDataInTable($tRecord[0]['ADD_TAB_UID'], $data);
|
$oAdditionalTables->saveDataInTable($tRecord[0]['ADD_TAB_UID'], $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$fsData = intval(fread($fp, 9));
|
$fsData = intval(fread($fp, 9));
|
||||||
@@ -662,10 +708,7 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
$this->success = true;
|
$this->success = true;
|
||||||
$this->message = 'File Imported "'.$filename.'" Successfully';
|
$this->message = 'File Imported "'.$filename.'" Successfully';
|
||||||
|
|
||||||
} else {
|
|
||||||
$this->success = false;
|
|
||||||
$this->message = 'INVALID_FILE';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch(Exception $e){
|
} catch(Exception $e){
|
||||||
@@ -674,6 +717,139 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export PM tables
|
||||||
|
* @author: Erik Amaru Ortiz <aortiz.erik@gmail.com>
|
||||||
|
*/
|
||||||
|
public function export($httpData)
|
||||||
|
{
|
||||||
|
require_once 'classes/model/AdditionalTables.php';
|
||||||
|
|
||||||
|
$tablesToExport = json_decode($httpData->rows);
|
||||||
|
|
||||||
|
try{
|
||||||
|
G::LoadCLass('net');
|
||||||
|
$net = new NET(G::getIpAddress());
|
||||||
|
|
||||||
|
G::LoadClass("system");
|
||||||
|
|
||||||
|
$META = " \n-----== ProcessMaker Open Source Private Tables ==-----\n".
|
||||||
|
" @Ver: 1.0 Oct-2009\n".
|
||||||
|
" @Processmaker version: ".System::getVersion()."\n".
|
||||||
|
" -------------------------------------------------------\n".
|
||||||
|
" @Export Date: ".date("l jS \of F Y h:i:s A")."\n".
|
||||||
|
" @Server address: ".getenv('SERVER_NAME')." (".getenv('SERVER_ADDR').")\n".
|
||||||
|
" @Client address: ".$net->hostname."\n".
|
||||||
|
" @Workspace: ".SYS_SYS."\n".
|
||||||
|
" @Export trace back:\n\n";
|
||||||
|
|
||||||
|
$EXPORT_TRACEBACK = Array();
|
||||||
|
$c = 0;
|
||||||
|
foreach ($tablesToExport as $table) {
|
||||||
|
$at = new additionalTables();
|
||||||
|
$tableData = $at->getAllData($table->ADD_TAB_UID);
|
||||||
|
$rows = $tableData['rows'];
|
||||||
|
$count = $tableData['count'];
|
||||||
|
|
||||||
|
array_push($EXPORT_TRACEBACK, Array(
|
||||||
|
'uid' => $table->ADD_TAB_UID,
|
||||||
|
'name' => $table->ADD_TAB_NAME,
|
||||||
|
'num_regs' => $tableData['count'],
|
||||||
|
'schema' => $table->_SCHEMA ? 'yes': 'no',
|
||||||
|
'data' => $table->_DATA ? 'yes': 'no'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$sTrace = "TABLE UID TABLE NAME\tREGS\tSCHEMA\tDATA\n";
|
||||||
|
|
||||||
|
foreach($EXPORT_TRACEBACK as $row){
|
||||||
|
$sTrace .= "{$row['uid']}\t{$row['name']}\t\t{$row['num_regs']}\t{$row['schema']}\t{$row['data']}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$META .= $sTrace;
|
||||||
|
|
||||||
|
///////////////EXPORT PROCESS
|
||||||
|
$PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP;
|
||||||
|
|
||||||
|
$filenameOnly = strtolower('SYS-'.SYS_SYS."_".date("Y-m-d").'_'.date("Hi").".pmt");
|
||||||
|
|
||||||
|
$filename = $PUBLIC_ROOT_PATH . $filenameOnly;
|
||||||
|
$fp = fopen( $filename, "wb");
|
||||||
|
|
||||||
|
$bytesSaved = 0;
|
||||||
|
$bufferType = '@META';
|
||||||
|
$fsData = sprintf("%09d", strlen($META));
|
||||||
|
$fsbufferType = sprintf("%09d", strlen($bufferType));
|
||||||
|
$bytesSaved += fwrite($fp, $fsbufferType); //writing the size of $oData
|
||||||
|
$bytesSaved += fwrite($fp, $bufferType); //writing the $oData
|
||||||
|
$bytesSaved += fwrite($fp, $fsData); //writing the size of $oData
|
||||||
|
$bytesSaved += fwrite($fp, $META); //writing the $oData
|
||||||
|
|
||||||
|
foreach($tablesToExport as $table){
|
||||||
|
|
||||||
|
if ($table->_SCHEMA) {
|
||||||
|
$oAdditionalTables = new AdditionalTables();
|
||||||
|
$aData = $oAdditionalTables->load($table->ADD_TAB_UID, true);
|
||||||
|
|
||||||
|
$bufferType = '@SCHEMA';
|
||||||
|
$SDATA = serialize($aData);
|
||||||
|
$fsUid = sprintf("%09d", strlen($table->ADD_TAB_UID));
|
||||||
|
$fsData = sprintf("%09d", strlen ($SDATA));
|
||||||
|
$fsbufferType = sprintf("%09d", strlen($bufferType));
|
||||||
|
|
||||||
|
$bytesSaved += fwrite($fp, $fsbufferType); //writing the size of $oData
|
||||||
|
$bytesSaved += fwrite($fp, $bufferType); //writing the $oData
|
||||||
|
$bytesSaved += fwrite($fp, $fsUid ); //writing the size of xml file
|
||||||
|
$bytesSaved += fwrite($fp, $table->ADD_TAB_UID); //writing the xmlfile
|
||||||
|
$bytesSaved += fwrite($fp, $fsData); //writing the size of xml file
|
||||||
|
$bytesSaved += fwrite($fp, $SDATA); //writing the xmlfile
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($table->_DATA) {
|
||||||
|
//export data
|
||||||
|
$oAdditionalTables = new additionalTables();
|
||||||
|
$tableData = $oAdditionalTables->getAllData($table->ADD_TAB_UID);
|
||||||
|
|
||||||
|
$SDATA = serialize($tableData['rows']);
|
||||||
|
$bufferType = '@DATA';
|
||||||
|
|
||||||
|
$fsbufferType = sprintf("%09d", strlen($bufferType));
|
||||||
|
$fsTableName = sprintf("%09d", strlen($table->ADD_TAB_NAME));
|
||||||
|
$fsData = sprintf("%09d", strlen ($SDATA));
|
||||||
|
|
||||||
|
$bytesSaved += fwrite($fp, $fsbufferType); //writing type size
|
||||||
|
$bytesSaved += fwrite($fp, $bufferType); //writing type
|
||||||
|
$bytesSaved += fwrite($fp, $fsTableName ); //writing the size of xml file
|
||||||
|
$bytesSaved += fwrite($fp, $table->ADD_TAB_NAME); //writing the xmlfile
|
||||||
|
$bytesSaved += fwrite($fp, $fsData); //writing the size of xml file
|
||||||
|
$bytesSaved += fwrite($fp, $SDATA); //writing the xmlfile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose ($fp);
|
||||||
|
|
||||||
|
$filenameLink = "pmTables/streamExported?f=$filenameOnly";
|
||||||
|
$size = round(($bytesSaved/1024), 2)." Kb";
|
||||||
|
$meta = "<pre>".$META."</pre>";
|
||||||
|
$filename = $filenameOnly;
|
||||||
|
$link = $filenameLink;
|
||||||
|
|
||||||
|
// $G_PUBLISH = new Publisher();
|
||||||
|
// $G_PUBLISH->AddContent('xmlform', 'xmlform', 'additionalTables/doExport', '', $aFields, '');
|
||||||
|
// G::RenderPage('publish', 'raw');
|
||||||
|
|
||||||
|
$result->success = true;
|
||||||
|
$result->filename = $filenameOnly;
|
||||||
|
$result->link = $link;
|
||||||
|
$result->message = "Generated file: $filenameOnly, size: $size";
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
$result->success = false;
|
||||||
|
$result->message = $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public function exportList()
|
public function exportList()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -114,7 +114,16 @@ Ext.onReady(function(){
|
|||||||
|
|
||||||
//row editor for table columns grid
|
//row editor for table columns grid
|
||||||
editor = new Ext.ux.grid.RowEditor({
|
editor = new Ext.ux.grid.RowEditor({
|
||||||
saveText: _("ID_UPDATE")
|
saveText: _("ID_UPDATE"),
|
||||||
|
listeners: {
|
||||||
|
afteredit: {
|
||||||
|
fn:function(rowEditor, obj, data, rowIndex ){
|
||||||
|
if (data.phantom === true) {
|
||||||
|
store.reload(); // only if it is an insert
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var proxy = new Ext.data.HttpProxy({
|
var proxy = new Ext.data.HttpProxy({
|
||||||
@@ -142,16 +151,16 @@ Ext.onReady(function(){
|
|||||||
totalProperty: 'count'
|
totalProperty: 'count'
|
||||||
})
|
})
|
||||||
|
|
||||||
store = new Ext.data.GroupingStore({
|
store = new Ext.data.Store({
|
||||||
proxy : proxy,
|
proxy : proxy,
|
||||||
reader : reader,
|
reader : reader,
|
||||||
writer : writer, // <-- plug a DataWriter into the store just as you would a Reader
|
writer : writer, // <-- plug a DataWriter into the store just as you would a Reader
|
||||||
autoSave: true // <-- false would delay executing create, update, destroy requests until specifically told to do so with some [save] buton.
|
autoSave: true // <-- false would delay executing create, update, destroy requests until specifically told to do so with some [save] buton.
|
||||||
});
|
});
|
||||||
|
|
||||||
Ext.data.DataProxy.addListener('write', function(proxy, action, result, res, rs) {
|
/*Ext.data.DataProxy.addListener('write', function(proxy, action, result, res, rs) {
|
||||||
PMExt.notify('UPDATE', 'the record was updated successfully.');
|
PMExt.notify('UPDATE', 'the record was updated successfully.');
|
||||||
});
|
});*/
|
||||||
|
|
||||||
// load the store immeditately
|
// load the store immeditately
|
||||||
//store.load();
|
//store.load();
|
||||||
@@ -225,16 +234,12 @@ Ext.onReady(function(){
|
|||||||
sm: smodel,
|
sm: smodel,
|
||||||
tbar:[newButton,'-',editButton, deleteButton,'-',importButton,{xtype: 'tbfill' }, backButton],
|
tbar:[newButton,'-',editButton, deleteButton,'-',importButton,{xtype: 'tbfill' }, backButton],
|
||||||
bbar: bbarpaging,
|
bbar: bbarpaging,
|
||||||
listeners: {
|
/*listeners: {
|
||||||
//rowdblclick: EditPMTableRow,
|
//rowdblclick: EditPMTableRow,
|
||||||
render: function(){
|
render: function(){
|
||||||
this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')});
|
this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')});
|
||||||
}
|
}
|
||||||
},
|
},*/
|
||||||
view: new Ext.grid.GroupingView({
|
|
||||||
forceFit:true,
|
|
||||||
groupTextTpl: '{text}'
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
infoGrid.on('rowcontextmenu',
|
infoGrid.on('rowcontextmenu',
|
||||||
|
|||||||
@@ -1,169 +1,165 @@
|
|||||||
var store;
|
|
||||||
var cmodel;
|
|
||||||
var smodel;
|
|
||||||
var infoGrid;
|
|
||||||
var viewport;
|
|
||||||
|
|
||||||
var cancelButton;
|
var checkColumn;
|
||||||
var exportButton;
|
|
||||||
|
|
||||||
var w;
|
var Export = function() {
|
||||||
|
return {
|
||||||
|
//config objects
|
||||||
|
windowConfig : {},
|
||||||
|
targetGridConfig : {},
|
||||||
|
|
||||||
Ext.onReady(function(){
|
// defining components
|
||||||
|
targetGrid : {},
|
||||||
|
window : {},
|
||||||
|
// init
|
||||||
|
init : function() {
|
||||||
|
Ext.form.Field.prototype.msgTarget = 'side';
|
||||||
Ext.QuickTips.init();
|
Ext.QuickTips.init();
|
||||||
|
|
||||||
var reader = new Ext.data.ArrayReader({}, [{name: 'action'}]);
|
this.configure();
|
||||||
|
|
||||||
var comboStore = new Ext.data.Store({
|
this.targetGrid = new Ext.grid.EditorGridPanel(this.targetGridConfig);
|
||||||
reader: reader,
|
this.window = new Ext.Window(this.windowConfig);
|
||||||
data: Ext.grid.dummyData
|
this.window.add(this.targetGrid);
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
exportButton = new Ext.Action({
|
|
||||||
text: _('ID_EXPORT'),
|
|
||||||
iconCls: 'silk-add',
|
|
||||||
icon: '/images/export.png',
|
|
||||||
handler: ExportPMTables
|
|
||||||
});
|
|
||||||
|
|
||||||
cancelButton = new Ext.Action({
|
Export.configure = function()
|
||||||
text: _('ID_BACK'),
|
{
|
||||||
icon: '/images/back-icon.png',
|
/**
|
||||||
handler: CancelExport
|
* TARGET GRID CONFIG
|
||||||
});
|
*/
|
||||||
|
this.targetGridConfig = {
|
||||||
|
id : 'targetGrid',
|
||||||
|
title : 'To Export tables',
|
||||||
|
region: 'east',
|
||||||
|
width : 450,
|
||||||
|
split : true,
|
||||||
|
clicksToEdit: 2,
|
||||||
|
columnLines: true
|
||||||
|
};
|
||||||
|
|
||||||
store = new Ext.data.GroupingStore( {
|
this.targetGridConfig.store = new Ext.data.ArrayStore({
|
||||||
proxy : new Ext.data.HttpProxy({
|
|
||||||
url: '../pmTablesProxy/exportList?id='+EXPORT_TABLES.UID_LIST
|
|
||||||
}),
|
|
||||||
reader : new Ext.data.JsonReader( {
|
|
||||||
root: '',
|
|
||||||
fields: [
|
fields: [
|
||||||
{name : 'ADD_TAB_UID'},
|
{name : 'ADD_TAB_UID'},
|
||||||
{name : 'ADD_TAB_NAME'},
|
{name : 'ADD_TAB_NAME'},
|
||||||
{name : 'ADD_TAB_DESCRIPTION'},
|
{name : '_TYPE'},
|
||||||
{name : 'CH_SCHEMA'},
|
{name : '_SCHEMA'},
|
||||||
{name : 'CH_DATA'}
|
{name : '_DATA'}
|
||||||
]
|
]
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var action_edit = new Ext.form.ComboBox({
|
|
||||||
typeAhead: true,
|
schemaColumn = new Ext.grid.CheckColumn({
|
||||||
triggerAction: 'all',
|
header: 'Schema',
|
||||||
mode: 'local',
|
dataIndex: '_SCHEMA',
|
||||||
store: comboStore,
|
width: 55,
|
||||||
displayField: 'action',
|
checked: true
|
||||||
valueField: 'action'
|
|
||||||
});
|
});
|
||||||
|
|
||||||
cmodel = new Ext.grid.ColumnModel({
|
dataColumn = new Ext.grid.CheckColumn({
|
||||||
|
header: 'Data',
|
||||||
|
dataIndex: '_DATA',
|
||||||
|
width: 55
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
this.targetGridConfig.cm = new Ext.grid.ColumnModel({
|
||||||
defaults: {
|
defaults: {
|
||||||
width: 10,
|
|
||||||
sortable: true
|
sortable: true
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
new Ext.grid.RowNumberer(),
|
new Ext.grid.RowNumberer(),
|
||||||
//smodel,
|
|
||||||
{id:'ADD_TAB_UID', dataIndex: 'ADD_TAB_UID', hidden:true, hideable:false},
|
{id:'ADD_TAB_UID', dataIndex: 'ADD_TAB_UID', hidden:true, hideable:false},
|
||||||
{header: _('ID_NAME'), dataIndex: 'ADD_TAB_NAME', width: 20, align:'left'},
|
{header: _('ID_TABLE'), dataIndex: 'ADD_TAB_NAME', width: 300},
|
||||||
{header: _('ID_DESCRIPTION'), dataIndex: 'ADD_TAB_DESCRIPTION', width: 50, hidden:false, align:'left'},//,
|
{header: _('ID_TYPE'), dataIndex: '_TYPE', width:70},
|
||||||
{header: _('ID_SCHEMA'), dataIndex: 'CH_SCHEMA', hidden: false, width: 20, editor: action_edit, align: 'center'},
|
schemaColumn,
|
||||||
{header: 'DATA', dataIndex: 'CH_DATA', hidden: false, width: 20, editor: action_edit, align: 'center'}
|
dataColumn
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
infoGrid = new Ext.grid.EditorGridPanel({
|
this.targetGridConfig.plugins = [schemaColumn, dataColumn];
|
||||||
store: store,
|
|
||||||
cm: cmodel,
|
|
||||||
width: 600,
|
|
||||||
height: 300,
|
|
||||||
title: _('ID_ADDITIONAL_TABLES') + ': ' +_('ID_TITLE_EXPORT_TOOL'),
|
|
||||||
frame: false,
|
|
||||||
clicksToEdit: 1,
|
|
||||||
id: 'infoGrid',
|
|
||||||
|
|
||||||
sm: new Ext.grid.RowSelectionModel({singleSelect: false}),
|
/**
|
||||||
tbar:[exportButton, {xtype: 'tbfill'} ,cancelButton],//'-', editButton, deleteButton,'-', dataButton,{xtype: 'tbfill'} , importButton, exportButton],
|
* WINDOW CONFIG
|
||||||
view: new Ext.grid.GroupingView({
|
*/
|
||||||
forceFit:true,
|
this.windowConfig = {
|
||||||
groupTextTpl: '{text}'
|
title: '',
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
infoGrid.store.load();
|
|
||||||
|
|
||||||
viewport = new Ext.Viewport({
|
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
autoScroll: false,
|
width: 550,
|
||||||
items: [
|
height: 400,
|
||||||
infoGrid
|
modal: true,
|
||||||
]
|
autoScroll: true,
|
||||||
});
|
maximizable: true,
|
||||||
|
closeAction: 'hide',
|
||||||
});
|
maximizable : false,
|
||||||
|
items: [],
|
||||||
//Cancels Export View
|
listeners:{
|
||||||
CancelExport = function(){
|
show:function() {
|
||||||
history.back();
|
this.loadMask = new Ext.LoadMask(this.body, { msg:'Loading. Please wait...' });
|
||||||
};
|
}
|
||||||
|
|
||||||
//Export Schema/Data from PM Tables
|
|
||||||
ExportPMTables = function(){
|
|
||||||
iGrid = Ext.getCmp('infoGrid');
|
|
||||||
var storeExport = iGrid.getStore();
|
|
||||||
var UIDs = new Array();
|
|
||||||
var SCHs = new Array();
|
|
||||||
var DATs = new Array();
|
|
||||||
for (var r=0; r<storeExport.getCount(); r++){
|
|
||||||
row = storeExport.getAt(r);
|
|
||||||
UIDs[r] = row.data['ADD_TAB_UID'];
|
|
||||||
if (row.data['CH_SCHEMA']==_('ID_ACTION_EXPORT')){
|
|
||||||
SCHs[r] = row.data['ADD_TAB_UID'];
|
|
||||||
}else{
|
|
||||||
SCHs[r] = 0;
|
|
||||||
}
|
|
||||||
if (row.data['CH_DATA']==_('ID_ACTION_EXPORT')){
|
|
||||||
DATs[r] = row.data['ADD_TAB_UID'];
|
|
||||||
}else{
|
|
||||||
DATs[r] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ext.Ajax.request({
|
|
||||||
url: '../additionalTables/additionalTablesAjax',
|
|
||||||
success: SuccessExport,
|
|
||||||
failure: DoNothing,
|
|
||||||
params: { action: 'doExport', tables: UIDs.join(','), schema: SCHs.join(','), data: DATs.join(',') }
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//Response Export Handler
|
this.windowConfig.buttons = [{
|
||||||
SuccessExport = function(response, opts){
|
text: 'Export',
|
||||||
w = new Ext.Window({
|
handler: Export.submit
|
||||||
height: 350,
|
},{
|
||||||
width: 670,
|
text: 'Cancel',
|
||||||
resizable: false,
|
handler: function(){
|
||||||
html: response.responseText,
|
Export.window.hide();
|
||||||
autoscroll: false,
|
}
|
||||||
title: _('ID_TITLE_EXPORT_RESULT'),
|
|
||||||
closable: true,
|
|
||||||
buttons: [{
|
|
||||||
text: _('ID_CLOSE'),
|
|
||||||
// iconCls: 'silk-add',
|
|
||||||
handler: CloseExport
|
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
} //end configure
|
||||||
|
|
||||||
|
Export.submit = function()
|
||||||
|
{
|
||||||
|
|
||||||
|
var rows = Export.targetGrid.getStore();
|
||||||
|
var rowsData = new Array();
|
||||||
|
|
||||||
|
for (i=0; i < rows.getCount(); i++) {
|
||||||
|
row = rows.getAt(i);
|
||||||
|
if ( row.data._SCHEMA == false && row.data._DATA == false) {
|
||||||
|
PMExt.info('INFO', 'From each table you should select Schema/Data to export at least one.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
rowsData.push(row.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ext.Msg.show({
|
||||||
|
title : '', //TRANSLATIONS.ID_TITLE_START_CASE, //'Start Case',
|
||||||
|
msg : 'Processing...',
|
||||||
|
wait: true,
|
||||||
|
waitConfig: {interval:500}
|
||||||
});
|
});
|
||||||
w.show();
|
|
||||||
};
|
|
||||||
|
|
||||||
//Close Export Dialog
|
|
||||||
CloseExport = function(){
|
|
||||||
w.close();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//Do Nothing Function
|
Ext.Ajax.request({
|
||||||
DoNothing = function(){};
|
url: 'pmTablesProxy/export',
|
||||||
|
params: {
|
||||||
|
rows : Ext.util.JSON.encode(rowsData)
|
||||||
|
},
|
||||||
|
success: function(resp){
|
||||||
|
Ext.Msg.hide();
|
||||||
|
Export.window.hide();
|
||||||
|
result = Ext.util.JSON.decode(resp.responseText);
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
location.href = result.link;
|
||||||
|
} else {
|
||||||
|
PMExt.error(_('ID_ERROR', result.message));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
failure: function(obj, resp){
|
||||||
|
Ext.Msg.alert( _('ID_ERROR'), resp.result.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Ext.onReady(Export.init, Export, true);
|
||||||
|
|
||||||
Ext.grid.dummyData = [['Export'],['Ignore']];
|
|
||||||
|
|
||||||
|
|||||||
@@ -245,6 +245,7 @@ Ext.onReady(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
cmodelColumns = new Array();
|
cmodelColumns = new Array();
|
||||||
|
cmodelColumns.push(new Ext.grid.CheckboxSelectionModel());
|
||||||
cmodelColumns.push({id:'ADD_TAB_UID', dataIndex: 'ADD_TAB_UID', hidden:true, hideable:false});
|
cmodelColumns.push({id:'ADD_TAB_UID', dataIndex: 'ADD_TAB_UID', hidden:true, hideable:false});
|
||||||
cmodelColumns.push({dataIndex: 'ADD_TAB_TAG', hidden:true, hideable:false});
|
cmodelColumns.push({dataIndex: 'ADD_TAB_TAG', hidden:true, hideable:false});
|
||||||
cmodelColumns.push({header: _('ID_NAME'), dataIndex: 'ADD_TAB_NAME', width: 300, align:'left', renderer: function(v,p,r){
|
cmodelColumns.push({header: _('ID_NAME'), dataIndex: 'ADD_TAB_NAME', width: 300, align:'left', renderer: function(v,p,r){
|
||||||
@@ -539,6 +540,23 @@ ImportPMTable = function(){
|
|||||||
|
|
||||||
//Load Export PM Tables Form
|
//Load Export PM Tables Form
|
||||||
ExportPMTable = function(){
|
ExportPMTable = function(){
|
||||||
|
var rows = Ext.getCmp('infoGrid').getSelectionModel().getSelections();
|
||||||
|
var toExportRows = new Array();
|
||||||
|
|
||||||
|
for(var i=0; i<rows.length; i++){
|
||||||
|
toExportRows.push([
|
||||||
|
rows[i].get('ADD_TAB_UID'),
|
||||||
|
rows[i].get('ADD_TAB_NAME'),
|
||||||
|
(rows[i].get('PRO_UID') == ''? 'Table': 'Report'),
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Export.targetGrid.store.loadData(toExportRows);
|
||||||
|
|
||||||
|
Export.window.show();
|
||||||
|
return;
|
||||||
iGrid = Ext.getCmp('infoGrid');
|
iGrid = Ext.getCmp('infoGrid');
|
||||||
rowsSelected = iGrid.getSelectionModel().getSelections();
|
rowsSelected = iGrid.getSelectionModel().getSelections();
|
||||||
//location.href = 'additionalTablesToExport?sUID='+RetrieveRowsID(rowsSelected)+'&rand='+Math.random();
|
//location.href = 'additionalTablesToExport?sUID='+RetrieveRowsID(rowsSelected)+'&rand='+Math.random();
|
||||||
|
|||||||
Reference in New Issue
Block a user