Merged in feature/PMCORE-2543 (pull request #7614)

PMCORE-2543

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Paula Quispe
2020-12-16 15:38:38 +00:00
committed by Julio Cesar Laura Avendaño
15 changed files with 696 additions and 65 deletions

View File

@@ -1256,4 +1256,14 @@ class AbstractCases implements CasesInterface
{
throw new Exception("Method '" . __FUNCTION__ . "' should be implemented in the extended class '" . get_class($this) . "'.");
}
/**
* Get the list counter
*
* @throws Exception
*/
public function getPagingCounters()
{
throw new Exception("Method '" . __FUNCTION__ . "' should be implemented in the extended class '" . get_class($this) . "'.");
}
}

View File

@@ -110,7 +110,7 @@ class Draft extends AbstractCases
}
/**
* Count the self-services cases by user
* Count how many cases the user has in DRAFT, does not apply filters
*
* @return int
*/
@@ -119,8 +119,23 @@ class Draft extends AbstractCases
$query = Delegation::query()->select();
// Add the initial scope for draft cases
$query->draft($this->getUserId());
$this->filters($query);
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
return $query->count();
/**
* Count how many cases the user has in DRAFT, needs to apply filters
*
* @return int
*/
public function getPagingCounters()
{
$query = Delegation::query()->select();
// Add the initial scope for draft cases
$query->draft($this->getUserId());
// Apply filters
$this->filters($query);
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
}

View File

@@ -114,18 +114,32 @@ class Inbox extends AbstractCases
}
/**
* Get the number of rows corresponding to the List Inbox
* Count how many cases the user has in TO_DO, does not apply filters
*
* @return int
*/
public function getCounter()
{
$query = Delegation::query()->select();
// Scope that sets the queries for List Inbox
$query->inbox($this->getUserId());
// Return the number of rows
return $query->count();
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
/**
* Count how many cases the user has in TO_DO, needs to apply filters
*
* @return int
*/
public function getPagingCounters()
{
$query = Delegation::query()->select();
// Scope that sets the queries for List Inbox
$query->inbox($this->getUserId());
// Apply filters
$this->filters($query);
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
}

View File

@@ -214,7 +214,7 @@ class Participated extends AbstractCases
}
/**
* Get the number of rows corresponding to the Participated
* Get the number of rows corresponding has Participation, does not apply filters
*
* @return int
*/
@@ -249,4 +249,43 @@ class Participated extends AbstractCases
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
/**
* Count how many cases the user has Participation, needs to apply filters
*
* @return int
*/
public function getPagingCounters()
{
// Get base query
$query = Delegation::query()->select();
// Join with application
$query->joinApplication();
// Scope that sets the queries for Participated
$query->participated($this->getUserId());
// Get filter
$filter = $this->getParticipatedStatus();
switch ($filter) {
case 'STARTED':
// Scope that search for the STARTED by user
$query->caseStarted();
break;
case 'IN_PROGRESS':
// Only distinct APP_NUMBER
$query->distinct();
// Scope for in progress cases
$query->statusIds([self::STATUS_DRAFT, self::STATUS_TODO]);
break;
case 'COMPLETED':
// Scope that search for the COMPLETED
$query->caseCompleted();
// Scope to set the last thread
$query->lastThread();
break;
}
// Apply filters
$this->filters($query);
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
}

View File

@@ -109,7 +109,7 @@ class Paused extends AbstractCases
}
/**
* Get the total for the paused cases list
* Count how many cases the user has in PAUSED, does not apply filters
*
* @return int
*/
@@ -118,7 +118,23 @@ class Paused extends AbstractCases
$query = Delegation::query()->select();
// Scope that set the paused cases
$query->paused($this->getUserId(), $this->getTaskId(), $this->getCaseNumber());
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
return $query->count();
/**
* Count how many cases the user has in PAUSED, needs to apply filters
*
* @return int
*/
public function getPagingCounters()
{
$query = Delegation::query()->select();
// Scope that set the paused cases
$query->paused($this->getUserId(), $this->getTaskId(), $this->getCaseNumber());
// Apply filters
$this->filters($query);
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
}

View File

@@ -177,15 +177,24 @@ class Search extends AbstractCases
}
/**
* Get the number of rows corresponding to the advanced search
* Count how many cases the user has in the advanced search, does not apply filters
*
* @return int
*/
public function getCounter()
{
$query = Delegation::query()->select();
// The search does not have a counters
return 0;
}
// Return the number of rows
return $query->count();
/**
* Get the number of rows corresponding to the advanced search, needs to apply filters
*
* @return int
*/
public function getPagingCounters()
{
// The search always will enable the pagination
return 0;
}
}

View File

@@ -169,7 +169,7 @@ class Supervising extends AbstractCases
}
/**
* Gets the total of Review cases
* Count how many cases the user has in Supervising, does not apply filters
*
* @return int
*/
@@ -186,4 +186,25 @@ class Supervising extends AbstractCases
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
/**
* Count how many cases the user has in Supervising, needs to apply filters
*
* @return int
*/
public function getPagingCounters()
{
// Get base query
$query = Delegation::query()->select();
// Only distinct APP_NUMBER
$query->distinct();
// Get the list of processes of the supervisor
$processes = ProcessUser::getProcessesOfSupervisor($this->getUserUid());
// Scope the specific array of processes supervising
$query->processInList($processes);
// Apply filters
$this->filters($query);
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
}

View File

@@ -119,15 +119,32 @@ class Unassigned extends AbstractCases
}
/**
* Count the self-services cases by user
* Count how many cases the user has in SELF_SERVICE, does not apply filters
*
* @return int
*/
public function getCounter()
{
$query = Delegation::query()->select();
// Add the initial scope for self-service cases
$query->selfService($this->getUserUid());
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
return $query->count();
/**
* Count how many cases the user has in SELF_SERVICE, needs to apply filters
*
* @return int
*/
public function getPagingCounters()
{
$query = Delegation::query()->select();
// Add the initial scope for self-service cases
$query->selfService($this->getUserUid());
// Apply filters
$this->filters($query);
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
}

View File

@@ -86,7 +86,7 @@ class Home extends Api
$list->setProperties($properties);
$result = [];
$result['data'] = $list->getData();
$result['total'] = $list->getCounter();
$result['total'] = $list->getPagingCounters();
return $result;
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
@@ -141,7 +141,7 @@ class Home extends Api
$list->setProperties($properties);
$result = [];
$result['data'] = $list->getData();
$result['total'] = $list->getCounter();
$result['total'] = $list->getPagingCounters();
return $result;
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
@@ -198,7 +198,7 @@ class Home extends Api
$list->setProperties($properties);
$result = [];
$result['data'] = $list->getData();
$result['total'] = $list->getCounter();
$result['total'] = $list->getPagingCounters();
return $result;
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
@@ -253,7 +253,7 @@ class Home extends Api
$list->setProperties($properties);
$result = [];
$result['data'] = $list->getData();
$result['total'] = $list->getCounter();
$result['total'] = $list->getPagingCounters();
return $result;
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
@@ -329,14 +329,14 @@ class Home extends Api
$list->setParticipatedStatus($filter);
$list->setProperties($properties);
$result['data'] = $list->getData();
$result['total'] = $list->getCounter();
$result['total'] = $list->getPagingCounters();
break;
case 'SUPERVISING':
// Scope that search for the SUPERVISING cases by specific user
$list = new Supervising();
$list->setProperties($properties);
$result['data'] = $list->getData();
$result['total'] = $list->getCounter();
$result['total'] = $list->getPagingCounters();
break;
}
}