diff --git a/workflow/engine/classes/model/Process.php b/workflow/engine/classes/model/Process.php
index b191e9972..2286be1a0 100644
--- a/workflow/engine/classes/model/Process.php
+++ b/workflow/engine/classes/model/Process.php
@@ -655,6 +655,22 @@ class Process extends BaseProcess {
}
return $aProcesses;
}
+
+ function getAllProcessesByCategory(){
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(ProcessPeer::PRO_CATEGORY);
+ $oCriteria->addSelectColumn('COUNT(*) AS CNT');
+ $oCriteria->addGroupByColumn(ProcessPeer::PRO_CATEGORY);
+ $oDataSet = ProcessPeer::doSelectRS($oCriteria);
+ $oDataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $aProc = Array();
+ while ($oDataSet->next()){
+ $row = $oDataSet->getRow();
+ $aProc[$row['PRO_CATEGORY']] = $row['CNT'];
+ }
+ return $aProc;
+ }
+
} // Process
function ordProcessByProTitle($a, $b){
@@ -666,5 +682,7 @@ function ordProcessByProTitle($a, $b){
} else {
return 0;
}
+
+
}
diff --git a/workflow/engine/methods/processCategory/processCategoryList.php b/workflow/engine/methods/processCategory/processCategoryList.php
index dfa3c3f63..cab7169a4 100755
--- a/workflow/engine/methods/processCategory/processCategoryList.php
+++ b/workflow/engine/methods/processCategory/processCategoryList.php
@@ -1,40 +1,47 @@
.
+ *
+ * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
+ * Coral Gables, FL, 33134, USA, or email info@colosa.com.
+ *
+ */
if($RBAC->userCanAccess('PM_SETUP') != 1 && $RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1){
G::SendTemporalMessage('krlos', 'error', 'labels');
- //G::header('location: ../login/login');
die;
}
- try {
+G::LoadClass('configuration');
+$c = new Configurations();
+$configPage = $c->getConfiguration('processCategoryList', 'pageSize','',$_SESSION['USER_LOGGED']);
+$Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20;
- $G_MAIN_MENU = 'workflow';
- $G_SUB_MENU = 'processCategory';
- $G_ID_MENU_SELECTED = '';
- $G_ID_SUB_MENU_SELECTED = '';
+$G_MAIN_MENU = 'workflow';
+$G_SUB_MENU = 'processCategory';
+$G_ID_MENU_SELECTED = '';
+$G_ID_SUB_MENU_SELECTED = '';
- $G_PUBLISH = new Publisher;
+$G_PUBLISH = new Publisher;
-
- require_once ( "classes/model/ProcessCategory.php" );
-
- $Criteria = new Criteria('workflow');
- $Criteria->clearSelectColumns ( );
-
- $Criteria->addSelectColumn ( ProcessCategoryPeer::CATEGORY_UID );
- $Criteria->addSelectColumn ( ProcessCategoryPeer::CATEGORY_PARENT );
- $Criteria->addSelectColumn ( ProcessCategoryPeer::CATEGORY_NAME );
- $Criteria->addSelectColumn ( ProcessCategoryPeer::CATEGORY_ICON );
-
- $Criteria->add ( processCategoryPeer::CATEGORY_UID, "xx" , CRITERIA::NOT_EQUAL );
-
- $G_PUBLISH->AddContent('propeltable', 'paged-table', 'processCategory/processCategoryList', $Criteria , array(),'');
- G::RenderPage('publishBlank', 'blank');
-
- }
- catch ( Exception $e ) {
- $G_PUBLISH = new Publisher;
- $aMessage['MESSAGE'] = $e->getMessage();
- $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
- G::RenderPage( 'publishBlank', 'blank' );
- }
+$oHeadPublisher =& headPublisher::getSingleton();
+$oHeadPublisher->addExtJsScript('processCategory/processCategoryList', false); //adding a javascript file .js
+$oHeadPublisher->addContent('processCategory/processCategoryList'); //adding a html file .html.
+$oHeadPublisher->assign('FORMATS',$c->getFormats());
+$oHeadPublisher->assign('CONFIG', $Config);
+G::RenderPage('publish', 'extJs');
\ No newline at end of file
diff --git a/workflow/engine/methods/processCategory/processCategory_Ajax.php b/workflow/engine/methods/processCategory/processCategory_Ajax.php
new file mode 100755
index 000000000..04bb6bc1a
--- /dev/null
+++ b/workflow/engine/methods/processCategory/processCategory_Ajax.php
@@ -0,0 +1,165 @@
+.
+ *
+ * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
+ * Coral Gables, FL, 33134, USA, or email info@colosa.com.
+ *
+ */
+
+if(isset($_REQUEST['action'])) {
+ switch($_REQUEST['action']) {
+ case 'processCategoryList':
+ require_once 'classes/model/ProcessCategory.php';
+ require_once 'classes/model/Process.php';
+ G::LoadClass('configuration');
+ $co = new Configurations();
+ $config = $co->getConfiguration('processCategoryList', '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'] : '';
+
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn('COUNT(*) AS CNT');
+ $oCriteria->add(ProcessCategoryPeer::CATEGORY_UID,'',Criteria::NOT_EQUAL);
+ if ($filter != ''){
+ $oCriteria->add(ProcessCategoryPeer::CATEGORY_NAME,'%'.$filter.'%',Criteria::LIKE);
+ }
+ $oDat = ProcessCategoryPeer::doSelectRS($oCriteria);
+ $oDat->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDat->next();
+ $row = $oDat->getRow();
+ $total_categories = $row['CNT'];
+
+ $oCriteria->clear();
+ $oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_UID);
+ $oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
+ $oCriteria->add(ProcessCategoryPeer::CATEGORY_UID,'',Criteria::NOT_EQUAL);
+ if ($filter != ''){
+ $oCriteria->add(ProcessCategoryPeer::CATEGORY_NAME,'%'.$filter.'%',Criteria::LIKE);
+ }
+ $oCriteria->setLimit($limit);
+ $oCriteria->setOffset($start);
+ $oDataset = ProcessCategoryPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+
+ $proc = new Process();
+ $aProcess = $proc->getAllProcessesByCategory();
+
+ $aCat = array();
+ while ($oDataset->next()){
+ $aCat[] = $oDataset->getRow();
+ $index = sizeof($aCat)-1;
+ $aCat[$index]['TOTAL_PROCESSES'] = isset($aProcess[$aCat[$index]['CATEGORY_UID']]) ? $aProcess[$aCat[$index]['CATEGORY_UID']] : 0;
+ }
+ echo '{categories: '.G::json_encode($aCat).', total_categories: '.$total_categories.'}';
+ 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('processCategoryList', 'pageSize','',$_SESSION['USER_LOGGED']);
+ echo '{success: true}';
+ break;
+ case 'checkCategoryName':
+ require_once 'classes/model/ProcessCategory.php';
+ $catName = $_REQUEST['cat_name'];
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
+ $oCriteria->add(ProcessCategoryPeer::CATEGORY_NAME, $catName);
+ $oDataset = ProcessCategoryPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $row = $oDataset->getRow();
+ $response = isset($row['CATEGORY_NAME'])? 'false' : 'true' ;
+ echo $response;
+ break;
+ case 'saveNewCategory':
+ try{
+ require_once 'classes/model/ProcessCategory.php';
+ $catName = $_REQUEST['category'];
+ $pcat = new ProcessCategory();
+ $pcat->setNew(true);
+ $pcat->setCategoryUid(G::GenerateUniqueID());
+ $pcat->setCategoryName($catName);
+ $pcat->save();
+ echo '{success: true}';
+ }catch(Exception $ex){
+ echo '{success: false, error: '.$ex->getMessage().'}';
+ }
+ break;
+ case 'checkEditCategoryName':
+ require_once 'classes/model/ProcessCategory.php';
+ $catUID = $_REQUEST['cat_uid'];
+ $catName = $_REQUEST['cat_name'];
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
+ $oCriteria->add(ProcessCategoryPeer::CATEGORY_NAME, $catName);
+ $oCriteria->add(ProcessCategoryPeer::CATEGORY_UID,$catUID,Criteria::NOT_EQUAL);
+ $oDataset = ProcessCategoryPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $oDataset->next();
+ $row = $oDataset->getRow();
+ $response = isset($row['CATEGORY_NAME'])? 'false' : 'true' ;
+ echo $response;
+ break;
+ case 'updateCategory':
+ try{
+ require_once 'classes/model/ProcessCategory.php';
+ $catUID = $_REQUEST['cat_uid'];
+ $catName = $_REQUEST['category'];
+ $pcat = new ProcessCategory();
+ $pcat->setNew(false);
+ $pcat->setCategoryUid($catUID);
+ $pcat->setCategoryName($catName);
+ $pcat->save();
+ echo '{success: true}';
+ }catch(Exception $ex){
+ echo '{success: false, error: '.$ex->getMessage().'}';
+ }
+ break;
+ case 'canDeleteCategory':
+ require_once 'classes/model/Process.php';
+ $proc = new Process();
+ $aProcess = $proc->getAllProcessesByCategory();
+ $catUID = $_REQUEST['CAT_UID'];
+ $response = isset($aProcess[$catUID])? 'false' : 'true';
+ echo $response;
+ break;
+ case 'deleteCategory':
+ try{
+ require_once 'classes/model/ProcessCategory.php';
+ $catUID = $_REQUEST['cat_uid'];
+ $cat = new ProcessCategory();
+ $cat->setCategoryUid($catUID);
+ $cat->delete();
+ echo '{success: true}';
+ }catch(Exception $ex){
+ echo '{success: false, error: '.$ex->getMessage().'}';
+ }
+ break;
+ default: echo 'default';
+ }
+}
\ No newline at end of file
diff --git a/workflow/engine/templates/processCategory/processCategoryList.html b/workflow/engine/templates/processCategory/processCategoryList.html
new file mode 100755
index 000000000..432f567b5
--- /dev/null
+++ b/workflow/engine/templates/processCategory/processCategoryList.html
@@ -0,0 +1,3 @@
+
diff --git a/workflow/engine/templates/processCategory/processCategoryList.js b/workflow/engine/templates/processCategory/processCategoryList.js
new file mode 100755
index 000000000..3339ec882
--- /dev/null
+++ b/workflow/engine/templates/processCategory/processCategoryList.js
@@ -0,0 +1,487 @@
+/*
+ * @author: Qennix
+ * Feb 11st, 2011
+ */
+
+//Keyboard Events
+new Ext.KeyMap(document, [
+ {
+ key: Ext.EventObject.F5,
+ fn: function(keycode, e) {
+ if (! e.ctrlKey) {
+ if (Ext.isIE) {
+ // IE6 doesn't allow cancellation of the F5 key, so trick it into
+ // thinking some other key was pressed (backspace in this case)
+ e.browserEvent.keyCode = 8;
+ }
+ e.stopEvent();
+ document.location = document.location;
+ }else{
+ Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5');
+ }
+ }
+},
+{
+ key: Ext.EventObject.DELETE,
+ fn: function(k,e){
+ iGrid = Ext.getCmp('infoGrid');
+ rowSelected = iGrid.getSelectionModel().getSelected();
+ if (rowSelected){
+ DeleteCategory();
+ }
+ }
+},
+{
+ key: Ext.EventObject.F2,
+ fn: function(k,e){
+ iGrid = Ext.getCmp('infoGrid');
+ rowSelected = iGrid.getSelectionModel().getSelected();
+ if (rowSelected){
+ EditCategory();
+ }
+ }
+}
+]);
+
+var store;
+var cmodel;
+var infoGrid;
+var viewport;
+var smodel;
+var newButton;
+var editButton;
+var deleteButton;
+var usersButton;
+var permissionsButton;
+var searchButton;
+var serachText;
+var newForm;
+var comboStatusStore;
+var editForm;
+var contextMenu;
+var w;
+
+Ext.onReady(function(){
+ 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( {
+ 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') + ' ',
+ 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
+onMessageContextMenu = function (grid, rowIndex, e) {
+ e.stopEvent();
+ var coords = e.getXY();
+ contextMenu.showAt([coords[0], coords[1]]);
+};
+
+//Do Nothing Function
+DoNothing = function(){};
+
+//Open New Category Form
+NewCategoryWindow = function(){
+ w = new Ext.Window({
+ title: _('ID_NEW_CATEGORY'),
+ autoHeight: true,
+ width: 420,
+ items: [newForm]
+ });
+ w.show();
+};
+
+//Close Popup Window
+CloseWindow = function(){
+ w.hide();
+};
+
+//Save New Category
+SaveNewCategory = function(){
+ catName = newForm.getForm().findField('category').getValue();
+ viewport.getEl().mask(_('ID_PROCESSING'));
+ Ext.Ajax.request({
+ url: 'processCategory_Ajax',
+ params : {action: 'checkCategoryName', cat_name: catName},
+ success: function(r,o){
+ viewport.getEl().unmask();
+ resp = eval(r.responseText);
+ if (resp){
+ viewport.getEl().mask(_('ID_PROCESSING'));
+ newForm.getForm().submit({
+ success: function(f,a){
+ viewport.getEl().unmask();
+ w.hide(); //Hide popup widow
+ newForm.getForm().reset(); //Set empty form to next use
+ searchText.reset();
+ infoGrid.store.load();
+ response = Ext.decode(a.response.responseText);
+ if (response.success){
+ 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){
+ case Ext.form.Action.CLIENT_INVALID:
+ //Ext.Msg.alert('New Role Form','Invalid Data');
+ break;
+ }
+ }
+ });
+ }else{
+ PMExt.error(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_EXISTS'));
+ }
+ },
+ failure: function(r,o){
+ viewport.getEl().unmask();
+ }
+ });
+
+};
+
+//Update Selected Role
+UpdateCategory = function(){
+ catUID = editForm.getForm().findField('cat_uid').getValue();
+ catName = editForm.getForm().findField('category').getValue();
+ viewport.getEl().mask(_('ID_PROCESSING'));
+ Ext.Ajax.request({
+ url: 'processCategory_Ajax',
+ params : {action: 'checkEditCategoryName', cat_name: catName, cat_uid: catUID},
+ success: function(r,o){
+ viewport.getEl().unmask();
+ resp = eval(r.responseText);
+ if (resp){
+ viewport.getEl().mask(_('ID_PROCESSING'));
+ editForm.getForm().submit({
+ success: function(f,a){
+ viewport.getEl().unmask();
+ w.hide(); //Hide popup widow
+ newForm.getForm().reset(); //Set empty form to next use
+ searchText.reset();
+ infoGrid.store.load();
+ response = Ext.decode(a.response.responseText);
+ if (response.success){
+ 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){
+ case Ext.form.Action.CLIENT_INVALID:
+ //Ext.Msg.alert('New Role Form','Invalid Data');
+ break;
+ }
+ }
+ });
+ }else{
+ PMExt.error(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_EXISTS'));
+ }
+ },
+ failure: function(r,o){
+ viewport.getEl().unmask();
+ }
+ });
+};
+
+//Edit Selected Role
+EditCategory = function(){
+ rowSelected = infoGrid.getSelectionModel().getSelected();
+ if (rowSelected){
+ editForm.getForm().findField('cat_uid').setValue(rowSelected.data.CATEGORY_UID);
+ editForm.getForm().findField('category').setValue(rowSelected.data.CATEGORY_NAME);
+ w = new Ext.Window({
+ autoHeight: true,
+ width: 420,
+ title: _('ID_EDIT_CATEGORY'),
+ items: [editForm]
+ });
+ w.show();
+ }
+};
+
+//Check Can Delete Category
+DeleteCategory = function(){
+ rowSelected = infoGrid.getSelectionModel().getSelected();
+ if (rowSelected){
+ var swDelete = false;
+ viewport.getEl().mask(_('ID_PROCESSING'));
+ Ext.Ajax.request({
+ url: 'processCategory_Ajax',
+ params: {action: 'canDeleteCategory', CAT_UID: rowSelected.data.CATEGORY_UID},
+ success: function(response, opts){
+ viewport.getEl().unmask();
+ swDelete = eval(response.responseText);
+ if (swDelete){
+ Ext.Msg.confirm(_('ID_CONFIRM'), _('ID_CONFIRM_DELETE_CATEGORY'),
+ function(btn, text){
+ if (btn=="yes"){
+ viewport.getEl().mask(_('ID_PROCESSING'));
+ Ext.Ajax.request({
+ url: 'processCategory_Ajax',
+ params: {action: 'deleteCategory', cat_uid: rowSelected.data.CATEGORY_UID},
+ success: function(r,o){
+ viewport.getEl().unmask();
+ infoGrid.store.load(); //Reload store grid
+ editButton.disable(); //Disable Edit Button
+ deleteButton.disable(); //Disable Delete Button
+ resp = Ext.decode(r.responseText);
+ if (resp.success){
+ PMExt.notify(_('ID_PROCESS_CATEGORY'),_('ID_CATEGORY_SUCCESS_DELETE'));
+ }else{
+ PMExt.error(_('ID_ERROR'),_('ID_MSG_AJAX_FAILURE'));
+ }
+
+ },
+ failure: function(){viewport.getEl().unmask();}
+ });
+ }
+ });
+ }else{
+ PMExt.error(_('ID_PROCESS_CATEGORY'),_('ID_MSG_CANNOT_DELETE_CATEGORY'));
+ }
+ },
+ failure: function(){viewport.getEl().unmask(); DoNothing();}
+
+ });
+ }
+};
+
+//Load Grid By Default
+GridByDefault = function(){
+ searchText.reset();
+ infoGrid.store.load();
+};
+
+//Do Search Function
+DoSearch = function(){
+ infoGrid.store.load({params: {textFilter: searchText.getValue()}});
+};
+
+//Update Page Size Configuration
+UpdatePageConfig = function(pageSize){
+ Ext.Ajax.request({
+ url: 'processCategory_Ajax',
+ params: {action:'updatePageSize', size: pageSize}
+ });
+};
\ No newline at end of file