/** * Get Application data by appUid * * @param string $app_uid Unique id of the app * @param string $index * * return row app_cache_view * */ public function getDraftApp($app_uid, $index = 1) { $c = new \Criteria('workflow'); $c->clearSelectColumns(); $c->addSelectColumn(\AppCacheViewPeer::APP_NUMBER); $c->addSelectColumn(\AppCacheViewPeer::APP_STATUS); $c->addSelectColumn(\AppCacheViewPeer::DEL_INDEX); $c->addSelectColumn(\AppCacheViewPeer::APP_DEL_PREVIOUS_USER); $c->addSelectColumn(\AppCacheViewPeer::DEL_DELEGATE_DATE); $c->addSelectColumn(\AppCacheViewPeer::USR_UID); $c->addSelectColumn(\AppCacheViewPeer::PRO_UID); $c->addSelectColumn(\AppCacheViewPeer::APP_PRO_TITLE); $c->addSelectColumn(\AppCacheViewPeer::APP_TAS_TITLE); $c->addSelectColumn(\AppCacheViewPeer::DEL_THREAD_STATUS); $c->addSelectColumn(\AppCacheViewPeer::TAS_UID); $c->addSelectColumn(\AppCacheViewPeer::DEL_LAST_INDEX); $c->add(\AppCacheViewPeer::APP_UID, $app_uid); $c->add(\AppCacheViewPeer::DEL_INDEX, $index); $rs = \AppCacheViewPeer::doSelectRS($c); $rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $rows = array(); while ($rs->next()) { $rows[] = $rs->getRow(); } return $rows; }
function getProcessArray($userUid) { global $oAppCache; require_once "classes/model/AppCacheView.php"; $processes = array(); $processes[] = array('', G::LoadTranslation('ID_ALL_PROCESS')); $cProcess = new Criteria('workflow'); $cProcess->clearSelectColumns(); $cProcess->addSelectColumn(AppCacheViewPeer::PRO_UID); $cProcess->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE); $cProcess->setDistinct(AppCacheViewPeer::PRO_UID); $cProcess->addAscendingOrderByColumn(AppCacheViewPeer::APP_PRO_TITLE); $oDataset = AppCacheViewPeer::doSelectRS($cProcess); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array($aRow['PRO_UID'], $aRow['APP_PRO_TITLE']); $oDataset->next(); } return $processes; }
break; } //get the processes for this user in this action $cProcess->clearSelectColumns(); $cProcess->addSelectColumn(AppCacheViewPeer::PRO_UID); $cProcess->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE); $cProcess->setDistinct(AppCacheViewPeer::PRO_UID); if ($categoryUid) { require_once 'classes/model/Process.php'; $cProcess->addAlias('CP', 'PROCESS'); $cProcess->add('CP.PRO_CATEGORY', $categoryUid, Criteria::EQUAL); $cProcess->addJoin(AppCacheViewPeer::PRO_UID, 'CP.PRO_UID', Criteria::LEFT_JOIN); $cProcess->addAsColumn('CATEGORY_UID', 'CP.PRO_CATEGORY'); } $cProcess->addAscendingOrderByColumn(AppCacheViewPeer::APP_PRO_TITLE); $oDataset = AppCacheViewPeer::doSelectRS($cProcess); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array($aRow['PRO_UID'], $aRow['APP_PRO_TITLE']); $oDataset->next(); } return print G::json_encode($processes); } if ($actionAjax == "getUsersToReassign") { $_SESSION['TASK'] = $_REQUEST['TAS_UID']; $case = new Cases(); G::LoadClass('tasks'); $task = new Task(); $tasks = $task->load($_SESSION['TASK']); $result->data = $case->getUsersToReassign($_SESSION['TASK'], $_SESSION['USER_LOGGED'], $tasks['PRO_UID']);
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = AppCacheViewPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setAppUid($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setDelIndex($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setDelLastIndex($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setAppNumber($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setAppStatus($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setUsrUid($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setPreviousUsrUid($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setTasUid($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setProUid($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setDelDelegateDate($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setDelInitDate($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setDelTaskDueDate($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setDelFinishDate($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setDelThreadStatus($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setAppThreadStatus($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setAppTitle($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setAppProTitle($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setAppTasTitle($arr[$keys[17]]); } if (array_key_exists($keys[18], $arr)) { $this->setAppCurrentUser($arr[$keys[18]]); } if (array_key_exists($keys[19], $arr)) { $this->setAppDelPreviousUser($arr[$keys[19]]); } if (array_key_exists($keys[20], $arr)) { $this->setDelPriority($arr[$keys[20]]); } if (array_key_exists($keys[21], $arr)) { $this->setDelDuration($arr[$keys[21]]); } if (array_key_exists($keys[22], $arr)) { $this->setDelQueueDuration($arr[$keys[22]]); } if (array_key_exists($keys[23], $arr)) { $this->setDelDelayDuration($arr[$keys[23]]); } if (array_key_exists($keys[24], $arr)) { $this->setDelStarted($arr[$keys[24]]); } if (array_key_exists($keys[25], $arr)) { $this->setDelFinished($arr[$keys[25]]); } if (array_key_exists($keys[26], $arr)) { $this->setDelDelayed($arr[$keys[26]]); } if (array_key_exists($keys[27], $arr)) { $this->setAppCreateDate($arr[$keys[27]]); } if (array_key_exists($keys[28], $arr)) { $this->setAppFinishDate($arr[$keys[28]]); } if (array_key_exists($keys[29], $arr)) { $this->setAppUpdateDate($arr[$keys[29]]); } if (array_key_exists($keys[30], $arr)) { $this->setAppOverduePercentage($arr[$keys[30]]); } }
$oTmpReassignCriteria = $oCasesReassignList; $oTmpReassignCriteria->add(AppCacheViewPeer::TAS_UID, $data->TAS_UID); $rs = AppCacheViewPeer::doSelectRS($oTmpReassignCriteria); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->next(); $row = $rs->getRow(); $aCase = $oCases->loadCaseInCurrentDelegation($data->APP_UID); $oCases->reassignCase($aCase['APP_UID'], $aCase['DEL_INDEX'], $aCase['USR_UID'] != '' ? $aCase['USR_UID'] : $_SESSION['USER_LOGGED'], $data->APP_REASSIGN_USER_UID); $currentCasesReassigned++; $casesReassignedCount++; $serverResponse[] = array('APP_REASSIGN_USER' => $data->APP_REASSIGN_USER, 'APP_TITLE' => $data->APP_TITLE, 'TAS_TITLE' => $data->APP_TAS_TITLE, 'REASSIGNED_CASES' => $currentCasesReassigned); } } else { $oTmpReassignCriteria = $oCasesReassignList; $oTmpReassignCriteria->add(AppCacheViewPeer::TAS_UID, $aData->TAS_UID); $rs = AppCacheViewPeer::doSelectRS($oTmpReassignCriteria); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->next(); $row = $rs->getRow(); $currentCasesReassigned = 0; while (is_array($row)) { $APP_UID = $row['APP_UID']; $aCase = $oCases->loadCaseInCurrentDelegation($APP_UID); $oCases->reassignCase($aCase['APP_UID'], $aCase['DEL_INDEX'], $aCase['USR_UID'] != '' ? $aCase['USR_UID'] : $_SESSION['USER_LOGGED'], $aData->APP_REASSIGN_USER_UID); $currentCasesReassigned++; $casesReassignedCount++; // var_dump($aCase); // echo ("<br>"); $rs->next(); $row = $rs->getRow(); }
function getProcessArray($action, $userUid) { global $oAppCache; $processes = array(); $processes[] = array("", G::LoadTranslation("ID_ALL_PROCESS")); switch ($action) { case "simple_search": case "search": //In search action, the query to obtain all process is too slow, so we need to query directly to //process and content tables, and for that reason we need the current language in AppCacheView. G::loadClass("configuration"); $oConf = new Configurations(); $oConf->loadConfig($x, "APP_CACHE_VIEW_ENGINE", "", "", "", ""); $appCacheViewEngine = $oConf->aConfig; $lang = isset($appCacheViewEngine["LANG"]) ? $appCacheViewEngine["LANG"] : "en"; $cProcess = new Criteria("workflow"); $cProcess->clearSelectColumns(); $cProcess->addSelectColumn(ProcessPeer::PRO_UID); $cProcess->addSelectColumn(ContentPeer::CON_VALUE); $del = DBAdapter::getStringDelimiter(); $conds = array(); $conds[] = array(ProcessPeer::PRO_UID, ContentPeer::CON_ID); $conds[] = array(ContentPeer::CON_CATEGORY, $del . "PRO_TITLE" . $del); $conds[] = array(ContentPeer::CON_LANG, $del . $lang . $del); $cProcess->addJoinMC($conds, Criteria::LEFT_JOIN); $cProcess->add(ProcessPeer::PRO_STATUS, "ACTIVE"); $oDataset = ProcessPeer::doSelectRS($cProcess); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array($aRow["PRO_UID"], $aRow["CON_VALUE"]); $oDataset->next(); } return $processes; break; case "consolidated": default: $cProcess = $oAppCache->getToDoListCriteria($userUid); //fast enough break; } $cProcess->clearSelectColumns(); $cProcess->setDistinct(); $cProcess->addSelectColumn(AppCacheViewPeer::PRO_UID); $cProcess->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE); $oDataset = AppCacheViewPeer::doSelectRS($cProcess); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array($aRow["PRO_UID"], $aRow["APP_PRO_TITLE"]); $oDataset->next(); } return $processes; }
$index = 1; $content = new Content(); $tasTitleDefault = G::LoadTranslation('ID_TASK_NOT_RELATED'); while ($result->next()) { $row = $result->getRow(); $row['APP_MSG_FROM'] = htmlentities($row['APP_MSG_FROM'], ENT_QUOTES, "UTF-8"); $row['APP_MSG_STATUS'] = ucfirst($row['APP_MSG_STATUS']); if ($row['DEL_INDEX'] != 0) { $index = $row['DEL_INDEX']; } $criteria = new Criteria(); $criteria->addSelectColumn(AppCacheViewPeer::APP_TITLE); $criteria->addSelectColumn(AppCacheViewPeer::APP_TAS_TITLE); $criteria->add(AppCacheViewPeer::APP_UID, $row['APP_UID']); $criteria->add(AppCacheViewPeer::DEL_INDEX, $index); $resultCacheView = AppCacheViewPeer::doSelectRS($criteria); $resultCacheView->setFetchmode(ResultSet::FETCHMODE_ASSOC); $row['APP_TITLE'] = '-'; while ($resultCacheView->next()) { $rowCacheView = $resultCacheView->getRow(); $row['APP_TITLE'] = $rowCacheView['APP_TITLE']; $row['TAS_TITLE'] = $rowCacheView['APP_TAS_TITLE']; } if ($row['DEL_INDEX'] == 0) { $row['TAS_TITLE'] = $tasTitleDefault; } $data[] = $row; } $response = array(); $response['totalCount'] = $totalCount; $response['data'] = $data;
function getStatusArray($action, $userUid) { global $oAppCache; $status = array(); $status[] = array('', G::LoadTranslation('ID_ALL_STATUS')); //get the list based in the action provided switch ($action) { case 'sent': $cStatus = $oAppCache->getSentListProcessCriteria($userUid); // a little slow break; case 'simple_search': case 'search': $cStatus = new Criteria('workflow'); $cStatus->clearSelectColumns(); $cStatus->setDistinct(); $cStatus->addSelectColumn(ApplicationPeer::APP_STATUS); $oDataset = ApplicationPeer::doSelectRS($cStatus); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $status[] = array($aRow['APP_STATUS'], G::LoadTranslation('ID_CASES_STATUS_' . $aRow['APP_STATUS'])); //here we can have a translation for the status ( the second param) $oDataset->next(); } return $status; break; case 'selfservice': $cStatus = $oAppCache->getUnassignedListCriteria($userUid); break; case 'paused': $cStatus = $oAppCache->getPausedListCriteria($userUid); break; case 'to_revise': $cStatus = $oAppCache->getToReviseListCriteria($userUid); // $cStatus = $oAppCache->getPausedListCriteria($userUid); break; case 'to_reassign': $cStatus = $oAppCache->getToReassignListCriteria($userUid); break; case 'todo': case 'draft': case 'gral': // case 'to_revise' : // case 'to_revise' : default: return $status; break; } //get the status for this user in this action only for participated, unassigned, paused // if ( $action != 'todo' && $action != 'draft' && $action != 'to_revise') { if ($action != 'todo' && $action != 'draft') { //$cStatus = new Criteria('workflow'); $cStatus->clearSelectColumns(); $cStatus->setDistinct(); $cStatus->addSelectColumn(AppCacheViewPeer::APP_STATUS); $oDataset = AppCacheViewPeer::doSelectRS($cStatus); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $status[] = array($aRow['APP_STATUS'], G::LoadTranslation('ID_CASES_STATUS_' . $aRow['APP_STATUS'])); //here we can have a translation for the status ( the second param) $oDataset->next(); } } return $status; }
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, $configuration = true, $paged = true ) { $callback = isset($callback)? $callback : "stcCallback1001"; $dir = isset($dir)? $dir : "DESC"; if (isset($sort)) { G::LoadClass('phpSqlParser'); $parser = new PHPSQLParser($sort); $sort = $parser->parsed; $sort = $sort[''][0]; } $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 : ""; G::LoadClass("BasePeer"); G::LoadClass("configuration"); //require_once ("classes/model/AppCacheView.php"); //require_once ("classes/model/AppDelegation.php"); //require_once ("classes/model/AdditionalTables.php"); //require_once ("classes/model/AppDelay.php"); //require_once ("classes/model/Fields.php"); //require_once ("classes/model/Users.php"); //require_once ("classes/model/Process.php"); $oAppCache = new AppCacheView(); if ($configuration == true) { //get data configuration $conf = new Configurations(); $confCasesList = $conf->getConfiguration("casesList", ($action == "search" || $action == "simple_search")? "search" : $action); $oAppCache->confCasesList = $confCasesList; } $delimiter = DBAdapter::getStringDelimiter(); // get the action based list switch ($action) { case "draft": $Criteria = $oAppCache->getDraftListCriteria($userUid); $CriteriaCount = $oAppCache->getDraftCountCriteria($userUid); break; 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": //$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); break; case "completed": $Criteria = $oAppCache->getCompletedListCriteria($userUid); $CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid); break; case "cancelled": $Criteria = $oAppCache->getCancelledListCriteria($userUid); $CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid); break; 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); $Criteria->add (AppCacheViewPeer::DEL_LAST_INDEX,"1"); $CriteriaCount->add (AppCacheViewPeer::DEL_LAST_INDEX,"1"); break; default: //All status $Criteria = $oAppCache->getAllCasesListCriteria2($userUid); $CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid); break; } break; case "simple_search": $Criteria = $oAppCache->getSimpleSearchListCriteria(); $CriteriaCount = $oAppCache->getSimpleSearchCountCriteria(); break; case "to_revise": $Criteria = $oAppCache->getToReviseListCriteria($userUid); $CriteriaCount = $oAppCache->getToReviseCountCriteria($userUid); break; case "to_reassign": $Criteria = $oAppCache->getToReassignListCriteria($userUid); $CriteriaCount = $oAppCache->getToReassignCountCriteria($userUid); break; case "all": $Criteria = $oAppCache->getAllCasesListCriteria($userUid); $CriteriaCount = $oAppCache->getAllCasesCountCriteria($userUid); break; case "gral": //General criteria probably will be deprecated $Criteria = $oAppCache->getGeneralListCriteria(); $CriteriaCount = $oAppCache->getGeneralCountCriteria(); break; case "todo": $Criteria = $oAppCache->getToDoListCriteria($userUid); $CriteriaCount = $oAppCache->getToDoCountCriteria($userUid); break; default: //All status $Criteria = $oAppCache->getAllCasesListCriteria2($userUid); $CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid); break; } $arrayTaskTypeToExclude = array("WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT"); $Criteria->addJoin(AppCacheViewPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN); $Criteria->add(TaskPeer::TAS_TYPE, $arrayTaskTypeToExclude, Criteria::NOT_IN); $CriteriaCount->addJoin(AppCacheViewPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN); $CriteriaCount->add(TaskPeer::TAS_TYPE, $arrayTaskTypeToExclude, Criteria::NOT_IN); $Criteria->addAlias( 'CU', 'USERS' ); $Criteria->addJoin( AppCacheViewPeer::USR_UID, 'CU.USR_UID', Criteria::LEFT_JOIN ); $Criteria->addAsColumn( 'USR_UID', 'CU.USR_UID' ); $Criteria->addAsColumn( 'USR_FIRSTNAME', 'CU.USR_FIRSTNAME' ); $Criteria->addAsColumn( 'USR_LASTNAME', 'CU.USR_LASTNAME' ); $Criteria->addAsColumn( 'USR_USERNAME', 'CU.USR_USERNAME' ); $CriteriaCount->addAlias( 'CU', 'USERS' ); $CriteriaCount->addJoin( AppCacheViewPeer::USR_UID, 'CU.USR_UID', Criteria::LEFT_JOIN ); $CriteriaCount->addAsColumn( 'USR_UID', 'CU.USR_UID' ); $CriteriaCount->addAsColumn( 'USR_FIRSTNAME', 'CU.USR_FIRSTNAME' ); $CriteriaCount->addAsColumn( 'USR_LASTNAME', 'CU.USR_LASTNAME' ); $CriteriaCount->addAsColumn( 'USR_USERNAME', 'CU.USR_USERNAME' ); //Current delegation $appdelcrTableName = AppCacheViewPeer::TABLE_NAME; $appdelcrAppTasTitle = "APPDELCR.APP_TAS_TITLE"; $appdelcrAppTasTitleCount = $appdelcrAppTasTitle; switch ($action) { case "sent": $appdelcrTableName = AppDelegationPeer::TABLE_NAME; $appdelcrAppTasTitle = "(SELECT CON_VALUE FROM CONTENT WHERE CON_ID = APPDELCR.TAS_UID AND CON_LANG = " . $delimiter . SYS_LANG . $delimiter . " AND CON_CATEGORY = " . $delimiter . "TAS_TITLE" . $delimiter . ")"; $appdelcrAppTasTitleCount = "APPDELCR.TAS_UID"; break; case "to_reassign": $appdelcrAppTasTitle = "APP_CACHE_VIEW.APP_TAS_TITLE"; $appdelcrAppTasTitleCount = $appdelcrAppTasTitle; break; } $Criteria->addAsColumn("APPDELCR_APP_TAS_TITLE", $appdelcrAppTasTitle); $CriteriaCount->addAsColumn("APPDELCR_APP_TAS_TITLE", $appdelcrAppTasTitleCount); $Criteria->addAsColumn("USRCR_USR_UID", "USRCR.USR_UID"); $Criteria->addAsColumn("USRCR_USR_FIRSTNAME", "USRCR.USR_FIRSTNAME"); $Criteria->addAsColumn("USRCR_USR_LASTNAME", "USRCR.USR_LASTNAME"); $Criteria->addAsColumn("USRCR_USR_USERNAME", "USRCR.USR_USERNAME"); $CriteriaCount->addAsColumn("USRCR_USR_UID", "USRCR.USR_UID"); $CriteriaCount->addAsColumn("USRCR_USR_FIRSTNAME", "USRCR.USR_FIRSTNAME"); $CriteriaCount->addAsColumn("USRCR_USR_LASTNAME", "USRCR.USR_LASTNAME"); $CriteriaCount->addAsColumn("USRCR_USR_USERNAME", "USRCR.USR_USERNAME"); $Criteria->addAlias("APPDELCR", $appdelcrTableName); $Criteria->addAlias("USRCR", UsersPeer::TABLE_NAME); $CriteriaCount->addAlias("APPDELCR", $appdelcrTableName); $CriteriaCount->addAlias("USRCR", UsersPeer::TABLE_NAME); $arrayCondition = array(); $arrayCondition[] = array(AppCacheViewPeer::APP_UID, "APPDELCR.APP_UID"); $arrayCondition[] = array("APPDELCR.DEL_LAST_INDEX", 1); $Criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN); $CriteriaCount->addJoinMC($arrayCondition, Criteria::LEFT_JOIN); $arrayCondition = array(); $arrayCondition[] = array("APPDELCR.USR_UID", "USRCR.USR_UID"); $Criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN); $CriteriaCount->addJoinMC($arrayCondition, Criteria::LEFT_JOIN); //Previous user 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' ); $Criteria->addAsColumn( 'PREVIOUS_USR_LASTNAME', 'PU.USR_LASTNAME' ); $Criteria->addAsColumn( 'PREVIOUS_USR_USERNAME', 'PU.USR_USERNAME' ); $CriteriaCount->addAlias( 'PU', 'USERS' ); $CriteriaCount->addJoin( AppCacheViewPeer::PREVIOUS_USR_UID, 'PU.USR_UID', Criteria::LEFT_JOIN ); $CriteriaCount->addAsColumn( 'PREVIOUS_USR_FIRSTNAME', 'PU.USR_FIRSTNAME' ); $CriteriaCount->addAsColumn( 'PREVIOUS_USR_LASTNAME', 'PU.USR_LASTNAME' ); $CriteriaCount->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 (!empty($process)) { $Criteria->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL); $CriteriaCount->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL); } //Add the category filter if (!empty($category)) { require_once 'classes/model/Process.php'; $Criteria->addAlias("CP", "PROCESS"); $Criteria->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL); $Criteria->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN); $Criteria->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY"); $CriteriaCount->addAlias("CP", "PROCESS"); $CriteriaCount->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL); $CriteriaCount->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN); $CriteriaCount->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY"); } // 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 != "") { if ($dateFrom == $dateTo) { $dateSame = $dateFrom; $dateFrom = $dateSame . " 00:00:00"; $dateTo = $dateSame . " 23:59:59"; } else { $dateFrom = $dateFrom . " 00:00:00"; $dateTo = $dateTo . " 23:59:59"; } $Criteria->add( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL ) ) ); $CriteriaCount->add( $CriteriaCount->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL ) ) ); } else { $dateFrom = $dateFrom . " 00:00:00"; $Criteria->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL ); $CriteriaCount->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL ); } } elseif ($dateTo != "") { $dateTo = $dateTo . " 23:59:59"; $Criteria->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL ); $CriteriaCount->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL ); } //add the filter if ($filter != '') { switch ($filter) { case 'read': $Criteria->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL ); $CriteriaCount->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL ); break; case 'unread': $Criteria->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL ); $CriteriaCount->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL ); break; case 'started': $Criteria->add( AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL ); $CriteriaCount->add( AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL ); break; case 'completed': $Criteria->add( AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL ); $CriteriaCount->add( AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL ); break; } } //Add the search filter if ($search != '') { $oTmpCriteria = ''; //If there is PMTable for this case list if (is_array($oAppCache->confCasesList) && count($oAppCache->confCasesList) > 0 && isset($oAppCache->confCasesList["PMTable"]) && trim($oAppCache->confCasesList["PMTable"]) != "") { //Default configuration fields array $defaultFields = $oAppCache->getDefaultFields(); //Getting the table name $additionalTableUid = $oAppCache->confCasesList["PMTable"]; $additionalTable = AdditionalTablesPeer::retrieveByPK($additionalTableUid); $tableName = $additionalTable->getAddTabName(); $additionalTable = new AdditionalTables(); $tableData = $additionalTable->load($additionalTableUid, true); $tableField = array(); foreach ($tableData["FIELDS"] as $arrayField) { $tableField[] = $arrayField["FLD_NAME"]; } $oNewCriteria = new Criteria("workflow"); $sw = 0; foreach ($oAppCache->confCasesList["second"]["data"] as $fieldData) { if (!in_array($fieldData["name"], $defaultFields)) { if (in_array($fieldData["name"], $tableField)) { $fieldName = $tableName . "." . $fieldData["name"]; if ($sw == 0) { $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, "%" . $search . "%", Criteria::LIKE); } else { $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, "%" . $search . "%", Criteria::LIKE)->addOr($oTmpCriteria); } $sw = 1; } } } //add the default and hidden DEL_INIT_DATE } // the criteria adds new fields if there are defined PM Table Fields in the cases list if ($oTmpCriteria != '') { $Criteria->add( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE )->addOr( $oTmpCriteria ) ) ) ); } else { $Criteria->add( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE ) ) ) ); } // the count query needs to be the normal criteria query if there are defined PM Table Fields in the cases list if ($oTmpCriteria != '') { $CriteriaCount = $Criteria; } else { $CriteriaCount->add( $CriteriaCount->getNewCriterion( AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $CriteriaCount->getNewCriterion( AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $CriteriaCount->getNewCriterion( AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE ) ) ) ); } } // 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 = $paged; //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; } if ($category != '') { $totalCount = $oAppCache->getSearchCountCriteria(); $doCountAlreadyExecuted = true; } */ $tableNameAux = ''; $totalCount = 0; if ($doCountAlreadyExecuted == true) { // in the case of reassign the distinct attribute shows a diferent count result comparing to the // original list //Check also $distinct in the method getListCounters(), this in AppCacheView.php $distinct = true; if ($action != "sent" && (($action == "todo" || $action == "selfservice" || $action == "unassigned" || $action == "to_reassign" || $action == "to_revise") || ($status == "TO_DO"))) { $distinct = false; } // first check if there is a PMTable defined within the list, // the issue that brokes the normal criteria query seems to be fixed if (isset( $oAppCache->confCasesList['PMTable'] ) && ! empty( $oAppCache->confCasesList['PMTable'] )) { // then $oAdditionalTables = AdditionalTablesPeer::retrieveByPK( $oAppCache->confCasesList['PMTable'] ); $tableName = $oAdditionalTables->getAddTabName(); $tableNameAux = $tableName; $tableName = strtolower( $tableName ); $tableNameArray = explode( '_', $tableName ); foreach ($tableNameArray as $item) { $newTableName[] = ucfirst( $item ); } $tableName = implode( '', $newTableName ); // so the pm table class can be invoqued from the pm table model clases if (! class_exists( $tableName )) { require_once (PATH_DB . SYS_SYS . PATH_SEP . "classes" . PATH_SEP . $tableName . ".php"); } } $totalCount = AppCacheViewPeer::doCount($CriteriaCount, $distinct); } //Add sortable options $sortBk = $sort; if ($sortBk != "") { $sort = ""; //Current delegation (*) if (($action == "sent" || $action == "search" || $action == "simple_search" || $action == "to_revise" || $action == "to_reassign") && ($status != "TO_DO")) { switch ($sortBk) { case "APP_CACHE_VIEW.APP_CURRENT_USER": $sort = "USRCR_" . $conf->userNameFormatGetFirstFieldByUsersTable(); break; case "APP_CACHE_VIEW.APP_TAS_TITLE": $sort = "APPDELCR_APP_TAS_TITLE"; break; } } if (isset( $oAppCache->confCasesList['PMTable'] ) && ! empty( $oAppCache->confCasesList['PMTable'] ) && $tableNameAux != '') { $sortTable = explode(".", $sortBk); $additionalTableUid = $oAppCache->confCasesList["PMTable"]; require_once 'classes/model/Fields.php'; $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(FieldsPeer::FLD_UID); $oCriteria->addSelectColumn(FieldsPeer::FLD_INDEX); $oCriteria->addSelectColumn(FieldsPeer::FLD_NAME); $oCriteria->addSelectColumn(FieldsPeer::FLD_DESCRIPTION); $oCriteria->addSelectColumn(FieldsPeer::FLD_TYPE); $oCriteria->addSelectColumn(FieldsPeer::FLD_SIZE); $oCriteria->addSelectColumn(FieldsPeer::FLD_NULL); $oCriteria->addSelectColumn(FieldsPeer::FLD_AUTO_INCREMENT); $oCriteria->addSelectColumn(FieldsPeer::FLD_KEY); $oCriteria->addSelectColumn(FieldsPeer::FLD_FOREIGN_KEY); $oCriteria->addSelectColumn(FieldsPeer::FLD_FOREIGN_KEY_TABLE); $oCriteria->addSelectColumn(FieldsPeer::FLD_DYN_NAME); $oCriteria->addSelectColumn(FieldsPeer::FLD_DYN_UID); $oCriteria->addSelectColumn(FieldsPeer::FLD_FILTER); $oCriteria->add(FieldsPeer::ADD_TAB_UID, $additionalTableUid); $oCriteria->add(FieldsPeer::FLD_NAME, $sortTable[1]); $oCriteria->addAscendingOrderByColumn(FieldsPeer::FLD_INDEX); $oDataset = FieldsPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $row = $oDataset->getRow(); if (is_array($row)) { $sort = $tableNameAux . "." . $sortTable[1]; } } if ($sort == "") { $sort = $sortBk; } if (!in_array($sort, $Criteria->getSelectColumns())) { $sort = AppCacheViewPeer::APP_NUMBER; //DEFAULT VALUE } if ($dir == "DESC") { $Criteria->addDescendingOrderByColumn($sort); } else { $Criteria->addAscendingOrderByColumn($sort); } } //limit the results according the interface $Criteria->setLimit( $limit ); $Criteria->setOffset( $start ); //execute the query $oDataset = AppCacheViewPeer::doSelectRS( $Criteria, Propel::getDbConnection('workflow_ro') ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $result = array (); $result['totalCount'] = $totalCount; $rows = array (); $aPriorities = array ('1' => 'VL','2' => 'L','3' => 'N','4' => 'H','5' => 'VH'); $index = $start; while ($oDataset->next()) { $aRow = $oDataset->getRow(); //$aRow = $oAppCache->replaceRowUserData($aRow); /* * For participated cases, we want the last step in the case, not only the last step this user participated. To do that we get every case information again for the last step. (This could be solved by a subquery, but Propel might not support it and subqueries can be slower for larger * datasets). */ /*if ($action == 'sent' || $action == 'search') { $maxCriteria = new Criteria('workflow'); $maxCriteria->add(AppCacheViewPeer::APP_UID, $aRow['APP_UID'], Criteria::EQUAL); $maxCriteria->addDescendingOrderByColumn(AppCacheViewPeer::DEL_INDEX); $maxCriteria->setLimit(1); $maxDataset = AppCacheViewPeer::doSelectRS( $maxCriteria ); $maxDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $maxDataset->next(); $newData = $maxDataset->getRow(); foreach ($aRow as $col => $value) { if (array_key_exists($col, $newData)) $aRow[$col] = $newData[$col]; } $maxDataset->close(); }*/ //Current delegation (*) || $action == "search" || $action == "to_revise" if (($action == "sent" || $action == "simple_search" || $action == "to_reassign") && ($status != "TO_DO")) { //Current task $aRow["APP_TAS_TITLE"] = $aRow["APPDELCR_APP_TAS_TITLE"]; //Current user //if ($action != "to_reassign" ) { if (($action != "to_reassign") && ($action != "search") && ($action != "to revise")) { $aRow["USR_UID"] = $aRow["USRCR_USR_UID"]; $aRow["USR_FIRSTNAME"] = $aRow["USRCR_USR_FIRSTNAME"]; $aRow["USR_LASTNAME"] = $aRow["USRCR_USR_LASTNAME"]; $aRow["USR_USERNAME"] = $aRow["USRCR_USR_USERNAME"]; } } //Unassigned user if (! isset( $aRow['APP_CURRENT_USER'] )) { $aRow['APP_CURRENT_USER'] = "******" . strtoupper(G::LoadTranslation("ID_UNASSIGNED")) . "]"; } // replacing the status data with their respective translation if (isset( $aRow['APP_STATUS'] )) { $aRow['APP_STATUS_LABEL'] = G::LoadTranslation( "ID_{$aRow['APP_STATUS']}" ); } // replacing the priority data with their respective translation if (isset( $aRow['DEL_PRIORITY'] )) { $aRow['DEL_PRIORITY'] = G::LoadTranslation( "ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}" ); } $rows[] = $aRow; } $result['data'] = $rows; return $result; }
/** * @param $action * @param $categoryUid * @param $userUid * @return array * @throws \PropelException */ public function getProcessList ($action, $categoryUid, $userUid) { //$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : null; //$categoryUid = isset( $_REQUEST['CATEGORY_UID'] ) ? $_REQUEST['CATEGORY_UID'] : null; //$userUid = (isset( $_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '') ? $_SESSION['USER_LOGGED'] : null; // global $oAppCache; $oAppCache = new \AppCacheView(); $processes = array (); $processes[] = array ('',G::LoadTranslation( 'ID_ALL_PROCESS' )); //get the list based in the action provided switch ($action) { case 'draft': $cProcess = $oAppCache->getDraftListCriteria( $userUid ); //fast enough break; case 'sent': $cProcess = $oAppCache->getSentListProcessCriteria( $userUid ); // fast enough break; case 'simple_search': case 'search': //in search action, the query to obtain all process is too slow, so we need to query directly to //process and content tables, and for that reason we need the current language in AppCacheView. G::loadClass( 'configuration' ); $oConf = new \Configurations(); $oConf->loadConfig( $x, 'APP_CACHE_VIEW_ENGINE', '', '', '', '' ); $appCacheViewEngine = $oConf->aConfig; $lang = isset( $appCacheViewEngine['LANG'] ) ? $appCacheViewEngine['LANG'] : 'en'; $cProcess = new Criteria( 'workflow' ); $cProcess->clearSelectColumns(); $cProcess->addSelectColumn( \ProcessPeer::PRO_UID ); $cProcess->addSelectColumn( \ContentPeer::CON_VALUE ); if ($categoryUid) { $cProcess->add( \ProcessPeer::PRO_CATEGORY, $categoryUid ); } $del = DBAdapter::getStringDelimiter(); $conds = array (); $conds[] = array (ProcessPeer::PRO_UID,ContentPeer::CON_ID); $conds[] = array (ContentPeer::CON_CATEGORY,$del . 'PRO_TITLE' . $del); $conds[] = array (ContentPeer::CON_LANG,$del . $lang . $del); $cProcess->addJoinMC( $conds, Criteria::LEFT_JOIN ); $cProcess->add( ProcessPeer::PRO_STATUS, 'ACTIVE' ); $cProcess->addAscendingOrderByColumn(ContentPeer::CON_VALUE); $oDataset = ProcessPeer::doSelectRS( $cProcess ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array ($aRow['PRO_UID'],$aRow['CON_VALUE'] ); $oDataset->next(); } return print G::json_encode( $processes ); break; case 'unassigned': $cProcess = $oAppCache->getUnassignedListCriteria( $userUid ); break; case 'paused': $cProcess = $oAppCache->getPausedListCriteria( $userUid ); break; case 'to_revise': $cProcess = $oAppCache->getToReviseListCriteria( $userUid ); break; case 'to_reassign': $cProcess = $oAppCache->getToReassignListCriteria($userUid); break; case 'gral': $cProcess = $oAppCache->getGeneralListCriteria(); break; case 'todo': default: $cProcess = $oAppCache->getToDoListCriteria( $userUid ); //fast enough break; } //get the processes for this user in this action $cProcess->clearSelectColumns(); $cProcess->addSelectColumn( \AppCacheViewPeer::PRO_UID ); $cProcess->addSelectColumn( \AppCacheViewPeer::APP_PRO_TITLE ); $cProcess->setDistinct( \AppCacheViewPeer::PRO_UID ); if ($categoryUid) { require_once 'classes/model/Process.php'; $cProcess->addAlias( 'CP', 'PROCESS' ); $cProcess->add( 'CP.PRO_CATEGORY', $categoryUid, Criteria::EQUAL ); $cProcess->addJoin( \AppCacheViewPeer::PRO_UID, 'CP.PRO_UID', Criteria::LEFT_JOIN ); $cProcess->addAsColumn( 'CATEGORY_UID', 'CP.PRO_CATEGORY' ); } $cProcess->addAscendingOrderByColumn(\AppCacheViewPeer::APP_PRO_TITLE); $oDataset = \AppCacheViewPeer::doSelectRS( $cProcess, \Propel::getDbConnection('workflow_ro') ); $oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array ($aRow['PRO_UID'],$aRow['APP_PRO_TITLE'] ); $oDataset->next(); } return $processes; }
public function update($fields) { require_once "classes/model/AppCacheView.php"; require_once "classes/model/Configuration.php"; $con = Propel::getConnection(TaskPeer::DATABASE_NAME); try { $con->begin(); $this->load($fields["TAS_UID"]); $this->fromArray($fields, BasePeer::TYPE_FIELDNAME); if ($this->validate()) { $taskDefTitlePrevious = null; $criteria = new Criteria("workflow"); $criteria->addSelectColumn(ContentPeer::CON_VALUE); $criteria->add(ContentPeer::CON_CATEGORY, "TAS_DEF_TITLE"); $criteria->add(ContentPeer::CON_ID, $fields["TAS_UID"]); $criteria->add(ContentPeer::CON_LANG, SYS_LANG); $rsCriteria = ContentPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $taskDefTitlePrevious = $row["CON_VALUE"]; } $contentResult = 0; if (array_key_exists("TAS_TITLE", $fields)) { $contentResult += $this->setTasTitle($fields["TAS_TITLE"]); } if (array_key_exists("TAS_DESCRIPTION", $fields)) { $contentResult += $this->setTasDescription($fields["TAS_DESCRIPTION"]); } if (array_key_exists("TAS_DEF_TITLE", $fields)) { $contentResult += $this->setTasDefTitle($fields["TAS_DEF_TITLE"]); } if (array_key_exists("TAS_DEF_DESCRIPTION", $fields)) { $contentResult += $this->setTasDefDescription($fields["TAS_DEF_DESCRIPTION"]); } if (array_key_exists("TAS_DEF_PROC_CODE", $fields)) { $contentResult += $this->setTasDefProcCode($fields["TAS_DEF_PROC_CODE"]); } if (array_key_exists("TAS_DEF_MESSAGE", $fields)) { $contentResult += $this->setTasDefMessage(trim($fields["TAS_DEF_MESSAGE"])); } if (array_key_exists("TAS_DEF_SUBJECT_MESSAGE", $fields)) { $contentResult += $this->setTasDefSubjectMessage(trim($fields["TAS_DEF_SUBJECT_MESSAGE"])); } if (array_key_exists("TAS_CALENDAR", $fields)) { $contentResult += $this->setTasCalendar($fields['TAS_UID'], $fields["TAS_CALENDAR"]); } $result = $this->save(); $result = $result == 0 ? $contentResult > 0 ? 1 : 0 : $result; $con->commit(); if ($result == 1 && array_key_exists("TAS_DEF_TITLE", $fields) && $fields["TAS_DEF_TITLE"] != $taskDefTitlePrevious) { $criteria = new Criteria("workflow"); $criteria->addAsColumn("APPCV_NUM_ROWS", "COUNT(DISTINCT " . AppCacheViewPeer::APP_UID . ")"); $criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN"); $criteria->add(AppCacheViewPeer::TAS_UID, $fields["TAS_UID"]); $rsCriteria = AppCacheViewPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rsCriteria->next(); $row = $rsCriteria->getRow(); $appcvNumRows = intval($row["APPCV_NUM_ROWS"]); if ($appcvNumRows <= 1000) { $appcv = new AppCacheView(); $appcv->appTitleByTaskCaseLabelUpdate($fields["TAS_UID"], SYS_LANG); $result = 2; } else { //Delete record $criteria = new Criteria("workflow"); $criteria->add(ConfigurationPeer::CFG_UID, "TAS_APP_TITLE_UPDATE"); $criteria->add(ConfigurationPeer::OBJ_UID, $fields["TAS_UID"]); $criteria->add(ConfigurationPeer::CFG_VALUE, SYS_LANG); $numRowDeleted = ConfigurationPeer::doDelete($criteria); //Insert record $conf = new Configuration(); $conf->create(array("CFG_UID" => "TAS_APP_TITLE_UPDATE", "OBJ_UID" => $fields["TAS_UID"], "CFG_VALUE" => SYS_LANG, "PRO_UID" => "", "USR_UID" => "", "APP_UID" => "")); $result = 3; } } return $result; } else { $con->rollback(); throw new Exception("Failed Validation in class " . get_class($this) . "."); } } catch (Exception $e) { $con->rollback(); throw $e; } }
break; } //get the processes for this user in this action $cProcess->clearSelectColumns(); $cProcess->addSelectColumn(AppCacheViewPeer::PRO_UID); $cProcess->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE); $cProcess->setDistinct(AppCacheViewPeer::PRO_UID); if ($categoryUid) { require_once 'classes/model/Process.php'; $cProcess->addAlias('CP', 'PROCESS'); $cProcess->add('CP.PRO_CATEGORY', $categoryUid, Criteria::EQUAL); $cProcess->addJoin(AppCacheViewPeer::PRO_UID, 'CP.PRO_UID', Criteria::LEFT_JOIN); $cProcess->addAsColumn('CATEGORY_UID', 'CP.PRO_CATEGORY'); } $cProcess->addAscendingOrderByColumn(AppCacheViewPeer::APP_PRO_TITLE); $oDataset = AppCacheViewPeer::doSelectRS($cProcess, Propel::getDbConnection('workflow_ro')); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array($aRow['PRO_UID'], $aRow['APP_PRO_TITLE']); $oDataset->next(); } return print G::json_encode($processes); } if ($actionAjax == "getUsersToReassign") { $_SESSION['TASK'] = $_REQUEST['TAS_UID']; $case = new Cases(); G::LoadClass('tasks'); $task = new Task(); $tasks = $task->load($_SESSION['TASK']); $result = new stdclass();
/** * Get list for Cases * * @access public * @param array $dataList, Data for list * @return array * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia */ public function getList($dataList = array()) { Validator::isArray($dataList, '$dataList'); if (!isset($dataList["userId"])) { throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('userId','')))); } else { Validator::usrUid($dataList["userId"], "userId"); } $user = new \ProcessMaker\BusinessModel\User(); if (!$user->checkPermission($dataList["userId"], "PM_ALLCASES")) { throw new \Exception(\G::LoadTranslation("ID_CASE_USER_NOT_HAVE_PERMISSION", array($dataList["userId"]))); } G::LoadClass("applications"); $solrEnabled = false; $userUid = $dataList["userId"]; $callback = isset( $dataList["callback"] ) ? $dataList["callback"] : "stcCallback1001"; $dir = isset( $dataList["dir"] ) ? $dataList["dir"] : "DESC"; $sort = isset( $dataList["sort"] ) ? $dataList["sort"] : "APP_CACHE_VIEW.APP_NUMBER"; $start = isset( $dataList["start"] ) ? $dataList["start"] : "0"; $limit = isset( $dataList["limit"] ) ? $dataList["limit"] : ""; $filter = isset( $dataList["filter"] ) ? $dataList["filter"] : ""; $process = isset( $dataList["process"] ) ? $dataList["process"] : ""; $category = isset( $dataList["category"] ) ? $dataList["category"] : ""; $status = isset( $dataList["status"] ) ? strtoupper( $dataList["status"] ) : ""; $user = isset( $dataList["user"] ) ? $dataList["user"] : ""; $search = isset( $dataList["search"] ) ? $dataList["search"] : ""; $action = isset( $dataList["action"] ) ? $dataList["action"] : "todo"; $paged = isset( $dataList["paged"] ) ? $dataList["paged"] : true; $type = "extjs"; $dateFrom = (!empty( $dataList["dateFrom"] )) ? substr( $dataList["dateFrom"], 0, 10 ) : ""; $dateTo = (!empty( $dataList["dateTo"] )) ? substr( $dataList["dateTo"], 0, 10 ) : ""; $first = isset( $dataList["first"] ) ? true :false; $valuesCorrect = array('todo', 'draft', 'paused', 'sent', 'selfservice', 'unassigned', 'search'); if (!in_array($action, $valuesCorrect)) { throw (new \Exception(\G::LoadTranslation("ID_INCORRECT_VALUE_ACTION"))); } $start = (int)$start; $start = abs($start); if ($start != 0) { $start--; } $limit = (int)$limit; $limit = abs($limit); if ($limit == 0) { G::LoadClass("configuration"); $conf = new \Configurations(); $generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', ''); if (isset($generalConfCasesList['casesListRowNumber'])) { $limit = (int)$generalConfCasesList['casesListRowNumber']; } else { $limit = 25; } } else { $limit = (int)$limit; } if ($sort != 'APP_CACHE_VIEW.APP_NUMBER') { $sort = G::toUpper($sort); $columnsAppCacheView = \AppCacheViewPeer::getFieldNames(\BasePeer::TYPE_FIELDNAME); if (!(in_array($sort, $columnsAppCacheView))) { $sort = 'APP_CACHE_VIEW.APP_NUMBER'; } } $dir = G::toUpper($dir); if (!($dir == 'DESC' || $dir == 'ASC')) { $dir = 'DESC'; } if ($process != '') { Validator::proUid($process, '$pro_uid'); } if ($category != '') { Validator::catUid($category, '$cat_uid'); } $status = G::toUpper($status); $listStatus = array('TO_DO', 'DRAFT', 'COMPLETED', 'CANCEL', 'OPEN', 'CLOSE'); if (!(in_array($status, $listStatus))) { $status = ''; } if ($user != '') { Validator::usrUid($user, '$usr_uid'); } if ($dateFrom != '') { Validator::isDate($dateFrom, 'Y-m-d', '$date_from'); } if ($dateTo != '') { Validator::isDate($dateTo, 'Y-m-d', '$date_to'); } if ($action == 'search' || $action == 'to_reassign') { $userUid = ($user == "CURRENT_USER") ? $userUid : $user; if ($first) { $result = array(); $result['totalCount'] = 0; $result['data'] = array(); return $result; } } if (( $action == "todo" || $action == "draft" || $action == "paused" || $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"] ); if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) { //Check if there are missing records to reindex and reindex them $ApplicationSolrIndex->synchronizePendingApplications(); $solrEnabled = true; } } if ($solrEnabled) { $result = $ApplicationSolrIndex->getAppGridData( $userUid, $start, $limit, $action, $filter, $search, $process, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort, $category ); } else { G::LoadClass("applications"); $apps = new \Applications(); $result = $apps->getAll( $userUid, $start, $limit, $action, $filter, $search, $process, $status, $type, $dateFrom, $dateTo, $callback, $dir, (strpos($sort, ".") !== false)? $sort : "APP_CACHE_VIEW." . $sort, $category, true, $paged ); } if (!empty($result['data'])) { foreach ($result['data'] as &$value) { $value = array_change_key_case($value, CASE_LOWER); } } if ($paged == false) { $response = $result['data']; } else { $response['total'] = $result['totalCount']; $response['start'] = $start+1; $response['limit'] = $limit; $response['sort'] = G::toLower($sort); $response['dir'] = G::toLower($dir); $response['cat_uid'] = $category; $response['pro_uid'] = $process; $response['search'] = $search; if ($action == 'search') { $response['app_status'] = G::toLower($status); $response['usr_uid'] = $user; $response['date_from'] = $dateFrom; $response['date_to'] = $dateTo; } $response['data'] = $result['data']; } return $response; }
/** * This function checks if List tables are going to migrated * * return boolean value */ public function listFirstExecution ($action){ $this->initPropel(true); switch ($action) { case 'insert': $conf = new Configuration(); if (!($conf->exists('MIGRATED_LIST', 'list', 'list', 'list', 'list'))) { $data["CFG_UID"] ='MIGRATED_LIST'; $data["OBJ_UID"] ='list'; $data["CFG_VALUE"]='true'; $data["PRO_UID"] ='list'; $data["USR_UID"] ='list'; $data["APP_UID"] ='list'; $conf->create($data); } return true; break; case 'check': $criteria = new Criteria("workflow"); $criteria->addSelectColumn(ConfigurationPeer::CFG_UID); $criteria->add(ConfigurationPeer::CFG_UID, "MIGRATED_LIST", CRITERIA::EQUAL); $rsCriteria = AppCacheViewPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $aRows = array (); while ($rsCriteria->next()) { $aRows[] = $rsCriteria->getRow(); } if(empty($aRows)){ return false; //If is false continue with the migrated } else { return true; //Stop } break; default: return true; } }
$Criteria->add(AppCacheViewPeer::USR_UID, $sUIDUserLogged); //$totalCount = AppCacheViewPeer::doCount( $Criteria ); if (isset($limit)) { $Criteria->setLimit($limit); } if (isset($start)) { $Criteria->setOffset($start); } if ($sort != '') { if ($dir == 'DESC') { $Criteria->addDescendingOrderByColumn($sort); } else { $Criteria->addAscendingOrderByColumn($sort); } } $oDataset = AppCacheViewPeer::doSelectRS($Criteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $result = array(); $rows = array(); $index = isset($start) ? $start : 0; while ($aRow = $oDataset->getRow()) { $aRow['index'] = ++$index; $rows[] = $aRow; $oDataset->next(); } $result['totalCount'] = count($rows); $result['data'] = $rows; print G::json_encode($result); } catch (Exception $e) { $G_PUBLISH = new Publisher();
public function appTitleByTaskCaseLabelUpdate($taskUid, $lang, $cron = 0) { $taskDefTitle = null; $criteria = new Criteria("workflow"); $criteria->addSelectColumn(ContentPeer::CON_VALUE); $criteria->add(ContentPeer::CON_CATEGORY, "TAS_DEF_TITLE"); $criteria->add(ContentPeer::CON_ID, $taskUid); $criteria->add(ContentPeer::CON_LANG, $lang); $rsCriteria = ContentPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $taskDefTitle = $row["CON_VALUE"]; } //Get cases $criteriaAPPCV = new Criteria("workflow"); $criteriaAPPCV->setDistinct(); $criteriaAPPCV->addSelectColumn(AppCacheViewPeer::APP_UID); $criteriaAPPCV->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN"); $criteriaAPPCV->add(AppCacheViewPeer::TAS_UID, $taskUid); $rsCriteriaAPPCV = AppCacheViewPeer::doSelectRS($criteriaAPPCV); $rsCriteriaAPPCV->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($rsCriteriaAPPCV->next()) { if ($cron == 1) { $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron"))); $arrayCron["processcTimeStart"] = time(); @file_put_contents(PATH_DATA . "cron", serialize($arrayCron)); } $row = $rsCriteriaAPPCV->getRow(); $appcvAppUid = $row["APP_UID"]; //Current task? $criteria = new Criteria("workflow"); $criteria->addSelectColumn(AppCacheViewPeer::APP_UID); $criteria->add(AppCacheViewPeer::APP_UID, $appcvAppUid); $criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN"); $criteria->add(AppCacheViewPeer::TAS_UID, $taskUid); $rsCriteria = AppCacheViewPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); if ($rsCriteria->next()) { $appTitle = $taskDefTitle; $app = new Application(); $arrayAppField = $app->Load($appcvAppUid); $appTitle = !empty($appTitle) ? $appTitle : "#" . $arrayAppField["APP_NUMBER"]; $appTitleNew = G::replaceDataField($appTitle, unserialize($arrayAppField["APP_DATA"])); if (isset($arrayAppField["APP_TITLE"]) && $arrayAppField["APP_TITLE"] != $appTitleNew) { //Updating the value in content, where... $criteria1 = new Criteria("workflow"); $criteria1->add(ContentPeer::CON_CATEGORY, "APP_TITLE"); $criteria1->add(ContentPeer::CON_ID, $appcvAppUid); $criteria1->add(ContentPeer::CON_LANG, $lang); //Update set $criteria2 = new Criteria("workflow"); $criteria2->add(ContentPeer::CON_VALUE, $appTitleNew); BasePeer::doUpdate($criteria1, $criteria2, Propel::getConnection("workflow")); } } } }
function executeCaseSelfService() { try { global $sFilter; if ($sFilter != "" && strpos($sFilter, "unassigned-case") === false) { return false; } $criteria = new Criteria("workflow"); //SELECT $criteria->addSelectColumn(AppCacheViewPeer::APP_UID); $criteria->addSelectColumn(AppCacheViewPeer::DEL_INDEX); $criteria->addSelectColumn(AppCacheViewPeer::DEL_DELEGATE_DATE); $criteria->addSelectColumn(AppCacheViewPeer::APP_NUMBER); $criteria->addSelectColumn(AppCacheViewPeer::PRO_UID); $criteria->addSelectColumn(TaskPeer::TAS_UID); $criteria->addSelectColumn(TaskPeer::TAS_SELFSERVICE_TIME); $criteria->addSelectColumn(TaskPeer::TAS_SELFSERVICE_TIME_UNIT); $criteria->addSelectColumn(TaskPeer::TAS_SELFSERVICE_TRIGGER_UID); //FROM $condition = array(); $condition[] = array(AppCacheViewPeer::TAS_UID, TaskPeer::TAS_UID); $condition[] = array(TaskPeer::TAS_SELFSERVICE_TIMEOUT, 1); $criteria->addJoinMC($condition, Criteria::LEFT_JOIN); //WHERE $criteria->add(AppCacheViewPeer::USR_UID, ""); $criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN"); //QUERY $rsCriteria = AppCacheViewPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); setExecutionMessage("Unassigned case"); saveLog("unassignedCase", "action", "Unassigned case", "c"); $date = new dates(); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $appcacheAppUid = $row["APP_UID"]; $appcacheDelIndex = $row["DEL_INDEX"]; $appcacheDelDelegateDate = $row["DEL_DELEGATE_DATE"]; $appcacheAppNumber = $row["APP_NUMBER"]; $appcacheProUid = $row["PRO_UID"]; $taskUid = $row["TAS_UID"]; $taskSelfServiceTime = intval($row["TAS_SELFSERVICE_TIME"]); $taskSelfServiceTimeUnit = $row["TAS_SELFSERVICE_TIME_UNIT"]; $taskSelfServiceTriggerUid = $row["TAS_SELFSERVICE_TRIGGER_UID"]; $dueDate = $date->calculateDate($appcacheDelDelegateDate, $taskSelfServiceTime, $taskSelfServiceTimeUnit, 1); if (time() > $dueDate["DUE_DATE_SECONDS"]) { $sessProcess = null; $sessProcessSw = 0; //Load data $case = new Cases(); $appFields = $case->loadCase($appcacheAppUid); $appFields["APP_DATA"]["APPLICATION"] = $appcacheAppUid; if (isset($_SESSION["PROCESS"])) { $sessProcess = $_SESSION["PROCESS"]; $sessProcessSw = 1; } $_SESSION["PROCESS"] = $appFields["PRO_UID"]; //Execute trigger $criteriaTgr = new Criteria(); $criteriaTgr->add(TriggersPeer::TRI_UID, $taskSelfServiceTriggerUid); $rsCriteriaTgr = TriggersPeer::doSelectRS($criteriaTgr); $rsCriteriaTgr->setFetchmode(ResultSet::FETCHMODE_ASSOC); if ($rsCriteriaTgr->next()) { $row = $rsCriteriaTgr->getRow(); if (is_array($row) && $row["TRI_TYPE"] == "SCRIPT") { $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron"))); $arrayCron["processcTimeProcess"] = 60; //Minutes $arrayCron["processcTimeStart"] = time(); @file_put_contents(PATH_DATA . "cron", serialize($arrayCron)); //Trigger global $oPMScript; $oPMScript = new PMScript(); $oPMScript->setFields($appFields["APP_DATA"]); $oPMScript->setScript($row["TRI_WEBBOT"]); $oPMScript->execute(); $appFields["APP_DATA"] = array_merge($appFields["APP_DATA"], $oPMScript->aFields); $case->updateCase($appFields["APP_UID"], $appFields); saveLog("unassignedCase", "action", "OK Executed tigger to the case {$appcacheAppNumber}"); } } unset($_SESSION["PROCESS"]); if ($sessProcessSw == 1) { $_SESSION["PROCESS"] = $sessProcess; } } } setExecutionResultMessage("DONE"); } catch (Exception $e) { setExecutionResultMessage("WITH ERRORS", "error"); eprintln(" '-" . $e->getMessage(), "red"); saveLog("unassignedCase", "error", "Error in unassigned case: " . $e->getMessage()); } }
/** * Get unassigned case list * * @param string $userId * @return $result will return an object */ public function unassignedCaseList ($userId) { try { $result = array (); $oAppCache = new AppCacheView(); $Criteria = $oAppCache->getUnassignedListCriteria( $userId ); $oDataset = AppCacheViewPeer::doSelectRS( $Criteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $result[] = array ('guid' => $aRow['APP_UID'], 'name' => $aRow['APP_NUMBER'], 'delIndex' => $aRow['DEL_INDEX'], 'processId' => $aRow['PRO_UID']); $oDataset->next(); } return $result; } catch (Exception $e) { $result[] = array ('guid' => $e->getMessage(), 'name' => $e->getMessage(), 'status' => $e->getMessage(), 'status' => $e->getMessage(), 'processId' => $e->getMessage()); return $result; } }
/** * Retrieve object using using composite pkey values. * @param string $app_uid * @param int $del_index * @param Connection $con * @return AppCacheView */ public static function retrieveByPK($app_uid, $del_index, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $criteria = new Criteria(); $criteria->add(AppCacheViewPeer::APP_UID, $app_uid); $criteria->add(AppCacheViewPeer::DEL_INDEX, $del_index); $v = AppCacheViewPeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }
function getSimpleDashboardData() { G::LoadClass("BasePeer"); require_once "classes/model/AppCacheView.php"; require_once 'classes/model/Process.php'; $sUIDUserLogged = $_SESSION['USER_LOGGED']; $Criteria = new Criteria('workflow'); $Criteria->clearSelectColumns(); $Criteria->addSelectColumn(AppCacheViewPeer::PRO_UID); $Criteria->addSelectColumn(AppCacheViewPeer::APP_UID); $Criteria->addSelectColumn(AppCacheViewPeer::APP_NUMBER); $Criteria->addSelectColumn(AppCacheViewPeer::APP_STATUS); $Criteria->addSelectColumn(AppCacheViewPeer::DEL_INDEX); $Criteria->addSelectColumn(AppCacheViewPeer::APP_TITLE); $Criteria->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE); $Criteria->addSelectColumn(AppCacheViewPeer::APP_TAS_TITLE); $Criteria->addSelectColumn(AppCacheViewPeer::APP_DEL_PREVIOUS_USER); $Criteria->addSelectColumn(AppCacheViewPeer::DEL_TASK_DUE_DATE); $Criteria->addSelectColumn(AppCacheViewPeer::APP_UPDATE_DATE); $Criteria->addSelectColumn(AppCacheViewPeer::DEL_PRIORITY); $Criteria->addSelectColumn(AppCacheViewPeer::DEL_DELAYED); $Criteria->addSelectColumn(AppCacheViewPeer::USR_UID); $Criteria->addSelectColumn(AppCacheViewPeer::APP_THREAD_STATUS); $Criteria->add(AppCacheViewPeer::APP_STATUS, array("TO_DO", "DRAFT"), CRITERIA::IN); $Criteria->add(AppCacheViewPeer::USR_UID, array($sUIDUserLogged, ""), CRITERIA::IN); $Criteria->add(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); //$Criteria->add ( AppCacheViewPeer::APP_THREAD_STATUS, 'OPEN' ); $Criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, 'OPEN'); //execute the query $oDataset = AppCacheViewPeer::doSelectRS($Criteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $oProcess = new Process(); $rows = array(); $processNames = array(); while ($aRow = $oDataset->getRow()) { // G::pr($aRow); if (!isset($processNames[$aRow['PRO_UID']])) { $aProcess = $oProcess->load($aRow['PRO_UID']); $processNames[$aRow['PRO_UID']] = $aProcess['PRO_TITLE']; } if ($aRow['USR_UID'] == "") { $aRow['APP_STATUS'] = "UNASSIGNED"; } if (in_array($aRow['APP_STATUS'], array("TO_DO", "UNASSIGNED")) && $aRow['APP_THREAD_STATUS'] == "OPEN" || $aRow['APP_STATUS'] == "DRAFT") { $rows[$processNames[$aRow['PRO_UID']]][$aRow['APP_STATUS']][$aRow['DEL_DELAYED']][] = $aRow['APP_UID']; if (!isset($rows[$processNames[$aRow['PRO_UID']]][$aRow['APP_STATUS']]['count'])) { $rows[$processNames[$aRow['PRO_UID']]][$aRow['APP_STATUS']]['count'] = 0; } $rows[$processNames[$aRow['PRO_UID']]][$aRow['APP_STATUS']]['count']++; } $oDataset->next(); } //Generate different groups of data for graphs $rowsResponse = array(); $i = 0; foreach ($rows as $processID => $processInfo) { $i++; if ($i <= 10) { $rowsResponse['caseStatusByProcess'][] = array('process' => $processID, 'inbox' => isset($processInfo['TO_DO']['count']) ? $processInfo['TO_DO']['count'] : 0, 'draft' => isset($processInfo['DRAFT']['count']) ? $processInfo['DRAFT']['count'] : 0, 'unassigned' => isset($processInfo['UNASSIGNED']['count']) ? $processInfo['UNASSIGNED']['count'] : 0); } } $rowsResponse['caseDelayed'][] = array('delayed' => 'On Time', 'total' => 100); $rowsResponse['caseDelayed'][] = array('delayed' => 'Delayed', 'total' => 50); print_r(G::json_encode($rowsResponse)); }
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 : ""; G::LoadClass("BasePeer"); G::LoadClass("configuration"); //require_once ("classes/model/AppCacheView.php"); //require_once ("classes/model/AppDelegation.php"); //require_once ("classes/model/AdditionalTables.php"); //require_once ("classes/model/AppDelay.php"); //require_once ("classes/model/Fields.php"); //require_once ("classes/model/Users.php"); //require_once ("classes/model/Process.php"); $oAppCache = new AppCacheView(); //get data configuration $conf = new Configurations(); $confCasesList = $conf->getConfiguration('casesList', $action == 'search' || $action == 'simple_search' ? 'sent' : $action); $oAppCache->confCasesList = $confCasesList; // get the action based list switch ($action) { case "draft": $Criteria = $oAppCache->getDraftListCriteria($userUid); $CriteriaCount = $oAppCache->getDraftCountCriteria($userUid); break; 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": //$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); break; case "completed": $Criteria = $oAppCache->getCompletedListCriteria($userUid); $CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid); break; case "cancelled": $Criteria = $oAppCache->getCancelledListCriteria($userUid); $CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid); break; 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": $Criteria = $oAppCache->getSimpleSearchListCriteria(); $CriteriaCount = $oAppCache->getSimpleSearchCountCriteria(); break; case "to_revise": $Criteria = $oAppCache->getToReviseListCriteria($userUid); $CriteriaCount = $oAppCache->getToReviseCountCriteria($userUid); break; case "to_reassign": $Criteria = $oAppCache->getToReassignListCriteria($userUid); $CriteriaCount = $oAppCache->getToReassignCountCriteria($userUid); break; case "all": $Criteria = $oAppCache->getAllCasesListCriteria($userUid); $CriteriaCount = $oAppCache->getAllCasesCountCriteria($userUid); break; case "gral": //General criteria probably will be deprecated $Criteria = $oAppCache->getGeneralListCriteria(); $CriteriaCount = $oAppCache->getGeneralCountCriteria(); break; case "todo": $Criteria = $oAppCache->getToDoListCriteria($userUid); $CriteriaCount = $oAppCache->getToDoCountCriteria($userUid); break; default: //All status $Criteria = $oAppCache->getAllCasesListCriteria2($userUid); $CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid); break; } $Criteria->addAlias('CU', 'USERS'); $Criteria->addJoin(AppCacheViewPeer::USR_UID, 'CU.USR_UID', Criteria::LEFT_JOIN); $Criteria->addAsColumn('USR_UID', 'CU.USR_UID'); $Criteria->addAsColumn('USR_FIRSTNAME', 'CU.USR_FIRSTNAME'); $Criteria->addAsColumn('USR_LASTNAME', 'CU.USR_LASTNAME'); $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" || ($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'); $Criteria->addAsColumn('PREVIOUS_USR_LASTNAME', 'PU.USR_LASTNAME'); $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 (!empty($process)) { $Criteria->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL); $CriteriaCount->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL); } //Add the category filter if (!empty($category)) { $Criteria->addAlias("CP", "PROCESS"); $Criteria->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL); $Criteria->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN); $Criteria->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY"); $CriteriaCount->addAlias("CP", "PROCESS"); $CriteriaCount->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL); $CriteriaCount->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN); $CriteriaCount->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY"); } // 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 != '') { $Criteria->add($Criteria->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL)->addAnd($Criteria->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL))); $CriteriaCount->add($CriteriaCount->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL)->addAnd($Criteria->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL))); } else { $Criteria->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL); $CriteriaCount->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL); } } elseif ($dateTo != '') { $Criteria->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL); $CriteriaCount->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL); } //add the filter if ($filter != '') { switch ($filter) { case 'read': $Criteria->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL); $CriteriaCount->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL); break; case 'unread': $Criteria->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL); $CriteriaCount->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL); break; case 'started': $Criteria->add(AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL); $CriteriaCount->add(AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL); break; case 'completed': $Criteria->add(AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL); $CriteriaCount->add(AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL); break; } } //add the search filter if ($search != '') { $defaultFields = $oAppCache->getDefaultFields(); $oTmpCriteria = ''; // if there is PMTABLE for this case list: if (!empty($oAppCache->confCasesList) && isset($oAppCache->confCasesList['PMTable']) && trim($oAppCache->confCasesList['PMTable']) != '') { // getting the table name $oAdditionalTables = AdditionalTablesPeer::retrieveByPK($oAppCache->confCasesList['PMTable']); $tableName = $oAdditionalTables->getAddTabName(); $oNewCriteria = new Criteria('workflow'); $counter = 0; foreach ($oAppCache->confCasesList['second']['data'] as $fieldData) { if (!in_array($fieldData['name'], $defaultFields)) { $fieldName = $tableName . '.' . $fieldData['name']; if ($counter == 0) { $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, '%' . $search . '%', Criteria::LIKE); } else { $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, '%' . $search . '%', Criteria::LIKE)->addOr($oTmpCriteria); } $counter++; } } //add the default and hidden DEL_INIT_DATE } // the criteria adds new fields if there are defined PM Table Fields in the cases list if ($oTmpCriteria != '') { $Criteria->add($Criteria->getNewCriterion(AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE)->addOr($oTmpCriteria)))); } else { $Criteria->add($Criteria->getNewCriterion(AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE)))); } // the count query needs to be the normal criteria query if there are defined PM Table Fields in the cases list if ($oTmpCriteria != '') { $CriteriaCount = $Criteria; } else { $CriteriaCount->add($CriteriaCount->getNewCriterion(AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($CriteriaCount->getNewCriterion(AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($CriteriaCount->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE)))); } } // 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; } if ($category != '') { $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 //Check also $distinct in the method getListCounters(), this in AppCacheView.php $distinct = true; if ($action == "todo" || $action == "to_reassign" || $status == "TO_DO") { $distinct = false; } // first check if there is a PMTable defined within the list, // the issue that brokes the normal criteria query seems to be fixed if (isset($oAppCache->confCasesList['PMTable']) && !empty($oAppCache->confCasesList['PMTable'])) { // then $oAdditionalTables = AdditionalTablesPeer::retrieveByPK($oAppCache->confCasesList['PMTable']); $tableName = $oAdditionalTables->getAddTabName(); $tableName = strtolower($tableName); $tableNameArray = explode('_', $tableName); foreach ($tableNameArray as $item) { $newTableName[] = ucfirst($item); } $tableName = implode('', $newTableName); // so the pm table class can be invoqued from the pm table model clases if (!class_exists($tableName)) { require_once PATH_DB . SYS_SYS . PATH_SEP . "classes" . PATH_SEP . $tableName . ".php"; } } $totalCount = AppCacheViewPeer::doCount($CriteriaCount, $distinct); } //add sortable options if ($sort != '') { if ($dir == 'DESC') { $Criteria->addDescendingOrderByColumn($sort); } else { $Criteria->addAscendingOrderByColumn($sort); } } //limit the results according the interface $Criteria->setLimit($limit); $Criteria->setOffset($start); //execute the query $oDataset = AppCacheViewPeer::doSelectRS($Criteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $result = array(); $result['totalCount'] = $totalCount; $rows = array(); $aPriorities = array('1' => 'VL', '2' => 'L', '3' => 'N', '4' => 'H', '5' => 'VH'); $index = $start; while ($aRow = $oDataset->getRow()) { //$aRow = $oAppCache->replaceRowUserData($aRow); /* * For participated cases, we want the last step in the case, not only the last step this user participated. To do that we get every case information again for the last step. (This could be solved by a subquery, but Propel might not support it and subqueries can be slower for larger * datasets). */ /*if ($action == 'sent' || $action == 'search') { $maxCriteria = new Criteria('workflow'); $maxCriteria->add(AppCacheViewPeer::APP_UID, $aRow['APP_UID'], Criteria::EQUAL); $maxCriteria->addDescendingOrderByColumn(AppCacheViewPeer::DEL_INDEX); $maxCriteria->setLimit(1); $maxDataset = AppCacheViewPeer::doSelectRS( $maxCriteria ); $maxDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $maxDataset->next(); $newData = $maxDataset->getRow(); foreach ($aRow as $col => $value) { if (array_key_exists($col, $newData)) $aRow[$col] = $newData[$col]; } $maxDataset->close(); }*/ if (!isset($aRow['APP_CURRENT_USER'])) { $aRow['APP_CURRENT_USER'] = "******"; } // replacing the status data with their respective translation if (isset($aRow['APP_STATUS'])) { $aRow['APP_STATUS'] = G::LoadTranslation("ID_{$aRow['APP_STATUS']}"); } // replacing the priority data with their respective translation if (isset($aRow['DEL_PRIORITY'])) { $aRow['DEL_PRIORITY'] = G::LoadTranslation("ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}"); } $rows[] = $aRow; $oDataset->next(); } $result['data'] = $rows; return $result; }