insert duplicity validation for departments, roles, groups and process categories

This commit is contained in:
Enrique Ponce de Leon
2011-02-24 16:44:18 +00:00
parent b6d32c9498
commit 3f0c7dfb1a
7 changed files with 1174 additions and 1095 deletions

View File

@@ -168,7 +168,7 @@ switch ($_POST['action'])
G::LoadClass('groups');
$newGroup['GRP_UID'] = '';
$newGroup['GRP_STATUS'] = G::toUpper($_POST['status']);
$newGroup['GRP_TITLE'] = $_POST['name'];
$newGroup['GRP_TITLE'] = trim($_POST['name']);
unset($newGroup['GRP_UID']);
$group = new Groupwf();
$group->create($newGroup);
@@ -178,7 +178,7 @@ switch ($_POST['action'])
G::LoadClass('groups');
$editGroup['GRP_UID'] = $_POST['grp_uid'];
$editGroup['GRP_STATUS'] = G::toUpper($_POST['status']);
$editGroup['GRP_TITLE'] = $_POST['name'];
$editGroup['GRP_TITLE'] = trim($_POST['name']);
$group = new Groupwf();
$group->update($editGroup);
echo '{success: true}';

View File

@@ -99,7 +99,7 @@ if(isset($_REQUEST['action'])) {
case 'saveNewCategory':
try{
require_once 'classes/model/ProcessCategory.php';
$catName = $_REQUEST['category'];
$catName = trim($_REQUEST['category']);
$pcat = new ProcessCategory();
$pcat->setNew(true);
$pcat->setCategoryUid(G::GenerateUniqueID());
@@ -129,7 +129,7 @@ if(isset($_REQUEST['action'])) {
try{
require_once 'classes/model/ProcessCategory.php';
$catUID = $_REQUEST['cat_uid'];
$catName = $_REQUEST['category'];
$catName = trim($_REQUEST['category']);
$pcat = new ProcessCategory();
$pcat->setNew(false);
$pcat->setCategoryUid($catUID);

View File

@@ -38,7 +38,7 @@ switch ($REQUEST) {
$aData['ROL_UID'] = $newid;
//$aData['ROL_PARENT'] = $_POST['parent'];
$aData['ROL_SYSTEM'] = '00000000000000000000000000000002';
$aData['ROL_CODE'] = $_POST['code'];
$aData['ROL_CODE'] = trim($_POST['code']);
$aData['ROL_NAME'] = $_POST['name'];
$aData['ROL_CREATE_DATE'] = date("Y-M-d H:i:s");
$aData['ROL_UPDATE_DATE'] = date("Y-M-d H:i:s");
@@ -61,7 +61,7 @@ switch ($REQUEST) {
$aData['ROL_UID'] = $_POST['rol_uid'];
//$aData['ROL_PARENT'] = $_POST['parent'];
$aData['ROL_CODE'] = $_POST['code'];
$aData['ROL_CODE'] = trim($_POST['code']);
$aData['ROL_NAME'] = $_POST['name'];
$aData['ROL_UPDATE_DATE'] = date("Y-M-d H:i:s");
$aData['ROL_STATUS'] = $_POST['status'];
@@ -310,8 +310,20 @@ switch ($REQUEST) {
$c->saveConfig('rolesList', 'pageSize','',$_SESSION['USER_LOGGED']);
echo '{success: true}';
break;
case 'checkRoleCode':
$rol_code = $_POST['ROL_CODE'];
$oCriteria = new Criteria('rbac');
$oCriteria->addSelectColumn(RolesPeer::ROL_UID);
$oCriteria->add(RolesPeer::ROL_CODE, $rol_code);
$oDataset = RolesPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($oDataset->next()){
$response = 'false';
}else{
$response = 'true';
}
echo '{success:'.$response.'}';
break;
default: echo 'default';
}

View File

@@ -4,7 +4,9 @@
*/
//Keyboard Events
new Ext.KeyMap(document, {
new Ext.KeyMap(document,
[
{
key: Ext.EventObject.F5,
fn: function(keycode, e) {
if (! e.ctrlKey) {
@@ -19,22 +21,21 @@ new Ext.KeyMap(document, {
Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5');
}
}
},
{
key: Ext.EventObject.DELETE,
fn: function(k,e){ DeleteDepartmentAction();}
},
{
key: Ext.EventObject.F2,
fn: function(k,e){ EditDepartmentAction(); }
}
//,
//{
// key: Ext.EventObject.DELETE,
// fn: function(k,e){
// var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode();
// //if (typeof dep_node != 'undefined')
// //if(dep_node.attributes.leaf){
// DeleteDepartmentAction();
// //}
// }
//}
]
);
var treePanel;
var rootNode;
var w;
Ext.onReady(function() {
Ext.QuickTips.init();
@@ -92,8 +93,6 @@ Ext.onReady(function() {
deleteButton.disable();
}
}
//var tree = Ext.getCmp('treePanel');
//alert(treePanel.getRootNode());
}
}
});
@@ -179,7 +178,6 @@ Ext.onReady(function() {
text:'Departments'
});
treePanel = new Ext.ux.tree.TreeGrid({
title: _('ID_DEPARTMENTS'),
autoScroll: true,
@@ -250,7 +248,8 @@ NewRootDepartment = function(){
modal: true,
closable: false,
width: 420,
items: [newForm]
items: [newForm],
id: 'w'
});
w.show();
};
@@ -265,20 +264,23 @@ NewSubDepartment = function(){
modal: true,
closable: false,
width: 420,
items: [newForm]
items: [newForm],
id: 'w'
});
w.show();
};
//Close PopUp Window
CloseWindow = function(){
w.hide();
Ext.getCmp('w').hide();
};
SaveNewDepartment = function(){
var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode();
if (dep_node) dep_node.unselect();
var dep_name = newForm.getForm().findField('dep_name').getValue();
dep_name = dep_name.trim();
if (dep_name=='') return;
var dep_parent = newForm.getForm().findField('parent').getValue();
Ext.Ajax.request({
url: 'departments_Ajax',
@@ -297,7 +299,7 @@ SaveNewDepartment = function(){
deleteButton.disable();
usersButton.disable();
newForm.getForm().findField('dep_name').reset();
w.hide();
CloseWindow();
PMExt.notify(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_SUCCESS_NEW'));
},
failure: function(r,o){
@@ -316,6 +318,8 @@ SaveNewDepartment = function(){
SaveEditDepartment = function(){
var dep_name = editForm.getForm().findField('dep_name').getValue();
dep_name = dep_name.trim();
if (dep_name=='') return;
var dep_parent = editForm.getForm().findField('dep_parent').getValue();
var dep_uid = editForm.getForm().findField('dep_uid').getValue();
var dep_status = editForm.getForm().findField('status').getValue();
@@ -339,7 +343,7 @@ SaveEditDepartment = function(){
deleteButton.disable();
usersButton.disable();
newForm.getForm().findField('dep_name').reset();
w.hide();
CloseWindow();
PMExt.notify(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_SUCCESS_UPDATE'));
},
failure: function(r,o){
@@ -356,7 +360,6 @@ SaveEditDepartment = function(){
});
};
//Edit Department Action
EditDepartmentAction = function(){
var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode();
@@ -374,7 +377,8 @@ EditDepartmentAction = function(){
modal: true,
closable: false,
width: 420,
items: [editForm]
items: [editForm],
id: 'w'
});
w.show();
};
@@ -382,6 +386,7 @@ EditDepartmentAction = function(){
//Delete Department Action
DeleteDepartmentAction = function(){
var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode();
if (!dep_node.attributes.leaf) return;
var DEP_UID = dep_node.attributes.DEP_UID;
if (dep_node) dep_node.unselect();
viewport.getEl().mask(_('ID_PROCESSING'));

View File

@@ -59,6 +59,7 @@ var searchButton;
var searchText;
var contextMenu;
var pageSize;
var w;
Ext.onReady(function(){
Ext.QuickTips.init();
@@ -337,6 +338,7 @@ NewGroupWindow = function(){
title: _('ID_CREATE_GROUP_TITLE'),
closable: false,
modal: true,
id: 'w',
items: [newForm]
});
w.show();
@@ -355,7 +357,7 @@ DoSearch = function(){
//Close Popup Window
CloseWindow = function(){
w.hide();
Ext.getCmp('w').hide();
};
//Check Group Name Availability
@@ -379,6 +381,7 @@ CheckGroupName = function(grp_name, function_success, function_failure){
//Save Group Button
SaveNewGroupAction = function(){
var group = newForm.getForm().findField('name').getValue();
group = group.trim();
if (group != '') CheckGroupName(group, SaveNewGroup, DuplicateGroupName);
};
@@ -391,7 +394,7 @@ DuplicateGroupName = function(){
SaveNewGroup = function(){
newForm.getForm().submit({
success: function(f,a){
w.hide(); //Hide popup widow
CloseWindow(); //Hide popup widow
newForm.getForm().reset(); //Set empty form to next use
searchText.reset();
infoGrid.store.load(); //Reload store grid
@@ -421,6 +424,7 @@ EditGroupWindow = function(){
title: _('ID_EDIT_GROUP_TITLE'),
closable: false,
modal: true,
id: 'w',
items: [editForm]
});
w.show();
@@ -429,6 +433,7 @@ EditGroupWindow = function(){
//Save Edit Group Button
SaveEditGroupAction = function(){
var group = editForm.getForm().findField('name').getValue();
group = group.trim();
rowSelected = infoGrid.getSelectionModel().getSelected();
if (group != ''){
if (rowSelected.data.CON_VALUE.toUpperCase() == group.toUpperCase()){
@@ -443,7 +448,7 @@ SaveEditGroupAction = function(){
SaveEditGroup = function(){
editForm.getForm().submit({
success: function(f,a){
w.hide(); //Hide popup widow
CloseWindow(); //Hide popup widow
DoSearch(); //Reload store grid
editButton.disable(); //Disable Edit Button
deleteButton.disable(); //Disable Delete Button

View File

@@ -302,19 +302,23 @@ NewCategoryWindow = function(){
title: _('ID_NEW_CATEGORY'),
autoHeight: true,
width: 420,
items: [newForm]
items: [newForm],
id: 'w',
model: true
});
w.show();
};
//Close Popup Window
CloseWindow = function(){
w.hide();
Ext.getCmp('w').hide();
};
//Save New Category
SaveNewCategory = function(){
catName = newForm.getForm().findField('category').getValue();
catName = catName.trim();
if (catName == '') return;
viewport.getEl().mask(_('ID_PROCESSING'));
Ext.Ajax.request({
url: 'processCategory_Ajax',
@@ -327,7 +331,7 @@ SaveNewCategory = function(){
newForm.getForm().submit({
success: function(f,a){
viewport.getEl().unmask();
w.hide(); //Hide popup widow
CloseWindow(); //Hide popup widow
newForm.getForm().reset(); //Set empty form to next use
searchText.reset();
infoGrid.store.load();
@@ -362,6 +366,8 @@ SaveNewCategory = function(){
UpdateCategory = function(){
catUID = editForm.getForm().findField('cat_uid').getValue();
catName = editForm.getForm().findField('category').getValue();
catName = catName.trim();
if (catName == '') return;
viewport.getEl().mask(_('ID_PROCESSING'));
Ext.Ajax.request({
url: 'processCategory_Ajax',
@@ -374,7 +380,7 @@ UpdateCategory = function(){
editForm.getForm().submit({
success: function(f,a){
viewport.getEl().unmask();
w.hide(); //Hide popup widow
CloseWindow(); //Hide popup widow
newForm.getForm().reset(); //Set empty form to next use
searchText.reset();
infoGrid.store.load();
@@ -414,7 +420,9 @@ EditCategory = function(){
autoHeight: true,
width: 420,
title: _('ID_EDIT_CATEGORY'),
items: [editForm]
items: [editForm],
id: 'w',
modal: true
});
w.show();
}

View File

@@ -356,6 +356,8 @@ NewRoleWindow = function(){
w = new Ext.Window({
title: _('ID_CREATE_ROLE_TITLE'),
autoHeight: true,
id: 'w',
modal: true,
width: 420,
items: [newForm]
});
@@ -364,20 +366,34 @@ NewRoleWindow = function(){
//Close Popup Window
CloseWindow = function(){
w.hide();
Ext.getCmp('w').hide();
};
//Save New Role
SaveNewRole = function(){
rol_code = newForm.getForm().findField('code').getValue();
rol_code.trim();
if (rol_code == '') return;
viewport.getEl().mask(_('ID_PROCESSING'));
Ext.Ajax.request({
url: 'roles_Ajax',
params: {request: 'checkRoleCode', ROL_CODE: rol_code},
success: function(r,o){
viewport.getEl().unmask();
resp = Ext.util.JSON.decode(r.responseText);
if (resp.success){
viewport.getEl().mask(_('ID_PROCESSING'));
newForm.getForm().submit({
success: function(f,a){
w.hide(); //Hide popup widow
viewport.getEl().unmask();
CloseWindow(); //Hide popup widow
newForm.getForm().reset(); //Set empty form to next use
searchText.reset();
infoGrid.store.load(); //Reload store grid
PMExt.notify(_('ID_ROLES'),_('ID_ROLES_SUCCESS_NEW'));
},
failure: function(f,a){
viewport.getEl().unmask();
switch(a.failureType){
case Ext.form.Action.CLIENT_INVALID:
//Ext.Msg.alert('New Role Form','Invalid Data');
@@ -385,19 +401,42 @@ SaveNewRole = function(){
}
}
});
}else{
PMExt.error(_('ID_ROLES'),_('ID_ROLE_EXISTS'));
}
},
failure: function(r,o){
viewport.getEl().unmask();
}
});
};
//Update Selected Role
UpdateRole = function(){
rol_code = editForm.getForm().findField('code').getValue();
rol_code.trim();
if (rol_code == '') return;
viewport.getEl().mask(_('ID_PROCESSING'));
Ext.Ajax.request({
url: 'roles_Ajax',
params: {request: 'checkRoleCode', ROL_CODE: rol_code},
success: function(r,o){
viewport.getEl().unmask();
resp = Ext.util.JSON.decode(r.responseText);
if (resp.success){
viewport.getEl().mask(_('ID_PROCESSING'));
editForm.getForm().submit({
success: function(f,a){
w.hide(); //Hide popup widow
viewport.getEl().unmask();
CloseWindow(); //Hide popup widow
DoSearch(); //Reload store grid
editButton.disable(); //Disable Edit Button
deleteButton.disable(); //Disable Delete Button
PMExt.notify(_('ID_ROLES'),_('ID_ROLES_SUCCESS_UPDATE'));
},
failure: function(f,a){
viewport.getEl().unmask();
switch(a.failureType){
case Ext.form.Action.CLIENT_INVALID:
//Ext.Msg.alert('New Role Form','Invalid Data');
@@ -406,6 +445,14 @@ UpdateRole = function(){
}
});
}else{
PMExt.error(_('ID_ROLES'),_('ID_ROLE_EXISTS'));
}
},
failure: function(r,o) {
viewport.getEl().unmask();
}
});
};
//Edit Selected Role
@@ -421,6 +468,8 @@ EditRole = function(){
editForm.getForm().findField('status').setValue(rowSelected.data.ROL_STATUS);
w = new Ext.Window({
autoHeight: true,
id: 'w',
modal: true,
width: 420,
title: _('ID_EDIT_ROLE_TITLE'),
items: [editForm]