2014-03-14 15:33:35 -04:00
|
|
|
<?php
|
|
|
|
|
namespace BusinessModel;
|
|
|
|
|
|
|
|
|
|
use \G;
|
|
|
|
|
use \UsersPeer;
|
|
|
|
|
use \CasesPeer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*/
|
|
|
|
|
class Cases
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Get list for Cases
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $dataList, Data for list
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*/
|
|
|
|
|
public function getList($dataList = array())
|
|
|
|
|
{
|
2014-03-17 15:13:34 -04:00
|
|
|
Validator::isArray($dataList, '$dataList');
|
|
|
|
|
if (!isset($dataList["userId"])) {
|
|
|
|
|
throw (new \Exception("The user with userId: '' does not exist."));
|
|
|
|
|
} else {
|
|
|
|
|
Validator::usrUid($dataList["userId"], "userId");
|
|
|
|
|
}
|
2014-03-14 15:33:35 -04:00
|
|
|
|
2014-03-17 15:13:34 -04:00
|
|
|
G::LoadClass("applications");
|
2014-03-14 15:33:35 -04:00
|
|
|
$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";
|
2014-03-24 10:52:36 -04:00
|
|
|
$paged = isset( $dataList["paged"] ) ? $dataList["paged"] : true;
|
2014-03-14 15:33:35 -04:00
|
|
|
$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;
|
|
|
|
|
|
2014-03-17 15:13:34 -04:00
|
|
|
$valuesCorrect = array('todo', 'draft', 'paused', 'sent', 'selfservice', 'unassigned', 'search');
|
|
|
|
|
if (!in_array($action, $valuesCorrect)) {
|
|
|
|
|
throw (new \Exception('The value for $action is incorrect.'));
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 15:33:35 -04:00
|
|
|
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,
|
2014-03-24 10:52:36 -04:00
|
|
|
$category,
|
|
|
|
|
true,
|
|
|
|
|
$paged
|
2014-03-14 15:33:35 -04:00
|
|
|
);
|
|
|
|
|
}
|
2014-03-17 09:17:14 -04:00
|
|
|
if (!empty($result['data'])) {
|
|
|
|
|
foreach ($result['data'] as &$value) {
|
|
|
|
|
$value = array_change_key_case($value, CASE_LOWER);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-24 10:52:36 -04:00
|
|
|
if ($paged == false) {
|
|
|
|
|
$result = $result['data'];
|
|
|
|
|
} else {
|
|
|
|
|
$result['total'] = $result['totalCount'];
|
|
|
|
|
unset($result['totalCount']);
|
|
|
|
|
|
|
|
|
|
$result['start'] = $start;
|
|
|
|
|
$result['limit'] = $limit;
|
|
|
|
|
$result['sort'] = $sort;
|
|
|
|
|
$result['category'] = $category;
|
|
|
|
|
$result['process'] = $process;
|
|
|
|
|
$result['search'] = $search;
|
|
|
|
|
}
|
2014-03-14 15:33:35 -04:00
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-17 15:24:14 -04:00
|
|
|
/**
|
|
|
|
|
* Get data of a Case
|
|
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $applicationUid Unique id of Case
|
2014-03-17 15:24:14 -04:00
|
|
|
* @param string $userUid Unique id of User
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with data of Case Info
|
|
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function getCaseInfo($applicationUid, $userUid)
|
2014-03-17 15:24:14 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$solrEnabled = 0;
|
|
|
|
|
if (($solrEnv = \System::solrEnv()) !== false) {
|
|
|
|
|
\G::LoadClass("AppSolr");
|
|
|
|
|
$appSolr = new \AppSolr(
|
|
|
|
|
$solrEnv["solr_enabled"],
|
|
|
|
|
$solrEnv["solr_host"],
|
|
|
|
|
$solrEnv["solr_instance"]
|
|
|
|
|
);
|
|
|
|
|
if ($appSolr->isSolrEnabled() && $solrEnv["solr_enabled"] == true) {
|
|
|
|
|
//Check if there are missing records to reindex and reindex them
|
|
|
|
|
$appSolr->synchronizePendingApplications();
|
|
|
|
|
$solrEnabled = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($solrEnabled == 1) {
|
|
|
|
|
try {
|
|
|
|
|
\G::LoadClass("searchIndex");
|
|
|
|
|
$arrayData = array();
|
|
|
|
|
$delegationIndexes = array();
|
|
|
|
|
$columsToInclude = array("APP_UID");
|
|
|
|
|
$solrSearchText = null;
|
|
|
|
|
//Todo
|
|
|
|
|
$solrSearchText = $solrSearchText . (($solrSearchText != null)? " OR " : null) . "(APP_STATUS:TO_DO AND APP_ASSIGNED_USERS:" . $userUid . ")";
|
|
|
|
|
$delegationIndexes[] = "APP_ASSIGNED_USER_DEL_INDEX_" . $userUid . "_txt";
|
|
|
|
|
//Draft
|
|
|
|
|
$solrSearchText = $solrSearchText . (($solrSearchText != null)? " OR " : null) . "(APP_STATUS:DRAFT AND APP_DRAFT_USER:" . $userUid . ")";
|
|
|
|
|
//Index is allways 1
|
|
|
|
|
$solrSearchText = "($solrSearchText)";
|
|
|
|
|
//Add del_index dynamic fields to list of resulting columns
|
|
|
|
|
$columsToIncludeFinal = array_merge($columsToInclude, $delegationIndexes);
|
|
|
|
|
$solrRequestData = \Entity_SolrRequestData::createForRequestPagination(
|
|
|
|
|
array(
|
|
|
|
|
"workspace" => $solrEnv["solr_instance"],
|
|
|
|
|
"startAfter" => 0,
|
|
|
|
|
"pageSize" => 1000,
|
|
|
|
|
"searchText" => $solrSearchText,
|
|
|
|
|
"numSortingCols" => 1,
|
|
|
|
|
"sortCols" => array("APP_NUMBER"),
|
|
|
|
|
"sortDir" => array(strtolower("DESC")),
|
|
|
|
|
"includeCols" => $columsToIncludeFinal,
|
|
|
|
|
"resultFormat" => "json"
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
//Use search index to return list of cases
|
|
|
|
|
$searchIndex = new \BpmnEngine_Services_SearchIndex($appSolr->isSolrEnabled(), $solrEnv["solr_host"]);
|
|
|
|
|
//Execute query
|
|
|
|
|
$solrQueryResult = $searchIndex->getDataTablePaginatedList($solrRequestData);
|
|
|
|
|
//Get the missing data from database
|
|
|
|
|
$arrayApplicationUid = array();
|
|
|
|
|
foreach ($solrQueryResult->aaData as $i => $data) {
|
|
|
|
|
$arrayApplicationUid[] = $data["APP_UID"];
|
|
|
|
|
}
|
|
|
|
|
$aaappsDBData = $appSolr->getListApplicationDelegationData($arrayApplicationUid);
|
|
|
|
|
foreach ($solrQueryResult->aaData as $i => $data) {
|
|
|
|
|
//Initialize array
|
|
|
|
|
$delIndexes = array(); //Store all the delegation indexes
|
|
|
|
|
//Complete empty values
|
|
|
|
|
$applicationUid = $data["APP_UID"]; //APP_UID
|
|
|
|
|
//Get all the indexes returned by Solr as columns
|
|
|
|
|
for($i = count($columsToInclude); $i <= count($data) - 1; $i++) {
|
|
|
|
|
if (is_array($data[$columsToIncludeFinal[$i]])) {
|
|
|
|
|
foreach ($data[$columsToIncludeFinal[$i]] as $delIndex) {
|
|
|
|
|
$delIndexes[] = $delIndex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Verify if the delindex is an array
|
|
|
|
|
//if is not check different types of repositories
|
|
|
|
|
//the delegation index must always be defined.
|
|
|
|
|
if (count($delIndexes) == 0) {
|
|
|
|
|
$delIndexes[] = 1; // the first default index
|
|
|
|
|
}
|
|
|
|
|
//Remove duplicated
|
|
|
|
|
$delIndexes = array_unique($delIndexes);
|
|
|
|
|
//Get records
|
|
|
|
|
foreach ($delIndexes as $delIndex) {
|
|
|
|
|
$aRow = array();
|
|
|
|
|
//Copy result values to new row from Solr server
|
|
|
|
|
$aRow["APP_UID"] = $data["APP_UID"];
|
|
|
|
|
//Get delegation data from DB
|
|
|
|
|
//Filter data from db
|
|
|
|
|
$indexes = $appSolr->aaSearchRecords($aaappsDBData, array(
|
|
|
|
|
"APP_UID" => $applicationUid,
|
|
|
|
|
"DEL_INDEX" => $delIndex
|
|
|
|
|
));
|
|
|
|
|
foreach ($indexes as $index) {
|
|
|
|
|
$row = $aaappsDBData[$index];
|
|
|
|
|
}
|
|
|
|
|
if(!isset($row))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2014-03-17 17:06:59 -04:00
|
|
|
\G::LoadClass('wsBase');
|
|
|
|
|
$ws = new \wsBase();
|
2014-03-20 17:05:04 -04:00
|
|
|
$fields = $ws->getCaseInfo($applicationUid, $row["DEL_INDEX"]);
|
|
|
|
|
$array = json_decode(json_encode($fields), true);
|
|
|
|
|
if ($array ["status_code"] != 0) {
|
|
|
|
|
throw (new \Exception($array ["message"]));
|
|
|
|
|
} else {
|
|
|
|
|
$array['app_uid'] = $array['caseId'];
|
|
|
|
|
$array['app_number'] = $array['caseNumber'];
|
|
|
|
|
$array['app_name'] = $array['caseName'];
|
|
|
|
|
$array['app_status'] = $array['caseStatus'];
|
|
|
|
|
$array['app_init_usr_uid'] = $array['caseCreatorUser'];
|
|
|
|
|
$array['app_init_usr_username'] = $array['caseCreatorUserName'];
|
|
|
|
|
$array['pro_uid'] = $array['processId'];
|
|
|
|
|
$array['pro_name'] = $array['processName'];
|
|
|
|
|
$array['app_create_date'] = $array['createDate'];
|
|
|
|
|
$array['app_update_date'] = $array['updateDate'];
|
|
|
|
|
$array['current_task'] = $array['currentUsers'];
|
|
|
|
|
for ($i = 0; $i<=count($array['current_task'])-1; $i++) {
|
|
|
|
|
$current_task = $array['current_task'][$i];
|
|
|
|
|
$current_task['usr_uid'] = $current_task['userId'];
|
2014-03-21 16:45:35 -04:00
|
|
|
$current_task['usr_name'] = trim($current_task['userName']);
|
2014-03-20 17:05:04 -04:00
|
|
|
$current_task['tas_uid'] = $current_task['taskId'];
|
|
|
|
|
$current_task['tas_title'] = $current_task['taskName'];
|
|
|
|
|
$current_task['del_index'] = $current_task['delIndex'];
|
|
|
|
|
$current_task['del_thread'] = $current_task['delThread'];
|
|
|
|
|
$current_task['del_thread_status'] = $current_task['delThreadStatus'];
|
|
|
|
|
unset($current_task['userId']);
|
|
|
|
|
unset($current_task['userName']);
|
|
|
|
|
unset($current_task['taskId']);
|
|
|
|
|
unset($current_task['taskName']);
|
|
|
|
|
unset($current_task['delIndex']);
|
|
|
|
|
unset($current_task['delThread']);
|
|
|
|
|
unset($current_task['delThreadStatus']);
|
|
|
|
|
$aCurrent_task[] = $current_task;
|
|
|
|
|
}
|
|
|
|
|
unset($array['status_code']);
|
|
|
|
|
unset($array['message']);
|
|
|
|
|
unset($array['timestamp']);
|
|
|
|
|
unset($array['caseParalell']);
|
|
|
|
|
unset($array['caseId']);
|
|
|
|
|
unset($array['caseNumber']);
|
|
|
|
|
unset($array['caseName']);
|
|
|
|
|
unset($array['caseStatus']);
|
|
|
|
|
unset($array['caseCreatorUser']);
|
|
|
|
|
unset($array['caseCreatorUserName']);
|
|
|
|
|
unset($array['processId']);
|
|
|
|
|
unset($array['processName']);
|
|
|
|
|
unset($array['createDate']);
|
|
|
|
|
unset($array['updateDate']);
|
|
|
|
|
unset($array['currentUsers']);
|
|
|
|
|
$current_task = json_decode(json_encode($aCurrent_task), false);
|
|
|
|
|
$oResponse = json_decode(json_encode($array), false);
|
|
|
|
|
$oResponse->current_task = $current_task;
|
|
|
|
|
}
|
2014-03-17 17:06:59 -04:00
|
|
|
//Return
|
2014-03-20 17:05:04 -04:00
|
|
|
return $oResponse;
|
2014-03-17 15:24:14 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (\InvalidIndexSearchTextException $e) {
|
|
|
|
|
$arrayData = array();
|
2014-03-20 17:05:04 -04:00
|
|
|
$arrayData[] = array ("app_uid" => $e->getMessage(),
|
|
|
|
|
"app_name" => $e->getMessage(),
|
|
|
|
|
"del_index" => $e->getMessage(),
|
|
|
|
|
"pro_uid" => $e->getMessage());
|
|
|
|
|
throw (new \Exception($arrayData));
|
2014-03-17 15:24:14 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
$criteria->addSelectColumn(\AppCacheViewPeer::DEL_INDEX);
|
|
|
|
|
$criteria->add(\AppCacheViewPeer::USR_UID, $userUid);
|
2014-03-20 17:05:04 -04:00
|
|
|
$criteria->add(\AppCacheViewPeer::APP_UID, $applicationUid);
|
2014-03-17 15:24:14 -04:00
|
|
|
$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"))
|
|
|
|
|
);
|
|
|
|
|
$criteria->addDescendingOrderByColumn(\AppCacheViewPeer::APP_NUMBER);
|
|
|
|
|
$rsCriteria = \AppCacheViewPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
2014-03-20 17:05:04 -04:00
|
|
|
$row["DEL_INDEX"] = '';
|
2014-03-17 15:24:14 -04:00
|
|
|
while ($rsCriteria->next()) {
|
|
|
|
|
$row = $rsCriteria->getRow();
|
|
|
|
|
}
|
2014-03-17 17:06:59 -04:00
|
|
|
\G::LoadClass('wsBase');
|
|
|
|
|
$ws = new \wsBase();
|
2014-03-20 17:05:04 -04:00
|
|
|
$fields = $ws->getCaseInfo($applicationUid, $row["DEL_INDEX"]);
|
|
|
|
|
$array = json_decode(json_encode($fields), true);
|
|
|
|
|
if ($array ["status_code"] != 0) {
|
|
|
|
|
throw (new \Exception($array ["message"]));
|
|
|
|
|
} else {
|
|
|
|
|
$array['app_uid'] = $array['caseId'];
|
|
|
|
|
$array['app_number'] = $array['caseNumber'];
|
|
|
|
|
$array['app_name'] = $array['caseName'];
|
|
|
|
|
$array['app_status'] = $array['caseStatus'];
|
|
|
|
|
$array['app_init_usr_uid'] = $array['caseCreatorUser'];
|
|
|
|
|
$array['app_init_usr_username'] = $array['caseCreatorUserName'];
|
|
|
|
|
$array['pro_uid'] = $array['processId'];
|
|
|
|
|
$array['pro_name'] = $array['processName'];
|
|
|
|
|
$array['app_create_date'] = $array['createDate'];
|
|
|
|
|
$array['app_update_date'] = $array['updateDate'];
|
|
|
|
|
$array['current_task'] = $array['currentUsers'];
|
|
|
|
|
for ($i = 0; $i<=count($array['current_task'])-1; $i++) {
|
|
|
|
|
$current_task = $array['current_task'][$i];
|
|
|
|
|
$current_task['usr_uid'] = $current_task['userId'];
|
2014-03-21 16:40:02 -04:00
|
|
|
$current_task['usr_name'] = trim($current_task['userName']);
|
2014-03-20 17:05:04 -04:00
|
|
|
$current_task['tas_uid'] = $current_task['taskId'];
|
|
|
|
|
$current_task['tas_title'] = $current_task['taskName'];
|
|
|
|
|
$current_task['del_index'] = $current_task['delIndex'];
|
|
|
|
|
$current_task['del_thread'] = $current_task['delThread'];
|
|
|
|
|
$current_task['del_thread_status'] = $current_task['delThreadStatus'];
|
|
|
|
|
unset($current_task['userId']);
|
|
|
|
|
unset($current_task['userName']);
|
|
|
|
|
unset($current_task['taskId']);
|
|
|
|
|
unset($current_task['taskName']);
|
|
|
|
|
unset($current_task['delIndex']);
|
|
|
|
|
unset($current_task['delThread']);
|
|
|
|
|
unset($current_task['delThreadStatus']);
|
|
|
|
|
$aCurrent_task[] = $current_task;
|
|
|
|
|
}
|
|
|
|
|
unset($array['status_code']);
|
|
|
|
|
unset($array['message']);
|
|
|
|
|
unset($array['timestamp']);
|
|
|
|
|
unset($array['caseParalell']);
|
|
|
|
|
unset($array['caseId']);
|
|
|
|
|
unset($array['caseNumber']);
|
|
|
|
|
unset($array['caseName']);
|
|
|
|
|
unset($array['caseStatus']);
|
|
|
|
|
unset($array['caseCreatorUser']);
|
|
|
|
|
unset($array['caseCreatorUserName']);
|
|
|
|
|
unset($array['processId']);
|
|
|
|
|
unset($array['processName']);
|
|
|
|
|
unset($array['createDate']);
|
|
|
|
|
unset($array['updateDate']);
|
|
|
|
|
unset($array['currentUsers']);
|
|
|
|
|
}
|
|
|
|
|
$current_task = json_decode(json_encode($aCurrent_task), false);
|
|
|
|
|
$oResponse = json_decode(json_encode($array), false);
|
|
|
|
|
$oResponse->current_task = $current_task;
|
2014-03-17 17:06:59 -04:00
|
|
|
//Return
|
2014-03-20 17:05:04 -04:00
|
|
|
return $oResponse;
|
2014-03-17 15:24:14 -04:00
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get data Task Case
|
|
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $applicationUid Unique id of Case
|
|
|
|
|
* @param string $userUid Unique id of User
|
2014-03-17 15:24:14 -04:00
|
|
|
*
|
|
|
|
|
* return array Return an array with Task Case
|
|
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function getTaskCase($applicationUid, $userUid)
|
2014-03-17 15:24:14 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-03-18 11:59:28 -04:00
|
|
|
$result = array ();
|
2014-03-17 15:24:14 -04:00
|
|
|
\G::LoadClass('wsBase');
|
2014-03-18 11:59:28 -04:00
|
|
|
$oCriteria = new \Criteria( 'workflow' );
|
|
|
|
|
$del = \DBAdapter::getStringDelimiter();
|
|
|
|
|
$oCriteria->addSelectColumn( \AppDelegationPeer::DEL_INDEX );
|
|
|
|
|
$oCriteria->addSelectColumn( \AppDelegationPeer::TAS_UID );
|
|
|
|
|
$oCriteria->addAsColumn( 'TAS_TITLE', 'C1.CON_VALUE' );
|
|
|
|
|
$oCriteria->addAlias( "C1", 'CONTENT' );
|
|
|
|
|
$tasTitleConds = array ();
|
|
|
|
|
$tasTitleConds[] = array (\AppDelegationPeer::TAS_UID,'C1.CON_ID');
|
|
|
|
|
$tasTitleConds[] = array ('C1.CON_CATEGORY',$del . 'TAS_TITLE' . $del);
|
|
|
|
|
$tasTitleConds[] = array ('C1.CON_LANG',$del . SYS_LANG . $del);
|
|
|
|
|
$oCriteria->addJoinMC( $tasTitleConds, \Criteria::LEFT_JOIN );
|
2014-03-20 17:05:04 -04:00
|
|
|
$oCriteria->add( \AppDelegationPeer::APP_UID, $applicationUid );
|
|
|
|
|
$oCriteria->add( \AppDelegationPeer::USR_UID, $userUid );
|
2014-03-18 11:59:28 -04:00
|
|
|
$oCriteria->add( \AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN' );
|
|
|
|
|
$oCriteria->add( \AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL );
|
|
|
|
|
$oDataset = \AppDelegationPeer::doSelectRS( $oCriteria );
|
|
|
|
|
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
while ($aRow = $oDataset->getRow()) {
|
2014-03-20 17:05:04 -04:00
|
|
|
$result = array ('tas_uid' => $aRow['TAS_UID'],
|
|
|
|
|
'tas_title' => $aRow['TAS_TITLE'],
|
|
|
|
|
'del_index' => $aRow['DEL_INDEX']);
|
2014-03-18 11:59:28 -04:00
|
|
|
$oDataset->next();
|
|
|
|
|
}
|
2014-03-17 15:24:14 -04:00
|
|
|
//Return
|
2014-03-20 17:05:04 -04:00
|
|
|
if(empty($result)) {
|
|
|
|
|
throw (new \Exception('Incorrect or unavailable information about this case: ' .$applicationUid));
|
|
|
|
|
} else {
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
2014-03-17 15:24:14 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add New Case
|
|
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $processUid Unique id of Project
|
|
|
|
|
* @param string $taskUid Unique id of Activity (task)
|
|
|
|
|
* @param string $userUid Unique id of Case
|
2014-03-17 15:24:14 -04:00
|
|
|
* @param array $variables
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with Task Case
|
|
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function addCase($processUid, $taskUid, $userUid, $variables)
|
2014-03-17 15:24:14 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
\G::LoadClass('wsBase');
|
|
|
|
|
$ws = new \wsBase();
|
|
|
|
|
if ($variables) {
|
|
|
|
|
$variables = array_shift($variables);
|
|
|
|
|
}
|
2014-03-20 17:05:04 -04:00
|
|
|
$fields = $ws->newCase($processUid, $userUid, $taskUid, $variables);
|
|
|
|
|
$array = json_decode(json_encode($fields), true);
|
|
|
|
|
if ($array ["status_code"] != 0) {
|
|
|
|
|
throw (new \Exception($array ["message"]));
|
|
|
|
|
} else {
|
|
|
|
|
$array['app_uid'] = $array['caseId'];
|
|
|
|
|
$array['app_number'] = $array['caseNumber'];
|
|
|
|
|
unset($array['status_code']);
|
|
|
|
|
unset($array['message']);
|
|
|
|
|
unset($array['timestamp']);
|
|
|
|
|
unset($array['caseId']);
|
|
|
|
|
unset($array['caseNumber']);
|
|
|
|
|
}
|
|
|
|
|
$oResponse = json_decode(json_encode($array), false);
|
2014-03-17 15:24:14 -04:00
|
|
|
//Return
|
2014-03-20 17:05:04 -04:00
|
|
|
return $oResponse;
|
2014-03-17 15:24:14 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add New Case Impersonate
|
|
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $processUid Unique id of Project
|
|
|
|
|
* @param string $userUid Unique id of User
|
|
|
|
|
* @param string $taskUid Unique id of Case
|
2014-03-17 15:24:14 -04:00
|
|
|
* @param array $variables
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with Task Case
|
|
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function addCaseImpersonate($processUid, $userUid, $taskUid, $variables)
|
2014-03-17 15:24:14 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
\G::LoadClass('wsBase');
|
|
|
|
|
$ws = new \wsBase();
|
2014-03-17 17:06:59 -04:00
|
|
|
if ($variables) {
|
|
|
|
|
$variables = array_shift($variables);
|
2014-03-24 11:03:23 -04:00
|
|
|
} elseif ($variables == null) {
|
|
|
|
|
$variables = array(array());
|
2014-03-17 17:06:59 -04:00
|
|
|
}
|
2014-03-20 17:05:04 -04:00
|
|
|
$fields = $ws->newCaseImpersonate($processUid, $userUid, $variables, $taskUid);
|
|
|
|
|
$array = json_decode(json_encode($fields), true);
|
|
|
|
|
if ($array ["status_code"] != 0) {
|
|
|
|
|
throw (new \Exception($array ["message"]));
|
|
|
|
|
} else {
|
|
|
|
|
$array['app_uid'] = $array['caseId'];
|
|
|
|
|
$array['app_number'] = $array['caseNumber'];
|
|
|
|
|
unset($array['status_code']);
|
|
|
|
|
unset($array['message']);
|
|
|
|
|
unset($array['timestamp']);
|
|
|
|
|
unset($array['caseId']);
|
|
|
|
|
unset($array['caseNumber']);
|
|
|
|
|
}
|
|
|
|
|
$oResponse = json_decode(json_encode($array), false);
|
2014-03-17 15:24:14 -04:00
|
|
|
//Return
|
2014-03-20 17:05:04 -04:00
|
|
|
return $oResponse;
|
2014-03-17 15:24:14 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reassign Case
|
|
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $applicationUid Unique id of Case
|
2014-03-17 15:24:14 -04:00
|
|
|
* @param string $userUid Unique id of User
|
|
|
|
|
* @param string $delIndex
|
|
|
|
|
* @param string $userUidSource Unique id of User Source
|
|
|
|
|
* @param string $userUid $userUidTarget id of User Target
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with Task Case
|
|
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function updateReassignCase($applicationUid, $userUid, $delIndex, $userUidSource, $userUidTarget)
|
2014-03-17 15:24:14 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-03-18 17:05:30 -04:00
|
|
|
if (!$delIndex) {
|
2014-03-20 17:05:04 -04:00
|
|
|
$delIndex = \AppDelegation::getCurrentIndex($applicationUid);
|
2014-03-18 17:05:30 -04:00
|
|
|
}
|
2014-03-17 15:24:14 -04:00
|
|
|
\G::LoadClass('wsBase');
|
|
|
|
|
$ws = new \wsBase();
|
2014-03-20 17:05:04 -04:00
|
|
|
$fields = $ws->reassignCase($userUid, $applicationUid, $delIndex, $userUidSource, $userUidTarget);
|
|
|
|
|
$array = json_decode(json_encode($fields), true);
|
|
|
|
|
if ($array ["status_code"] != 0) {
|
|
|
|
|
throw (new \Exception($array ["message"]));
|
|
|
|
|
} else {
|
|
|
|
|
unset($array['status_code']);
|
|
|
|
|
unset($array['message']);
|
|
|
|
|
unset($array['timestamp']);
|
|
|
|
|
}
|
2014-03-17 15:24:14 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-18 12:31:36 -04:00
|
|
|
/**
|
|
|
|
|
* Put cancel case
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string $app_uid, Uid for case
|
|
|
|
|
* @param string $usr_uid, Uid for user
|
|
|
|
|
* @param string $del_index, Index for case
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*/
|
|
|
|
|
public function putCancelCase($app_uid, $usr_uid, $del_index = false) {
|
|
|
|
|
Validator::appUid($app_uid, '$cas_uid');
|
|
|
|
|
Validator::usrUid($usr_uid, '$usr_uid');
|
|
|
|
|
|
|
|
|
|
if ($del_index === false) {
|
|
|
|
|
$del_index = \AppDelegation::getCurrentIndex($app_uid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$case = new \Cases();
|
|
|
|
|
$case->cancelCase( $app_uid, $del_index, $usr_uid );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Put pause case
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string $app_uid , Uid for case
|
|
|
|
|
* @param string $usr_uid , Uid for user
|
|
|
|
|
* @param bool|string $del_index , Index for case
|
|
|
|
|
* @param null|string $unpaused_date, Date for unpaused
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*/
|
|
|
|
|
public function putPauseCase($app_uid, $usr_uid, $del_index = false, $unpaused_date = null) {
|
|
|
|
|
Validator::appUid($app_uid, '$cas_uid');
|
|
|
|
|
Validator::usrUid($usr_uid, '$usr_uid');
|
|
|
|
|
if ($unpaused_date != null) {
|
|
|
|
|
Validator::isDate($unpaused_date, 'Y-m-d', '$unpaused_date');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($del_index === false) {
|
|
|
|
|
$del_index = \AppDelegation::getCurrentIndex($app_uid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$case = new \Cases();
|
|
|
|
|
$case->pauseCase( $app_uid, $del_index, $usr_uid, $unpaused_date );
|
|
|
|
|
}
|
2014-03-18 14:37:47 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Put unpause case
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string $app_uid , Uid for case
|
|
|
|
|
* @param string $usr_uid , Uid for user
|
|
|
|
|
* @param bool|string $del_index , Index for case
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*/
|
|
|
|
|
public function putUnpauseCase($app_uid, $usr_uid, $del_index = false) {
|
|
|
|
|
Validator::appUid($app_uid, '$cas_uid');
|
|
|
|
|
Validator::usrUid($usr_uid, '$usr_uid');
|
|
|
|
|
|
|
|
|
|
if ($del_index === false) {
|
|
|
|
|
$del_index = \AppDelegation::getCurrentIndex($app_uid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$case = new \Cases();
|
|
|
|
|
$case->unpauseCase( $app_uid, $del_index, $usr_uid );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Put execute trigger case
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string $app_uid , Uid for case
|
|
|
|
|
* @param string $usr_uid , Uid for user
|
|
|
|
|
* @param bool|string $del_index , Index for case
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*/
|
|
|
|
|
public function putExecuteTriggerCase($app_uid, $tri_uid, $usr_uid, $del_index = false) {
|
|
|
|
|
Validator::appUid($app_uid, '$cas_uid');
|
|
|
|
|
Validator::triUid($tri_uid, '$tri_uid');
|
|
|
|
|
Validator::usrUid($usr_uid, '$usr_uid');
|
|
|
|
|
|
|
|
|
|
if ($del_index === false) {
|
|
|
|
|
$del_index = \AppDelegation::getCurrentIndex($app_uid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$case = new \wsBase();
|
|
|
|
|
$case->executeTrigger( $usr_uid, $app_uid, $tri_uid, $del_index );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete case
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string $app_uid, Uid for case
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*/
|
|
|
|
|
public function deleteCase($app_uid) {
|
|
|
|
|
Validator::appUid($app_uid, '$cas_uid');
|
|
|
|
|
$case = new \Cases();
|
|
|
|
|
$case->removeCase( $app_uid );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-18 17:05:30 -04:00
|
|
|
* Route Case
|
2014-03-17 17:06:59 -04:00
|
|
|
*
|
2014-03-20 17:05:04 -04:00
|
|
|
* @param string $applicationUid Unique id of Case
|
2014-03-17 17:06:59 -04:00
|
|
|
* @param string $userUid Unique id of User
|
|
|
|
|
* @param string $delIndex
|
|
|
|
|
* @param string $bExecuteTriggersBeforeAssignment
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with Task Case
|
|
|
|
|
*/
|
2014-03-20 17:05:04 -04:00
|
|
|
public function updateRouteCase($applicationUid, $userUid, $delIndex)
|
2014-03-17 17:06:59 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-03-18 17:05:30 -04:00
|
|
|
if (!$delIndex) {
|
2014-03-20 17:05:04 -04:00
|
|
|
$delIndex = \AppDelegation::getCurrentIndex($applicationUid);
|
2014-03-18 17:05:30 -04:00
|
|
|
}
|
2014-03-17 17:06:59 -04:00
|
|
|
\G::LoadClass('wsBase');
|
|
|
|
|
$ws = new \wsBase();
|
2014-03-20 17:05:04 -04:00
|
|
|
$fields = $ws->derivateCase($userUid, $applicationUid, $delIndex, $bExecuteTriggersBeforeAssignment = false);
|
|
|
|
|
$array = json_decode(json_encode($fields), true);
|
|
|
|
|
if ($array ["status_code"] != 0) {
|
|
|
|
|
throw (new \Exception($array ["message"]));
|
|
|
|
|
} else {
|
|
|
|
|
unset($array['status_code']);
|
|
|
|
|
unset($array['message']);
|
|
|
|
|
unset($array['timestamp']);
|
|
|
|
|
}
|
2014-03-17 17:06:59 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-18 17:05:30 -04:00
|
|
|
|
2014-03-18 11:59:28 -04:00
|
|
|
/**
|
|
|
|
|
* get all upload document that they have send it
|
|
|
|
|
*
|
|
|
|
|
* @param string $sProcessUID Unique id of Process
|
|
|
|
|
* @param string $sApplicationUID Unique id of Case
|
|
|
|
|
* @param string $sTasKUID Unique id of Activity
|
|
|
|
|
* @param string $sUserUID Unique id of User
|
|
|
|
|
* @return object
|
|
|
|
|
*/
|
|
|
|
|
public function getAllUploadedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID)
|
|
|
|
|
{
|
|
|
|
|
\G::LoadClass("configuration");
|
|
|
|
|
$conf = new \Configurations();
|
|
|
|
|
$confEnvSetting = $conf->getFormats();
|
|
|
|
|
//verifica si existe la tabla OBJECT_PERMISSION
|
|
|
|
|
$cases = new \cases();
|
|
|
|
|
$cases->verifyTable();
|
|
|
|
|
$listing = false;
|
|
|
|
|
$oPluginRegistry = & \PMPluginRegistry::getSingleton();
|
|
|
|
|
if ($oPluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST)) {
|
|
|
|
|
$folderData = new \folderData(null, null, $sApplicationUID, null, $sUserUID);
|
|
|
|
|
$folderData->PMType = "INPUT";
|
|
|
|
|
$folderData->returnList = true;
|
|
|
|
|
//$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
|
|
|
|
$listing = $oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData);
|
|
|
|
|
}
|
|
|
|
|
$aObjectPermissions = $cases->getAllObjects($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID);
|
|
|
|
|
if (!is_array($aObjectPermissions)) {
|
|
|
|
|
$aObjectPermissions = array(
|
|
|
|
|
'DYNAFORMS' => array(-1),
|
|
|
|
|
'INPUT_DOCUMENTS' => array(-1),
|
|
|
|
|
'OUTPUT_DOCUMENTS' => array(-1)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (!isset($aObjectPermissions['DYNAFORMS'])) {
|
|
|
|
|
$aObjectPermissions['DYNAFORMS'] = array(-1);
|
|
|
|
|
} else {
|
|
|
|
|
if (!is_array($aObjectPermissions['DYNAFORMS'])) {
|
|
|
|
|
$aObjectPermissions['DYNAFORMS'] = array(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isset($aObjectPermissions['INPUT_DOCUMENTS'])) {
|
|
|
|
|
$aObjectPermissions['INPUT_DOCUMENTS'] = array(-1);
|
|
|
|
|
} else {
|
|
|
|
|
if (!is_array($aObjectPermissions['INPUT_DOCUMENTS'])) {
|
|
|
|
|
$aObjectPermissions['INPUT_DOCUMENTS'] = array(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isset($aObjectPermissions['OUTPUT_DOCUMENTS'])) {
|
|
|
|
|
$aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1);
|
|
|
|
|
} else {
|
|
|
|
|
if (!is_array($aObjectPermissions['OUTPUT_DOCUMENTS'])) {
|
|
|
|
|
$aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$aDelete = $cases->getAllObjectsFrom($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID, 'DELETE');
|
|
|
|
|
$oAppDocument = new \AppDocument();
|
|
|
|
|
$oCriteria = new \Criteria('workflow');
|
|
|
|
|
$oCriteria->add(\AppDocumentPeer::APP_UID, $sApplicationUID);
|
|
|
|
|
$oCriteria->add(\AppDocumentPeer::APP_DOC_TYPE, array('INPUT'), \Criteria::IN);
|
|
|
|
|
$oCriteria->add(\AppDocumentPeer::APP_DOC_STATUS, array('ACTIVE'), \Criteria::IN);
|
|
|
|
|
//$oCriteria->add(AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['INPUT_DOCUMENTS'], Criteria::IN);
|
|
|
|
|
$oCriteria->add(
|
|
|
|
|
$oCriteria->getNewCriterion(
|
|
|
|
|
\AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['INPUT_DOCUMENTS'], \Criteria::IN)->
|
|
|
|
|
addOr($oCriteria->getNewCriterion(\AppDocumentPeer::USR_UID, array($sUserUID, '-1'), \Criteria::IN))
|
|
|
|
|
);
|
|
|
|
|
$aConditions = array();
|
|
|
|
|
$aConditions[] = array(\AppDocumentPeer::APP_UID, \AppDelegationPeer::APP_UID);
|
|
|
|
|
$aConditions[] = array(\AppDocumentPeer::DEL_INDEX, \AppDelegationPeer::DEL_INDEX);
|
|
|
|
|
$oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
|
|
|
|
|
$oCriteria->add(\AppDelegationPeer::PRO_UID, $sProcessUID);
|
|
|
|
|
$oCriteria->addAscendingOrderByColumn(\AppDocumentPeer::APP_DOC_INDEX);
|
|
|
|
|
$oDataset = \AppDocumentPeer::doSelectRS($oCriteria);
|
|
|
|
|
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
$aInputDocuments = array();
|
|
|
|
|
$aInputDocuments[] = array(
|
|
|
|
|
'APP_DOC_UID' => 'char',
|
|
|
|
|
'DOC_UID' => 'char',
|
|
|
|
|
'APP_DOC_COMMENT' => 'char',
|
|
|
|
|
'APP_DOC_FILENAME' => 'char', 'APP_DOC_INDEX' => 'integer'
|
|
|
|
|
);
|
|
|
|
|
$oUser = new \Users();
|
|
|
|
|
while ($aRow = $oDataset->getRow()) {
|
|
|
|
|
$oCriteria2 = new \Criteria('workflow');
|
|
|
|
|
$oCriteria2->add(\AppDelegationPeer::APP_UID, $sApplicationUID);
|
|
|
|
|
$oCriteria2->add(\AppDelegationPeer::DEL_INDEX, $aRow['DEL_INDEX']);
|
|
|
|
|
$oDataset2 = \AppDelegationPeer::doSelectRS($oCriteria2);
|
|
|
|
|
$oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$oDataset2->next();
|
|
|
|
|
$aRow2 = $oDataset2->getRow();
|
|
|
|
|
$oTask = new \Task();
|
|
|
|
|
if ($oTask->taskExists($aRow2['TAS_UID'])) {
|
|
|
|
|
$aTask = $oTask->load($aRow2['TAS_UID']);
|
|
|
|
|
} else {
|
|
|
|
|
$aTask = array('TAS_TITLE' => '(TASK DELETED)');
|
|
|
|
|
}
|
|
|
|
|
$aAux = $oAppDocument->load($aRow['APP_DOC_UID'], $aRow['DOC_VERSION']);
|
|
|
|
|
$lastVersion = $oAppDocument->getLastAppDocVersion($aRow['APP_DOC_UID'], $sApplicationUID);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$aAux1 = $oUser->load($aAux['USR_UID']);
|
|
|
|
|
|
|
|
|
|
$sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]);
|
|
|
|
|
} catch (Exception $oException) {
|
|
|
|
|
//$sUser = '(USER DELETED)';
|
|
|
|
|
$sUser = '***';
|
|
|
|
|
}
|
|
|
|
|
$aFields = array(
|
|
|
|
|
'APP_DOC_UID' => $aAux['APP_DOC_UID'],
|
|
|
|
|
'DOC_UID' => $aAux['DOC_UID'],
|
|
|
|
|
'APP_DOC_COMMENT' => $aAux['APP_DOC_COMMENT'],
|
|
|
|
|
'APP_DOC_FILENAME' => $aAux['APP_DOC_FILENAME'],
|
|
|
|
|
'APP_DOC_INDEX' => $aAux['APP_DOC_INDEX'],
|
|
|
|
|
'TYPE' => $aAux['APP_DOC_TYPE'],
|
|
|
|
|
'ORIGIN' => $aTask['TAS_TITLE'],
|
|
|
|
|
'CREATE_DATE' => $aAux['APP_DOC_CREATE_DATE'],
|
|
|
|
|
'CREATED_BY' => $sUser
|
|
|
|
|
);
|
|
|
|
|
if ($aFields['APP_DOC_FILENAME'] != '') {
|
|
|
|
|
$aFields['TITLE'] = $aFields['APP_DOC_FILENAME'];
|
|
|
|
|
} else {
|
|
|
|
|
$aFields['TITLE'] = $aFields['APP_DOC_COMMENT'];
|
|
|
|
|
}
|
|
|
|
|
//$aFields['POSITION'] = $_SESSION['STEP_POSITION'];
|
|
|
|
|
$aFields['CONFIRM'] = \G::LoadTranslation('ID_CONFIRM_DELETE_ELEMENT');
|
|
|
|
|
if (in_array($aRow['APP_DOC_UID'], $aDelete['INPUT_DOCUMENTS'])) {
|
|
|
|
|
$aFields['ID_DELETE'] = \G::LoadTranslation('ID_DELETE');
|
|
|
|
|
}
|
|
|
|
|
$aFields['DOWNLOAD_LABEL'] = \G::LoadTranslation('ID_DOWNLOAD');
|
|
|
|
|
$aFields['DOWNLOAD_LINK'] = "cases_ShowDocument?a=" . $aRow['APP_DOC_UID'] . "&v=" . $aRow['DOC_VERSION'];
|
|
|
|
|
$aFields['DOC_VERSION'] = $aRow['DOC_VERSION'];
|
|
|
|
|
if (is_array($listing)) {
|
|
|
|
|
foreach ($listing as $folderitem) {
|
|
|
|
|
if ($folderitem->filename == $aRow['APP_DOC_UID']) {
|
|
|
|
|
$aFields['DOWNLOAD_LABEL'] = \G::LoadTranslation('ID_GET_EXTERNAL_FILE');
|
|
|
|
|
$aFields['DOWNLOAD_LINK'] = $folderitem->downloadScript;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($lastVersion == $aRow['DOC_VERSION']) {
|
|
|
|
|
//Show only last version
|
|
|
|
|
$aInputDocuments[] = $aFields;
|
|
|
|
|
}
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
}
|
|
|
|
|
$oAppDocument = new \AppDocument();
|
|
|
|
|
$oCriteria = new \Criteria('workflow');
|
|
|
|
|
$oCriteria->add(\AppDocumentPeer::APP_UID, $sApplicationUID);
|
|
|
|
|
$oCriteria->add(\AppDocumentPeer::APP_DOC_TYPE, array('ATTACHED'), \Criteria::IN);
|
|
|
|
|
$oCriteria->add(\AppDocumentPeer::APP_DOC_STATUS, array('ACTIVE'), \Criteria::IN);
|
|
|
|
|
$oCriteria->add(
|
|
|
|
|
$oCriteria->getNewCriterion(
|
|
|
|
|
\AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['INPUT_DOCUMENTS'], \Criteria::IN
|
|
|
|
|
)->
|
|
|
|
|
addOr($oCriteria->getNewCriterion(\AppDocumentPeer::USR_UID, array($sUserUID, '-1'), \Criteria::IN)));
|
|
|
|
|
$aConditions = array();
|
|
|
|
|
$aConditions[] = array(\AppDocumentPeer::APP_UID, \AppDelegationPeer::APP_UID);
|
|
|
|
|
$aConditions[] = array(\AppDocumentPeer::DEL_INDEX, \AppDelegationPeer::DEL_INDEX);
|
|
|
|
|
$oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
|
|
|
|
|
$oCriteria->add(\AppDelegationPeer::PRO_UID, $sProcessUID);
|
|
|
|
|
$oCriteria->addAscendingOrderByColumn(\AppDocumentPeer::APP_DOC_INDEX);
|
|
|
|
|
$oDataset = \AppDocumentPeer::doSelectRS($oCriteria);
|
|
|
|
|
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
while ($aRow = $oDataset->getRow()) {
|
|
|
|
|
$oCriteria2 = new \Criteria('workflow');
|
|
|
|
|
$oCriteria2->add(\AppDelegationPeer::APP_UID, $sApplicationUID);
|
|
|
|
|
$oCriteria2->add(\AppDelegationPeer::DEL_INDEX, $aRow['DEL_INDEX']);
|
|
|
|
|
$oDataset2 = \AppDelegationPeer::doSelectRS($oCriteria2);
|
|
|
|
|
$oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$oDataset2->next();
|
|
|
|
|
$aRow2 = $oDataset2->getRow();
|
|
|
|
|
$oTask = new \Task();
|
|
|
|
|
if ($oTask->taskExists($aRow2['TAS_UID'])) {
|
|
|
|
|
$aTask = $oTask->load($aRow2['TAS_UID']);
|
|
|
|
|
} else {
|
|
|
|
|
$aTask = array('TAS_TITLE' => '(TASK DELETED)');
|
|
|
|
|
}
|
|
|
|
|
$aAux = $oAppDocument->load($aRow['APP_DOC_UID'], $aRow['DOC_VERSION']);
|
|
|
|
|
$lastVersion = $oAppDocument->getLastAppDocVersion($aRow['APP_DOC_UID'], $sApplicationUID);
|
|
|
|
|
try {
|
|
|
|
|
$aAux1 = $oUser->load($aAux['USR_UID']);
|
|
|
|
|
|
|
|
|
|
$sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]);
|
|
|
|
|
} catch (Exception $oException) {
|
|
|
|
|
$sUser = '***';
|
|
|
|
|
}
|
|
|
|
|
$aFields = array(
|
|
|
|
|
'APP_DOC_UID' => $aAux['APP_DOC_UID'],
|
|
|
|
|
'DOC_UID' => $aAux['DOC_UID'],
|
|
|
|
|
'APP_DOC_COMMENT' => $aAux['APP_DOC_COMMENT'],
|
|
|
|
|
'APP_DOC_FILENAME' => $aAux['APP_DOC_FILENAME'],
|
|
|
|
|
'APP_DOC_INDEX' => $aAux['APP_DOC_INDEX'],
|
|
|
|
|
'TYPE' => $aAux['APP_DOC_TYPE'],
|
|
|
|
|
'ORIGIN' => $aTask['TAS_TITLE'],
|
|
|
|
|
'CREATE_DATE' => $aAux['APP_DOC_CREATE_DATE'],
|
|
|
|
|
'CREATED_BY' => $sUser
|
|
|
|
|
);
|
|
|
|
|
if ($aFields['APP_DOC_FILENAME'] != '') {
|
|
|
|
|
$aFields['TITLE'] = $aFields['APP_DOC_FILENAME'];
|
|
|
|
|
} else {
|
|
|
|
|
$aFields['TITLE'] = $aFields['APP_DOC_COMMENT'];
|
|
|
|
|
}
|
|
|
|
|
//$aFields['POSITION'] = $_SESSION['STEP_POSITION'];
|
|
|
|
|
$aFields['CONFIRM'] = G::LoadTranslation('ID_CONFIRM_DELETE_ELEMENT');
|
|
|
|
|
if (in_array($aRow['APP_DOC_UID'], $aDelete['INPUT_DOCUMENTS'])) {
|
|
|
|
|
$aFields['ID_DELETE'] = G::LoadTranslation('ID_DELETE');
|
|
|
|
|
}
|
|
|
|
|
$aFields['DOWNLOAD_LABEL'] = G::LoadTranslation('ID_DOWNLOAD');
|
|
|
|
|
$aFields['DOWNLOAD_LINK'] = "cases_ShowDocument?a=" . $aRow['APP_DOC_UID'];
|
|
|
|
|
if ($lastVersion == $aRow['DOC_VERSION']) {
|
|
|
|
|
//Show only last version
|
|
|
|
|
$aInputDocuments[] = $aFields;
|
|
|
|
|
}
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
}
|
|
|
|
|
// Get input documents added/modified by a supervisor - Begin
|
|
|
|
|
$oAppDocument = new \AppDocument();
|
|
|
|
|
$oCriteria = new \Criteria('workflow');
|
|
|
|
|
$oCriteria->add(\AppDocumentPeer::APP_UID, $sApplicationUID);
|
|
|
|
|
$oCriteria->add(\AppDocumentPeer::APP_DOC_TYPE, array('INPUT'), \Criteria::IN);
|
|
|
|
|
$oCriteria->add(\AppDocumentPeer::APP_DOC_STATUS, array('ACTIVE'), \Criteria::IN);
|
|
|
|
|
$oCriteria->add(\AppDocumentPeer::DEL_INDEX, 100000);
|
|
|
|
|
$oCriteria->addJoin(\AppDocumentPeer::APP_UID, \ApplicationPeer::APP_UID, \Criteria::LEFT_JOIN);
|
|
|
|
|
$oCriteria->add(\ApplicationPeer::PRO_UID, $sProcessUID);
|
|
|
|
|
$oCriteria->addAscendingOrderByColumn(\AppDocumentPeer::APP_DOC_INDEX);
|
|
|
|
|
$oDataset = \AppDocumentPeer::doSelectRS($oCriteria);
|
|
|
|
|
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
$oUser = new \Users();
|
|
|
|
|
while ($aRow = $oDataset->getRow()) {
|
|
|
|
|
$aTask = array('TAS_TITLE' => '[ ' . G::LoadTranslation('ID_SUPERVISOR') . ' ]');
|
|
|
|
|
$aAux = $oAppDocument->load($aRow['APP_DOC_UID'], $aRow['DOC_VERSION']);
|
|
|
|
|
$lastVersion = $oAppDocument->getLastAppDocVersion($aRow['APP_DOC_UID'], $sApplicationUID);
|
|
|
|
|
try {
|
|
|
|
|
$aAux1 = $oUser->load($aAux['USR_UID']);
|
|
|
|
|
$sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]);
|
|
|
|
|
} catch (Exception $oException) {
|
|
|
|
|
$sUser = '***';
|
|
|
|
|
}
|
|
|
|
|
$aFields = array(
|
|
|
|
|
'APP_DOC_UID' => $aAux['APP_DOC_UID'],
|
|
|
|
|
'DOC_UID' => $aAux['DOC_UID'],
|
|
|
|
|
'APP_DOC_COMMENT' => $aAux['APP_DOC_COMMENT'],
|
|
|
|
|
'APP_DOC_FILENAME' => $aAux['APP_DOC_FILENAME'],
|
|
|
|
|
'APP_DOC_INDEX' => $aAux['APP_DOC_INDEX'],
|
|
|
|
|
'TYPE' => $aAux['APP_DOC_TYPE'],
|
|
|
|
|
'ORIGIN' => $aTask['TAS_TITLE'],
|
|
|
|
|
'CREATE_DATE' => $aAux['APP_DOC_CREATE_DATE'],
|
|
|
|
|
'CREATED_BY' => $sUser
|
|
|
|
|
);
|
|
|
|
|
if ($aFields['APP_DOC_FILENAME'] != '') {
|
|
|
|
|
$aFields['TITLE'] = $aFields['APP_DOC_FILENAME'];
|
|
|
|
|
} else {
|
|
|
|
|
$aFields['TITLE'] = $aFields['APP_DOC_COMMENT'];
|
|
|
|
|
}
|
|
|
|
|
//$aFields['POSITION'] = $_SESSION['STEP_POSITION'];
|
|
|
|
|
$aFields['CONFIRM'] = \G::LoadTranslation('ID_CONFIRM_DELETE_ELEMENT');
|
|
|
|
|
if (in_array($aRow['APP_DOC_UID'], $aDelete['INPUT_DOCUMENTS'])) {
|
|
|
|
|
$aFields['ID_DELETE'] = \G::LoadTranslation('ID_DELETE');
|
|
|
|
|
}
|
|
|
|
|
$aFields['DOWNLOAD_LABEL'] = \G::LoadTranslation('ID_DOWNLOAD');
|
|
|
|
|
$aFields['DOWNLOAD_LINK'] = "cases_ShowDocument?a=" . $aRow['APP_DOC_UID'] . "&v=" . $aRow['DOC_VERSION'];
|
|
|
|
|
$aFields['DOC_VERSION'] = $aRow['DOC_VERSION'];
|
|
|
|
|
if (is_array($listing)) {
|
|
|
|
|
foreach ($listing as $folderitem) {
|
|
|
|
|
if ($folderitem->filename == $aRow['APP_DOC_UID']) {
|
|
|
|
|
$aFields['DOWNLOAD_LABEL'] = \G::LoadTranslation('ID_GET_EXTERNAL_FILE');
|
|
|
|
|
$aFields['DOWNLOAD_LINK'] = $folderitem->downloadScript;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($lastVersion == $aRow['DOC_VERSION']) {
|
|
|
|
|
//Show only last version
|
|
|
|
|
$aInputDocuments[] = $aFields;
|
|
|
|
|
}
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
}
|
|
|
|
|
// Get input documents added/modified by a supervisor - End
|
|
|
|
|
global $_DBArray;
|
|
|
|
|
$_DBArray['inputDocuments'] = $aInputDocuments;
|
|
|
|
|
\G::LoadClass('ArrayPeer');
|
|
|
|
|
$oCriteria = new \Criteria('dbarray');
|
|
|
|
|
$oCriteria->setDBArrayTable('inputDocuments');
|
|
|
|
|
$oCriteria->addDescendingOrderByColumn('CREATE_DATE');
|
|
|
|
|
return $oCriteria;
|
|
|
|
|
}
|
2014-03-18 14:37:47 -04:00
|
|
|
}
|