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

View File

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

View File

@@ -24,296 +24,308 @@
*/ */
$REQUEST = (isset($_GET['request']))?$_GET['request']:$_POST['request']; $REQUEST = (isset($_GET['request']))?$_GET['request']:$_POST['request'];
switch ($REQUEST) { switch ($REQUEST) {
case 'newRole': case 'newRole':
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'roles/roles_New', '', ''); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'roles/roles_New', '', '');
G::RenderPage('publish', 'raw'); G::RenderPage('publish', 'raw');
break; break;
case 'saveNewRole': case 'saveNewRole':
$newid = md5($_POST['code'].date("d-M-Y_H:i:s")); $newid = md5($_POST['code'].date("d-M-Y_H:i:s"));
$aData['ROL_UID'] = $newid; $aData['ROL_UID'] = $newid;
//$aData['ROL_PARENT'] = $_POST['parent']; //$aData['ROL_PARENT'] = $_POST['parent'];
$aData['ROL_SYSTEM'] = '00000000000000000000000000000002'; $aData['ROL_SYSTEM'] = '00000000000000000000000000000002';
$aData['ROL_CODE'] = $_POST['code']; $aData['ROL_CODE'] = trim($_POST['code']);
$aData['ROL_NAME'] = $_POST['name']; $aData['ROL_NAME'] = $_POST['name'];
$aData['ROL_CREATE_DATE'] = date("Y-M-d H:i:s"); $aData['ROL_CREATE_DATE'] = date("Y-M-d H:i:s");
$aData['ROL_UPDATE_DATE'] = date("Y-M-d H:i:s"); $aData['ROL_UPDATE_DATE'] = date("Y-M-d H:i:s");
$aData['ROL_STATUS'] = $_POST['status']; $aData['ROL_STATUS'] = $_POST['status'];
$oCriteria = $RBAC->createRole($aData); $oCriteria = $RBAC->createRole($aData);
echo '{success: true}'; echo '{success: true}';
break; break;
case 'editRole':
$ROL_UID = $_GET['ROL_UID'];
$aFields = $RBAC->loadById($ROL_UID);
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'roles/roles_Edit', '', $aFields);
G::RenderPage('publish', 'raw');
break;
case 'updateRole':
$aData['ROL_UID'] = $_POST['rol_uid'];
//$aData['ROL_PARENT'] = $_POST['parent'];
$aData['ROL_CODE'] = $_POST['code'];
$aData['ROL_NAME'] = $_POST['name'];
$aData['ROL_UPDATE_DATE'] = date("Y-M-d H:i:s");
$aData['ROL_STATUS'] = $_POST['status'];
$oCriteria = $RBAC->updateRole($aData);
echo '{success: true}';
break;
case 'show': case 'editRole':
G::LoadClass('ArrayPeer');
$aRoles = $RBAC->getAllRoles(); $ROL_UID = $_GET['ROL_UID'];
$aFields = $RBAC->loadById($ROL_UID);
$fields = Array(
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'roles/roles_Edit', '', $aFields);
G::RenderPage('publish', 'raw');
break;
case 'updateRole':
$aData['ROL_UID'] = $_POST['rol_uid'];
//$aData['ROL_PARENT'] = $_POST['parent'];
$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'];
$oCriteria = $RBAC->updateRole($aData);
echo '{success: true}';
break;
case 'show':
G::LoadClass('ArrayPeer');
$aRoles = $RBAC->getAllRoles();
$fields = Array(
'ROL_UID'=>'char', 'ROL_UID'=>'char',
'ROL_PARENT'=>'char', 'ROL_PARENT'=>'char',
'ROL_SYSTEM'=>'char', 'ROL_SYSTEM'=>'char',
'ROL_CREATE_DATE'=>'char', 'ROL_CREATE_DATE'=>'char',
'ROL_UPDATE_DATE'=>'char', 'ROL_UPDATE_DATE'=>'char',
'ROL_STATUS'=>'char' 'ROL_STATUS'=>'char'
); );
$rows = array_merge(Array($fields), $aRoles);
global $_DBArray;
$_DBArray['virtual_roles'] = $rows;
$oCriteria = new Criteria('dbarray');
$oCriteria->setDBArrayTable('virtual_roles');
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('propeltable', 'paged-table', 'roles/roles_List', $oCriteria);
G::RenderPage('publish', 'raw');
break;
case 'deleteRole':
$oCriteria = $RBAC->removeRole($_POST['ROL_UID']);
break;
case 'canDeleteRole':
if($RBAC->numUsersWithRole($_POST['ROL_UID']) == 0){
echo 'true';
} else {
echo 'false';
}
break;
case 'verifyNewRole': $rows = array_merge(Array($fields), $aRoles);
$response = ($RBAC->verifyNewRole($_POST['code']))?'true':'false';
print($response); global $_DBArray;
break; $_DBArray['virtual_roles'] = $rows;
$oCriteria = new Criteria('dbarray');
case 'updateDataRole': $oCriteria->setDBArrayTable('virtual_roles');
require_once 'classes/model/om/BaseRoles.php';
require_once 'classes/model/Content.php'; $G_PUBLISH = new Publisher;
$oCriteria = new Criteria('rbac'); $G_PUBLISH->AddContent('propeltable', 'paged-table', 'roles/roles_List', $oCriteria);
$oCriteria->addSelectColumn(RolesPeer::ROL_UID); G::RenderPage('publish', 'raw');
$oCriteria->addSelectColumn(RolesPeer::ROL_PARENT); break;
$oCriteria->addSelectColumn(RolesPeer::ROL_SYSTEM);
$oCriteria->addSelectColumn(RolesPeer::ROL_CODE); case 'deleteRole':
$oCriteria->addSelectColumn(RolesPeer::ROL_CREATE_DATE); $oCriteria = $RBAC->removeRole($_POST['ROL_UID']);
$oCriteria->addSelectColumn(RolesPeer::ROL_UPDATE_DATE); break;
$oCriteria->addSelectColumn(RolesPeer::ROL_STATUS);
$oCriteria->add(RolesPeer::ROL_CODE, $_GET['code']); case 'canDeleteRole':
$result = RolesPeer::doSelectRS($oCriteria); if($RBAC->numUsersWithRole($_POST['ROL_UID']) == 0){
$result->setFetchmode(ResultSet::FETCHMODE_ASSOC); echo 'true';
$result->next(); } else {
$row = $result->getRow(); echo 'false';
}
$oCriteria1 = new Criteria('workflow');
$oCriteria1->add(ContentPeer::CON_CATEGORY, 'ROL_NAME'); break;
$oCriteria1->add(ContentPeer::CON_ID, $row['ROL_UID']);
$oCriteria1->add(ContentPeer::CON_LANG, SYS_LANG); case 'verifyNewRole':
$oDataset1 = ContentPeer::doSelectRS($oCriteria1); $response = ($RBAC->verifyNewRole($_POST['code']))?'true':'false';
$oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC); print($response);
$oDataset1->next(); break;
$aRow1 = $oDataset1->getRow();
$row['ROL_NAME'] = $aRow1['CON_VALUE']; case 'updateDataRole':
$row['ROL_UPDATE_DATE'] = date("Y-M-d H:i:s"); require_once 'classes/model/om/BaseRoles.php';
require_once 'classes/model/Content.php';
$oCriteria = new Criteria('rbac');
$oCriteria->addSelectColumn(RolesPeer::ROL_UID);
$oCriteria->addSelectColumn(RolesPeer::ROL_PARENT);
$oCriteria->addSelectColumn(RolesPeer::ROL_SYSTEM);
$oCriteria->addSelectColumn(RolesPeer::ROL_CODE);
$oCriteria->addSelectColumn(RolesPeer::ROL_CREATE_DATE);
$oCriteria->addSelectColumn(RolesPeer::ROL_UPDATE_DATE);
$oCriteria->addSelectColumn(RolesPeer::ROL_STATUS);
$oCriteria->add(RolesPeer::ROL_CODE, $_GET['code']);
$result = RolesPeer::doSelectRS($oCriteria);
$result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$result->next();
$row = $result->getRow();
$oCriteria1 = new Criteria('workflow');
$oCriteria1->add(ContentPeer::CON_CATEGORY, 'ROL_NAME');
$oCriteria1->add(ContentPeer::CON_ID, $row['ROL_UID']);
$oCriteria1->add(ContentPeer::CON_LANG, SYS_LANG);
$oDataset1 = ContentPeer::doSelectRS($oCriteria1);
$oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset1->next();
$aRow1 = $oDataset1->getRow();
$row['ROL_NAME'] = $aRow1['CON_VALUE'];
$row['ROL_UPDATE_DATE'] = date("Y-M-d H:i:s");
$RBAC->updateRole($row);
//$response = ($RBAC->verifyNewRole($_GET['code']))?'true':'false';
break;
case 'usersIntoRole':
$_GET['ROL_UID'] = (isset($_GET['ROL_UID']))?$_GET['ROL_UID']:$_POST['ROL_UID'];
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'roles/roles_Tree' );
G::RenderPage('publish', 'raw');
break;
$RBAC->updateRole($row);
//$response = ($RBAC->verifyNewRole($_GET['code']))?'true':'false';
break;
case 'usersIntoRole':
$_GET['ROL_UID'] = (isset($_GET['ROL_UID']))?$_GET['ROL_UID']:$_POST['ROL_UID'];
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'roles/roles_Tree' );
G::RenderPage('publish', 'raw');
break;
case 'deleteUserRole': case 'deleteUserRole':
$USR_UID = $_POST['USR_UID']; $USR_UID = $_POST['USR_UID'];
$ROL_UID = $_POST['ROL_UID']; $ROL_UID = $_POST['ROL_UID'];
$RBAC->deleteUserRole($ROL_UID, $USR_UID); $RBAC->deleteUserRole($ROL_UID, $USR_UID);
$_GET['ROL_UID'] = $ROL_UID; $_GET['ROL_UID'] = $ROL_UID;
$G_PUBLISH = new Publisher; $G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'roles/roles_Tree' ); $G_PUBLISH->AddContent('view', 'roles/roles_Tree' );
G::RenderPage('publish', 'raw'); G::RenderPage('publish', 'raw');
break; break;
case 'showUsers': case 'showUsers':
$ROL_UID = $_POST['ROL_UID']; $ROL_UID = $_POST['ROL_UID'];
$_GET['ROL_UID'] = $ROL_UID; $_GET['ROL_UID'] = $ROL_UID;
$G_PUBLISH = new Publisher; $G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'roles/roles_AssignRole' ); $G_PUBLISH->AddContent('view', 'roles/roles_AssignRole' );
G::RenderPage('publish', 'raw'); G::RenderPage('publish', 'raw');
break; break;
case 'showPermissions':
$ROL_UID = $_POST['ROL_UID'];
$_GET['ROL_UID'] = $ROL_UID;
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'roles/roles_AssignPermissions' );
G::RenderPage('publish', 'raw');
break;
case 'assignUserToRole':
$ROL_UID = $_POST['ROL_UID']; case 'showPermissions':
$aUserIuds = explode(",",$_POST['aUsers']); $ROL_UID = $_POST['ROL_UID'];
foreach($aUserIuds as $key=>$val){ $_GET['ROL_UID'] = $ROL_UID;
$sData['USR_UID'] = $val; $G_PUBLISH = new Publisher;
$sData['ROL_UID'] = $ROL_UID; $G_PUBLISH->AddContent('view', 'roles/roles_AssignPermissions' );
$RBAC->assignUserToRole($sData); G::RenderPage('publish', 'raw');
} break;
// $_GET['ROL_UID'] = $ROL_UID; case 'assignUserToRole':
// $G_PUBLISH = new Publisher;
// $G_PUBLISH->AddContent('view', 'roles/roles_Tree' );
// G::RenderPage('publish', 'raw');
break;
case 'assignPermissionToRole':
$USR_UID = $_POST['PER_UID'];
$ROL_UID = $_POST['ROL_UID'];
$sData['PER_UID'] = $USR_UID;
$sData['ROL_UID'] = $ROL_UID;
$RBAC->assignPermissionRole($sData);
// $_GET['ROL_UID'] = $ROL_UID;
// $G_PUBLISH = new Publisher;
// $G_PUBLISH->AddContent('view', 'roles/roles_permissionsTree' );
// G::RenderPage('publish', 'raw');
break;
case 'viewPermitions':
$_GET['ROL_UID'] = (isset($_GET['ROL_UID']))?$_GET['ROL_UID']:$_POST['ROL_UID'];
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'roles/roles_permissionsTree' );
G::RenderPage('publish', 'raw');
break;
case 'deletePermissionRole':
$PER_UID = $_POST['PER_UID'];
$ROL_UID = $_POST['ROL_UID'];
$RBAC->deletePermissionRole($ROL_UID, $PER_UID);
$_GET['ROL_UID'] = $ROL_UID;
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'roles/roles_permissionsTree');
G::RenderPage('publish', 'raw');
break;
case 'assignPermissionToRoleMultiple':
$USR_UID = $_POST['PER_UID'];
$ROL_UID = $_POST['ROL_UID'];
$arrPer = explode(',',$USR_UID);
foreach ($arrPer as $PER_UID){
unset($sData);
$sData['PER_UID'] = $PER_UID;
$sData['ROL_UID'] = $ROL_UID;
$RBAC->assignPermissionRole($sData);
}
break;
case 'deletePermissionToRoleMultiple':
$USR_UID = $_POST['PER_UID'];
$ROL_UID = $_POST['ROL_UID'];
$arrPer = explode(',',$USR_UID);
foreach ($arrPer as $PER_UID){
$RBAC->deletePermissionRole($ROL_UID, $PER_UID);
}
break;
case 'deleteUserRoleMultiple':
$USR_UID = $_POST['USR_UID'];
$ROL_UID = $_POST['ROL_UID'];
$arrUsers = explode(',',$USR_UID);
foreach ($arrUsers as $aUID){
$RBAC->deleteUserRole($ROL_UID, $aUID);
}
break;
case 'rolesList':
require_once (PATH_RBAC . "model/RolesPeer.php");
require_once ("classes/model/Content.php");
G::LoadClass('configuration');
$co = new Configurations();
$config = $co->getConfiguration('rolesList', 'pageSize','',$_SESSION['USER_LOGGED']);
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
$start = isset($_POST['start']) ? $_POST['start'] : 0;
$limit = isset($_POST['limit']) ? $_POST['limit'] : $limit_size;
$filter = isset($_REQUEST['textFilter'])? $_REQUEST['textFilter'] : '';
$ROL_UID = $_POST['ROL_UID'];
global $RBAC; $aUserIuds = explode(",",$_POST['aUsers']);
$Criterias = $RBAC->getAllRolesFilter($start,$limit,$filter); foreach($aUserIuds as $key=>$val){
$sData['USR_UID'] = $val;
$rs = RolesPeer::DoSelectRs($Criterias['LIST']); $sData['ROL_UID'] = $ROL_UID;
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $RBAC->assignUserToRole($sData);
}
$content = new Content();
$rNames = $content->getAllContentsByRole();
$aUsers = $RBAC->getAllUsersByRole();
$aRows = Array();
while($rs->next()){
$aRows[] = $rs->getRow();
$index = sizeof($aRows)-1;
$aRows[$index]['ROL_NAME'] = isset($rNames[$aRows[$index]['ROL_UID']])? $rNames[$aRows[$index]['ROL_UID']] : '';
$aRows[$index]['TOTAL_USERS'] = isset($aUsers[$aRows[$index]['ROL_UID']])? $aUsers[$aRows[$index]['ROL_UID']] : 0;
}
$oData = RolesPeer::doSelectRS($Criterias['COUNTER']);
$oData->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oData->next();
$row = $oData->getRow();
$total_roles = $row['CNT'];
echo '{roles: '.G::json_encode($aRows).', total_roles: '.$total_roles.'}';
break;
case 'updatePageSize':
G::LoadClass('configuration');
$c = new Configurations();
$arr['pageSize'] = $_REQUEST['size'];
$arr['dateSave'] = date('Y-m-d H:i:s');
$config = Array();
$config[] = $arr;
$c->aConfig = $config;
$c->saveConfig('rolesList', 'pageSize','',$_SESSION['USER_LOGGED']);
echo '{success: true}';
break;
// $_GET['ROL_UID'] = $ROL_UID;
// $G_PUBLISH = new Publisher;
default: echo 'default'; // $G_PUBLISH->AddContent('view', 'roles/roles_Tree' );
// G::RenderPage('publish', 'raw');
break;
case 'assignPermissionToRole':
$USR_UID = $_POST['PER_UID'];
$ROL_UID = $_POST['ROL_UID'];
$sData['PER_UID'] = $USR_UID;
$sData['ROL_UID'] = $ROL_UID;
$RBAC->assignPermissionRole($sData);
// $_GET['ROL_UID'] = $ROL_UID;
// $G_PUBLISH = new Publisher;
// $G_PUBLISH->AddContent('view', 'roles/roles_permissionsTree' );
// G::RenderPage('publish', 'raw');
break;
case 'viewPermitions':
$_GET['ROL_UID'] = (isset($_GET['ROL_UID']))?$_GET['ROL_UID']:$_POST['ROL_UID'];
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'roles/roles_permissionsTree' );
G::RenderPage('publish', 'raw');
break;
case 'deletePermissionRole':
$PER_UID = $_POST['PER_UID'];
$ROL_UID = $_POST['ROL_UID'];
$RBAC->deletePermissionRole($ROL_UID, $PER_UID);
$_GET['ROL_UID'] = $ROL_UID;
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'roles/roles_permissionsTree');
G::RenderPage('publish', 'raw');
break;
case 'assignPermissionToRoleMultiple':
$USR_UID = $_POST['PER_UID'];
$ROL_UID = $_POST['ROL_UID'];
$arrPer = explode(',',$USR_UID);
foreach ($arrPer as $PER_UID){
unset($sData);
$sData['PER_UID'] = $PER_UID;
$sData['ROL_UID'] = $ROL_UID;
$RBAC->assignPermissionRole($sData);
}
break;
case 'deletePermissionToRoleMultiple':
$USR_UID = $_POST['PER_UID'];
$ROL_UID = $_POST['ROL_UID'];
$arrPer = explode(',',$USR_UID);
foreach ($arrPer as $PER_UID){
$RBAC->deletePermissionRole($ROL_UID, $PER_UID);
}
break;
case 'deleteUserRoleMultiple':
$USR_UID = $_POST['USR_UID'];
$ROL_UID = $_POST['ROL_UID'];
$arrUsers = explode(',',$USR_UID);
foreach ($arrUsers as $aUID){
$RBAC->deleteUserRole($ROL_UID, $aUID);
}
break;
case 'rolesList':
require_once (PATH_RBAC . "model/RolesPeer.php");
require_once ("classes/model/Content.php");
G::LoadClass('configuration');
$co = new Configurations();
$config = $co->getConfiguration('rolesList', 'pageSize','',$_SESSION['USER_LOGGED']);
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
$start = isset($_POST['start']) ? $_POST['start'] : 0;
$limit = isset($_POST['limit']) ? $_POST['limit'] : $limit_size;
$filter = isset($_REQUEST['textFilter'])? $_REQUEST['textFilter'] : '';
global $RBAC;
$Criterias = $RBAC->getAllRolesFilter($start,$limit,$filter);
$rs = RolesPeer::DoSelectRs($Criterias['LIST']);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$content = new Content();
$rNames = $content->getAllContentsByRole();
$aUsers = $RBAC->getAllUsersByRole();
$aRows = Array();
while($rs->next()){
$aRows[] = $rs->getRow();
$index = sizeof($aRows)-1;
$aRows[$index]['ROL_NAME'] = isset($rNames[$aRows[$index]['ROL_UID']])? $rNames[$aRows[$index]['ROL_UID']] : '';
$aRows[$index]['TOTAL_USERS'] = isset($aUsers[$aRows[$index]['ROL_UID']])? $aUsers[$aRows[$index]['ROL_UID']] : 0;
}
$oData = RolesPeer::doSelectRS($Criterias['COUNTER']);
$oData->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oData->next();
$row = $oData->getRow();
$total_roles = $row['CNT'];
echo '{roles: '.G::json_encode($aRows).', total_roles: '.$total_roles.'}';
break;
case 'updatePageSize':
G::LoadClass('configuration');
$c = new Configurations();
$arr['pageSize'] = $_REQUEST['size'];
$arr['dateSave'] = date('Y-m-d H:i:s');
$config = Array();
$config[] = $arr;
$c->aConfig = $config;
$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,238 +4,236 @@
*/ */
//Keyboard Events //Keyboard Events
new Ext.KeyMap(document, { new Ext.KeyMap(document,
key: Ext.EventObject.F5, [
fn: function(keycode, e) { {
if (! e.ctrlKey) { key: Ext.EventObject.F5,
if (Ext.isIE) { fn: function(keycode, e) {
// IE6 doesn't allow cancellation of the F5 key, so trick it into if (! e.ctrlKey) {
// thinking some other key was pressed (backspace in this case) if (Ext.isIE) {
e.browserEvent.keyCode = 8; // IE6 doesn't allow cancellation of the F5 key, so trick it into
} // thinking some other key was pressed (backspace in this case)
e.stopEvent(); e.browserEvent.keyCode = 8;
document.location = document.location; }
}else{ e.stopEvent();
Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5'); document.location = document.location;
} }else{
} Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5');
} }
//, }
//{ },
// key: Ext.EventObject.DELETE, {
// fn: function(k,e){ key: Ext.EventObject.DELETE,
// var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode(); fn: function(k,e){ DeleteDepartmentAction();}
// //if (typeof dep_node != 'undefined') },
// //if(dep_node.attributes.leaf){ {
// DeleteDepartmentAction(); key: Ext.EventObject.F2,
// //} fn: function(k,e){ EditDepartmentAction(); }
// } }
//} ]
); );
var treePanel; var treePanel;
var rootNode; var rootNode;
var w;
Ext.onReady(function() { Ext.onReady(function() {
Ext.QuickTips.init(); Ext.QuickTips.init();
newButton = new Ext.Action({
text: _('ID_NEW_DEPARTMENT'),
iconCls: ' button_menu_ext ss_sprite ss_add',
handler: NewRootDepartment
});
newSubButton = new Ext.Action({
text: _('ID_NEW_SUB_DEPARTMENT'),
iconCls: ' button_menu_ext ss_sprite ss_add',
handler: NewSubDepartment,
disabled: true
});
editButton = new Ext.Action({
text: _('ID_EDIT'),
iconCls: 'button_menu_ext ss_sprite ss_pencil',
handler: EditDepartmentAction,
disabled: true
});
deleteButton = new Ext.Action({ newButton = new Ext.Action({
text: _('ID_DELETE'), text: _('ID_NEW_DEPARTMENT'),
iconCls: 'button_menu_ext ss_sprite ss_delete', iconCls: ' button_menu_ext ss_sprite ss_add',
handler: DeleteDepartmentAction, handler: NewRootDepartment
disabled: true });
});
newSubButton = new Ext.Action({
usersButton = new Ext.Action({ text: _('ID_NEW_SUB_DEPARTMENT'),
text: _('ID_USERS'), iconCls: ' button_menu_ext ss_sprite ss_add',
iconCls: 'button_menu_ext ss_sprite ss_user_add', handler: NewSubDepartment,
handler: UsersButtonAction, disabled: true
disabled: true });
});
editButton = new Ext.Action({
contextMenu = new Ext.menu.Menu({ text: _('ID_EDIT'),
items: [newSubButton,'-',editButton, deleteButton,'-',usersButton] iconCls: 'button_menu_ext ss_sprite ss_pencil',
}); handler: EditDepartmentAction,
disabled: true
smodel = new Ext.tree.DefaultSelectionModel({ });
listeners:{
selectionchange: function(sm, node){ deleteButton = new Ext.Action({
editButton.enable(); text: _('ID_DELETE'),
newSubButton.enable(); iconCls: 'button_menu_ext ss_sprite ss_delete',
usersButton.enable(); handler: DeleteDepartmentAction,
if (!node){ disabled: true
deleteButton.disable(); });
}else{
if (node.attributes.leaf){ usersButton = new Ext.Action({
deleteButton.enable(); text: _('ID_USERS'),
}else{ iconCls: 'button_menu_ext ss_sprite ss_user_add',
deleteButton.disable(); handler: UsersButtonAction,
} disabled: true
} });
//var tree = Ext.getCmp('treePanel');
//alert(treePanel.getRootNode()); contextMenu = new Ext.menu.Menu({
} items: [newSubButton,'-',editButton, deleteButton,'-',usersButton]
} });
});
smodel = new Ext.tree.DefaultSelectionModel({
comboStatusStore = new Ext.data.SimpleStore({ listeners:{
fields: ['id','value'], selectionchange: function(sm, node){
data: [['ACTIVE',_('ID_ACTIVE')],['INACTIVE',_('ID_INACTIVE')]] editButton.enable();
}); newSubButton.enable();
usersButton.enable();
comboDepManager = new Ext.data.GroupingStore( { if (!node){
proxy : new Ext.data.HttpProxy({ deleteButton.disable();
url: 'departments_Ajax?action=usersByDepartment' }else{
}), if (node.attributes.leaf){
reader : new Ext.data.JsonReader( { deleteButton.enable();
root: 'users', }else{
fields : [ deleteButton.disable();
{name : 'USR_UID'}, }
{name : 'USR_VALUE'}
]
})
});
newForm = new Ext.FormPanel({
url: 'departments_Ajax?request=saveNewDepartment',
frame: true,
items:[
{xtype: 'textfield', name: 'parent', hidden: true},
{xtype: 'textfield', fieldLabel: _('ID_DEPARTMENT_NAME'), name: 'dep_name', width: 230, allowBlank: false}
],
buttons: [
{text: _('ID_SAVE'), handler: SaveNewDepartment},
{text: _('ID_CANCEL'), handler: CloseWindow}
],
labelWidth: 120
});
editForm = new Ext.FormPanel({
url: 'departments_Ajax?request=saveEditDepartment',
frame: true,
items:[
{xtype: 'textfield', name: 'dep_uid', hidden: true},
{xtype: 'textfield', name: 'dep_parent', hidden: true},
{xtype: 'textfield', fieldLabel: _('ID_DEPARTMENT_NAME'), name: 'dep_name', width: 230, allowBlank: false},
{
xtype: 'combo',
fieldLabel: _('ID_STATUS'),
hiddenName: 'status',
typeAhead: true,
mode: 'local',
store: comboStatusStore,
displayField: 'value',
valueField:'id',
allowBlank: false,
triggerAction: 'all',
emptyText: _('ID_SELECT_STATUS'),
selectOnFocus:true
}
,
{
xtype: 'combo',
fieldLabel: 'Manager',
hiddenName: 'manager',
typeAhead: true,
mode: 'local',
store: comboDepManager,
displayField: 'USR_VALUE',
valueField:'USR_UID',
allowBlank: true,
triggerAction: 'all',
emptyText: '',
selectOnFocus:true
}
],
buttons: [
{text: _('ID_SAVE'), handler: SaveEditDepartment},
{text: _('ID_CANCEL'), handler: CloseWindow}
],
labelWidth: 120
});
rootNode = new Ext.tree.AsyncTreeNode({
text:'Departments'
});
treePanel = new Ext.ux.tree.TreeGrid({
title: _('ID_DEPARTMENTS'),
autoScroll: true,
width: 720,
height: 300,
id: 'treePanel',
columns:[{
header: _('ID_DEPARTMENT_NAME'),
dataIndex: 'DEP_TITLE',
width: 320
},{
header: _('ID_STATUS'),
width: 100,
dataIndex: 'DEP_STATUS',
align: 'center',
tpl: new Ext.XTemplate('{DEP_STATUS:this.formatStatus}', {
formatStatus: function(v) {
switch(v){
case 'ACTIVE': return '<font color="green">' + _('ID_ACTIVE') + '</font>'; break;
case 'INACTIVE': return '<font color="red">' + _('ID_INACTIVE') + '</font>'; break;
}
}
})
},{
header: _('ID_MANAGER'),
width: 220,
dataIndex: 'DEP_MANAGER_NAME'
},{
header: _('ID_USERS'),
width: 80,
dataIndex: 'DEP_TOTAL_USERS',
align: 'center',
sortType: 'asFloat'
} }
], }
selModel: smodel, }
tbar: [newButton,'-',newSubButton,'-',editButton, deleteButton,'-',usersButton], });
dataUrl:'departments_Ajax?action=departmentList',
root: rootNode comboStatusStore = new Ext.data.SimpleStore({
}); fields: ['id','value'],
data: [['ACTIVE',_('ID_ACTIVE')],['INACTIVE',_('ID_INACTIVE')]]
treePanel.on('contextmenu', treeContextHandler); });
viewport = new Ext.Viewport({ comboDepManager = new Ext.data.GroupingStore( {
layout: 'fit', proxy : new Ext.data.HttpProxy({
autoScroll: false, url: 'departments_Ajax?action=usersByDepartment'
items: [treePanel] }),
}); reader : new Ext.data.JsonReader( {
root: 'users',
fields : [
{name : 'USR_UID'},
{name : 'USR_VALUE'}
]
})
});
newForm = new Ext.FormPanel({
url: 'departments_Ajax?request=saveNewDepartment',
frame: true,
items:[
{xtype: 'textfield', name: 'parent', hidden: true},
{xtype: 'textfield', fieldLabel: _('ID_DEPARTMENT_NAME'), name: 'dep_name', width: 230, allowBlank: false}
],
buttons: [
{text: _('ID_SAVE'), handler: SaveNewDepartment},
{text: _('ID_CANCEL'), handler: CloseWindow}
],
labelWidth: 120
});
editForm = new Ext.FormPanel({
url: 'departments_Ajax?request=saveEditDepartment',
frame: true,
items:[
{xtype: 'textfield', name: 'dep_uid', hidden: true},
{xtype: 'textfield', name: 'dep_parent', hidden: true},
{xtype: 'textfield', fieldLabel: _('ID_DEPARTMENT_NAME'), name: 'dep_name', width: 230, allowBlank: false},
{
xtype: 'combo',
fieldLabel: _('ID_STATUS'),
hiddenName: 'status',
typeAhead: true,
mode: 'local',
store: comboStatusStore,
displayField: 'value',
valueField:'id',
allowBlank: false,
triggerAction: 'all',
emptyText: _('ID_SELECT_STATUS'),
selectOnFocus:true
}
,
{
xtype: 'combo',
fieldLabel: 'Manager',
hiddenName: 'manager',
typeAhead: true,
mode: 'local',
store: comboDepManager,
displayField: 'USR_VALUE',
valueField:'USR_UID',
allowBlank: true,
triggerAction: 'all',
emptyText: '',
selectOnFocus:true
}
],
buttons: [
{text: _('ID_SAVE'), handler: SaveEditDepartment},
{text: _('ID_CANCEL'), handler: CloseWindow}
],
labelWidth: 120
});
rootNode = new Ext.tree.AsyncTreeNode({
text:'Departments'
});
treePanel = new Ext.ux.tree.TreeGrid({
title: _('ID_DEPARTMENTS'),
autoScroll: true,
width: 720,
height: 300,
id: 'treePanel',
columns:[{
header: _('ID_DEPARTMENT_NAME'),
dataIndex: 'DEP_TITLE',
width: 320
},{
header: _('ID_STATUS'),
width: 100,
dataIndex: 'DEP_STATUS',
align: 'center',
tpl: new Ext.XTemplate('{DEP_STATUS:this.formatStatus}', {
formatStatus: function(v) {
switch(v){
case 'ACTIVE': return '<font color="green">' + _('ID_ACTIVE') + '</font>'; break;
case 'INACTIVE': return '<font color="red">' + _('ID_INACTIVE') + '</font>'; break;
}
}
})
},{
header: _('ID_MANAGER'),
width: 220,
dataIndex: 'DEP_MANAGER_NAME'
},{
header: _('ID_USERS'),
width: 80,
dataIndex: 'DEP_TOTAL_USERS',
align: 'center',
sortType: 'asFloat'
}
],
selModel: smodel,
tbar: [newButton,'-',newSubButton,'-',editButton, deleteButton,'-',usersButton],
dataUrl:'departments_Ajax?action=departmentList',
root: rootNode
});
treePanel.on('contextmenu', treeContextHandler);
viewport = new Ext.Viewport({
layout: 'fit',
autoScroll: false,
items: [treePanel]
});
}); });
//Funtion Handles Context Menu Opening //Funtion Handles Context Menu Opening
treeContextHandler = function(node, evt){ treeContextHandler = function(node, evt){
node.select(); node.select();
var coords = evt.getXY(); var coords = evt.getXY();
contextMenu.showAt([coords[0], coords[1]]); contextMenu.showAt([coords[0], coords[1]]);
}; };
//Do Nothing Function //Do Nothing Function
@@ -243,120 +241,125 @@ DoNothing = function(){};
//Call New Department at Root //Call New Department at Root
NewRootDepartment = function(){ NewRootDepartment = function(){
newForm.getForm().findField('parent').setValue(''); newForm.getForm().findField('parent').setValue('');
w = new Ext.Window({ w = new Ext.Window({
title: _('ID_NEW_DEPARTMENT'), title: _('ID_NEW_DEPARTMENT'),
autoHeight: true, autoHeight: true,
modal: true, modal: true,
closable: false, closable: false,
width: 420, width: 420,
items: [newForm] items: [newForm],
}); id: 'w'
w.show(); });
w.show();
}; };
//Call New Sub Department at Parent //Call New Sub Department at Parent
NewSubDepartment = function(){ NewSubDepartment = function(){
var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode(); var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode();
newForm.getForm().findField('parent').setValue(dep_node.attributes.DEP_UID); newForm.getForm().findField('parent').setValue(dep_node.attributes.DEP_UID);
w = new Ext.Window({ w = new Ext.Window({
title: _('ID_NEW_SUB_DEPARTMENT'), title: _('ID_NEW_SUB_DEPARTMENT'),
autoHeight: true, autoHeight: true,
modal: true, modal: true,
closable: false, closable: false,
width: 420, width: 420,
items: [newForm] items: [newForm],
}); id: 'w'
w.show(); });
w.show();
}; };
//Close PopUp Window //Close PopUp Window
CloseWindow = function(){ CloseWindow = function(){
w.hide(); Ext.getCmp('w').hide();
}; };
SaveNewDepartment = function(){ SaveNewDepartment = function(){
var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode(); var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode();
if (dep_node) dep_node.unselect(); if (dep_node) dep_node.unselect();
var dep_name = newForm.getForm().findField('dep_name').getValue(); var dep_name = newForm.getForm().findField('dep_name').getValue();
var dep_parent = newForm.getForm().findField('parent').getValue(); dep_name = dep_name.trim();
Ext.Ajax.request({ if (dep_name=='') return;
url: 'departments_Ajax', var dep_parent = newForm.getForm().findField('parent').getValue();
params: {action: 'checkDepartmentName', name: dep_name, parent: dep_parent}, Ext.Ajax.request({
success: function(resp, opt){ url: 'departments_Ajax',
var res_ok = eval(resp.responseText); params: {action: 'checkDepartmentName', name: dep_name, parent: dep_parent},
if (res_ok){ success: function(resp, opt){
Ext.Ajax.request({ var res_ok = eval(resp.responseText);
url: 'departments_Ajax', if (res_ok){
params: {action: 'saveDepartment', name: dep_name, parent: dep_parent}, Ext.Ajax.request({
success: function(r,o){ url: 'departments_Ajax',
var xtree = Ext.getCmp('treePanel'); params: {action: 'saveDepartment', name: dep_name, parent: dep_parent},
treePanel.getLoader().load(rootNode); success: function(r,o){
newSubButton.disable(); var xtree = Ext.getCmp('treePanel');
editButton.disable(); treePanel.getLoader().load(rootNode);
deleteButton.disable(); newSubButton.disable();
usersButton.disable(); editButton.disable();
newForm.getForm().findField('dep_name').reset(); deleteButton.disable();
w.hide(); usersButton.disable();
PMExt.notify(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_SUCCESS_NEW')); newForm.getForm().findField('dep_name').reset();
}, CloseWindow();
failure: function(r,o){ PMExt.notify(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_SUCCESS_NEW'));
DoNothing(); },
} failure: function(r,o){
}); DoNothing();
}else{ }
PMExt.error(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_EXISTS')); });
} }else{
}, PMExt.error(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_EXISTS'));
failure: function(resp, opt){ }
DoNothing(); },
} failure: function(resp, opt){
}); DoNothing();
}
});
}; };
SaveEditDepartment = function(){ SaveEditDepartment = function(){
var dep_name = editForm.getForm().findField('dep_name').getValue(); var dep_name = editForm.getForm().findField('dep_name').getValue();
var dep_parent = editForm.getForm().findField('dep_parent').getValue(); dep_name = dep_name.trim();
var dep_uid = editForm.getForm().findField('dep_uid').getValue(); if (dep_name=='') return;
var dep_status = editForm.getForm().findField('status').getValue(); var dep_parent = editForm.getForm().findField('dep_parent').getValue();
var dep_manager = editForm.getForm().findField('manager').getValue(); var dep_uid = editForm.getForm().findField('dep_uid').getValue();
var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode(); var dep_status = editForm.getForm().findField('status').getValue();
if (dep_node) dep_node.unselect(); var dep_manager = editForm.getForm().findField('manager').getValue();
Ext.Ajax.request({ var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode();
url: 'departments_Ajax', if (dep_node) dep_node.unselect();
params: {action: 'checkEditDepartmentName', name: dep_name, parent: dep_parent, uid: dep_uid}, Ext.Ajax.request({
success: function(resp, opt){ url: 'departments_Ajax',
var res_ok = eval(resp.responseText); params: {action: 'checkEditDepartmentName', name: dep_name, parent: dep_parent, uid: dep_uid},
if (res_ok){ success: function(resp, opt){
Ext.Ajax.request({ var res_ok = eval(resp.responseText);
url: 'departments_Ajax', if (res_ok){
params: {action: 'updateDepartment', uid: dep_uid, name: dep_name, status: dep_status, manager: dep_manager}, Ext.Ajax.request({
success: function(r,o){ url: 'departments_Ajax',
var xtree = Ext.getCmp('treePanel'); params: {action: 'updateDepartment', uid: dep_uid, name: dep_name, status: dep_status, manager: dep_manager},
xtree.getLoader().load(xtree.root); success: function(r,o){
newSubButton.disable(); var xtree = Ext.getCmp('treePanel');
editButton.disable(); xtree.getLoader().load(xtree.root);
deleteButton.disable(); newSubButton.disable();
usersButton.disable(); editButton.disable();
newForm.getForm().findField('dep_name').reset(); deleteButton.disable();
w.hide(); usersButton.disable();
PMExt.notify(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_SUCCESS_UPDATE')); newForm.getForm().findField('dep_name').reset();
}, CloseWindow();
failure: function(r,o){ PMExt.notify(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_SUCCESS_UPDATE'));
DoNothing(); },
} failure: function(r,o){
}); DoNothing();
}else{ }
PMExt.error(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_EXISTS')); });
} }else{
}, PMExt.error(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_EXISTS'));
failure: function(resp, opt){ }
DoNothing(); },
} failure: function(resp, opt){
}); DoNothing();
}
});
}; };
//Edit Department Action //Edit Department Action
EditDepartmentAction = function(){ EditDepartmentAction = function(){
var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode(); var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode();
@@ -365,71 +368,73 @@ EditDepartmentAction = function(){
editForm.getForm().findField('dep_name').setValue(dep_node.attributes.DEP_TITLE); editForm.getForm().findField('dep_name').setValue(dep_node.attributes.DEP_TITLE);
editForm.getForm().findField('status').setValue(dep_node.attributes.DEP_STATUS); editForm.getForm().findField('status').setValue(dep_node.attributes.DEP_STATUS);
editForm.getForm().findField('manager').getStore().addListener('load',function(s,r,o){ editForm.getForm().findField('manager').getStore().addListener('load',function(s,r,o){
editForm.getForm().findField('manager').setValue(dep_node.attributes.DEP_MANAGER); editForm.getForm().findField('manager').setValue(dep_node.attributes.DEP_MANAGER);
}); });
editForm.getForm().findField('manager').store.load({params: {DEP_UID: dep_node.attributes.DEP_UID }}); editForm.getForm().findField('manager').store.load({params: {DEP_UID: dep_node.attributes.DEP_UID }});
w = new Ext.Window({ w = new Ext.Window({
title: _('ID_EDIT_DEPARTMENT'), title: _('ID_EDIT_DEPARTMENT'),
autoHeight: true, autoHeight: true,
modal: true, modal: true,
closable: false, closable: false,
width: 420, width: 420,
items: [editForm] items: [editForm],
id: 'w'
}); });
w.show(); w.show();
}; };
//Delete Department Action //Delete Department Action
DeleteDepartmentAction = function(){ DeleteDepartmentAction = function(){
var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode(); var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode();
var DEP_UID = dep_node.attributes.DEP_UID; if (!dep_node.attributes.leaf) return;
if (dep_node) dep_node.unselect(); var DEP_UID = dep_node.attributes.DEP_UID;
viewport.getEl().mask(_('ID_PROCESSING')); if (dep_node) dep_node.unselect();
Ext.Ajax.request({ viewport.getEl().mask(_('ID_PROCESSING'));
url: 'departments_Ajax', Ext.Ajax.request({
params: {action: 'canDeleteDepartment', dep_uid: DEP_UID }, url: 'departments_Ajax',
success: function(r,o){ params: {action: 'canDeleteDepartment', dep_uid: DEP_UID },
viewport.getEl().unmask(); success: function(r,o){
var response = Ext.util.JSON.decode(r.responseText); viewport.getEl().unmask();
if (response.success){ var response = Ext.util.JSON.decode(r.responseText);
if (response.success){
Ext.Msg.confirm(_('ID_DEPARTMENTS'), _('ID_CONFIRM_DELETE_DEPARTMENT'),
function(btn, text){ Ext.Msg.confirm(_('ID_DEPARTMENTS'), _('ID_CONFIRM_DELETE_DEPARTMENT'),
if (btn=='yes'){ function(btn, text){
viewport.getEl().mask(_('ID_PROCESSING')); if (btn=='yes'){
Ext.Ajax.request({ viewport.getEl().mask(_('ID_PROCESSING'));
url: 'departments_Ajax', Ext.Ajax.request({
params: {action: 'deleteDepartment', DEP_UID: DEP_UID}, url: 'departments_Ajax',
success: function(r,o){ params: {action: 'deleteDepartment', DEP_UID: DEP_UID},
viewport.getEl().unmask(); success: function(r,o){
treePanel.getRootNode().reload(); viewport.getEl().unmask();
newSubButton.disable(); treePanel.getRootNode().reload();
editButton.disable(); newSubButton.disable();
deleteButton.disable(); editButton.disable();
usersButton.disable(); deleteButton.disable();
PMExt.notify(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_SUCCESS_DELETE')); usersButton.disable();
}, PMExt.notify(_('ID_DEPARTMENTS'), _('ID_DEPARTMENT_SUCCESS_DELETE'));
failure: function(r,o){ },
viewport.getEl().unmask(); failure: function(r,o){
} viewport.getEl().unmask();
}); }
} });
}); }
});
}else{
PMExt.error(_('ID_DEPARTMENTS'),_('ID_MSG_CANNOT_DELETE_DEPARTMENT')); }else{
} PMExt.error(_('ID_DEPARTMENTS'),_('ID_MSG_CANNOT_DELETE_DEPARTMENT'));
}, }
failure: function(r,o){ },
viewport.getEl().unmask(); failure: function(r,o){
viewport.getEl().unmask();
}
}); }
});
}; };
//User Assined Action //User Assined Action
UsersButtonAction = function(){ UsersButtonAction = function(){
var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode(); var dep_node = Ext.getCmp('treePanel').getSelectionModel().getSelectedNode();
var DEP_UID = dep_node.attributes.DEP_UID; var DEP_UID = dep_node.attributes.DEP_UID;
location.href= 'departmentUsers?dUID=' + DEP_UID; location.href= 'departmentUsers?dUID=' + DEP_UID;
}; };

View File

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

View File

@@ -5,43 +5,43 @@
//Keyboard Events //Keyboard Events
new Ext.KeyMap(document, [ new Ext.KeyMap(document, [
{ {
key: Ext.EventObject.F5, key: Ext.EventObject.F5,
fn: function(keycode, e) { fn: function(keycode, e) {
if (! e.ctrlKey) { if (! e.ctrlKey) {
if (Ext.isIE) { if (Ext.isIE) {
// IE6 doesn't allow cancellation of the F5 key, so trick it into // IE6 doesn't allow cancellation of the F5 key, so trick it into
// thinking some other key was pressed (backspace in this case) // thinking some other key was pressed (backspace in this case)
e.browserEvent.keyCode = 8; e.browserEvent.keyCode = 8;
} }
e.stopEvent(); e.stopEvent();
document.location = document.location; document.location = document.location;
}else{ }else{
Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5'); Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5');
} }
} }
}, },
{ {
key: Ext.EventObject.DELETE, key: Ext.EventObject.DELETE,
fn: function(k,e){ fn: function(k,e){
iGrid = Ext.getCmp('infoGrid'); iGrid = Ext.getCmp('infoGrid');
rowSelected = iGrid.getSelectionModel().getSelected(); rowSelected = iGrid.getSelectionModel().getSelected();
if (rowSelected){ if (rowSelected){
DeleteCategory(); DeleteCategory();
} }
} }
}, },
{ {
key: Ext.EventObject.F2, key: Ext.EventObject.F2,
fn: function(k,e){ fn: function(k,e){
iGrid = Ext.getCmp('infoGrid'); iGrid = Ext.getCmp('infoGrid');
rowSelected = iGrid.getSelectionModel().getSelected(); rowSelected = iGrid.getSelectionModel().getSelected();
if (rowSelected){ if (rowSelected){
EditCategory(); EditCategory();
} }
} }
} }
]); ]);
var store; var store;
var cmodel; var cmodel;
@@ -60,237 +60,237 @@ var comboStatusStore;
var editForm; var editForm;
var contextMenu; var contextMenu;
var w; var w;
Ext.onReady(function(){ Ext.onReady(function(){
Ext.QuickTips.init(); Ext.QuickTips.init();
pageSize = parseInt(CONFIG.pageSize);
newButton = new Ext.Action({
text: _('ID_NEW'),
iconCls: 'button_menu_ext ss_sprite ss_add',
handler: NewCategoryWindow
});
editButton = new Ext.Action({
text: _('ID_EDIT'),
iconCls: 'button_menu_ext ss_sprite ss_pencil',
handler: EditCategory,
disabled: true
});
deleteButton = new Ext.Action({
text: _('ID_DELETE'),
iconCls: 'button_menu_ext ss_sprite ss_delete',
handler: DeleteCategory,
disabled: true
});
searchButton = new Ext.Action({
text: _('ID_SEARCH'),
handler: DoSearch
});
contextMenu = new Ext.menu.Menu({
items: [editButton, deleteButton]
});
searchText = new Ext.form.TextField ({
id: 'searchText',
ctCls:'pm_search_text_field',
allowBlank: true,
width: 150,
emptyText: _('ID_ENTER_SEARCH_TERM'),//'enter search term',
listeners: {
specialkey: function(f,e){
if (e.getKey() == e.ENTER) {
DoSearch();
}
},
focus: function(f,e) {
var row = infoGrid.getSelectionModel().getSelected();
infoGrid.getSelectionModel().deselectRow(infoGrid.getStore().indexOf(row));
}
}
});
clearTextButton = new Ext.Action({
text: 'X',
ctCls:'pm_search_x_button',
handler: GridByDefault
});
newForm = new Ext.FormPanel({
url: 'processCategory_Ajax?action=saveNewCategory',
frame: true,
items:[
{xtype: 'textfield', fieldLabel: _('ID_CATEGORY_NAME'), name: 'category', width: 250, allowBlank: false}
],
buttons: [
{text: _('ID_SAVE'), handler: SaveNewCategory},
{text: _('ID_CANCEL'), handler: CloseWindow}
]
});
editForm = new Ext.FormPanel({
url: 'processCategory_Ajax?action=updateCategory',
frame: true,
items:[
{xtype: 'textfield', name: 'cat_uid', hidden: true },
{xtype: 'textfield', fieldLabel: _('ID_CATEGORY_NAME'), name: 'category', width: 250, allowBlank: false}
],
buttons: [
{text: _('ID_SAVE'), handler: UpdateCategory},
{text: _('ID_CANCEL'), handler: CloseWindow}
]
});
smodel = new Ext.grid.RowSelectionModel({
singleSelect: true,
listeners:{
rowselect: function(sm){
editButton.enable();
deleteButton.enable();
},
rowdeselect: function(sm){
editButton.disable();
deleteButton.disable();
}
}
});
store = new Ext.data.GroupingStore( { pageSize = parseInt(CONFIG.pageSize);
proxy : new Ext.data.HttpProxy({
url: 'processCategory_Ajax?action=processCategoryList' newButton = new Ext.Action({
}), text: _('ID_NEW'),
reader : new Ext.data.JsonReader( { iconCls: 'button_menu_ext ss_sprite ss_add',
root: 'categories', handler: NewCategoryWindow
totalProperty: 'total_categories', });
fields : [
{name : 'CATEGORY_UID'}, editButton = new Ext.Action({
{name : 'CATEGORY_PARENT'}, text: _('ID_EDIT'),
{name : 'CATEGORY_NAME'}, iconCls: 'button_menu_ext ss_sprite ss_pencil',
{name : 'CATEGORY_ICON'}, handler: EditCategory,
{name : 'TOTAL_PROCESSES', type:'int'} disabled: true
] });
})
}); deleteButton = new Ext.Action({
text: _('ID_DELETE'),
cmodel = new Ext.grid.ColumnModel({ iconCls: 'button_menu_ext ss_sprite ss_delete',
defaults: { handler: DeleteCategory,
width: 50, disabled: true
sortable: true });
},
columns: [ searchButton = new Ext.Action({
{id:'CATEGORY_UID', dataIndex: 'CATEGORY_UID', hidden:true, hideable:false}, text: _('ID_SEARCH'),
{header: _('ID_CATEGORY_NAME'), dataIndex: 'CATEGORY_NAME', width: 500, hidden:false, align:'left'}, handler: DoSearch
{header: _('ID_PROCESSES'), dataIndex: 'TOTAL_PROCESSES', width: 100, hidden: false, align: 'center'} });
]
}); contextMenu = new Ext.menu.Menu({
items: [editButton, deleteButton]
storePageSize = new Ext.data.SimpleStore({ });
fields: ['size'],
data: [['20'],['30'],['40'],['50'],['100']], searchText = new Ext.form.TextField ({
autoLoad: true id: 'searchText',
}); ctCls:'pm_search_text_field',
allowBlank: true,
comboPageSize = new Ext.form.ComboBox({ width: 150,
typeAhead : false, emptyText: _('ID_ENTER_SEARCH_TERM'),//'enter search term',
mode : 'local', listeners: {
triggerAction : 'all', specialkey: function(f,e){
store: storePageSize, if (e.getKey() == e.ENTER) {
valueField: 'size', DoSearch();
displayField: 'size',
width: 50,
editable: false,
listeners:{
select: function(c,d,i){
UpdatePageConfig(d.data['size']);
bbarpaging.pageSize = parseInt(d.data['size']);
bbarpaging.moveFirst();
} }
},
focus: function(f,e) {
var row = infoGrid.getSelectionModel().getSelected();
infoGrid.getSelectionModel().deselectRow(infoGrid.getStore().indexOf(row));
} }
}); }
});
comboPageSize.setValue(pageSize);
bbarpaging = new Ext.PagingToolbar({
pageSize: pageSize,
store: store,
displayInfo: true,
displayMsg: _('ID_GRID_PAGE_DISPLAYING_CATEGORY_MESSAGE') + '&nbsp; &nbsp; ',
emptyMsg: _('ID_GRID_PAGE_NO_CATEGORY_MESSAGE'),
items: ['-',_('ID_PAGE_SIZE')+':',comboPageSize]
});
infoGrid = new Ext.grid.GridPanel({
region: 'center',
layout: 'fit',
id: 'infoGrid',
height:100,
autoWidth : true,
stateful : true,
stateId : 'grid',
enableColumnResize: true,
enableHdMenu: true,
frame:false,
//iconCls:'icon-grid',
columnLines: false,
viewConfig: {
forceFit:true
},
title : _('ID_PROCESS_CATEGORY'),
store: store,
cm: cmodel,
sm: smodel,
tbar: [newButton, '-', editButton, deleteButton, {xtype: 'tbfill'}, searchText,clearTextButton,searchButton],
bbar: bbarpaging,
listeners: {
rowdblclick: EditCategory,
render: function(){
this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')});
}
},
view: new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl: '{text}'
})
});
infoGrid.on('rowcontextmenu',
function (grid, rowIndex, evt) {
var sm = grid.getSelectionModel();
sm.selectRow(rowIndex, sm.isSelected(rowIndex));
},
this
);
infoGrid.on('contextmenu',
function (evt) {
evt.preventDefault();
},
this
);
infoGrid.addListener('rowcontextmenu',onMessageContextMenu,this);
infoGrid.store.load(); clearTextButton = new Ext.Action({
text: 'X',
ctCls:'pm_search_x_button',
handler: GridByDefault
});
viewport = new Ext.Viewport({ newForm = new Ext.FormPanel({
layout: 'fit', url: 'processCategory_Ajax?action=saveNewCategory',
autoScroll: false, frame: true,
items: [ items:[
infoGrid {xtype: 'textfield', fieldLabel: _('ID_CATEGORY_NAME'), name: 'category', width: 250, allowBlank: false}
] ],
}); buttons: [
{text: _('ID_SAVE'), handler: SaveNewCategory},
{text: _('ID_CANCEL'), handler: CloseWindow}
]
});
editForm = new Ext.FormPanel({
url: 'processCategory_Ajax?action=updateCategory',
frame: true,
items:[
{xtype: 'textfield', name: 'cat_uid', hidden: true },
{xtype: 'textfield', fieldLabel: _('ID_CATEGORY_NAME'), name: 'category', width: 250, allowBlank: false}
],
buttons: [
{text: _('ID_SAVE'), handler: UpdateCategory},
{text: _('ID_CANCEL'), handler: CloseWindow}
]
});
smodel = new Ext.grid.RowSelectionModel({
singleSelect: true,
listeners:{
rowselect: function(sm){
editButton.enable();
deleteButton.enable();
},
rowdeselect: function(sm){
editButton.disable();
deleteButton.disable();
}
}
});
store = new Ext.data.GroupingStore( {
proxy : new Ext.data.HttpProxy({
url: 'processCategory_Ajax?action=processCategoryList'
}),
reader : new Ext.data.JsonReader( {
root: 'categories',
totalProperty: 'total_categories',
fields : [
{name : 'CATEGORY_UID'},
{name : 'CATEGORY_PARENT'},
{name : 'CATEGORY_NAME'},
{name : 'CATEGORY_ICON'},
{name : 'TOTAL_PROCESSES', type:'int'}
]
})
});
cmodel = new Ext.grid.ColumnModel({
defaults: {
width: 50,
sortable: true
},
columns: [
{id:'CATEGORY_UID', dataIndex: 'CATEGORY_UID', hidden:true, hideable:false},
{header: _('ID_CATEGORY_NAME'), dataIndex: 'CATEGORY_NAME', width: 500, hidden:false, align:'left'},
{header: _('ID_PROCESSES'), dataIndex: 'TOTAL_PROCESSES', width: 100, hidden: false, align: 'center'}
]
});
storePageSize = new Ext.data.SimpleStore({
fields: ['size'],
data: [['20'],['30'],['40'],['50'],['100']],
autoLoad: true
});
comboPageSize = new Ext.form.ComboBox({
typeAhead : false,
mode : 'local',
triggerAction : 'all',
store: storePageSize,
valueField: 'size',
displayField: 'size',
width: 50,
editable: false,
listeners:{
select: function(c,d,i){
UpdatePageConfig(d.data['size']);
bbarpaging.pageSize = parseInt(d.data['size']);
bbarpaging.moveFirst();
}
}
});
comboPageSize.setValue(pageSize);
bbarpaging = new Ext.PagingToolbar({
pageSize: pageSize,
store: store,
displayInfo: true,
displayMsg: _('ID_GRID_PAGE_DISPLAYING_CATEGORY_MESSAGE') + '&nbsp; &nbsp; ',
emptyMsg: _('ID_GRID_PAGE_NO_CATEGORY_MESSAGE'),
items: ['-',_('ID_PAGE_SIZE')+':',comboPageSize]
});
infoGrid = new Ext.grid.GridPanel({
region: 'center',
layout: 'fit',
id: 'infoGrid',
height:100,
autoWidth : true,
stateful : true,
stateId : 'grid',
enableColumnResize: true,
enableHdMenu: true,
frame:false,
//iconCls:'icon-grid',
columnLines: false,
viewConfig: {
forceFit:true
},
title : _('ID_PROCESS_CATEGORY'),
store: store,
cm: cmodel,
sm: smodel,
tbar: [newButton, '-', editButton, deleteButton, {xtype: 'tbfill'}, searchText,clearTextButton,searchButton],
bbar: bbarpaging,
listeners: {
rowdblclick: EditCategory,
render: function(){
this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')});
}
},
view: new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl: '{text}'
})
});
infoGrid.on('rowcontextmenu',
function (grid, rowIndex, evt) {
var sm = grid.getSelectionModel();
sm.selectRow(rowIndex, sm.isSelected(rowIndex));
},
this
);
infoGrid.on('contextmenu',
function (evt) {
evt.preventDefault();
},
this
);
infoGrid.addListener('rowcontextmenu',onMessageContextMenu,this);
infoGrid.store.load();
viewport = new Ext.Viewport({
layout: 'fit',
autoScroll: false,
items: [
infoGrid
]
});
}); });
//Funtion Handles Context Menu Opening //Funtion Handles Context Menu Opening
onMessageContextMenu = function (grid, rowIndex, e) { onMessageContextMenu = function (grid, rowIndex, e) {
e.stopEvent(); e.stopEvent();
var coords = e.getXY(); var coords = e.getXY();
contextMenu.showAt([coords[0], coords[1]]); contextMenu.showAt([coords[0], coords[1]]);
}; };
//Do Nothing Function //Do Nothing Function
@@ -298,184 +298,192 @@ DoNothing = function(){};
//Open New Category Form //Open New Category Form
NewCategoryWindow = function(){ NewCategoryWindow = function(){
w = new Ext.Window({ w = new Ext.Window({
title: _('ID_NEW_CATEGORY'), title: _('ID_NEW_CATEGORY'),
autoHeight: true, autoHeight: true,
width: 420, width: 420,
items: [newForm] items: [newForm],
}); id: 'w',
w.show(); model: true
});
w.show();
}; };
//Close Popup Window //Close Popup Window
CloseWindow = function(){ CloseWindow = function(){
w.hide(); Ext.getCmp('w').hide();
}; };
//Save New Category //Save New Category
SaveNewCategory = function(){ SaveNewCategory = function(){
catName = newForm.getForm().findField('category').getValue(); catName = newForm.getForm().findField('category').getValue();
viewport.getEl().mask(_('ID_PROCESSING')); catName = catName.trim();
Ext.Ajax.request({ if (catName == '') return;
url: 'processCategory_Ajax', viewport.getEl().mask(_('ID_PROCESSING'));
params : {action: 'checkCategoryName', cat_name: catName}, Ext.Ajax.request({
success: function(r,o){ url: 'processCategory_Ajax',
viewport.getEl().unmask(); params : {action: 'checkCategoryName', cat_name: catName},
resp = eval(r.responseText); success: function(r,o){
if (resp){ viewport.getEl().unmask();
viewport.getEl().mask(_('ID_PROCESSING')); resp = eval(r.responseText);
newForm.getForm().submit({ if (resp){
success: function(f,a){ viewport.getEl().mask(_('ID_PROCESSING'));
viewport.getEl().unmask(); newForm.getForm().submit({
w.hide(); //Hide popup widow success: function(f,a){
newForm.getForm().reset(); //Set empty form to next use viewport.getEl().unmask();
searchText.reset(); CloseWindow(); //Hide popup widow
infoGrid.store.load(); newForm.getForm().reset(); //Set empty form to next use
response = Ext.decode(a.response.responseText); searchText.reset();
if (response.success){ infoGrid.store.load();
PMExt.notify(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_SUCCESS_NEW')); response = Ext.decode(a.response.responseText);
}else{ if (response.success){
PMExt.error(_('ID_ERROR'),_('ID_MSG_AJAX_FAILURE')); PMExt.notify(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_SUCCESS_NEW'));
} }else{
}, PMExt.error(_('ID_ERROR'),_('ID_MSG_AJAX_FAILURE'));
failure: function(f,a){ }
viewport.getEl().unmask(); },
switch(a.failureType){ failure: function(f,a){
case Ext.form.Action.CLIENT_INVALID: viewport.getEl().unmask();
//Ext.Msg.alert('New Role Form','Invalid Data'); switch(a.failureType){
break; case Ext.form.Action.CLIENT_INVALID:
} //Ext.Msg.alert('New Role Form','Invalid Data');
} break;
}); }
}else{ }
PMExt.error(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_EXISTS')); });
} }else{
}, PMExt.error(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_EXISTS'));
failure: function(r,o){ }
viewport.getEl().unmask(); },
} failure: function(r,o){
}); viewport.getEl().unmask();
}
});
}; };
//Update Selected Role //Update Selected Role
UpdateCategory = function(){ UpdateCategory = function(){
catUID = editForm.getForm().findField('cat_uid').getValue(); catUID = editForm.getForm().findField('cat_uid').getValue();
catName = editForm.getForm().findField('category').getValue(); catName = editForm.getForm().findField('category').getValue();
viewport.getEl().mask(_('ID_PROCESSING')); catName = catName.trim();
Ext.Ajax.request({ if (catName == '') return;
url: 'processCategory_Ajax', viewport.getEl().mask(_('ID_PROCESSING'));
params : {action: 'checkEditCategoryName', cat_name: catName, cat_uid: catUID}, Ext.Ajax.request({
success: function(r,o){ url: 'processCategory_Ajax',
viewport.getEl().unmask(); params : {action: 'checkEditCategoryName', cat_name: catName, cat_uid: catUID},
resp = eval(r.responseText); success: function(r,o){
if (resp){ viewport.getEl().unmask();
viewport.getEl().mask(_('ID_PROCESSING')); resp = eval(r.responseText);
editForm.getForm().submit({ if (resp){
success: function(f,a){ viewport.getEl().mask(_('ID_PROCESSING'));
viewport.getEl().unmask(); editForm.getForm().submit({
w.hide(); //Hide popup widow success: function(f,a){
newForm.getForm().reset(); //Set empty form to next use viewport.getEl().unmask();
searchText.reset(); CloseWindow(); //Hide popup widow
infoGrid.store.load(); newForm.getForm().reset(); //Set empty form to next use
response = Ext.decode(a.response.responseText); searchText.reset();
if (response.success){ infoGrid.store.load();
PMExt.notify(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_SUCCESS_UPDATE')); response = Ext.decode(a.response.responseText);
}else{ if (response.success){
PMExt.error(_('ID_ERROR'),_('ID_MSG_AJAX_FAILURE')); PMExt.notify(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_SUCCESS_UPDATE'));
} }else{
}, PMExt.error(_('ID_ERROR'),_('ID_MSG_AJAX_FAILURE'));
failure: function(f,a){ }
viewport.getEl().unmask(); },
switch(a.failureType){ failure: function(f,a){
case Ext.form.Action.CLIENT_INVALID: viewport.getEl().unmask();
//Ext.Msg.alert('New Role Form','Invalid Data'); switch(a.failureType){
break; case Ext.form.Action.CLIENT_INVALID:
} //Ext.Msg.alert('New Role Form','Invalid Data');
} break;
}); }
}else{ }
PMExt.error(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_EXISTS')); });
} }else{
}, PMExt.error(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_EXISTS'));
failure: function(r,o){ }
viewport.getEl().unmask(); },
} failure: function(r,o){
}); viewport.getEl().unmask();
}
});
}; };
//Edit Selected Role //Edit Selected Role
EditCategory = function(){ EditCategory = function(){
rowSelected = infoGrid.getSelectionModel().getSelected(); rowSelected = infoGrid.getSelectionModel().getSelected();
if (rowSelected){ if (rowSelected){
editForm.getForm().findField('cat_uid').setValue(rowSelected.data.CATEGORY_UID); editForm.getForm().findField('cat_uid').setValue(rowSelected.data.CATEGORY_UID);
editForm.getForm().findField('category').setValue(rowSelected.data.CATEGORY_NAME); editForm.getForm().findField('category').setValue(rowSelected.data.CATEGORY_NAME);
w = new Ext.Window({ w = new Ext.Window({
autoHeight: true, autoHeight: true,
width: 420, width: 420,
title: _('ID_EDIT_CATEGORY'), title: _('ID_EDIT_CATEGORY'),
items: [editForm] items: [editForm],
}); id: 'w',
w.show(); modal: true
} });
w.show();
}
}; };
//Check Can Delete Category //Check Can Delete Category
DeleteCategory = function(){ DeleteCategory = function(){
rowSelected = infoGrid.getSelectionModel().getSelected(); rowSelected = infoGrid.getSelectionModel().getSelected();
if (rowSelected){ if (rowSelected){
var swDelete = false; var swDelete = false;
viewport.getEl().mask(_('ID_PROCESSING')); viewport.getEl().mask(_('ID_PROCESSING'));
Ext.Ajax.request({ Ext.Ajax.request({
url: 'processCategory_Ajax', url: 'processCategory_Ajax',
params: {action: 'canDeleteCategory', CAT_UID: rowSelected.data.CATEGORY_UID}, params: {action: 'canDeleteCategory', CAT_UID: rowSelected.data.CATEGORY_UID},
success: function(response, opts){ success: function(response, opts){
viewport.getEl().unmask(); viewport.getEl().unmask();
swDelete = eval(response.responseText); swDelete = eval(response.responseText);
if (swDelete){ if (swDelete){
Ext.Msg.confirm(_('ID_CONFIRM'), _('ID_CONFIRM_DELETE_CATEGORY'), Ext.Msg.confirm(_('ID_CONFIRM'), _('ID_CONFIRM_DELETE_CATEGORY'),
function(btn, text){ function(btn, text){
if (btn=="yes"){ if (btn=="yes"){
viewport.getEl().mask(_('ID_PROCESSING')); viewport.getEl().mask(_('ID_PROCESSING'));
Ext.Ajax.request({ Ext.Ajax.request({
url: 'processCategory_Ajax', url: 'processCategory_Ajax',
params: {action: 'deleteCategory', cat_uid: rowSelected.data.CATEGORY_UID}, params: {action: 'deleteCategory', cat_uid: rowSelected.data.CATEGORY_UID},
success: function(r,o){ success: function(r,o){
viewport.getEl().unmask(); viewport.getEl().unmask();
infoGrid.store.load(); //Reload store grid infoGrid.store.load(); //Reload store grid
editButton.disable(); //Disable Edit Button editButton.disable(); //Disable Edit Button
deleteButton.disable(); //Disable Delete Button deleteButton.disable(); //Disable Delete Button
resp = Ext.decode(r.responseText); resp = Ext.decode(r.responseText);
if (resp.success){ if (resp.success){
PMExt.notify(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_SUCCESS_DELETE')); PMExt.notify(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_SUCCESS_DELETE'));
}else{ }else{
PMExt.error(_('ID_ERROR'),_('ID_MSG_AJAX_FAILURE')); PMExt.error(_('ID_ERROR'),_('ID_MSG_AJAX_FAILURE'));
} }
}, },
failure: function(){viewport.getEl().unmask();} failure: function(){viewport.getEl().unmask();}
}); });
} }
}); });
}else{ }else{
PMExt.error(_('ID_PROCESS_CATEGORY'),_('ID_MSG_CANNOT_DELETE_CATEGORY')); PMExt.error(_('ID_PROCESS_CATEGORY'),_('ID_MSG_CANNOT_DELETE_CATEGORY'));
} }
}, },
failure: function(){viewport.getEl().unmask(); DoNothing();} failure: function(){viewport.getEl().unmask(); DoNothing();}
}); });
} }
}; };
//Load Grid By Default //Load Grid By Default
GridByDefault = function(){ GridByDefault = function(){
searchText.reset(); searchText.reset();
infoGrid.store.load(); infoGrid.store.load();
}; };
//Do Search Function //Do Search Function
DoSearch = function(){ DoSearch = function(){
infoGrid.store.load({params: {textFilter: searchText.getValue()}}); infoGrid.store.load({params: {textFilter: searchText.getValue()}});
}; };
//Update Page Size Configuration //Update Page Size Configuration

View File

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