Merged in release/3.7.3 (pull request #8351)

release/3.7.3
This commit is contained in:
Paula Quispe
2022-01-17 20:52:18 +00:00
142 changed files with 5095 additions and 1774 deletions

View File

@@ -1343,6 +1343,10 @@ class AbstractCases implements CasesInterface
*/
public function setProperties(array $properties)
{
// Filter by category
if (!empty($properties['category'])) {
$this->setCategoryId($properties['category']);
}
// Filter by process
if (!empty($properties['process'])) {
$this->setProcessId($properties['process']);
@@ -1552,16 +1556,16 @@ class AbstractCases implements CasesInterface
$list = end($listArray);
switch ($list) {
case 'Inbox':
$query->inbox($this->getUserId());
$query->inboxMetrics();
break;
case 'Draft':
$query->draft($this->getUserId());
$query->draftMetrics();
break;
case 'Paused':
$query->paused($this->getUserId());
$query->pausedMetrics();
break;
case 'Unassigned':
$query->selfService($this->getUserUid());
$query->selfServiceMetrics();
break;
}
$query->joinProcess();
@@ -1604,16 +1608,16 @@ class AbstractCases implements CasesInterface
$list = end($listArray);
switch ($list) {
case 'Inbox':
$query->inbox($this->getUserId());
$query->inboxMetrics();
break;
case 'Draft':
$query->draft($this->getUserId());
$query->draftMetrics();
break;
case 'Paused':
$query->paused($this->getUserId());
$query->pausedMetrics();
break;
case 'Unassigned':
$query->selfService($this->getUserUid());
$query->selfServiceMetrics();
break;
}
$query->joinProcess();
@@ -1657,16 +1661,16 @@ class AbstractCases implements CasesInterface
$list = end($listArray);
switch ($list) {
case 'Inbox':
$query->inbox($this->getUserId());
$query->inboxMetrics();
break;
case 'Draft':
$query->draft($this->getUserId());
$query->draftMetrics();
break;
case 'Paused':
$query->paused($this->getUserId());
$query->pausedMetrics();
break;
case 'Unassigned':
$query->selfService($this->getUserUid());
$query->selfServiceMetrics();
break;
}
$query->joinProcess();

View File

@@ -6,6 +6,8 @@ use G;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\ProcessCategory;
use ProcessMaker\Model\User;
class Draft extends AbstractCases
@@ -15,6 +17,7 @@ class Draft extends AbstractCases
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.CATEGORY_ID', // Category
'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task
'APP_DELEGATION.DEL_TASK_DUE_DATE', // Due Date
@@ -66,6 +69,10 @@ class Draft extends AbstractCases
if (!empty($this->getCaseTitle())) {
$query->title($this->getCaseTitle());
}
// Specific category
if ($this->getCategoryId()) {
$query->categoryId($this->getCategoryId());
}
// Specific process
if ($this->getProcessId()) {
$query->processId($this->getProcessId());
@@ -112,6 +119,9 @@ class Draft extends AbstractCases
$results = $query->get();
// Prepare the result
$results->transform(function ($item, $key) {
// Get the category
$category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : '';
$item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY');
// Get priority label
$priorityLabel = self::PRIORITIES[$item['DEL_PRIORITY']];
$item['DEL_PRIORITY_LABEL'] = G::LoadTranslation("ID_PRIORITY_{$priorityLabel}");
@@ -127,10 +137,25 @@ class Draft extends AbstractCases
$item['DEL_DELEGATE_DATE_LABEL'] = applyMaskDateEnvironment($item['DEL_DELEGATE_DATE']);
// Get the send by related to the previous index
$previousThread = Delegation::getThreadInfo($item['APP_NUMBER'], $item['DEL_PREVIOUS']);
$userInfo = !empty($previousThread) ? User::getInformation($previousThread['USR_ID']) : [];
$userInfo = [];
$dummyInfo = [];
if (!empty($previousThread)) {
// When the task has an user
$userInfo = ($previousThread['USR_ID'] !== 0) ? User::getInformation($previousThread['USR_ID']) : [];
// When the task does not have users refers to dummy task
$taskInfo = ($previousThread['USR_ID'] === 0) ? Task::title($previousThread['TAS_ID']) : [];
if (!empty($taskInfo)) {
$dummyInfo = [
'task_id' => $previousThread['TAS_ID'],
'name' => $taskInfo['title'],
'type' => $taskInfo['type']
];
}
}
$result = [];
$result['del_previous'] = $item['DEL_PREVIOUS'];
$result['user_tooltip'] = $userInfo;
$result['dummy_task'] = $dummyInfo;
$item['SEND_BY_INFO'] = $result;
return $item;
@@ -183,6 +208,11 @@ class Draft extends AbstractCases
$query = Delegation::query()->select();
// Add the initial scope for draft cases
$query->draft($this->getUserId());
// Check if the category was defined
if ($this->getCategoryId()) {
// Join with process if the filter with category exist
$query->joinProcess();
}
// Apply filters
$this->filters($query);
// Return the number of rows
@@ -228,4 +258,16 @@ class Draft extends AbstractCases
'total' => $count
];
}
/**
* Count how many cases there are in DRAFT
*
* @return int
*/
public function getCounterMetrics()
{
$query = Delegation::query()->select();
$query->draftMetrics();
return $query->count(['APPLICATION.APP_NUMBER']);
}
}

View File

@@ -38,7 +38,9 @@ class Home
/**
* Get the draft cases.
*
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -47,10 +49,12 @@ class Home
* @param string $filterCases
* @param string $sort
* @param callable $callback
*
* @return array
*/
public function getDraft(
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -67,6 +71,7 @@ class Home
$properties['caseNumber'] = $caseNumber;
$properties['caseTitle'] = $caseTitle;
$properties['filterCases'] = $filterCases;
$properties['category'] = $category;
$properties['process'] = $process;
$properties['task'] = $task;
// Get the user that access to the API
@@ -87,7 +92,9 @@ class Home
/**
* Get the inbox cases.
*
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -99,10 +106,12 @@ class Home
* @param string $sort
* @param string $sendBy
* @param callable $callback
*
* @return array
*/
public function getInbox(
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -124,6 +133,7 @@ class Home
$properties['delegateFrom'] = $delegateFrom;
$properties['delegateTo'] = $delegateTo;
$properties['filterCases'] = $filterCases;
$properties['category'] = $category;
$properties['process'] = $process;
$properties['task'] = $task;
// Get the user that access to the API
@@ -145,7 +155,9 @@ class Home
/**
* Get the unassigned cases.
*
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -157,10 +169,12 @@ class Home
* @param string $sort
* @param string $sendBy
* @param callable $callback
*
* @return array
*/
public function getUnassigned(
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -182,6 +196,7 @@ class Home
$properties['delegateFrom'] = $delegateFrom;
$properties['delegateTo'] = $delegateTo;
$properties['filterCases'] = $filterCases;
$properties['category'] = $category;
$properties['process'] = $process;
$properties['task'] = $task;
// Get the user that access to the API
@@ -205,7 +220,9 @@ class Home
/**
* Get the paused cases.
*
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -217,10 +234,12 @@ class Home
* @param string $sort
* @param string $sendBy
* @param callable $callback
*
* @return array
*/
public function getPaused(
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -242,6 +261,7 @@ class Home
$properties['delegateFrom'] = $delegateFrom;
$properties['delegateTo'] = $delegateTo;
$properties['filterCases'] = $filterCases;
$properties['category'] = $category;
$properties['process'] = $process;
$properties['task'] = $task;
// Get the user that access to the API
@@ -263,6 +283,7 @@ class Home
/**
* Build the columns and data from the custom list.
*
* @param string $type
* @param int $id
* @param array $arguments
@@ -339,14 +360,16 @@ class Home
}
};
}
$arguments[1] = $proId;
$arguments[2] = $proId;
}
}
/**
* Get the custom draft cases.
*
* @param int $id
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -355,11 +378,13 @@ class Home
* @param string $filterCases
* @param string $sort
* @param array $customFilters
*
* @return array
*/
public function getCustomDraft(
int $id,
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -372,6 +397,7 @@ class Home
{
$arguments = [
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -382,7 +408,7 @@ class Home
];
//clear duplicate indexes
$keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'filterCases', 'sort'];
$keys = ['caseNumber', 'category', 'process', 'task', 'limit', 'offset', 'caseTitle', 'filterCases', 'sort'];
foreach ($keys as $value) {
unset($customFilters[$value]);
}
@@ -398,8 +424,10 @@ class Home
/**
* Get the custom inbox cases.
*
* @param int $id
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -411,11 +439,13 @@ class Home
* @param string $sort
* @param string $sendBy
* @param array $customFilters
*
* @return array
*/
public function getCustomInbox(
int $id,
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -431,6 +461,7 @@ class Home
{
$arguments = [
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -444,7 +475,7 @@ class Home
];
//clear duplicate indexes
$keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy'];
$keys = ['caseNumber', 'category', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy'];
foreach ($keys as $value) {
unset($customFilters[$value]);
}
@@ -460,8 +491,10 @@ class Home
/**
* Get the custom unassigned cases.
*
* @param int $id
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -473,11 +506,13 @@ class Home
* @param string $sort
* @param string $sendBy
* @param array $customFilters
*
* @return array
*/
public function getCustomUnassigned(
int $id,
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -493,6 +528,7 @@ class Home
{
$arguments = [
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -506,7 +542,7 @@ class Home
];
//clear duplicate indexes
$keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy'];
$keys = ['caseNumber', 'category', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy'];
foreach ($keys as $value) {
unset($customFilters[$value]);
}
@@ -522,8 +558,10 @@ class Home
/**
* Get the custom paused cases.
*
* @param int $id
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -535,11 +573,13 @@ class Home
* @param string $sort
* @param string $sendBy
* @param array $customFilters
*
* @return array
*/
public function getCustomPaused(
int $id,
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -555,6 +595,7 @@ class Home
{
$arguments = [
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -568,7 +609,7 @@ class Home
];
//clear duplicate indexes
$keys = ['caseNumber', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy'];
$keys = ['caseNumber', 'category', 'process', 'task', 'limit', 'offset', 'caseTitle', 'delegateFrom', 'delegateTo', 'filterCases', 'sort', 'sendBy'];
foreach ($keys as $value) {
unset($customFilters[$value]);
}

View File

@@ -6,6 +6,8 @@ use G;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\ProcessCategory;
use ProcessMaker\Model\User;
class Inbox extends AbstractCases
@@ -15,6 +17,7 @@ class Inbox extends AbstractCases
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.CATEGORY_ID', // Category
'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task
'USERS.USR_USERNAME', // Current UserName
@@ -69,6 +72,10 @@ class Inbox extends AbstractCases
if (!empty($this->getCaseTitle())) {
$query->title($this->getCaseTitle());
}
// Specific category
if ($this->getCategoryId()) {
$query->categoryId($this->getCategoryId());
}
// Specific process
if ($this->getProcessId()) {
$query->processId($this->getProcessId());
@@ -81,7 +88,6 @@ class Inbox extends AbstractCases
if (!empty($this->getCaseUid())) {
$query->appUid($this->getCaseUid());
}
// Specific delegate date from
if (!empty($this->getDelegateFrom())) {
$query->delegateDateFrom($this->getDelegateFrom());
@@ -90,8 +96,7 @@ class Inbox extends AbstractCases
if (!empty($this->getDelegateTo())) {
$query->delegateDateTo($this->getDelegateTo());
}
// Specific usrId represented by sendBy.
// Specific usrId represented by sendBy
if (!empty($this->getSendBy())) {
$query->sendBy($this->getSendBy());
}
@@ -113,7 +118,7 @@ class Inbox extends AbstractCases
// Join with users
$query->joinUser();
// Join with task
$query->JoinTask();
$query->joinTask();
// Join with application for add the initial scope for TO_DO cases
$query->inbox($this->getUserId());
/** Apply filters */
@@ -132,6 +137,9 @@ class Inbox extends AbstractCases
$results = $query->get();
// Prepare the result
$results->transform(function ($item, $key) {
// Get the category
$category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : '';
$item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY');
// Get priority label
$priorityLabel = self::PRIORITIES[$item['DEL_PRIORITY']];
$item['DEL_PRIORITY_LABEL'] = G::LoadTranslation("ID_PRIORITY_{$priorityLabel}");
@@ -147,10 +155,26 @@ class Inbox extends AbstractCases
$item['DEL_DELEGATE_DATE_LABEL'] = applyMaskDateEnvironment($item['DEL_DELEGATE_DATE']);
// Get the send by related to the previous index
$previousThread = Delegation::getThreadInfo($item['APP_NUMBER'], $item['DEL_PREVIOUS']);
$userInfo = !empty($previousThread) ? User::getInformation($previousThread['USR_ID']) : [];
$userInfo = [];
$dummyInfo = [];
if (!empty($previousThread)) {
// When the task has an user
$userInfo = ($previousThread['USR_ID'] !== 0) ? User::getInformation($previousThread['USR_ID']) : [];
// When the task does not have users refers to dummy task
$taskInfo = ($previousThread['USR_ID'] === 0) ? Task::title($previousThread['TAS_ID']) : [];
if (!empty($taskInfo)) {
$dummyInfo = [
'task_id' => $previousThread['TAS_ID'],
'name' => $taskInfo['title'],
'type' => $taskInfo['type']
];
}
}
$result = [];
$result['del_previous'] = $item['DEL_PREVIOUS'];
$result['key_name'] = !empty($userInfo) ? 'user_tooltip' : 'dummy_task';
$result['user_tooltip'] = $userInfo;
$result['dummy_task'] = $dummyInfo;
$item['SEND_BY_INFO'] = $result;
return $item;
@@ -201,6 +225,11 @@ class Inbox extends AbstractCases
$query = Delegation::query()->select();
// Scope that sets the queries for List Inbox
$query->inbox($this->getUserId());
// Check if the category was defined
if ($this->getCategoryId()) {
// Join with process if the filter with category exist
$query->joinProcess();
}
// Apply filters
$this->filters($query);
// Return the number of rows
@@ -246,4 +275,16 @@ class Inbox extends AbstractCases
'total' => $count
];
}
/**
* Count how many cases there are in TO_DO
*
* @return int
*/
public function getCounterMetrics()
{
$query = Delegation::query()->select();
$query->inboxMetrics();
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
}

View File

@@ -2,10 +2,12 @@
namespace ProcessMaker\BusinessModel\Cases;
use G;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\AppNotes;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\ProcessCategory;
use ProcessMaker\Model\User;
class Participated extends AbstractCases
@@ -15,6 +17,7 @@ class Participated extends AbstractCases
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.CATEGORY_ID', // Category
'PROCESS.PRO_TITLE', // Process Name
'TASK.TAS_TITLE', // Pending Task
'TASK.TAS_ASSIGN_TYPE', // Task assign rule
@@ -68,10 +71,14 @@ class Participated extends AbstractCases
// Specific case title
if (!empty($this->getCaseTitle())) {
// Get the result
$result = Delegation::casesThreadTitle($this->getCaseTitle(), $this->getOffset(), $this->getLimit());
$result = Delegation::casesThreadTitle($this->getCaseTitle());
// Add the filter
$query->specificCases($result);
}
// Specific category
if ($this->getCategoryId()) {
$query->categoryId($this->getCategoryId());
}
// Scope to search for an specific process
if ($this->getProcessId()) {
$query->processId($this->getProcessId());
@@ -168,6 +175,9 @@ class Participated extends AbstractCases
$results = $query->get();
// Prepare the result
$results->transform(function ($item, $key) use ($filter) {
// Get the category
$category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : '';
$item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY');
// Apply the date format defined in environment
$item['APP_CREATE_DATE_LABEL'] = !empty($item['APP_CREATE_DATE']) ? applyMaskDateEnvironment($item['APP_CREATE_DATE']): null;
$item['APP_FINISH_DATE_LABEL'] = !empty($item['APP_FINISH_DATE']) ? applyMaskDateEnvironment($item['APP_FINISH_DATE']): null;
@@ -367,6 +377,11 @@ class Participated extends AbstractCases
$query->lastThread();
break;
}
// Check if the category was defined
if ($this->getCategoryId()) {
// Join with process if the filter with category exist
$query->joinProcess();
}
// Apply filters
$this->filters($query);
// Return the number of rows

View File

@@ -5,6 +5,8 @@ namespace ProcessMaker\BusinessModel\Cases;
use G;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\ProcessCategory;
use ProcessMaker\Model\User;
class Paused extends AbstractCases
@@ -14,6 +16,7 @@ class Paused extends AbstractCases
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.CATEGORY_ID', // Category
'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task
'USERS.USR_USERNAME', // Current UserName
@@ -68,6 +71,10 @@ class Paused extends AbstractCases
if (!empty($this->getCaseTitle())) {
$query->title($this->getCaseTitle());
}
// Specific category
if ($this->getCategoryId()) {
$query->categoryId($this->getCategoryId());
}
// Specific process
if ($this->getProcessId()) {
$query->processId($this->getProcessId());
@@ -80,7 +87,6 @@ class Paused extends AbstractCases
if (!empty($this->getCaseUid())) {
$query->appUid($this->getCaseUid());
}
// Specific delegate date from
if (!empty($this->getDelegateFrom())) {
$query->delegateDateFrom($this->getDelegateFrom());
@@ -89,8 +95,7 @@ class Paused extends AbstractCases
if (!empty($this->getDelegateTo())) {
$query->delegateDateTo($this->getDelegateTo());
}
// Specific usrId represented by sendBy.
// Specific usrId represented by sendBy
if (!empty($this->getSendBy())) {
$query->sendBy($this->getSendBy());
}
@@ -109,7 +114,7 @@ class Paused extends AbstractCases
// Join with process
$query->joinProcess();
// Join with task
$query->JoinTask();
$query->joinTask();
// Scope that set the paused cases
$query->paused($this->getUserId());
/** Apply filters */
@@ -126,6 +131,9 @@ class Paused extends AbstractCases
$results = $query->get();
// Prepare the result
$results->transform(function ($item, $key) {
// Get the category
$category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : '';
$item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY');
// Get priority label
$priorityLabel = self::PRIORITIES[$item['DEL_PRIORITY']];
$item['DEL_PRIORITY_LABEL'] = G::LoadTranslation("ID_PRIORITY_{$priorityLabel}");
@@ -141,10 +149,26 @@ class Paused extends AbstractCases
$item['DEL_DELEGATE_DATE_LABEL'] = applyMaskDateEnvironment($item['DEL_DELEGATE_DATE']);
// Get the send by related to the previous index
$previousThread = Delegation::getThreadInfo($item['APP_NUMBER'], $item['DEL_PREVIOUS']);
$userInfo = !empty($previousThread) ? User::getInformation($previousThread['USR_ID']) : [];
$userInfo = [];
$dummyInfo = [];
if (!empty($previousThread)) {
// When the task has an user
$userInfo = ($previousThread['USR_ID'] !== 0) ? User::getInformation($previousThread['USR_ID']) : [];
// When the task does not have users refers to dummy task
$taskInfo = ($previousThread['USR_ID'] === 0) ? Task::title($previousThread['TAS_ID']) : [];
if (!empty($taskInfo)) {
$dummyInfo = [
'task_id' => $previousThread['TAS_ID'],
'name' => $taskInfo['title'],
'type' => $taskInfo['type']
];
}
}
$result = [];
$result['del_previous'] = $item['DEL_PREVIOUS'];
$result['key_name'] = !empty($userInfo) ? 'user_tooltip' : 'dummy_task';
$result['user_tooltip'] = $userInfo;
$result['dummy_task'] = $dummyInfo;
$item['SEND_BY_INFO'] = $result;
return $item;
@@ -195,6 +219,11 @@ class Paused extends AbstractCases
$query = Delegation::query()->select();
// Scope that set the paused cases
$query->paused($this->getUserId());
// Check if the category was defined
if ($this->getCategoryId()) {
// Join with process if the filter with category exist
$query->joinProcess();
}
// Apply filters
$this->filters($query);
// Return the number of rows
@@ -240,4 +269,16 @@ class Paused extends AbstractCases
'total' => $count
];
}
/**
* Count how many cases there are in PAUSED
*
* @return int
*/
public function getCounterMetrics()
{
$query = Delegation::query()->select();
$query->pausedMetrics();
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
}

View File

@@ -7,8 +7,7 @@ use ProcessMaker\Model\Application;
use ProcessMaker\Model\AppNotes;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\User;
use ProcessMaker\Model\ProcessCategory;
class Search extends AbstractCases
{
@@ -17,6 +16,7 @@ class Search extends AbstractCases
// Columns view in the cases list
'APPLICATION.APP_NUMBER', // Case #
'APPLICATION.APP_TITLE AS DEL_TITLE', // Case Title
'PROCESS.CATEGORY_ID', // Category
'PROCESS.PRO_TITLE', // Process
'APPLICATION.APP_STATUS', // Status
'APPLICATION.APP_CREATE_DATE', // Case create date
@@ -156,6 +156,9 @@ class Search extends AbstractCases
$results = $query->get();
// Prepare the result
$results->transform(function ($item, $key) {
// Get the category
$category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : '';
$item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY');
// Apply the date format defined in environment
$item['APP_CREATE_DATE_LABEL'] = !empty($item['APP_CREATE_DATE']) ? applyMaskDateEnvironment($item['APP_CREATE_DATE']): null;
$item['APP_FINISH_DATE_LABEL'] = !empty($item['APP_FINISH_DATE']) ? applyMaskDateEnvironment($item['APP_FINISH_DATE']): null;

View File

@@ -2,9 +2,11 @@
namespace ProcessMaker\BusinessModel\Cases;
use G;
use ProcessMaker\Model\AppNotes;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\ProcessUser;
use ProcessMaker\Model\ProcessCategory;
use ProcessMaker\Model\User;
class Supervising extends AbstractCases
@@ -14,6 +16,7 @@ class Supervising extends AbstractCases
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.CATEGORY_ID', // Category
'PROCESS.PRO_TITLE', // Process Name
'TASK.TAS_TITLE', // Pending Task
'APPLICATION.APP_STATUS', // Status
@@ -66,10 +69,14 @@ class Supervising extends AbstractCases
// Specific case title
if (!empty($this->getCaseTitle())) {
// Get the result
$result = Delegation::casesThreadTitle($this->getCaseTitle(), $this->getOffset(), $this->getLimit());
$result = Delegation::casesThreadTitle($this->getCaseTitle());
// Add the filter
$query->specificCases($result);
}
// Specific category
if ($this->getCategoryId()) {
$query->categoryId($this->getCategoryId());
}
// Scope to search for an specific process
if ($this->getProcessId()) {
$query->processId($this->getProcessId());
@@ -144,6 +151,9 @@ class Supervising extends AbstractCases
$results = $query->get();
// Prepare the result
$results->transform(function ($item, $key) {
// Get the category
$category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : '';
$item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY');
// Get task color label
$item['TAS_COLOR'] = $this->getTaskColor($item['DEL_TASK_DUE_DATE']);
$item['TAS_COLOR_LABEL'] = self::TASK_COLORS[$item['TAS_COLOR']];
@@ -243,6 +253,11 @@ class Supervising extends AbstractCases
$processes = ProcessUser::getProcessesOfSupervisor($this->getUserUid());
// Scope the specific array of processes supervising
$query->processInList($processes);
// Check if the category was defined
if ($this->getCategoryId()) {
// Join with process if the filter with category exist
$query->joinProcess();
}
// Apply filters
$this->filters($query);
// Return the number of rows

View File

@@ -6,6 +6,8 @@ use G;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\ProcessCategory;
use ProcessMaker\Model\User;
class Unassigned extends AbstractCases
@@ -15,6 +17,7 @@ class Unassigned extends AbstractCases
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.CATEGORY_ID', // Category
'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task
'USERS.USR_USERNAME', // Current UserName
@@ -69,6 +72,10 @@ class Unassigned extends AbstractCases
if ($this->getCaseTitle()) {
$query->title($this->getCaseTitle());
}
// Specific category
if ($this->getCategoryId()) {
$query->categoryId($this->getCategoryId());
}
// Specific process
if ($this->getProcessId()) {
$query->processId($this->getProcessId());
@@ -90,8 +97,7 @@ class Unassigned extends AbstractCases
if (!empty($this->getDelegateTo())) {
$query->delegateDateTo($this->getDelegateTo());
}
// Specific usrId represented by sendBy.
// Specific usrId represented by sendBy
if (!empty($this->getSendBy())) {
$query->sendBy($this->getSendBy());
}
@@ -134,6 +140,9 @@ class Unassigned extends AbstractCases
$results = $query->get();
// Prepare the result
$results->transform(function ($item, $key) {
// Get the category
$category = !empty($item['CATEGORY_ID']) ? ProcessCategory::getCategory($item['CATEGORY_ID']) : '';
$item['CATEGORY'] = !empty($category) ? $category : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY');
// Get priority label
$priorityLabel = self::PRIORITIES[$item['DEL_PRIORITY']];
$item['DEL_PRIORITY_LABEL'] = G::LoadTranslation("ID_PRIORITY_{$priorityLabel}");
@@ -149,10 +158,26 @@ class Unassigned extends AbstractCases
$item['DEL_DELEGATE_DATE_LABEL'] = applyMaskDateEnvironment($item['DEL_DELEGATE_DATE']);
// Get the send by related to the previous index
$previousThread = Delegation::getThreadInfo($item['APP_NUMBER'], $item['DEL_PREVIOUS']);
$userInfo = !empty($previousThread) ? User::getInformation($previousThread['USR_ID']) : [];
$userInfo = [];
$dummyInfo = [];
if (!empty($previousThread)) {
// When the task has an user
$userInfo = ($previousThread['USR_ID'] !== 0) ? User::getInformation($previousThread['USR_ID']) : [];
// When the task does not have users refers to dummy task
$taskInfo = ($previousThread['USR_ID'] === 0) ? Task::title($previousThread['TAS_ID']) : [];
if (!empty($taskInfo)) {
$dummyInfo = [
'task_id' => $previousThread['TAS_ID'],
'name' => $taskInfo['title'],
'type' => $taskInfo['type']
];
}
}
$result = [];
$result['del_previous'] = $item['DEL_PREVIOUS'];
$result['key_name'] = !empty($userInfo) ? 'user_tooltip' : 'dummy_task';
$result['user_tooltip'] = $userInfo;
$result['dummy_task'] = $dummyInfo;
$item['SEND_BY_INFO'] = $result;
return $item;
@@ -203,6 +228,11 @@ class Unassigned extends AbstractCases
$query = Delegation::query()->select();
// Add the initial scope for self-service cases
$query->selfService($this->getUserUid());
// Check if the category was defined
if ($this->getCategoryId()) {
// Join with process if the filter with category exist
$query->joinProcess();
}
// Apply filters
$this->filters($query);
// Return the number of rows
@@ -248,4 +278,16 @@ class Unassigned extends AbstractCases
'total' => $count
];
}
/**
* Count how many cases there are in SELF_SERVICE
*
* @return int
*/
public function getCounterMetrics()
{
$query = Delegation::query()->select();
$query->selfServiceMetrics();
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
}

View File

@@ -874,8 +874,8 @@ class Light
session_start();
session_regenerate_id();
setcookie("workspaceSkin", SYS_SKIN, time() + (24 * 60 * 60), "/sys" . config("system.workspace"), null, false,
true);
$cookieOptions = Bootstrap::buildCookieOptions(['expires' => time() + (24 * 60 * 60), 'path' => '/sys' . config('system.workspace'), 'httponly' => true]);
setcookie('workspaceSkin', SYS_SKIN, $cookieOptions);
if (strlen($msg) > 0) {
$_SESSION['G_MESSAGE'] = $msg;

View File

@@ -138,7 +138,7 @@ class ChangeLogResult
$totalCount = 0;
$values = [];
$this->getLogsFromDataBase($this->appUid, function($row) use(&$logs, &$totalCount, &$values) {
$this->getLogsFromDataBase($this->appUid, function ($row) use (&$logs, &$totalCount, &$values) {
$appData = $this->getAppData($row['DATA']);
$this->removeVariables($appData);
@@ -146,22 +146,52 @@ class ChangeLogResult
if ((int) $row['SOURCE_ID'] === ChangeLog::FromABE) {
$hasPermission = true;
}
if (in_array((int) $row['EXECUTED_AT'], [ChangeLog::BEFORE_ASSIGNMENT, ChangeLog::BEFORE_ROUTING, ChangeLog::AFTER_ROUTING])) {
$hasPermission = true;
}
$count = 0;
foreach ($appData as $key => $value) {
if ($hasPermission && (!isset($values[$key]) || $values[$key] !== $value)) {
// Apply mask
$dateLabel = applyMaskDateEnvironment($row['DATE'],'', false);
$dateLabel = applyMaskDateEnvironment($row['DATE'], '', false);
// Apply the timezone
$dateLabel = DateTime::convertUtcToTimeZone($dateLabel);
$previousValue = !isset($values[$key]) ? null : $values[$key];
//get 'title' label
$objectTitle = '';
if ((int) $row['OBJECT_TYPE'] === ChangeLog::DYNAFORM) {
$objectTitle = G::LoadTranslation('ID_DYNAFORM') . ': ' . $row['DYN_TITLE'];
}
if ((int) $row['OBJECT_TYPE'] === ChangeLog::TRIGGER) {
if ((int) $row['EXECUTED_AT'] === ChangeLog::BEFORE_ASSIGNMENT) {
$objectTitle = G::LoadTranslation('ID_BEFORE_ASSIGNMENT');
}
if ((int) $row['EXECUTED_AT'] === ChangeLog::BEFORE_ROUTING) {
$objectTitle = G::LoadTranslation('ID_BEFORE_DERIVATION');
}
if ((int) $row['EXECUTED_AT'] === ChangeLog::AFTER_ROUTING) {
$objectTitle = G::LoadTranslation('ID_AFTER_DERIVATION');
}
}
//get 'from' label
$from = ChangeLog::getChangeLog()->getApplicationNameById($row['SOURCE_ID']);
if ((int) $row['SOURCE_ID'] === ChangeLog::FromUnknow) {
if ((int) $row['EXECUTED_AT'] === ChangeLog::BEFORE_ROUTING ||
(int) $row['EXECUTED_AT'] === ChangeLog::AFTER_ROUTING) {
$from = ChangeLog::getChangeLog()->getApplicationNameById(ChangeLog::FromWeb);
}
}
$record = ''
. G::LoadTranslation('ID_TASK') . ': ' . $row['TAS_TITLE'] . ' / '
. G::LoadTranslation('ID_DYNAFORM') . ': ' . $row['DYN_TITLE'] . ' / '
. $objectTitle . ' / '
. G::LoadTranslation('ID_LAN_UPDATE_DATE') . ': ' . $dateLabel . ' / '
. G::LoadTranslation('ID_USER') . ': ' . $row['USR_USERNAME'] . ' / '
. G::LoadTranslation('ID_FROM') . ': ' . ChangeLog::getChangeLog()->getApplicationNameById($row['SOURCE_ID']);
. G::LoadTranslation('ID_FROM') . ': ' . $from;
$struct = new LogStruct();
$struct->setField($key)
@@ -210,6 +240,7 @@ class ChangeLogResult
. "A.USR_ID, "
. "A.OBJECT_ID, "
. "A.OBJECT_UID, "
. "A.OBJECT_TYPE, "
. "A.EXECUTED_AT, "
. "A.SOURCE_ID, "
. "A.DATA, "
@@ -220,8 +251,8 @@ class ChangeLogResult
. "LEFT JOIN PROCESS AS C ON (C.PRO_ID=A.PRO_ID) "
. "LEFT JOIN TASK AS D ON (D.TAS_ID=A.TAS_ID) "
. "LEFT JOIN USERS AS E ON (E.USR_ID=A.USR_ID) "
. "LEFT JOIN DYNAFORM AS F ON (F.DYN_ID=A.OBJECT_ID AND A.OBJECT_TYPE=" . ChangeLog::DYNAFORM . ") "
. "ORDER BY A.DATE ASC ";
. "LEFT JOIN DYNAFORM AS F ON (F.DYN_ID=A.OBJECT_ID AND A.OBJECT_TYPE IN (" . ChangeLog::DYNAFORM . ", " . ChangeLog::TRIGGER . ")) "
. "ORDER BY A.CHANGE_LOG_ID,A.DATE ASC ";
$stmt = $conn->prepareStatement($sql);
$stmt->set(1, $appUid);

View File

@@ -86,6 +86,21 @@ class System
'disable_task_manager_routing_async' => '0',
'on_one_server_enable' => 0,
'at_risk_delegation_max_time' => '0.2',
'samesite_cookie_setting' => ''
];
public static $cookieDefaultOptions = [
'expires' => 0,
'path' => '/',
'domain' => '',
'secure' => false,
'httponly' => true,
'samesite' => ''
];
public static $cookieSameSiteValues = [
'Lax',
'Strict'
];
/**
@@ -1252,6 +1267,13 @@ class System
$config['at_risk_delegation_max_time'] = self::$defaultConfig['at_risk_delegation_max_time'];
}
$value = ucfirst(strtolower($config['samesite_cookie_setting']));
if (in_array($value, self::$cookieSameSiteValues)) {
$config['samesite_cookie_setting'] = $value;
} else {
$config['samesite_cookie_setting'] = '';
}
return $config;
}
@@ -1778,4 +1800,29 @@ class System
$parseDsn["pass"] = urldecode($parseDsn["pass"]);
return $parseDsn;
}
/**
* Build the options for a cookie, according to the system configuration and values optionally sent to this method
*
* @param array $options
* @return array
*/
public static function buildCookieOptions(array $options = [])
{
// Get system values
$cookieOptions = self::$cookieDefaultOptions;
$systemConfiguration = self::getSystemConfiguration();
// Always set "secure" option according to the server protocol
$cookieOptions['secure'] = G::is_https();
// Set the "samesite" option according to the system configuration
$cookieOptions['samesite'] = $systemConfiguration['samesite_cookie_setting'];
// Overrides the cookie options with the values sent to the method
$cookieOptions = array_merge($cookieOptions, $options);
// Return the cookie options
return $cookieOptions;
}
}

View File

@@ -222,7 +222,7 @@ abstract class Importer
foreach ($objectList as $rowObject) {
if ($rowObject['name'] === 'PROCESSDEFINITION') {
$onlyDiagram = true;
$this->removeProject($onlyDiagram);
$this->removeProject($onlyDiagram, $objectsToImport);
}
}
} catch (\Exception $e) {
@@ -453,7 +453,14 @@ abstract class Importer
$project->setDisabled();
}
public function removeProject($onlyDiagram = false)
/**
* Remove the project
*
* @param bool $onlyDiagram
* @param array $objectsToImport
* @return void
*/
public function removeProject($onlyDiagram = false, $objectsToImport = [])
{
/* @var $process \Process */
$processes = new \Processes();
@@ -464,7 +471,7 @@ abstract class Importer
$process->load($this->metadata["uid"]);
$this->currentProcessTitle = $process->getProTitle();
$project = \ProcessMaker\Project\Adapter\BpmnWorkflow::load($this->metadata["uid"]);
$project->remove(true, false, $onlyDiagram);
$project->remove(true, false, $onlyDiagram, $objectsToImport);
}
/**

View File

@@ -381,6 +381,15 @@ class CaseList extends Model
'typeSearch' => 'search text',
'enableFilter' => false,
'set' => true
], [
'list' => ['inbox', 'draft', 'paused', 'unassigned'],
'field' => 'process_category',
'name' => G::LoadTranslation('ID_PROCESS_CATEGORY'),
'type' => 'string',
'source' => 'APPLICATION',
'typeSearch' => 'search text',
'enableFilter' => false,
'set' => true
], [
'list' => ['inbox', 'draft', 'paused', 'unassigned'],
'field' => 'process_name',

View File

@@ -1069,6 +1069,64 @@ class Delegation extends Model
return $query;
}
/**
* Scope the Inbox cases no matter the user
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeInboxMetrics($query)
{
$query->joinApplication();
$query->status(Application::STATUS_TODO);
$query->threadOpen();
return $query;
}
/**
* Scope a draft cases no matter the user
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeDraftMetrics($query)
{
$query->joinApplication();
$query->status(Application::STATUS_DRAFT);
$query->threadOpen();
return $query;
}
/**
* Scope paused cases list no matter the user
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopePausedMetrics($query)
{
$query->joinAppDelay('PAUSE');
$query->joinApplication();
return $query;
}
/**
* Scope a self service cases no matter the user
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeSelfServiceMetrics($query)
{
$query->taskAssignType('SELF_SERVICE');
$query->threadOpen()->withoutUserId();
return $query;
}
/**
* Get specific cases unassigned that the user can view
*
@@ -2123,12 +2181,10 @@ class Delegation extends Model
* Get cases filter by thread title
*
* @param string $search
* @param int $offset
* @param int $limit
*
* @return array
*/
public static function casesThreadTitle(string $search, int $offset = 0, int $limit = 15)
public static function casesThreadTitle(string $search)
{
// Get the case numbers related to this filter
$query = Delegation::query()->select(['APP_NUMBER']);
@@ -2136,8 +2192,6 @@ class Delegation extends Model
$query->title($search);
// Group by
$query->groupBy('APP_NUMBER');
// Apply the limit
$query->offset($offset)->limit($limit);
// Get the result
$results = $query->get();

View File

@@ -5,6 +5,11 @@ namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
use ListUnassigned as PropelListUnassigned;
/**
* Class ListUnassigned
*
* @deprecated Class deprecated in Release 3.6.0
*/
class ListUnassigned extends Model
{
protected $table = "LIST_UNASSIGNED";

View File

@@ -78,6 +78,7 @@ class Process extends Model
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $proUid
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeProcess($query, $proUid)
@@ -90,6 +91,7 @@ class Process extends Model
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $title
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTitle($query, $title)
@@ -102,6 +104,7 @@ class Process extends Model
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $status
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeNoStatus($query, $status = 'DISABLED')
@@ -120,6 +123,19 @@ class Process extends Model
return $query->where('PRO_SUBPROCESS', '=', 1);
}
/**
* Scope a query to include a specific process categoryId
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $category
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCategoryId($query, $category)
{
return $query->where('PROCESS.CATEGORY_ID', $category);
}
/**
* Scope a query to include a specific process category
*
@@ -407,14 +423,14 @@ class Process extends Model
* Get all processes, paged optionally, can be sent a string to filter results by "PRO_TITLE"
*
* @param string $text
* @param string $category
* @param int $catId
* @param int $offset
* @param int $limit
* @param bool $paged
*
* @return array
*/
public static function getProcessesForHome($text = null, $category = null, $offset = null, $limit = null, $paged = true)
public static function getProcessesForHome($text = null, $catId = 0, $offset = null, $limit = null, $paged = true)
{
// Get base query
$query = Process::query()->select(['PRO_ID', 'PRO_TITLE']);
@@ -424,9 +440,9 @@ class Process extends Model
$query->title($text);
}
// Set "PRO_CATEGORY" condition if is sent
if (!is_null($category)) {
$query->category($category);
// Set "CATEGORY_ID" condition if is sent
if ($catId) {
$query->categoryId($catId);
}
// Set "PRO_STATUS" condition
@@ -452,6 +468,7 @@ class Process extends Model
* Return true if process is active, false otherwise.
* @param int|string $proId
* @param string $key
*
* @return bool
*/
public static function isActive($proId, string $key = 'PRO_ID'): bool

View File

@@ -17,6 +17,18 @@ class ProcessCategory extends Model
public $timestamps = false;
/**
* Scope a query to specific category id
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $category
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCategory($query, $category)
{
return $query->where('CATEGORY_ID', $category);
}
/**
* Scope a query to specific category name
*
@@ -92,4 +104,22 @@ class ProcessCategory extends Model
return $query->first()->CATEGORY_ID;
}
}
/**
* Get category name
*
* @param int $category
*
* @return string
*/
public static function getCategory(int $category)
{
$query = ProcessCategory::query()->select(['CATEGORY_NAME']);
$query->category($category);
if ($query->first()) {
return $query->first()->CATEGORY_NAME;
} else {
return '';
}
}
}

View File

@@ -120,16 +120,18 @@ class Task extends Model
*
* @param integer $tasId
*
* @return string
* @return array
*/
public function title($tasId)
public static function title($tasId)
{
$query = Task::query()->select('TAS_TITLE');
$query = Task::query()->select('TAS_TITLE', 'TAS_TYPE');
$query->where('TAS_ID', $tasId);
$results = $query->get();
$title = '';
$results->each(function ($item, $key) use (&$title) {
$type = '';
$results->each(function ($item, $key) use (&$title, &$type) {
$title = $item->TAS_TITLE;
$type = $item->TAS_TYPE;
switch ($title) {
case "INTERMEDIATE-THROW-EMAIL-EVENT":
$title = G::LoadTranslation('ID_INTERMEDIATE_THROW_EMAIL_EVENT');
@@ -143,10 +145,41 @@ class Task extends Model
case "INTERMEDIATE-CATCH-TIMER-EVENT":
$title = G::LoadTranslation('ID_INTERMEDIATE_CATCH_TIMER_EVENT');
break;
case "SCRIPT-TASK":
$title = G::LoadTranslation('ID_SCRIPT_TASK_UNTITLED');
break;
case "SERVICE-TASK":
$title = G::LoadTranslation('ID_SERVICE_TASK_UNTITLED');
break;
default:
$title = G::LoadTranslation('ID_ANONYMOUS');
}
switch ($type) {
case "INTERMEDIATE-THROW-EMAIL-EVENT":
$type = G::LoadTranslation('ID_EMAIL_EVENT');
break;
case "INTERMEDIATE-THROW-MESSAGE-EVENT":
case "INTERMEDIATE-CATCH-MESSAGE-EVENT":
$type = G::LoadTranslation('ID_MESSAGE_EVENT');
break;
case "INTERMEDIATE-CATCH-TIMER-EVENT":
$type = G::LoadTranslation('ID_TIMER_EVENT');
break;
case "SCRIPT-TASK":
$type = G::LoadTranslation('ID_SCRIPT_TASK');
break;
case "SERVICE-TASK":
$type = G::LoadTranslation('ID_SERVICE_TASK');
break;
default:
$type = G::LoadTranslation('ID_NONE');
}
});
return $title;
return [
'title' => $title,
'type' => $type,
];
}
/**

View File

@@ -1248,10 +1248,19 @@ class BpmnWorkflow extends Project\Bpmn
}
}
public function remove($flagForceRemoveProject = false, $flagRemoveCases = true, $onlyDiagram = false)
/**
* Remove Project
*
* @param bool $flagForceRemoveProject
* @param bool $flagRemoveCases
* @param bool $onlyDiagram
* @param array $objectsToImport
* @return void
*/
public function remove($flagForceRemoveProject = false, $flagRemoveCases = true, $onlyDiagram = false, $objectsToImport = [])
{
parent::remove($flagForceRemoveProject);
$this->wp->remove($flagRemoveCases, $onlyDiagram);
$this->wp->remove($flagRemoveCases, $onlyDiagram, $objectsToImport);
}
public static function createFromStruct(array $projectData, $generateUid = true, $allData = null)

View File

@@ -87,9 +87,15 @@ class WorkflowBpmn extends Project\Workflow
return parent::getList($start, $limit, $filter, $changeCaseTo);
}
public function remove($flagRemoveCases = true, $onlyDiagram = false)
/**
* Remove project bpmn.
* @param bool $flagRemoveCases
* @param bool $onlyDiagram
* @param array $objectsToImport
*/
public function remove($flagRemoveCases = true, $onlyDiagram = false, $objectsToImport = [])
{
parent::remove($flagRemoveCases, $onlyDiagram);
parent::remove($flagRemoveCases, $onlyDiagram, $objectsToImport);
$this->bp->remove();
}

View File

@@ -2,20 +2,21 @@
namespace ProcessMaker\Project;
use Criteria;
use ProcessMaker\Plugins\PluginRegistry;
use ResultSet;
use ObjectPermissionPeer;
use Process as ClassesProcess;
use Tasks;
use Task as ClassesTask;
use ProcessMaker\Exception;
use ProcessMaker\Model\ProcessCategory;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Util;
use ProcessMaker\Util\Common;
use ProcessUserPeer;
use ReportTables;
use ResultSet;
use Route;
use RoutePeer;
use ProcessMaker\Model\ProcessCategory;
use ProcessMaker\Util\Common;
use ProcessMaker\Exception;
use ProcessMaker\Util;
use ReportTables;
use StepSupervisorPeer;
use Tasks;
use Task as ClassesTask;
/**
* Class Workflow
@@ -115,11 +116,20 @@ class Workflow extends Handler
$process->update($data);
}
public function remove($flagRemoveCases = true, $onlyDiagram = false)
/**
* Remove project
*
* @param bool $flagRemoveCases
* @param bool $onlyDiagram
* @param array $objectsToImport
* @return void
* @throws \Exception
*/
public function remove($flagRemoveCases = true, $onlyDiagram = false, $objectsToImport = [])
{
try {
self::log("Remove Process with uid: {$this->proUid}");
$this->deleteProcess($this->proUid, $flagRemoveCases, $onlyDiagram);
$this->deleteProcess($this->proUid, $flagRemoveCases, $onlyDiagram, $objectsToImport);
self::log("Remove Process Success!");
} catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
@@ -579,7 +589,17 @@ class Workflow extends Handler
}
}
public function deleteProcess($sProcessUID, $flagRemoveCases = true, $onlyDiagram = false)
/**
* Delete process
*
* @param string $sProcessUID
* @param bool $flagRemoveCases
* @param bool $onlyDiagram
* @param array $objectsToImport
* @return bool
* @throws \Exception
*/
public function deleteProcess($sProcessUID, $flagRemoveCases = true, $onlyDiagram = false, $objectsToImport = [])
{
try {
@@ -761,18 +781,24 @@ class Workflow extends Handler
$oDataset->next();
}
}
//Delete the supervisors
$oCriteria = new Criteria('workflow');
$oCriteria->add(\ProcessUserPeer::PRO_UID, $sProcessUID);
\ProcessUserPeer::doDelete($oCriteria);
//Delete the object permissions
$oCriteria = new Criteria('workflow');
$oCriteria->add(\ObjectPermissionPeer::PRO_UID, $sProcessUID);
\ObjectPermissionPeer::doDelete($oCriteria);
//Delete the step supervisors
$oCriteria = new Criteria('workflow');
$oCriteria->add(\StepSupervisorPeer::PRO_UID, $sProcessUID);
\StepSupervisorPeer::doDelete($oCriteria);
if (array_search('SUPERVISORS', array_column($objectsToImport, 'id')) !== false || empty($objectsToImport)) {
//Delete the supervisors
$oCriteria = new Criteria('workflow');
$oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
ProcessUserPeer::doDelete($oCriteria);
}
if (array_search('PERMISSIONS', array_column($objectsToImport, 'id')) !== false || empty($objectsToImport)) {
//Delete the object permissions
$oCriteria = new Criteria('workflow');
$oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID);
ObjectPermissionPeer::doDelete($oCriteria);
}
if (array_search('SUPERVISORSOBJECTS', array_column($objectsToImport, 'id')) !== false || empty($objectsToImport)) {
//Delete the step supervisors
$oCriteria = new Criteria('workflow');
$oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
StepSupervisorPeer::doDelete($oCriteria);
}
//Delete the report tables
$oCriteria = new Criteria('workflow');
$oCriteria->add(\ReportTablePeer::PRO_UID, $sProcessUID);

View File

@@ -51,6 +51,7 @@ class Home extends Api
* @url GET /draft
*
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -68,6 +69,7 @@ class Home extends Api
*/
public function doGetDraftCases(
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -81,6 +83,7 @@ class Home extends Api
$bmHome = new BMHome($this->getUserId());
return $bmHome->getDraft(
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -101,6 +104,7 @@ class Home extends Api
* @url GET /todo [This is kept for compatibility should not be used 'todo', the reason is to only handle the same verb (inbox) for all 'normal case list' and 'custom case list']
*
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -121,6 +125,7 @@ class Home extends Api
*/
public function doGetTodoCases(
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -137,6 +142,7 @@ class Home extends Api
$bmHome = new BMHome($this->getUserId());
return $bmHome->getInbox(
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -159,6 +165,7 @@ class Home extends Api
* @url GET /unassigned
*
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -179,6 +186,7 @@ class Home extends Api
*/
public function doGetUnassignedCases(
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -195,6 +203,7 @@ class Home extends Api
$bmHome = new BMHome($this->getUserId());
return $bmHome->getUnassigned(
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -217,6 +226,7 @@ class Home extends Api
* @url GET /paused
*
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -237,6 +247,7 @@ class Home extends Api
*/
public function doGetPausedCases(
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -253,6 +264,7 @@ class Home extends Api
$bmHome = new BMHome($this->getUserId());
return $bmHome->getPaused(
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -274,6 +286,7 @@ class Home extends Api
* @url POST /draft/:id
* @param int $id
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -290,6 +303,7 @@ class Home extends Api
public function doGetCustomDraftCases(
int $id,
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -305,6 +319,7 @@ class Home extends Api
return $bmHome->getCustomDraft(
$id,
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -324,6 +339,7 @@ class Home extends Api
* @url POST /inbox/:id
* @param int $id
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -343,6 +359,7 @@ class Home extends Api
public function doGetCustomInboxCases(
int $id,
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -361,6 +378,7 @@ class Home extends Api
return $bmHome->getCustomInbox(
$id,
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -383,6 +401,7 @@ class Home extends Api
* @url POST /unassigned/:id
* @param int $id
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -402,6 +421,7 @@ class Home extends Api
public function doGetCustomUnassignedCases(
int $id,
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -420,6 +440,7 @@ class Home extends Api
return $bmHome->getCustomUnassigned(
$id,
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -442,6 +463,7 @@ class Home extends Api
* @url POST /paused/:id
* @param int $id
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -461,6 +483,7 @@ class Home extends Api
public function doGetCustomPausedCases(
int $id,
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -479,6 +502,7 @@ class Home extends Api
return $bmHome->getCustomPaused(
$id,
$caseNumber,
$category,
$process,
$task,
$limit,
@@ -502,6 +526,7 @@ class Home extends Api
* @url GET /mycases
*
* @param int $caseNumber
* @param int $category
* @param int $process
* @param int $task
* @param int $limit
@@ -525,6 +550,7 @@ class Home extends Api
*/
public function doGetMyCases(
int $caseNumber = 0,
int $category = 0,
int $process = 0,
int $task = 0,
int $limit = 15,
@@ -544,6 +570,7 @@ class Home extends Api
$properties['caseNumber'] = $caseNumber;
$properties['caseTitle'] = $caseTitle;
$properties['filterCases'] = $filterCases;
$properties['category'] = $category;
$properties['process'] = $process;
$properties['task'] = $task;
// Get the user that access to the API
@@ -862,7 +889,7 @@ class Home extends Api
* @url GET /processes
*
* @param string $text
* @param string $category
* @param int $category
* @param int $offset
* @param int $limit
* @param bool $paged
@@ -874,7 +901,7 @@ class Home extends Api
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
public function getProcesses($text = null, $category = null, int $offset = 0, int $limit = 15, $paged = true)
public function getProcesses($text = null, $category = 0, int $offset = 0, int $limit = 15, $paged = true)
{
try {
return Process::getProcessesForHome($text, $category, $offset, $limit, $paged);

View File

@@ -3,11 +3,11 @@
namespace ProcessMaker\Services\Api;
use Exception;
use Luracast\Restler\RestException;
use ProcessMaker\BusinessModel\Cases\Draft;
use ProcessMaker\BusinessModel\Cases\Inbox;
use ProcessMaker\BusinessModel\Cases\Paused;
use ProcessMaker\BusinessModel\Cases\Unassigned;
use ProcessMaker\Model\User;
use ProcessMaker\Services\Api;
use RBAC;
@@ -46,8 +46,6 @@ class Metrics extends Api
*/
public function getProcessTotalCases($caseList, $category = null, $topTen = false, $processes = [])
{
$usrUid = $this->getUserId();
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
try {
switch ($caseList) {
case 'inbox':
@@ -61,10 +59,8 @@ class Metrics extends Api
break;
case 'unassigned':
$list = new Unassigned();
$list->setUserUid($usrUid);
break;
}
$list->setUserId($usrId);
$result = $list->getCountersByProcesses($category, $topTen, $processes);
return $result;
} catch (Exception $e) {
@@ -91,8 +87,6 @@ class Metrics extends Api
*/
public function getTotalCasesByRange($caseList, $processId = null, $dateFrom = null, $dateTo = null, $groupBy = 'day')
{
$usrUid = $this->getUserId();
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
try {
switch ($caseList) {
case 'inbox':
@@ -106,10 +100,8 @@ class Metrics extends Api
break;
case 'unassigned':
$list = new Unassigned();
$list->setUserUid($usrUid);
break;
}
$list->setUserId($usrId);
$result = $list->getCountersByRange($processId, $dateFrom, $dateTo, $groupBy);
return $result;
} catch (Exception $e) {
@@ -125,31 +117,21 @@ class Metrics extends Api
* @return array
*
* @throws RestException
*
* @class AccessControl {@permission TASK_METRICS_VIEW}
*/
public function getCountersList()
{
try {
$usrUid = $this->getUserId();
$properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0;
$listInbox = new Inbox();
$listInbox->setProperties($properties);
$listDraft = new Draft();
$listDraft->setUserUid($usrUid);
$listDraft->setProperties($properties);
$listPaused = new Paused();
$listPaused->setProperties($properties);
$listUnassigned = new Unassigned();
$listUnassigned->setUserUid($usrUid);
$listUnassigned->setProperties($properties);
$casesInbox = $listInbox->getCounter();
$casesDraft = $listDraft->getCounter();
$casesPaused = $listPaused->getCounter();
$casesUnassigned = $listUnassigned->getCounter();
$casesInbox = $listInbox->getCounterMetrics();
$casesDraft = $listDraft->getCounterMetrics();
$casesPaused = $listPaused->getCounterMetrics();
$casesUnassigned = $listUnassigned->getCounterMetrics();
$result = [
['List Name' => 'Inbox', 'Total' => $casesInbox, 'Color' => 'green'],
@@ -179,12 +161,12 @@ class Metrics extends Api
* @return array
*
* @throws RestException
*
* @class AccessControl {@permission TASK_METRICS_VIEW}
*/
public function getCasesRiskByProcess($caseList = 'inbox', $process, $dateFrom = null, $dateTo = null, $riskStatus = 'ON_TIME', $topCases = null)
{
try {
$usrUid = $this->getUserId();
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
switch ($caseList) {
case 'inbox':
$list = new Inbox();
@@ -197,10 +179,8 @@ class Metrics extends Api
break;
case 'unassigned':
$list = new Unassigned();
$list->setUserUid($usrUid);
break;
}
$list->setUserId($usrId);
$result = $list->getCasesRisk($process, $dateFrom, $dateTo, $riskStatus, $topCases);
return $result;
} catch (Exception $e) {

View File

@@ -1,6 +1,7 @@
<?php
namespace ProcessMaker\Services\OAuth2;
use Bootstrap;
use Luracast\Restler\iAuthenticate;
use Luracast\Restler\RestException;
use OAuth2\Request;
@@ -367,7 +368,8 @@ class Server implements iAuthenticate
$lifetime = 1440;
}
setcookie($session->getSessionName(), $_COOKIE[$session->getSessionName()], time() + $lifetime, "/", null, false, true);
$cookieOptions = Bootstrap::buildCookieOptions(['expires' => time() + $lifetime, 'secure' => false, 'httponly' => true]);
setcookie($session->getSessionName(), $_COOKIE[$session->getSessionName()], $cookieOptions);
}
}