Merge pull request #888 from victorsl/BUG-9830
BUG 9924 "Participated list only display TO_DO cases" SOLVED
This commit is contained in:
@@ -1,28 +1,40 @@
|
||||
<?php
|
||||
|
||||
class Applications
|
||||
{
|
||||
public function getAll(
|
||||
$userUid,
|
||||
$start = null,
|
||||
$limit = null,
|
||||
$action = null,
|
||||
$filter = null,
|
||||
$search = null,
|
||||
$process = null,
|
||||
$status = null,
|
||||
$type = null,
|
||||
$dateFrom = null,
|
||||
$dateTo = null,
|
||||
$callback = null,
|
||||
$dir = null,
|
||||
$sort = "APP_CACHE_VIEW.APP_NUMBER",
|
||||
$category = null
|
||||
) {
|
||||
$callback = isset($callback)? $callback : "stcCallback1001";
|
||||
$dir = isset($dir)? $dir : "DESC";
|
||||
$sort = isset($sort)? $sort : "";
|
||||
$start = isset($start)? $start : "0";
|
||||
$limit = isset($limit)? $limit : "25";
|
||||
$filter = isset($filter)? $filter : "";
|
||||
$search = isset($search)? $search : "";
|
||||
$process = isset($process)? $process : "";
|
||||
$category = isset($category)? $category : "";
|
||||
$status = isset($status)? $status : "";
|
||||
$action = isset($action)? $action : "todo";
|
||||
$type = isset($type)? $type : "extjs";
|
||||
$dateFrom = isset($dateFrom)? $dateFrom : "";
|
||||
$dateTo = isset($dateTo)? $dateTo : "";
|
||||
|
||||
public function getAll ($userUid, $start = null, $limit = null, $action = null, $filter = null, $search = null, $process = null, $user = null, $status = null, $type = null, $dateFrom = null, $dateTo = null, $callback = null, $dir = null, $sort = 'APP_CACHE_VIEW.APP_NUMBER', $category = null)
|
||||
{
|
||||
$callback = isset( $callback ) ? $callback : 'stcCallback1001';
|
||||
$dir = isset( $dir ) ? $dir : 'DESC';
|
||||
$sort = isset( $sort ) ? $sort : '';
|
||||
$start = isset( $start ) ? $start : '0';
|
||||
$limit = isset( $limit ) ? $limit : '25';
|
||||
$filter = isset( $filter ) ? $filter : '';
|
||||
$search = isset( $search ) ? $search : '';
|
||||
$process = isset( $process ) ? $process : '';
|
||||
$category = isset( $category ) ? $category : '';
|
||||
$user = isset( $user ) ? $user : '';
|
||||
$status = isset( $status ) ? strtoupper( $status ) : '';
|
||||
$action = isset( $action ) ? $action : 'todo';
|
||||
$type = isset( $type ) ? $type : 'extjs';
|
||||
$dateFrom = isset( $dateFrom ) ? $dateFrom : '';
|
||||
$dateTo = isset( $dateTo ) ? $dateTo : '';
|
||||
|
||||
G::LoadClass( "BasePeer" );
|
||||
G::LoadClass( 'configuration' );
|
||||
G::LoadClass("BasePeer");
|
||||
G::LoadClass("configuration");
|
||||
require_once ("classes/model/AppCacheView.php");
|
||||
require_once ("classes/model/AppDelegation.php");
|
||||
require_once ("classes/model/AdditionalTables.php");
|
||||
@@ -31,72 +43,107 @@ class Applications
|
||||
require_once ("classes/model/Users.php");
|
||||
require_once ("classes/model/Process.php");
|
||||
|
||||
//$userUid = ( isset($_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '' ) ? $_SESSION['USER_LOGGED'] : null; <-- passed by param
|
||||
$oAppCache = new AppCacheView();
|
||||
|
||||
//get data configuration
|
||||
$conf = new Configurations();
|
||||
$confCasesList = $conf->getConfiguration( 'casesList', ($action == 'search' || $action == 'simple_search') ? 'sent' : $action );
|
||||
// var_dump($confCasesList);
|
||||
$oAppCache->confCasesList = $confCasesList;
|
||||
|
||||
// get the action based list
|
||||
switch ($action) {
|
||||
case 'draft':
|
||||
$Criteria = $oAppCache->getDraftListCriteria( $userUid );
|
||||
$CriteriaCount = $oAppCache->getDraftCountCriteria( $userUid );
|
||||
case "draft":
|
||||
$Criteria = $oAppCache->getDraftListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getDraftCountCriteria($userUid);
|
||||
break;
|
||||
case 'sent':
|
||||
$Criteria = $oAppCache->getSentListCriteria( $userUid );
|
||||
$CriteriaCount = $oAppCache->getSentCountCriteria( $userUid );
|
||||
// var_dump($Criteria);
|
||||
case "sent":
|
||||
$Criteria = $oAppCache->getSentListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getSentCountCriteria($userUid);
|
||||
|
||||
if (!empty($status)) {
|
||||
$Criteria->add(AppCacheViewPeer::APP_STATUS, $status);
|
||||
$CriteriaCount->add(AppCacheViewPeer::APP_STATUS, $status);
|
||||
}
|
||||
break;
|
||||
case 'selfservice':
|
||||
case 'unassigned':
|
||||
$Criteria = $oAppCache->getUnassignedListCriteria( $userUid );
|
||||
$CriteriaCount = $oAppCache->getUnassignedCountCriteria( $userUid );
|
||||
case "selfservice":
|
||||
case "unassigned":
|
||||
//$userUid can't be empty or null
|
||||
$Criteria = $oAppCache->getUnassignedListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getUnassignedCountCriteria($userUid);
|
||||
break;
|
||||
case 'paused':
|
||||
$Criteria = $oAppCache->getPausedListCriteria( $userUid );
|
||||
$CriteriaCount = $oAppCache->getPausedCountCriteria( $userUid );
|
||||
case "paused":
|
||||
$Criteria = $oAppCache->getPausedListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getPausedCountCriteria($userUid);
|
||||
break;
|
||||
case 'completed':
|
||||
$Criteria = $oAppCache->getCompletedListCriteria( $userUid );
|
||||
$CriteriaCount = $oAppCache->getCompletedCountCriteria( $userUid );
|
||||
case "completed":
|
||||
$Criteria = $oAppCache->getCompletedListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid);
|
||||
break;
|
||||
case 'cancelled':
|
||||
$Criteria = $oAppCache->getCancelledListCriteria( $userUid );
|
||||
$CriteriaCount = $oAppCache->getCancelledCountCriteria( $userUid );
|
||||
case "cancelled":
|
||||
$Criteria = $oAppCache->getCancelledListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid);
|
||||
break;
|
||||
case 'search':
|
||||
$Criteria = $oAppCache->getSearchListCriteria();
|
||||
$CriteriaCount = $oAppCache->getSearchCountCriteria();
|
||||
case "search":
|
||||
//$Criteria = $oAppCache->getSearchListCriteria();
|
||||
//$CriteriaCount = $oAppCache->getSearchCountCriteria();
|
||||
|
||||
switch ($status) {
|
||||
case "TO_DO":
|
||||
$Criteria = $oAppCache->getToDoListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getToDoCountCriteria($userUid);
|
||||
break;
|
||||
case "DRAFT":
|
||||
$Criteria = $oAppCache->getDraftListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getDraftCountCriteria($userUid);
|
||||
break;
|
||||
case "PAUSED":
|
||||
$Criteria = $oAppCache->getPausedListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getPausedCountCriteria($userUid);
|
||||
break;
|
||||
case "CANCELLED":
|
||||
$Criteria = $oAppCache->getCancelledListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid);
|
||||
break;
|
||||
case "COMPLETED":
|
||||
$Criteria = $oAppCache->getCompletedListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid);
|
||||
break;
|
||||
default:
|
||||
//All status
|
||||
$Criteria = $oAppCache->getAllCasesListCriteria2($userUid);
|
||||
$CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'simple_search':
|
||||
case "simple_search":
|
||||
$Criteria = $oAppCache->getSimpleSearchListCriteria();
|
||||
$CriteriaCount = $oAppCache->getSimpleSearchCountCriteria();
|
||||
break;
|
||||
case 'to_revise':
|
||||
$Criteria = $oAppCache->getToReviseListCriteria( $userUid );
|
||||
$CriteriaCount = $oAppCache->getToReviseCountCriteria( $userUid );
|
||||
case "to_revise":
|
||||
$Criteria = $oAppCache->getToReviseListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getToReviseCountCriteria($userUid);
|
||||
break;
|
||||
case 'to_reassign':
|
||||
$Criteria = $oAppCache->getToReassignListCriteria();
|
||||
$CriteriaCount = $oAppCache->getToReassignCountCriteria();
|
||||
case "to_reassign":
|
||||
$Criteria = $oAppCache->getToReassignListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getToReassignCountCriteria($userUid);
|
||||
break;
|
||||
case 'all':
|
||||
$Criteria = $oAppCache->getAllCasesListCriteria( $userUid );
|
||||
$CriteriaCount = $oAppCache->getAllCasesCountCriteria( $userUid );
|
||||
case "all":
|
||||
$Criteria = $oAppCache->getAllCasesListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getAllCasesCountCriteria($userUid);
|
||||
break;
|
||||
// general criteria probably will be deprecated
|
||||
case 'gral':
|
||||
case "gral":
|
||||
//General criteria probably will be deprecated
|
||||
$Criteria = $oAppCache->getGeneralListCriteria();
|
||||
$CriteriaCount = $oAppCache->getGeneralCountCriteria();
|
||||
break;
|
||||
case 'todo':
|
||||
case "todo":
|
||||
$Criteria = $oAppCache->getToDoListCriteria($userUid);
|
||||
$CriteriaCount = $oAppCache->getToDoCountCriteria($userUid);
|
||||
break;
|
||||
default:
|
||||
$Criteria = $oAppCache->getToDoListCriteria( $userUid );
|
||||
$CriteriaCount = $oAppCache->getToDoCountCriteria( $userUid );
|
||||
//All status
|
||||
$Criteria = $oAppCache->getAllCasesListCriteria2($userUid);
|
||||
$CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -107,7 +154,7 @@ class Applications
|
||||
$Criteria->addAsColumn( 'USR_USERNAME', 'CU.USR_USERNAME' );
|
||||
|
||||
// Fix for previous user
|
||||
if ($action == 'todo' || $action == 'selfservice' || $action == 'unassigned' || $action == 'paused' || $action == 'to_revise' || $action == 'sent') {
|
||||
if (($action == "todo" || $action == "selfservice" || $action == "unassigned" || $action == "paused" || $action == "to_revise" || $action == "sent") || ($status == "TO_DO" || $status == "DRAFT" || $status == "PAUSED" || $status == "CANCELLED" || $status == "COMPLETED")) {
|
||||
$Criteria->addAlias( 'PU', 'USERS' );
|
||||
$Criteria->addJoin( AppCacheViewPeer::PREVIOUS_USR_UID, 'PU.USR_UID', Criteria::LEFT_JOIN );
|
||||
$Criteria->addAsColumn( 'PREVIOUS_USR_FIRSTNAME', 'PU.USR_FIRSTNAME' );
|
||||
@@ -115,11 +162,13 @@ class Applications
|
||||
$Criteria->addAsColumn( 'PREVIOUS_USR_USERNAME', 'PU.USR_USERNAME' );
|
||||
}
|
||||
|
||||
/*
|
||||
if (! is_array( $confCasesList )) {
|
||||
$rows = $this->getDefaultFields( $action );
|
||||
$result = $this->genericJsonResponse( '', array (), $rows, 20, '' );
|
||||
//$conf->saveObject($result,'casesList',$action,'','','');
|
||||
}
|
||||
*/
|
||||
|
||||
// add the process filter
|
||||
if ($process != '') {
|
||||
@@ -136,15 +185,19 @@ class Applications
|
||||
}
|
||||
|
||||
// add the user filter
|
||||
/*
|
||||
if ($user != '') {
|
||||
$Criteria->add( AppCacheViewPeer::USR_UID, $user, Criteria::EQUAL );
|
||||
$CriteriaCount->add( AppCacheViewPeer::USR_UID, $user, Criteria::EQUAL );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if ($status != '') {
|
||||
$Criteria->add( AppCacheViewPeer::APP_STATUS, $status, Criteria::EQUAL );
|
||||
$CriteriaCount->add( AppCacheViewPeer::APP_STATUS, $status, Criteria::EQUAL );
|
||||
}
|
||||
*/
|
||||
|
||||
if ($dateFrom != '') {
|
||||
if ($dateTo != '') {
|
||||
@@ -183,7 +236,6 @@ class Applications
|
||||
|
||||
//add the search filter
|
||||
if ($search != '') {
|
||||
|
||||
$defaultFields = $oAppCache->getDefaultFields();
|
||||
$oTmpCriteria = '';
|
||||
// if there is PMTABLE for this case list:
|
||||
@@ -222,13 +274,33 @@ class Applications
|
||||
}
|
||||
}
|
||||
|
||||
// this is the optimal way or query to render the cases search list
|
||||
// fixing the bug related to the wrong data displayed in the list
|
||||
/*
|
||||
if ($action == 'search') {
|
||||
$oDatasetIndex = AppCacheViewPeer::doSelectRS( $Criteria );
|
||||
$oDatasetIndex->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDatasetIndex->next();
|
||||
$maxDelIndexList = array ();
|
||||
// a list of MAX_DEL_INDEXES is required in order to validate the right row
|
||||
while ($aRow = $oDatasetIndex->getRow()) {
|
||||
$maxDelIndexList[] = $aRow['MAX_DEL_INDEX'];
|
||||
$oDatasetIndex->next();
|
||||
}
|
||||
// adding the validation condition in order to get the right row using the group by sentence
|
||||
$Criteria->add( AppCacheViewPeer::DEL_INDEX, $maxDelIndexList, Criteria::IN );
|
||||
//
|
||||
//$params = array($maxDelIndexList);
|
||||
}
|
||||
*/
|
||||
|
||||
//here we count how many records exists for this criteria.
|
||||
//BUT there are some special cases, and if we dont optimize them the server will crash.
|
||||
$doCountAlreadyExecuted = false;
|
||||
//case 1. when the SEARCH action is selected and none filter, search criteria is defined,
|
||||
//we need to count using the table APPLICATION, because APP_CACHE_VIEW takes 3 seconds
|
||||
|
||||
|
||||
/*
|
||||
if ($action == 'search' && $filter == '' && $search == '' && $process == '' && $status == '' && $dateFrom == '' && $dateTo == '' && $category == '') {
|
||||
$totalCount = $oAppCache->getSearchAllCount();
|
||||
$doCountAlreadyExecuted = true;
|
||||
@@ -237,11 +309,12 @@ class Applications
|
||||
$totalCount = $oAppCache->getSearchCountCriteria();
|
||||
$doCountAlreadyExecuted = true;
|
||||
}
|
||||
*/
|
||||
|
||||
if ($doCountAlreadyExecuted == false) {
|
||||
// in the case of reassign the distinct attribute shows a diferent count result comparing to the
|
||||
// original list
|
||||
if ($action == 'to_reassign' || $action == 'todo') {
|
||||
if (($action == "to_reassign" || $action == "todo") || ($status == "TO_DO")) {
|
||||
$distinct = false;
|
||||
} else {
|
||||
$distinct = true;
|
||||
@@ -279,26 +352,6 @@ class Applications
|
||||
$Criteria->setLimit( $limit );
|
||||
$Criteria->setOffset( $start );
|
||||
|
||||
// this is the optimal way or query to render the cases search list
|
||||
// fixing the bug related to the wrong data displayed in the list
|
||||
if ($action == 'search') {
|
||||
$oDatasetIndex = AppCacheViewPeer::doSelectRS( $Criteria );
|
||||
$oDatasetIndex->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
$oDatasetIndex->next();
|
||||
$maxDelIndexList = array ();
|
||||
// a list of MAX_DEL_INDEXES is required in order to validate the right row
|
||||
while ($aRow = $oDatasetIndex->getRow()) {
|
||||
$maxDelIndexList[] = $aRow['MAX_DEL_INDEX'];
|
||||
$oDatasetIndex->next();
|
||||
}
|
||||
// adding the validation condition in order to get the right row using the group by sentence
|
||||
$Criteria->add( AppCacheViewPeer::DEL_INDEX, $maxDelIndexList, Criteria::IN );
|
||||
//
|
||||
$params = array ($maxDelIndexList
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
//execute the query
|
||||
$oDataset = AppCacheViewPeer::doSelectRS( $Criteria );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
|
||||
@@ -100,7 +100,11 @@ class AppCacheView extends BaseAppCacheView
|
||||
$criteria->addSelectColumn(AppCacheViewPeer::PRO_UID);
|
||||
|
||||
$criteria->add(AppCacheViewPeer::APP_STATUS, "TO_DO", CRITERIA::EQUAL);
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
|
||||
if (!empty($userUid)) {
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
}
|
||||
|
||||
$criteria->add(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
|
||||
$criteria->add(AppCacheViewPeer::APP_THREAD_STATUS, 'OPEN');
|
||||
$criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, 'OPEN');
|
||||
@@ -145,7 +149,10 @@ class AppCacheView extends BaseAppCacheView
|
||||
}
|
||||
|
||||
$criteria->add(AppCacheViewPeer::APP_STATUS, "DRAFT", CRITERIA::EQUAL);
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
|
||||
if (!empty($userUid)) {
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
}
|
||||
|
||||
//$criteria->add(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
|
||||
$criteria->add(AppCacheViewPeer::APP_THREAD_STATUS, 'OPEN');
|
||||
@@ -175,27 +182,31 @@ class AppCacheView extends BaseAppCacheView
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the SENT cases list criteria
|
||||
* param $userUid the current userUid
|
||||
* param $doCount if true this will return the criteria for count cases only
|
||||
* @return Criteria object $Criteria
|
||||
* Gets the criteria object of the sent cases
|
||||
*
|
||||
* Return the criteria object of the sent cases
|
||||
*
|
||||
* @param string $userUid The user ID
|
||||
* @param bool $doCount If true this will return the criteria for count cases only
|
||||
* @return criteria Object criteria
|
||||
*/
|
||||
public function getSent($userUid, $doCount)
|
||||
{
|
||||
//adding configuration fields from the configuration options
|
||||
//Adding configuration fields from the configuration options
|
||||
//and forming the criteria object
|
||||
if ($doCount && !isset($this->confCasesList['PMTable']) && !empty($this->confCasesList['PMTable'])) {
|
||||
$criteria = new Criteria('workflow');
|
||||
if ($doCount && !isset($this->confCasesList["PMTable"]) && !empty($this->confCasesList["PMTable"])) {
|
||||
$criteria = new Criteria("workflow");
|
||||
} else {
|
||||
$criteria = $this->addPMFieldsToCriteria('sent');
|
||||
$criteria = $this->addPMFieldsToCriteria("sent");
|
||||
}
|
||||
|
||||
$criteria->add(AppCacheViewPeer::APP_STATUS, "DRAFT", CRITERIA::EQUAL);
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
if (!empty($userUid)) {
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
}
|
||||
|
||||
//$criteria->add(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
|
||||
$criteria->add(AppCacheViewPeer::APP_THREAD_STATUS, 'OPEN');
|
||||
$criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, 'OPEN');
|
||||
if (!$doCount) {
|
||||
$criteria->addGroupByColumn(AppCacheViewPeer::APP_UID);
|
||||
}
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
@@ -213,7 +224,9 @@ class AppCacheView extends BaseAppCacheView
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
|
||||
return $criteria;*/
|
||||
return $this->getSentListCriteria($userUid);
|
||||
//return $this->getSentListCriteria($userUid);
|
||||
|
||||
return $this->getSent($userUid, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,6 +236,7 @@ class AppCacheView extends BaseAppCacheView
|
||||
*/
|
||||
public function getSentListCriteria ($userUid)
|
||||
{
|
||||
/*
|
||||
$criteria = $this->addPMFieldsToCriteria('sent');
|
||||
|
||||
//$criteria->addAsColumn('MAX_DEL_INDEX', 'MAX(' . AppDelegationPeer::DEL_INDEX . ')');
|
||||
@@ -234,6 +248,9 @@ class AppCacheView extends BaseAppCacheView
|
||||
$criteria->add(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
|
||||
|
||||
return $criteria;
|
||||
*/
|
||||
|
||||
return $this->getSent($userUid, false);
|
||||
}
|
||||
|
||||
public function getSentListProcessCriteria($userUid)
|
||||
@@ -421,35 +438,43 @@ class AppCacheView extends BaseAppCacheView
|
||||
|
||||
public function getProUidSupervisor($userUid)
|
||||
{
|
||||
//finding cases PRO_UID where $userUid is supervising
|
||||
require_once ('classes/model/ProcessUser.php');
|
||||
require_once ('classes/model/GroupUser.php');
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ProcessUserPeer::USR_UID, $userUid);
|
||||
$oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
|
||||
$oDataset = ProcessUserPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aProcesses = array();
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aProcesses[] = $aRow['PRO_UID'];
|
||||
$oDataset->next();
|
||||
//finding cases PRO_UID where $userUid is supervising
|
||||
require_once ('classes/model/ProcessUser.php');
|
||||
require_once ('classes/model/GroupUser.php');
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
|
||||
if (!empty($userUid)) {
|
||||
$oCriteria->add(ProcessUserPeer::USR_UID, $userUid);
|
||||
}
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(ProcessUserPeer::PRO_UID);
|
||||
$oCriteria->add(ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');
|
||||
$oCriteria->addJoin(ProcessUserPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||
$oCriteria->add(GroupUserPeer::USR_UID, $userUid);
|
||||
$oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
|
||||
$oDataset = ProcessUserPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aProcesses[] = $aRow['PRO_UID'];
|
||||
$oDataset->next();
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aProcesses = array();
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aProcesses[] = $aRow['PRO_UID'];
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(ProcessUserPeer::PRO_UID);
|
||||
$oCriteria->add(ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');
|
||||
$oCriteria->addJoin(ProcessUserPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||
|
||||
if (!empty($userUid)) {
|
||||
$oCriteria->add(GroupUserPeer::USR_UID, $userUid);
|
||||
}
|
||||
|
||||
$oDataset = ProcessUserPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$aProcesses[] = $aRow['PRO_UID'];
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
return $aProcesses;
|
||||
@@ -475,15 +500,23 @@ class AppCacheView extends BaseAppCacheView
|
||||
|
||||
//add a validation to show the processes of which $userUid is supervisor
|
||||
//$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::USR_UID, $userUid)->
|
||||
addOr($criteria->getNewCriterion(AppCacheViewPeer::PRO_UID, $aProcesses, Criteria::IN))
|
||||
);
|
||||
|
||||
if (!empty($userUid)) {
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::USR_UID, $userUid)->addOr(
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::PRO_UID, $aProcesses, Criteria::IN))
|
||||
);
|
||||
} else {
|
||||
if (count($aProcesses) > 0) {
|
||||
$criteria->add(AppCacheViewPeer::PRO_UID, $aProcesses, Criteria::IN);
|
||||
}
|
||||
}
|
||||
|
||||
//join with APP_DELAY table using APP_UID and DEL_INDEX
|
||||
$appDelayConds[] = array(AppCacheViewPeer::APP_UID, AppDelayPeer::APP_UID);
|
||||
$appDelayConds[] = array(AppCacheViewPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX);
|
||||
$criteria->addJoinMC($appDelayConds, Criteria::LEFT_JOIN);
|
||||
$arrayCondition = array();
|
||||
$arrayCondition[] = array(AppCacheViewPeer::APP_UID, AppDelayPeer::APP_UID);
|
||||
$arrayCondition[] = array(AppCacheViewPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX);
|
||||
$criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
|
||||
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)->
|
||||
@@ -578,15 +611,14 @@ class AppCacheView extends BaseAppCacheView
|
||||
}
|
||||
|
||||
$criteria->add(AppCacheViewPeer::APP_STATUS, "COMPLETED", CRITERIA::EQUAL);
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
|
||||
//$criteria->add(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
|
||||
$criteria->add(AppCacheViewPeer::APP_THREAD_STATUS, 'OPEN');
|
||||
$criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, 'OPEN');
|
||||
if (!empty($userUid)) {
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
}
|
||||
|
||||
|
||||
//$c->add(AppDelegationPeer::DEL_PREVIOUS, '0', Criteria::NOT_EQUAL);
|
||||
$criteria->addGroupByColumn(AppCacheViewPeer::APP_UID);
|
||||
if (!$doCount) {
|
||||
$criteria->addGroupByColumn(AppCacheViewPeer::APP_UID);
|
||||
}
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
@@ -628,7 +660,11 @@ class AppCacheView extends BaseAppCacheView
|
||||
}
|
||||
|
||||
$criteria->add(AppCacheViewPeer::APP_STATUS, "CANCELLED", CRITERIA::EQUAL);
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
|
||||
if (!empty($userUid)) {
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
}
|
||||
|
||||
$criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, 'CLOSED');
|
||||
|
||||
return $criteria;
|
||||
@@ -900,7 +936,10 @@ class AppCacheView extends BaseAppCacheView
|
||||
public function getAllCasesCountCriteria($userUid)
|
||||
{
|
||||
$oCriteria = $this->getGeneralCases(true);
|
||||
$oCriteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
|
||||
if (!empty($userUid)) {
|
||||
$oCriteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
}
|
||||
|
||||
return $oCriteria;
|
||||
}
|
||||
@@ -912,11 +951,122 @@ class AppCacheView extends BaseAppCacheView
|
||||
public function getAllCasesListCriteria($userUid)
|
||||
{
|
||||
$oCriteria = $this->getGeneralCases(false);
|
||||
$oCriteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
|
||||
if (!empty($userUid)) {
|
||||
$oCriteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
}
|
||||
|
||||
return $oCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SQL string for an case
|
||||
*
|
||||
* Return the SQL string for an case
|
||||
*
|
||||
* @param string $fieldAppUid The field APP_UID
|
||||
* @param string $fieldDelIndex The field DEL_INDEX
|
||||
* @return string SQL string
|
||||
*/
|
||||
public function getAppDelaySql($fieldAppUid, $fieldDelIndex)
|
||||
{
|
||||
$sql = "SELECT DISTINCT " . AppDelayPeer::APP_UID . "
|
||||
FROM " . AppDelayPeer::TABLE_NAME . "
|
||||
WHERE " . AppDelayPeer::APP_UID . " = $fieldAppUid AND
|
||||
" . AppDelayPeer::APP_DEL_INDEX . " = $fieldDelIndex AND
|
||||
(" . AppDelayPeer::APP_DISABLE_ACTION_USER . " IS NULL OR " . AppDelayPeer::APP_DISABLE_ACTION_USER . " = '0') AND
|
||||
" . AppDelayPeer::APP_DELAY_UID . " IS NOT NULL AND
|
||||
" . AppDelayPeer::APP_TYPE . " = 'PAUSE'";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the criteria object of all cases
|
||||
*
|
||||
* Return the criteria object of all cases
|
||||
*
|
||||
* @param string $userUid The user ID
|
||||
* @param bool $doCount If true this will return the criteria for count cases only
|
||||
* @return criteria Object criteria
|
||||
*/
|
||||
public function getAllCases2($userUid, $doCount)
|
||||
{
|
||||
//Adding configuration fields from the configuration options
|
||||
//and forming the criteria object
|
||||
if ($doCount && !isset($this->confCasesList["PMTable"]) && !empty($this->confCasesList["PMTable"])) {
|
||||
$criteria = new Criteria("workflow");
|
||||
} else {
|
||||
$criteria = $this->addPMFieldsToCriteria("all");
|
||||
}
|
||||
|
||||
if (!empty($userUid)) {
|
||||
$criteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
}
|
||||
|
||||
//paused
|
||||
$sqlAppDelay = $this->getAppDelaySql(AppCacheViewPeer::APP_UID, AppCacheViewPeer::DEL_INDEX);
|
||||
|
||||
$criteria->add(
|
||||
//todo - getToDo()
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::APP_STATUS, "TO_DO", CRITERIA::EQUAL)->addAnd(
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL))->addAnd(
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::APP_THREAD_STATUS, "OPEN"))->addAnd(
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN"))
|
||||
)->addOr(
|
||||
//draft - getDraft()
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::APP_STATUS, "DRAFT", CRITERIA::EQUAL)->addAnd(
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::APP_THREAD_STATUS, "OPEN"))->addAnd(
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN"))
|
||||
)->addOr(
|
||||
//paused
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::APP_STATUS, "PAUSED")->addAnd(
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::APP_UID, AppCacheViewPeer::APP_UID . " IN ($sqlAppDelay)", Criteria::CUSTOM))
|
||||
)->addOr(
|
||||
//cancelled - getCancelled()
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::APP_STATUS, "CANCELLED", CRITERIA::EQUAL)->addAnd(
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::DEL_THREAD_STATUS, "CLOSED"))
|
||||
)->addOr(
|
||||
//completed - getCompleted()
|
||||
$criteria->getNewCriterion(AppCacheViewPeer::APP_STATUS, "COMPLETED", CRITERIA::EQUAL)
|
||||
);
|
||||
|
||||
if (!$doCount) {
|
||||
//completed - getCompleted()
|
||||
$criteria->addGroupByColumn(AppCacheViewPeer::APP_UID);
|
||||
|
||||
//$criteria->addGroupByColumn(AppCacheViewPeer::USR_UID);
|
||||
}
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the criteria object of all cases for the list
|
||||
*
|
||||
* Return the criteria object of all cases for the list
|
||||
*
|
||||
* @param string $userUid The user ID
|
||||
* @return criteria Object criteria
|
||||
*/
|
||||
public function getAllCasesListCriteria2($userUid)
|
||||
{
|
||||
return $this->getAllCases2($userUid, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the criteria object of all cases for the count
|
||||
*
|
||||
* Return the criteria object of all cases for the count
|
||||
*
|
||||
* @param string $userUid The user ID
|
||||
* @return criteria Object criteria
|
||||
*/
|
||||
public function getAllCasesCountCriteria2($userUid)
|
||||
{
|
||||
return $this->getAllCases2($userUid, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the ALL cases list criteria for count
|
||||
* @return Criteria object $Criteria
|
||||
@@ -935,7 +1085,7 @@ class AppCacheView extends BaseAppCacheView
|
||||
return $this->getGeneralCases(false);
|
||||
}
|
||||
|
||||
public function getToReassign($doCount)
|
||||
public function getToReassign($userUid, $doCount)
|
||||
{
|
||||
if ($doCount && !isset($this->confCasesList['PMTable']) && !empty($this->confCasesList['PMTable'])) {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
@@ -944,6 +1094,11 @@ class AppCacheView extends BaseAppCacheView
|
||||
}
|
||||
|
||||
$oCriteria->add(AppCacheViewPeer::APP_STATUS, 'TO_DO');
|
||||
|
||||
if (!empty($userUid)) {
|
||||
$oCriteria->add(AppCacheViewPeer::USR_UID, $userUid);
|
||||
}
|
||||
|
||||
$oCriteria->add(AppCacheViewPeer::APP_CURRENT_USER, '', Criteria::NOT_EQUAL);
|
||||
$oCriteria->add(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
|
||||
$oCriteria->add(AppCacheViewPeer::APP_THREAD_STATUS, 'OPEN');
|
||||
@@ -957,18 +1112,18 @@ class AppCacheView extends BaseAppCacheView
|
||||
* gets the ALL cases list criteria for count
|
||||
* @return Criteria object $Criteria
|
||||
*/
|
||||
public function getToReassignCountCriteria()
|
||||
public function getToReassignCountCriteria($userUid)
|
||||
{
|
||||
return $this->getToReassign(true);
|
||||
return $this->getToReassign($userUid, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the ALL cases list criteria for list
|
||||
* @return Criteria object $Criteria
|
||||
*/
|
||||
public function getToReassignListCriteria()
|
||||
public function getToReassignListCriteria($userUid)
|
||||
{
|
||||
return $this->getToReassign(false);
|
||||
return $this->getToReassign($userUid, false);
|
||||
}
|
||||
|
||||
public function getDefaultFields()
|
||||
|
||||
@@ -181,7 +181,7 @@ function getAllUsersArray ($action)
|
||||
|
||||
if ($action == 'to_reassign') {
|
||||
//now get users, just for the Search action
|
||||
$cUsers = $oAppCache->getToReassignListCriteria();
|
||||
$cUsers = $oAppCache->getToReassignListCriteria(null);
|
||||
$cUsers->addSelectColumn( AppCacheViewPeer::USR_UID );
|
||||
|
||||
if (g::MySQLSintaxis()) {
|
||||
@@ -237,7 +237,7 @@ function getStatusArray ($action, $userUid)
|
||||
// $cStatus = $oAppCache->getPausedListCriteria($userUid);
|
||||
break;
|
||||
case 'to_reassign':
|
||||
$cStatus = $oAppCache->getToReassignListCriteria();
|
||||
$cStatus = $oAppCache->getToReassignListCriteria($userUid);
|
||||
break;
|
||||
case 'todo':
|
||||
case 'draft':
|
||||
|
||||
@@ -99,7 +99,7 @@ if ($actionAjax == "processListExtJs") {
|
||||
$cProcess = $oAppCache->getToReviseListCriteria( $userUid );
|
||||
break;
|
||||
case 'to_reassign':
|
||||
$cProcess = $oAppCache->getToReassignListCriteria();
|
||||
$cProcess = $oAppCache->getToReassignListCriteria($userUid);
|
||||
$cProcess->addAscendingOrderByColumn( AppCacheViewPeer::APP_PRO_TITLE );
|
||||
break;
|
||||
case 'gral':
|
||||
|
||||
@@ -17,30 +17,82 @@ $dateFrom = isset( $_POST["dateFrom"] ) ? substr( $_POST["dateFrom"], 0, 10 ) :
|
||||
$dateTo = isset( $_POST["dateTo"] ) ? substr( $_POST["dateTo"], 0, 10 ) : "";
|
||||
|
||||
try {
|
||||
$userUid = (isset($_SESSION["USER_LOGGED"]) && $_SESSION["USER_LOGGED"] != "")? $_SESSION["USER_LOGGED"] : null;
|
||||
$result = "";
|
||||
$userUid = (isset( $_SESSION["USER_LOGGED"] ) && $_SESSION["USER_LOGGED"] != "") ? $_SESSION["USER_LOGGED"] : null;
|
||||
$user = ($user == "CURRENT_USER") ? $userUid : $user;
|
||||
|
||||
if (($action == "todo" || $action == "draft" || $action == "sent" || $action == "selfservice" || $action == "unassigned" || $action == "search") && (($solrConf = System::solrEnv()) !== false)) {
|
||||
G::LoadClass( "AppSolr" );
|
||||
if ((
|
||||
$action == "todo" || $action == "draft" || $action == "sent" || $action == "selfservice" ||
|
||||
$action == "unassigned" || $action == "search"
|
||||
) &&
|
||||
(($solrConf = System::solrEnv()) !== false)
|
||||
) {
|
||||
G::LoadClass("AppSolr");
|
||||
|
||||
$ApplicationSolrIndex = new AppSolr( $solrConf["solr_enabled"], $solrConf["solr_host"], $solrConf["solr_instance"] );
|
||||
$user = ($user == "CURRENT_USER")? $userUid : $user;
|
||||
|
||||
$data = $ApplicationSolrIndex->getAppGridData( $userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort );
|
||||
$ApplicationSolrIndex = new AppSolr(
|
||||
$solrConf["solr_enabled"],
|
||||
$solrConf["solr_host"],
|
||||
$solrConf["solr_instance"]
|
||||
);
|
||||
|
||||
$result = G::json_encode( $data );
|
||||
$data = $ApplicationSolrIndex->getAppGridData(
|
||||
$userUid,
|
||||
$start,
|
||||
$limit,
|
||||
$action,
|
||||
$filter,
|
||||
$search,
|
||||
$process,
|
||||
$user, //delete
|
||||
$status,
|
||||
$type,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$callback,
|
||||
$dir,
|
||||
$sort
|
||||
);
|
||||
|
||||
$result = G::json_encode($data);
|
||||
} else {
|
||||
G::LoadClass( "applications" );
|
||||
G::LoadClass("applications");
|
||||
|
||||
switch ($action) {
|
||||
case "search":
|
||||
case "to_reassign":
|
||||
$user = ($user == "CURRENT_USER")? $userUid : $user;
|
||||
$userUid = $user;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$apps = new Applications();
|
||||
$data = $apps->getAll( $userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort, $category );
|
||||
$data = $apps->getAll(
|
||||
$userUid,
|
||||
$start,
|
||||
$limit,
|
||||
$action,
|
||||
$filter,
|
||||
$search,
|
||||
$process,
|
||||
$status,
|
||||
$type,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$callback,
|
||||
$dir,
|
||||
$sort,
|
||||
$category
|
||||
);
|
||||
|
||||
$result = G::json_encode( $data );
|
||||
$result = G::json_encode($data);
|
||||
}
|
||||
|
||||
echo $result;
|
||||
} catch (Exception $e) {
|
||||
$msg = array ("error" => $e->getMessage() );
|
||||
echo G::json_encode( $msg );
|
||||
$msg = array("error" => $e->getMessage());
|
||||
echo G::json_encode($msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ $oCases = new Cases();
|
||||
require_once ('classes/model/Task.php');
|
||||
require_once ('classes/model/AppCacheView.php');
|
||||
$oAppCacheView = new AppCacheView();
|
||||
$oCasesReassignList = $oAppCacheView->getToReassignListCriteria();
|
||||
$oCasesReassignList = $oAppCacheView->getToReassignListCriteria(null);
|
||||
if (isset( $_POST['selected'] ) && $_POST['selected'] == 'true') {
|
||||
$oCasesReassignList->add( AppCacheViewPeer::APP_UID, $appSelectedUids, Criteria::IN );
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class Services_Rest_Case
|
||||
$app = new Applications();
|
||||
$userUid = Services_Rest_Auth::$userId;
|
||||
|
||||
return $app->getAll($userUid, $start, $limit, $type, $filter, $search, $process, $user, $status, $typeResource, $dateFrom, $dateTo);
|
||||
return $app->getAll($userUid, $start, $limit, $type, $filter, $search, $process, $status, $typeResource, $dateFrom, $dateTo);
|
||||
} else {
|
||||
// get a specific record.
|
||||
G::loadClass('wsBase');
|
||||
|
||||
Reference in New Issue
Block a user