* @copyright Colosa - Bolivia */ class Cases { /** * 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("The user with userId: '' does not exist.")); } else { Validator::usrUid($dataList["userId"], "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"] : "25"; $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"; $type = "extjs"; $dateFrom = isset( $dataList["dateFrom"] ) ? substr( $dataList["dateFrom"], 0, 10 ) : ""; $dateTo = isset( $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('The value for $action is incorrect.')); } 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 ); } if (!empty($result['data'])) { foreach ($result['data'] as &$value) { $value = array_change_key_case($value, CASE_LOWER); } } return $result; } }