CODE STYLE

This commit is contained in:
Ralph Asendeteufrer
2012-10-17 11:41:42 -04:00
parent ff2b54a2ed
commit 27e9c59fd1
8 changed files with 399 additions and 410 deletions

View File

@@ -12,36 +12,35 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
if(isset($_POST['function'])) {
switch($_POST['function']) {
case 'checkCategoryName':
$CategoryName = $_POST['CategoryName'];
require_once ( "classes/model/ProcessCategory.php" );
$processCategory = new ProcessCategory();
$aProcessCategory = $processCategory->loadByCategoryName($CategoryName);
if( is_array($aProcessCategory)) {
return print '1';
} else {
return print '0';
}
break;
default: echo 'default';
}
if (isset( $_POST['function'] )) {
switch ($_POST['function']) {
case 'checkCategoryName':
$CategoryName = $_POST['CategoryName'];
require_once ("classes/model/ProcessCategory.php");
$processCategory = new ProcessCategory();
$aProcessCategory = $processCategory->loadByCategoryName( $CategoryName );
if (is_array( $aProcessCategory )) {
return print '1';
} else {
return print '0';
}
break;
default:
echo 'default';
}
}

View File

@@ -1,41 +1,39 @@
<?php
if($RBAC->userCanAccess('PM_SETUP') != 1 && $RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1){
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
//G::header('location: ../login/login');
die;
}
//to do: improve the way to pass two or more parameters in the paged-table ( link )
$aux = explode ( '|', $_GET['id'] );
$index=0;
$CategoryUid = str_replace ( '"', '', $aux[$index++] );
require_once ( "classes/model/ProcessCategory.php" );
//if exists the row in the database propel will update it, otherwise will insert.
$tr = ProcessCategoryPeer::retrieveByPK( $CategoryUid );
if ( ( is_object ( $tr ) && get_class ($tr) == 'ProcessCategory' ) ) {
$fields['CATEGORY_UID'] = $tr->getCategoryUid();
$fields['LABEL_CATEGORY_UID'] = $tr->getCategoryUid();
$fields['CATEGORY_PARENT'] = $tr->getCategoryParent();
$fields['LABEL_CATEGORY_PARENT'] = $tr->getCategoryParent();
$fields['CATEGORY_NAME'] = $tr->getCategoryName();
$fields['LABEL_CATEGORY_NAME'] = $tr->getCategoryName();
$fields['CATEGORY_ICON'] = $tr->getCategoryIcon();
$fields['LABEL_CATEGORY_ICON'] = $tr->getCategoryIcon();
}
else
$fields = array();
$G_MAIN_MENU = 'workflow';
$G_SUB_MENU = 'processCategory';
$G_ID_MENU_SELECTED = '';
$G_ID_SUB_MENU_SELECTED = '';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'processCategory/processCategoryDelete', '', $fields, 'processCategoryDeleteExec' );
G::RenderPage('publishBlank', 'blank');
<?php
if ($RBAC->userCanAccess( 'PM_SETUP' ) != 1 && $RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) {
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
//G::header('location: ../login/login');
die();
}
//to do: improve the way to pass two or more parameters in the paged-table ( link )
$aux = explode( '|', $_GET['id'] );
$index = 0;
$CategoryUid = str_replace( '"', '', $aux[$index ++] );
require_once ("classes/model/ProcessCategory.php");
//if exists the row in the database propel will update it, otherwise will insert.
$tr = ProcessCategoryPeer::retrieveByPK( $CategoryUid );
if ((is_object( $tr ) && get_class( $tr ) == 'ProcessCategory')) {
$fields['CATEGORY_UID'] = $tr->getCategoryUid();
$fields['LABEL_CATEGORY_UID'] = $tr->getCategoryUid();
$fields['CATEGORY_PARENT'] = $tr->getCategoryParent();
$fields['LABEL_CATEGORY_PARENT'] = $tr->getCategoryParent();
$fields['CATEGORY_NAME'] = $tr->getCategoryName();
$fields['LABEL_CATEGORY_NAME'] = $tr->getCategoryName();
$fields['CATEGORY_ICON'] = $tr->getCategoryIcon();
$fields['LABEL_CATEGORY_ICON'] = $tr->getCategoryIcon();
} else
$fields = array ();
$G_MAIN_MENU = 'workflow';
$G_SUB_MENU = 'processCategory';
$G_ID_MENU_SELECTED = '';
$G_ID_SUB_MENU_SELECTED = '';
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'processCategory/processCategoryDelete', '', $fields, 'processCategoryDeleteExec' );
G::RenderPage( 'publishBlank', 'blank' );
?>

View File

@@ -1,46 +1,44 @@
<?php
if($RBAC->userCanAccess('PM_SETUP') != 1 && $RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1){
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
//G::header('location: ../login/login');
die;
}
try {
$form = $_POST['form'];
$CategoryUid = $form['CATEGORY_UID'];
require_once ( "classes/model/ProcessCategory.php" );
require_once 'classes/model/Process.php';
//we'are looking for data into process with this CategoryUid
$oCriteria = new Criteria('workflow');
$oCriteria->add(ProcessPeer::PRO_CATEGORY, $CategoryUid);
$oDataset = ProcessPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($oDataset->next()) {
$aDataProcess = $oDataset->getRow();
$oCriteria1 = new Criteria('workflow');
$oCriteria1->add(ProcessPeer::PRO_CATEGORY, '');
$oCriteria2 = new Criteria('workflow');
$oCriteria2->add(ProcessPeer::PRO_UID, $aDataProcess['PRO_UID']);
BasePeer::doUpdate($oCriteria2, $oCriteria1, Propel::getConnection('workflow'));
}
//if exists the row in the database propel will update it, otherwise will insert.
$tr = ProcessCategoryPeer::retrieveByPK( $CategoryUid );
if ( ( is_object ( $tr ) && get_class ($tr) == 'ProcessCategory' ) ) {
$tr->delete();
}
G::Header('location: processCategoryList');
}
catch ( Exception $e ) {
$G_PUBLISH = new Publisher;
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publish', 'blank' );
}
<?php
if ($RBAC->userCanAccess( 'PM_SETUP' ) != 1 && $RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) {
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
//G::header('location: ../login/login');
die();
}
try {
$form = $_POST['form'];
$CategoryUid = $form['CATEGORY_UID'];
require_once ("classes/model/ProcessCategory.php");
require_once 'classes/model/Process.php';
//we'are looking for data into process with this CategoryUid
$oCriteria = new Criteria( 'workflow' );
$oCriteria->add( ProcessPeer::PRO_CATEGORY, $CategoryUid );
$oDataset = ProcessPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
while ($oDataset->next()) {
$aDataProcess = $oDataset->getRow();
$oCriteria1 = new Criteria( 'workflow' );
$oCriteria1->add( ProcessPeer::PRO_CATEGORY, '' );
$oCriteria2 = new Criteria( 'workflow' );
$oCriteria2->add( ProcessPeer::PRO_UID, $aDataProcess['PRO_UID'] );
BasePeer::doUpdate( $oCriteria2, $oCriteria1, Propel::getConnection( 'workflow' ) );
}
//if exists the row in the database propel will update it, otherwise will insert.
$tr = ProcessCategoryPeer::retrieveByPK( $CategoryUid );
if ((is_object( $tr ) && get_class( $tr ) == 'ProcessCategory')) {
$tr->delete();
}
G::Header( 'location: processCategoryList' );
} catch (Exception $e) {
$G_PUBLISH = new Publisher();
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publish', 'blank' );
}

View File

@@ -1,35 +1,32 @@
<?php
if($RBAC->userCanAccess('PM_SETUP') != 1 && $RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1){
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
//G::header('location: ../login/login');
die;
}
$aux = explode ( '|', isset($_GET['id']) ? $_GET['id'] : '' );
$CategoryUid = str_replace ( '"', '', $aux[0] );
require_once ( "classes/model/ProcessCategory.php" );
//if exists the row in the database propel will update it, otherwise will insert.
$tr = ProcessCategoryPeer::retrieveByPK( $CategoryUid );
if ( ( is_object ( $tr ) && get_class ($tr) == 'ProcessCategory' ) ) {
$fields['CATEGORY_UID'] = $tr->getCategoryUid();
$fields['CATEGORY_PARENT'] = $tr->getCategoryParent();
$fields['CATEGORY_NAME'] = $tr->getCategoryName();
$fields['CATEGORY_ICON'] = $tr->getCategoryIcon();
}
else
$fields = array();
$G_MAIN_MENU = 'workflow';
$G_SUB_MENU = 'processCategory';
$G_ID_MENU_SELECTED = '';
$G_ID_SUB_MENU_SELECTED = '';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'processCategory/processCategoryEdit', '', $fields, 'processCategorySave' );
G::RenderPage('publishBlank', 'blank');
<?php
if ($RBAC->userCanAccess( 'PM_SETUP' ) != 1 && $RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) {
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
//G::header('location: ../login/login');
die();
}
$aux = explode( '|', isset( $_GET['id'] ) ? $_GET['id'] : '' );
$CategoryUid = str_replace( '"', '', $aux[0] );
require_once ("classes/model/ProcessCategory.php");
//if exists the row in the database propel will update it, otherwise will insert.
$tr = ProcessCategoryPeer::retrieveByPK( $CategoryUid );
if ((is_object( $tr ) && get_class( $tr ) == 'ProcessCategory')) {
$fields['CATEGORY_UID'] = $tr->getCategoryUid();
$fields['CATEGORY_PARENT'] = $tr->getCategoryParent();
$fields['CATEGORY_NAME'] = $tr->getCategoryName();
$fields['CATEGORY_ICON'] = $tr->getCategoryIcon();
} else
$fields = array ();
$G_MAIN_MENU = 'workflow';
$G_SUB_MENU = 'processCategory';
$G_ID_MENU_SELECTED = '';
$G_ID_SUB_MENU_SELECTED = '';
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'processCategory/processCategoryEdit', '', $fields, 'processCategorySave' );
G::RenderPage( 'publishBlank', 'blank' );
?>

View File

@@ -1,47 +1,46 @@
<?php
/**
* processCategoryList.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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');
die;
}
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_PUBLISH = new Publisher;
$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');
<?php
/**
* processCategoryList.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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' );
die();
}
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_PUBLISH = new Publisher();
$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' );

View File

@@ -1,27 +1,26 @@
<?php
if($RBAC->userCanAccess('PM_SETUP') != 1 && $RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1){
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
//G::header('location: ../login/login');
die;
}
require_once ( "classes/model/ProcessCategory.php" );
$fields['CATEGORY_UID'] = G::GenerateUniqueID();;
$fields['CATEGORY_PARENT'] = '';
$fields['CATEGORY_NAME'] = '';
$fields['CATEGORY_ICON'] = '';
$G_MAIN_MENU = 'workflow';
$G_SUB_MENU = 'processCategory';
$G_ID_MENU_SELECTED = '';
$G_ID_SUB_MENU_SELECTED = '';
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'processCategory/processCategoryNew', '', $fields, 'processCategorySave' );
G::RenderPage('publishBlank', 'blank');
?>
<?php
if ($RBAC->userCanAccess( 'PM_SETUP' ) != 1 && $RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) {
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
//G::header('location: ../login/login');
die();
}
require_once ("classes/model/ProcessCategory.php");
$fields['CATEGORY_UID'] = G::GenerateUniqueID();
;
$fields['CATEGORY_PARENT'] = '';
$fields['CATEGORY_NAME'] = '';
$fields['CATEGORY_ICON'] = '';
$G_MAIN_MENU = 'workflow';
$G_SUB_MENU = 'processCategory';
$G_ID_MENU_SELECTED = '';
$G_ID_SUB_MENU_SELECTED = '';
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'processCategory/processCategoryNew', '', $fields, 'processCategorySave' );
G::RenderPage( 'publishBlank', 'blank' );
?>

View File

@@ -1,59 +1,58 @@
<?php
try {
$form = $_POST['form'];
$CategoryUid = $form['CATEGORY_UID'];
$CategoryParent = $form['CATEGORY_PARENT'];
$CategoryName = $form['CATEGORY_NAME'];
$CategoryIcon = $form['CATEGORY_ICON'];
<?php
try {
$form = $_POST['form'];
$CategoryUid = $form['CATEGORY_UID'];
$CategoryParent = $form['CATEGORY_PARENT'];
$CategoryName = $form['CATEGORY_NAME'];
$CategoryIcon = $form['CATEGORY_ICON'];
require_once ("classes/model/ProcessCategory.php");
//if exists the row in the database propel will update it, otherwise will insert.
$tr = ProcessCategoryPeer::retrieveByPK( $CategoryUid );
$processCategory = new ProcessCategory();
$aProcessCategory = $processCategory->loadByCategoryName( $CategoryName );
if (! is_array( $aProcessCategory )) {
if (! (is_object( $tr ) && get_class( $tr ) == 'ProcessCategory')) {
$tr = new ProcessCategory();
}
$tr->setCategoryUid( $CategoryUid );
$tr->setCategoryParent( $CategoryParent );
$tr->setCategoryName( $CategoryName );
$tr->setCategoryIcon( $CategoryIcon );
if ($tr->validate()) {
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save();
} else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $tr->getValidationFailures();
foreach ($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
}
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
require_once ( "classes/model/ProcessCategory.php" );
//to do: uniform coderror structures for all classes
//if exists the row in the database propel will update it, otherwise will insert.
$tr = ProcessCategoryPeer::retrieveByPK( $CategoryUid );
$processCategory = new ProcessCategory();
$aProcessCategory = $processCategory->loadByCategoryName($CategoryName);
if(! is_array($aProcessCategory)) {
if ( ! ( is_object ( $tr ) && get_class ($tr) == 'ProcessCategory' ) ) {
$tr = new ProcessCategory();
}
$tr->setCategoryUid( $CategoryUid );
$tr->setCategoryParent( $CategoryParent );
$tr->setCategoryName( $CategoryName );
$tr->setCategoryIcon( $CategoryIcon );
if ($tr->validate() ) {
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save();
}
else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $tr->getValidationFailures();
foreach($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
//return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
}
//return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
//to do: uniform coderror structures for all classes
//if ( $res['codError'] < 0 ) {
// G::SendMessageText ( $res['message'] , 'error' );
//}
G::Header('location: processCategoryList');
//if ( $res['codError'] < 0 ) {
// G::SendMessageText ( $res['message'] , 'error' );
//}
G::Header( 'location: processCategoryList' );
} else {
// G::SendTemporalMessage("El registro ya existe", "warning", 'labels');
G::Header('location: processCategoryList');
die;
// G::SendTemporalMessage("El registro ya existe", "warning", 'labels');
G::Header( 'location: processCategoryList' );
die();
}
} catch ( Exception $e ) {
$G_PUBLISH = new Publisher;
} catch (Exception $e) {
$G_PUBLISH = new Publisher();
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publish', 'blank' );
}
}

View File

@@ -12,154 +12,154 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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 = trim($_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 = trim($_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';
}
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 = trim( $_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 = trim( $_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';
}
}