Merged in bugfix/PMCORE-3087 (pull request #7987)
PMCORE-3087 Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
@@ -58,6 +58,12 @@ class AbstractCases implements CasesInterface
|
||||
// Filter by user using the Id field
|
||||
private $userId = 0;
|
||||
|
||||
// Filter by user who completed using the Id field
|
||||
private $userCompleted = 0;
|
||||
|
||||
// Filter by user who started using the Id field
|
||||
private $userStarted = 0;
|
||||
|
||||
// Value to search, can be a text or an application number, know as "$search" in the old lists classes
|
||||
private $valueToSearch = '';
|
||||
|
||||
@@ -282,6 +288,46 @@ class AbstractCases implements CasesInterface
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set User Id value
|
||||
*
|
||||
* @param int $userId
|
||||
*/
|
||||
public function setUserCompletedId(int $userId)
|
||||
{
|
||||
$this->userCompleted = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get User Id value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getUserCompletedId()
|
||||
{
|
||||
return $this->userCompleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set User Id value
|
||||
*
|
||||
* @param int $userId
|
||||
*/
|
||||
public function setUserStartedId(int $userId)
|
||||
{
|
||||
$this->userStarted = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get User Id value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getUserStartedId()
|
||||
{
|
||||
return $this->userStarted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value to search
|
||||
*
|
||||
@@ -1294,6 +1340,34 @@ class AbstractCases implements CasesInterface
|
||||
if (!empty($properties['caseTitle'])) {
|
||||
$this->setCaseTitle($properties['caseTitle']);
|
||||
}
|
||||
// Filter by case uid
|
||||
if (!empty($properties['caseLink'])) {
|
||||
$this->setCaseUid($properties['caseLink']);
|
||||
}
|
||||
// Filter by array of case uids
|
||||
if (!empty($properties['appUidCheck'])) {
|
||||
$this->setCasesUids($properties['appUidCheck']);
|
||||
}
|
||||
// Sort column
|
||||
if (!empty($properties['sort'])) {
|
||||
$this->setOrderByColumn($properties['sort']);
|
||||
}
|
||||
// Direction column
|
||||
if (!empty($properties['dir'])) {
|
||||
$this->setOrderDirection($properties['dir']);
|
||||
}
|
||||
// Paged
|
||||
if (!empty($properties['paged'])) {
|
||||
$this->setPaged($properties['paged']);
|
||||
}
|
||||
// Start
|
||||
if (!empty($properties['start'])) {
|
||||
$this->setOffset($properties['start']);
|
||||
}
|
||||
// Limit
|
||||
if (!empty($properties['limit'])) {
|
||||
$this->setLimit($properties['limit']);
|
||||
}
|
||||
/** Apply filters related to INBOX */
|
||||
// Filter date related to delegate from
|
||||
if (get_class($this) === Inbox::class && !empty($properties['delegateFrom'])) {
|
||||
@@ -1372,33 +1446,13 @@ class AbstractCases implements CasesInterface
|
||||
if (get_class($this) === Search::class && !empty($properties['finishCaseTo'])) {
|
||||
$this->setFinishCaseTo($properties['finishCaseTo']);
|
||||
}
|
||||
// Filter by case uid
|
||||
if (!empty($properties['caseLink'])) {
|
||||
$this->setCaseUid($properties['caseLink']);
|
||||
// Filter date related to user who started
|
||||
if (get_class($this) === Search::class && !empty($properties['userCompleted'])) {
|
||||
$this->setUserCompletedId($properties['userCompleted']);
|
||||
}
|
||||
// Filter by array of case uids
|
||||
if (!empty($properties['appUidCheck'])) {
|
||||
$this->setCasesUids($properties['appUidCheck']);
|
||||
}
|
||||
// Sort column
|
||||
if (!empty($properties['sort'])) {
|
||||
$this->setOrderByColumn($properties['sort']);
|
||||
}
|
||||
// Direction column
|
||||
if (!empty($properties['dir'])) {
|
||||
$this->setOrderDirection($properties['dir']);
|
||||
}
|
||||
// Paged
|
||||
if (!empty($properties['paged'])) {
|
||||
$this->setPaged($properties['paged']);
|
||||
}
|
||||
// Start
|
||||
if (!empty($properties['start'])) {
|
||||
$this->setOffset($properties['start']);
|
||||
}
|
||||
// Limit
|
||||
if (!empty($properties['limit'])) {
|
||||
$this->setLimit($properties['limit']);
|
||||
// Filter date related to user who completed
|
||||
if (get_class($this) === Search::class && !empty($properties['userStarted'])) {
|
||||
$this->setUserStartedId($properties['userStarted']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,18 @@ class Search extends AbstractCases
|
||||
// Get only the open threads related to the user
|
||||
$query->where('APP_DELEGATION.DEL_THREAD_STATUS', '=', 'OPEN');
|
||||
}
|
||||
// Filter by user who started
|
||||
if ($this->getUserStartedId()) {
|
||||
// Get the case numbers related to this filter
|
||||
$result = Delegation::casesStartedBy($this->getUserStartedId(), $this->getOffset(), $this->getLimit());
|
||||
$query->specificCases($result);
|
||||
}
|
||||
// Filter by user who completed
|
||||
if ($this->getUserCompletedId()) {
|
||||
// Get the case numbers related to this filter
|
||||
$result = Delegation::casesCompletedBy($this->getUserCompletedId(), $this->getOffset(), $this->getLimit());
|
||||
$query->specificCases($result);
|
||||
}
|
||||
// Filter by task
|
||||
if ($this->getTaskId()) {
|
||||
// Join with delegation
|
||||
|
||||
@@ -2051,4 +2051,54 @@ class Delegation extends Model
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cases completed by specific user
|
||||
*
|
||||
* @param int $userId
|
||||
* @param int $offset
|
||||
* @param int $limit
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function casesCompletedBy(int $userId, int $offset = 0, int $limit = 15)
|
||||
{
|
||||
// Get the case numbers related to this filter
|
||||
$query = Delegation::query()->select(['APP_NUMBER']);
|
||||
// Filter the user
|
||||
$query->participated($userId);
|
||||
// Filter the last thread
|
||||
$query->lastThread();
|
||||
// Apply the limit
|
||||
$query->offset($offset)->limit($limit);
|
||||
// Get the result
|
||||
$results = $query->get();
|
||||
|
||||
return $results->values()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cases started by specific user
|
||||
*
|
||||
* @param int $userId
|
||||
* @param int $offset
|
||||
* @param int $limit
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function casesStartedBy(int $userId, int $offset = 0, int $limit = 15)
|
||||
{
|
||||
// Get the case numbers related to this filter
|
||||
$query = Delegation::query()->select(['APP_NUMBER']);
|
||||
// Filter the user
|
||||
$query->participated($userId);
|
||||
// Filter the first thread
|
||||
$query->caseStarted();
|
||||
// Apply the limit
|
||||
$query->offset($offset)->limit($limit);
|
||||
// Get the result
|
||||
$results = $query->get();
|
||||
|
||||
return $results->values()->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,6 +464,8 @@ class Home extends Api
|
||||
* @param int $process
|
||||
* @param int $task
|
||||
* @param int $user
|
||||
* @param int $userCompleted
|
||||
* @param int $userStarted
|
||||
* @param string $caseTitle
|
||||
* @param string $caseStatuses
|
||||
* @param string $filterCases
|
||||
@@ -487,6 +489,8 @@ class Home extends Api
|
||||
int $process = 0,
|
||||
int $task = 0,
|
||||
int $user = 0,
|
||||
int $userCompleted = 0,
|
||||
int $userStarted = 0,
|
||||
string $caseTitle = '',
|
||||
string $caseStatuses = '',
|
||||
string $filterCases = '',
|
||||
@@ -507,6 +511,8 @@ class Home extends Api
|
||||
$properties['process'] = $process;
|
||||
$properties['task'] = $task;
|
||||
$properties['user'] = $user;
|
||||
$properties['userCompleted'] = $userCompleted;
|
||||
$properties['userStarted'] = $userStarted;
|
||||
$properties['caseStatuses'] = explode(',', $caseStatuses);
|
||||
$properties['filterCases'] = $filterCases;
|
||||
$properties['startCaseFrom'] = $startCaseFrom;
|
||||
|
||||
Reference in New Issue
Block a user