BUG 0000 PM Tables + Report Tables ver. 2
(fixes in list an data handling)
This commit is contained in:
@@ -116,6 +116,9 @@ class pmTables extends Controller
|
|||||||
|
|
||||||
$this->includeExtJS('pmTables/' . $jsFile, $this->debug);
|
$this->includeExtJS('pmTables/' . $jsFile, $this->debug);
|
||||||
|
|
||||||
|
//fix for backware compatibility
|
||||||
|
$table['DBS_UID'] = $table['DBS_UID'] == null || $table['DBS_UID'] == '' ? 'workflow': $table['DBS_UID'];
|
||||||
|
|
||||||
$this->setJSVar('ADD_TAB_UID', $addTabUid);
|
$this->setJSVar('ADD_TAB_UID', $addTabUid);
|
||||||
$this->setJSVar('PRO_UID', isset($_GET['PRO_UID'])? $_GET['PRO_UID'] : false);
|
$this->setJSVar('PRO_UID', isset($_GET['PRO_UID'])? $_GET['PRO_UID'] : false);
|
||||||
$this->setJSVar('TABLE', $table);
|
$this->setJSVar('TABLE', $table);
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ require_once 'classes/model/AdditionalTables.php';
|
|||||||
class pmTablesProxy extends HttpProxyController
|
class pmTablesProxy extends HttpProxyController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected $className;
|
||||||
|
protected $classPeerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get pmtables list
|
* get pmtables list
|
||||||
* @param string $httpData->start
|
* @param string $httpData->start
|
||||||
@@ -381,18 +384,42 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
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);
|
||||||
$className = $table['ADD_TAB_CLASS_NAME'];
|
$this->className = $table['ADD_TAB_CLASS_NAME'];
|
||||||
$sClassPeerName = $className . 'Peer';
|
$this->classPeerName = $this->className . 'Peer';
|
||||||
|
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||||
|
|
||||||
|
if (!file_exists ($sPath . $this->className . '.php') ) {
|
||||||
|
throw new Exception("ERROR: $className class file doesn't exit!");
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once $sPath . $this->className . '.php';
|
||||||
$rows = G::json_decode($httpData->rows);
|
$rows = G::json_decode($httpData->rows);
|
||||||
|
eval('$obj = new ' .$this->className. '();');
|
||||||
if (is_array($rows)) {
|
if (is_array($rows)) {
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
foreach ($row as $key => $value) {
|
||||||
|
$action = 'set' . AdditionalTables::getPHPName($key);
|
||||||
|
$res = $obj->$action($value);
|
||||||
|
}
|
||||||
|
$this->success = $res ? true: false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foreach ($rows as $key => $value) {
|
||||||
|
$action = 'set' . AdditionalTables::getPHPName($key);
|
||||||
|
$obj->$action($value);
|
||||||
|
}
|
||||||
|
if ($obj->save() >0) {
|
||||||
|
$this->success = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->success = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else { //then is object
|
|
||||||
|
|
||||||
}
|
|
||||||
print_R($row);
|
$this->message = $this->success ? 'Saved Successfully' : 'Error Updating record';
|
||||||
//$sClassPeerName::retrieveByPk();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -406,27 +433,48 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
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);
|
||||||
$className = $table['ADD_TAB_CLASS_NAME'];
|
$this->className = $table['ADD_TAB_CLASS_NAME'];
|
||||||
$slassPeerName = $className . 'Peer';
|
$this->classPeerName = $this->className . 'Peer';
|
||||||
|
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||||
|
|
||||||
|
if (!file_exists ($sPath . $this->className . '.php') ) {
|
||||||
|
throw new Exception("ERROR: $className class file doesn't exit!");
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once $sPath . $this->className . '.php';
|
||||||
|
|
||||||
$rows = G::json_decode($httpData->rows);
|
$rows = G::json_decode($httpData->rows);
|
||||||
print_R($rows);
|
|
||||||
if (is_array($rows)) {
|
if (is_array($rows)) {
|
||||||
|
foreach($rows as $row) {
|
||||||
|
$result = $this->_dataUpdate($row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else { //then is object
|
else { //then is object
|
||||||
$keys = explode('-', $rows->__index__);
|
$result = $this->_dataUpdate($rows);
|
||||||
foreach ($keys as $key) {
|
|
||||||
$params .= is_numeric($key) ? $key : "'$key'";
|
|
||||||
}
|
|
||||||
|
|
||||||
$obj = null;
|
|
||||||
var_dump('$obj = $classPeerName::retrieveByPk('.implode(',', $params).')');
|
|
||||||
eval('$obj = $classPeerName::retrieveByPk('.implode(',', $params).')');
|
|
||||||
var_dump($obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//$sClassPeerName::retrieveByPk();
|
$this->success = $result;
|
||||||
|
$this->message = $result ? 'Updated Successfully' : 'Error Updating record';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataDestroy($httpData)
|
||||||
|
{
|
||||||
|
require_once 'classes/model/AdditionalTables.php';
|
||||||
|
$oAdditionalTables = new AdditionalTables();
|
||||||
|
$table = $oAdditionalTables->load($httpData->id, true);
|
||||||
|
$this->className = $table['ADD_TAB_CLASS_NAME'];
|
||||||
|
$this->classPeerName = $this->className . 'Peer';
|
||||||
|
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||||
|
|
||||||
|
if (!file_exists ($sPath . $this->className . '.php') ) {
|
||||||
|
throw new Exception("ERROR: $className class file doesn't exit!");
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once $sPath . $this->className . '.php';
|
||||||
|
|
||||||
|
$this->success = $this->_dataDestroy($httpData->rows);
|
||||||
|
$this->message = $this->success ? 'Deleted Successfully' : 'Error Deleting record';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -434,6 +482,62 @@ class pmTablesProxy extends HttpProxyController
|
|||||||
* - protected functions (non callable from controller outside) -
|
* - protected functions (non callable from controller outside) -
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update data from a addTable record
|
||||||
|
* @param $row
|
||||||
|
*/
|
||||||
|
function _dataUpdate($row)
|
||||||
|
{
|
||||||
|
$keys = explode('-', $row->__index__);
|
||||||
|
unset($row->__index__);
|
||||||
|
$params = array();
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
$params[] = is_numeric($key) ? $key : "'$key'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$obj = null;
|
||||||
|
eval('$obj = '.$this->classPeerName.'::retrieveByPk('.implode(',', $params).');');
|
||||||
|
|
||||||
|
if (is_object($obj)) {
|
||||||
|
foreach ($row as $key => $value) {
|
||||||
|
$action = 'set' . AdditionalTables::getPHPName($key);
|
||||||
|
$obj->$action($value);
|
||||||
|
}
|
||||||
|
$obj->save();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
$this->success = false;
|
||||||
|
$this->message = 'Update Failed';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update data from a addTable record
|
||||||
|
* @param $row
|
||||||
|
*/
|
||||||
|
function _dataDestroy($row)
|
||||||
|
{
|
||||||
|
$row = str_replace('"', '', $row);
|
||||||
|
$keys = explode('-', $row);
|
||||||
|
$params = array();
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
$params[] = is_numeric($key) ? $key : "'$key'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$obj = null;
|
||||||
|
eval('$obj = '.$this->classPeerName.'::retrieveByPk('.implode(',', $params).');');
|
||||||
|
|
||||||
|
if (is_object($obj)) {
|
||||||
|
$obj->delete();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
$this->success = false;
|
||||||
|
$this->message = 'Update Failed';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get report table default columns
|
* Get report table default columns
|
||||||
* @param $type
|
* @param $type
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ var store;
|
|||||||
var cmodel;
|
var cmodel;
|
||||||
var smodel;
|
var smodel;
|
||||||
var infoGrid;
|
var infoGrid;
|
||||||
|
var _fields;
|
||||||
|
|
||||||
Ext.onReady(function(){
|
Ext.onReady(function(){
|
||||||
|
|
||||||
@@ -89,27 +90,27 @@ Ext.onReady(function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// smodel = new Ext.grid.CheckboxSelectionModel({
|
smodel = new Ext.grid.CheckboxSelectionModel({
|
||||||
// listeners:{
|
listeners:{
|
||||||
// selectionchange: function(sm){
|
selectionchange: function(sm){
|
||||||
// var count_rows = sm.getCount();
|
var count_rows = sm.getCount();
|
||||||
// switch(count_rows){
|
switch(count_rows){
|
||||||
// case 0:
|
case 0:
|
||||||
// editButton.disable();
|
editButton.disable();
|
||||||
// deleteButton.disable();
|
deleteButton.disable();
|
||||||
// break;
|
break;
|
||||||
// case 1:
|
case 1:
|
||||||
// editButton.enable();
|
editButton.enable();
|
||||||
// deleteButton.enable();
|
deleteButton.enable();
|
||||||
// break;
|
break;
|
||||||
// default:
|
default:
|
||||||
// editButton.disable();
|
editButton.disable();
|
||||||
// deleteButton.disable();
|
//deleteButton.disable();
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
//row editor for table columns grid
|
//row editor for table columns grid
|
||||||
editor = new Ext.ux.grid.RowEditor({
|
editor = new Ext.ux.grid.RowEditor({
|
||||||
@@ -148,6 +149,10 @@ Ext.onReady(function(){
|
|||||||
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) {
|
||||||
|
PMExt.notify('UPDATE', 'the record was updated successfully.');
|
||||||
|
});
|
||||||
|
|
||||||
// load the store immeditately
|
// load the store immeditately
|
||||||
//store.load();
|
//store.load();
|
||||||
|
|
||||||
@@ -217,7 +222,7 @@ Ext.onReady(function(){
|
|||||||
store: store,
|
store: store,
|
||||||
cm: cmodel,
|
cm: cmodel,
|
||||||
plugins: [editor],
|
plugins: [editor],
|
||||||
//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: {
|
||||||
@@ -273,8 +278,24 @@ capitalize = function(s){
|
|||||||
DoNothing = function(){};
|
DoNothing = function(){};
|
||||||
|
|
||||||
//Load New PM Table Row Forms
|
//Load New PM Table Row Forms
|
||||||
|
var props = function(){};
|
||||||
|
|
||||||
NewPMTableRow = function(){
|
NewPMTableRow = function(){
|
||||||
location.href = 'additionalTablesDataNew?sUID=' + TABLES.UID;
|
var PMRow = infoGrid.getStore().recordType;
|
||||||
|
//var meta = mapPMFieldType(records[i].data['FIELD_UID']);
|
||||||
|
|
||||||
|
for(i=0; i<_fields.length; i++) {
|
||||||
|
props.prototype[_fields[i].name] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
var row = new PMRow(new props);
|
||||||
|
length = infoGrid.getStore().data.length;
|
||||||
|
|
||||||
|
editor.stopEditing();
|
||||||
|
store.insert(length, row);
|
||||||
|
infoGrid.getView().refresh();
|
||||||
|
infoGrid.getSelectionModel().selectRow(length);
|
||||||
|
editor.startEditing(length);
|
||||||
};
|
};
|
||||||
|
|
||||||
//Load PM Table Edition Row Form
|
//Load PM Table Edition Row Form
|
||||||
@@ -292,20 +313,12 @@ EditPMTableRow = function(){
|
|||||||
|
|
||||||
//Confirm PM Table Row Deletion Tasks
|
//Confirm PM Table Row Deletion Tasks
|
||||||
DeletePMTableRow = function(){
|
DeletePMTableRow = function(){
|
||||||
iGrid = Ext.getCmp('infoGrid');
|
|
||||||
rowsSelected = iGrid.getSelectionModel().getSelections();
|
PMExt.confirm(_('ID_CONFIRM'), _('ID_CONFIRM_REMOVE_FIELD'), function(){
|
||||||
Ext.Msg.confirm(_('ID_CONFIRM'), _('ID_MSG_CONFIRM_DELETE_ROW'),
|
var records = Ext.getCmp('infoGrid').getSelectionModel().getSelections();
|
||||||
function(btn, text){
|
Ext.each(records, Ext.getCmp('infoGrid').store.remove, Ext.getCmp('infoGrid').store);
|
||||||
if (btn=="yes"){
|
|
||||||
var aRowsSeleted = (RetrieveRowsID(rowsSelected)).split(",") ;
|
|
||||||
var aTablesPKF = (TABLES.PKF).split(","); ;
|
|
||||||
var sParam = '';
|
|
||||||
for(var i=0;i<aTablesPKF.length; i++){
|
|
||||||
sParam += '&' + aTablesPKF[i] + '=' + aRowsSeleted[i];
|
|
||||||
}
|
|
||||||
location.href = 'additionalTablesDataDelete?sUID='+TABLES.UID+sParam;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//Load Import PM Table From CSV Source
|
//Load Import PM Table From CSV Source
|
||||||
|
|||||||
@@ -222,8 +222,8 @@ Ext.onReady(function(){
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
cmodelColumns.push({header: 'Table Type', dataIndex: 'PRO_UID', width: 120, align:'left', renderer: function(v,p,r){
|
cmodelColumns.push({header: 'Table Type', dataIndex: 'PRO_UID', width: 120, align:'left', renderer: function(v,p,r){
|
||||||
color = r.get('PRO_UID') == '' ? 'green' : 'blue';
|
color = r.get('PRO_UID') ? 'green' : 'blue';
|
||||||
value = r.get('PRO_UID') == '' ? 'Table' : 'Report';
|
value = r.get('PRO_UID') ? 'Table' : 'Report';
|
||||||
return '<span style="color:'+color+'">'+value+'</span> ';
|
return '<span style="color:'+color+'">'+value+'</span> ';
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ EditPMTable = function(){
|
|||||||
var row = Ext.getCmp('infoGrid').getSelectionModel().getSelected();
|
var row = Ext.getCmp('infoGrid').getSelectionModel().getSelected();
|
||||||
|
|
||||||
if (row.data.TYPE != 'CLASSIC') {
|
if (row.data.TYPE != 'CLASSIC') {
|
||||||
tableType = row.data.PRO_UID !== '' ? 'report' : 'table';
|
tableType = row.data.PRO_UID ? 'report' : 'table';
|
||||||
proParam = PRO_UID !== false ? '&PRO_UID='+PRO_UID : '';
|
proParam = PRO_UID !== false ? '&PRO_UID='+PRO_UID : '';
|
||||||
location.href = 'pmTables/edit?id='+row.data.ADD_TAB_UID+'&tableType=' + tableType + proParam;
|
location.href = 'pmTables/edit?id='+row.data.ADD_TAB_UID+'&tableType=' + tableType + proParam;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user