PMCORE-3265 Service support send By filter (inbox, draft, paused, unassigned)

This commit is contained in:
Roly Gutierrez
2021-09-07 18:22:39 -04:00
parent 29512908d9
commit a9b20019e2
7 changed files with 105 additions and 9 deletions

View File

@@ -113,6 +113,9 @@ class AbstractCases implements CasesInterface
// Filter by specific cases, know as "$appUidCheck" in the old lists classes
private $casesUids = [];
// Filter by Send By
private $sendBy = '';
// Filter range related to the start case date
private $startCaseFrom = '';
@@ -749,6 +752,26 @@ class AbstractCases implements CasesInterface
return $this->casesUids;
}
/**
* Set send by.
*
* @param type $sendBy
*/
public function setSendBy(string $sendBy)
{
$this->sendBy = $sendBy;
}
/**
* Get send by.
*
* @return string
*/
public function getSendBy()
{
return $this->sendBy;
}
/**
* Set Cases Numbers
*
@@ -1381,6 +1404,10 @@ class AbstractCases implements CasesInterface
if (get_class($this) === Inbox::class && !empty($properties['delegateTo'])) {
$this->setDelegateTo($properties['delegateTo']);
}
// Filter by Send By
if (get_class($this) === Inbox::class && !empty($properties['sendBy'])) {
$this->setSendBy($properties['sendBy']);
}
/** Apply filters related to PAUSED */
// Filter date related to delegate from
if (get_class($this) === Paused::class && !empty($properties['delegateFrom'])) {
@@ -1390,6 +1417,10 @@ class AbstractCases implements CasesInterface
if (get_class($this) === Paused::class && !empty($properties['delegateTo'])) {
$this->setDelegateTo($properties['delegateTo']);
}
// Filter by Send By
if (get_class($this) === Paused::class && !empty($properties['sendBy'])) {
$this->setSendBy($properties['sendBy']);
}
/** Apply filters related to UNASSIGNED */
// Filter date related to delegate from
if (get_class($this) === Unassigned::class && !empty($properties['delegateFrom'])) {
@@ -1399,6 +1430,10 @@ class AbstractCases implements CasesInterface
if (get_class($this) === Unassigned::class && !empty($properties['delegateTo'])) {
$this->setDelegateTo($properties['delegateTo']);
}
// Filter by Send By
if (get_class($this) === Unassigned::class && !empty($properties['sendBy'])) {
$this->setSendBy($properties['sendBy']);
}
/** Apply filters related to MY CASES */
// My cases filter: started, in-progress, completed, supervising

View File

@@ -78,6 +78,7 @@ class Home
$sort = explode(',', $sort);
$properties['sort'] = $sort[0];
$properties['dir'] = $sort[1];
$properties['sendBy'] = $sendBy;
$list->setProperties($properties);
$result = [];
$result['data'] = DateTime::convertUtcToTimeZone($list->getData($callback));
@@ -97,6 +98,7 @@ class Home
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
* @param callable $callback
* @return array
*/
@@ -111,6 +113,7 @@ class Home
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC',
string $sendBy = '',
callable $callback = null
)
{
@@ -133,6 +136,7 @@ class Home
$sort = explode(',', $sort);
$properties['sort'] = $sort[0];
$properties['dir'] = $sort[1];
$properties['sendBy'] = $sendBy;
$list->setProperties($properties);
$result = [];
$result['data'] = DateTime::convertUtcToTimeZone($list->getData($callback));
@@ -152,6 +156,7 @@ class Home
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
* @param callable $callback
* @return array
*/
@@ -166,6 +171,7 @@ class Home
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC',
string $sendBy = '',
callable $callback = null
)
{
@@ -188,6 +194,7 @@ class Home
$sort = explode(',', $sort);
$properties['sort'] = $sort[0];
$properties['dir'] = $sort[1];
$properties['sendBy'] = $sendBy;
// todo: some queries related to the unassigned are using the USR_UID
$list->setUserUid($usrUid);
$list->setProperties($properties);
@@ -209,6 +216,7 @@ class Home
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
* @param callable $callback
* @return array
*/
@@ -223,6 +231,7 @@ class Home
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC',
string $sendBy = '',
callable $callback = null
)
{
@@ -245,6 +254,7 @@ class Home
$sort = explode(',', $sort);
$properties['sort'] = $sort[0];
$properties['dir'] = $sort[1];
$properties['sendBy'] = $sendBy;
$list->setProperties($properties);
$result = [];
$result['data'] = DateTime::convertUtcToTimeZone($list->getData($callback));
@@ -349,6 +359,7 @@ class Home
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
* @return array
*/
public function getCustomInbox(
@@ -362,7 +373,8 @@ class Home
string $delegateFrom = '',
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC'
string $sort = 'APP_NUMBER,DESC',
string $sendBy = ''
)
{
$arguments = func_get_args();
@@ -390,6 +402,7 @@ class Home
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
* @return array
*/
public function getCustomUnassigned(
@@ -403,7 +416,8 @@ class Home
string $delegateFrom = '',
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC'
string $sort = 'APP_NUMBER,DESC',
string $sendBy = ''
)
{
$arguments = func_get_args();
@@ -431,6 +445,7 @@ class Home
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
* @return array
*/
public function getCustomPaused(
@@ -444,7 +459,8 @@ class Home
string $delegateFrom = '',
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC'
string $sort = 'APP_NUMBER,DESC',
string $sendBy = ''
)
{
$arguments = func_get_args();

View File

@@ -91,6 +91,11 @@ class Inbox extends AbstractCases
$query->delegateDateTo($this->getDelegateTo());
}
// Specific usrId represented by sendBy.
if (!empty($this->getSendBy())) {
$query->sendBy($this->getSendBy());
}
return $query;
}

View File

@@ -90,6 +90,11 @@ class Paused extends AbstractCases
$query->delegateDateTo($this->getDelegateTo());
}
// Specific usrId represented by sendBy.
if (!empty($this->getSendBy())) {
$query->sendBy($this->getSendBy());
}
return $query;
}

View File

@@ -91,6 +91,11 @@ class Unassigned extends AbstractCases
$query->delegateDateTo($this->getDelegateTo());
}
// Specific usrId represented by sendBy.
if (!empty($this->getSendBy())) {
$query->sendBy($this->getSendBy());
}
return $query;
}

View File

@@ -1032,6 +1032,24 @@ class Delegation extends Model
return $query;
}
/**
* Scope sendBy.
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $usrId
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeSendBy($query, int $usrId)
{
$query->where(DB::raw($usrId), function ($sql) {
$sql->from('APP_DELEGATION AS B')
->select('B.USR_ID')
->where('B.APP_NUMBER', '=', DB::raw('APP_DELEGATION.APP_NUMBER'))
->where('B.DEL_INDEX', '=', DB::raw('APP_DELEGATION.DEL_PREVIOUS'))
->limit(1);
});
return $query;
}
/**
* Get specific cases unassigned that the user can view
*

View File

@@ -101,6 +101,7 @@ class Home extends Api
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
*
* @return array
*
@@ -119,7 +120,8 @@ class Home extends Api
string $delegateFrom = '',
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC'
string $sort = 'APP_NUMBER,DESC',
string $sendBy = ''
)
{
try {
@@ -145,6 +147,7 @@ class Home extends Api
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
*
* @return array
*
@@ -163,7 +166,8 @@ class Home extends Api
string $delegateFrom = '',
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC'
string $sort = 'APP_NUMBER,DESC',
string $sendBy = ''
)
{
try {
@@ -189,6 +193,7 @@ class Home extends Api
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
*
* @return array
*
@@ -207,7 +212,8 @@ class Home extends Api
string $delegateFrom = '',
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC'
string $sort = 'APP_NUMBER,DESC',
string $sendBy = ''
)
{
try {
@@ -269,6 +275,7 @@ class Home extends Api
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
* @return array
* @throws RestException
* @access protected
@@ -285,7 +292,8 @@ class Home extends Api
string $delegateFrom = '',
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC'
string $sort = 'APP_NUMBER,DESC',
string $sendBy = ''
)
{
try {
@@ -310,6 +318,7 @@ class Home extends Api
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
* @return array
* @throws RestException
* @access protected
@@ -326,7 +335,8 @@ class Home extends Api
string $delegateFrom = '',
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC'
string $sort = 'APP_NUMBER,DESC',
string $sendBy = ''
)
{
try {
@@ -351,6 +361,7 @@ class Home extends Api
* @param string $delegateTo
* @param string $filterCases
* @param string $sort
* @param string $sendBy
* @return array
* @throws RestException
* @access protected
@@ -367,7 +378,8 @@ class Home extends Api
string $delegateFrom = '',
string $delegateTo = '',
string $filterCases = '',
string $sort = 'APP_NUMBER,DESC'
string $sort = 'APP_NUMBER,DESC',
string $sendBy = ''
)
{
try {