Merged in bugfix/PMCORE-3073 (pull request #7982)
PMCORE-3073 Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
@@ -37,6 +37,9 @@ class AbstractCases implements CasesInterface
|
|||||||
// Order by column allowed
|
// Order by column allowed
|
||||||
const ORDER_BY_COLUMN_ALLOWED = ['APP_NUMBER', 'DEL_TITLE', 'PRO_TITLE'];
|
const ORDER_BY_COLUMN_ALLOWED = ['APP_NUMBER', 'DEL_TITLE', 'PRO_TITLE'];
|
||||||
|
|
||||||
|
// Filter by category using the Id field
|
||||||
|
private $categoryId = 0;
|
||||||
|
|
||||||
// Filter by category from a process, know as "$category" in the old lists classes
|
// Filter by category from a process, know as "$category" in the old lists classes
|
||||||
private $categoryUid = '';
|
private $categoryUid = '';
|
||||||
|
|
||||||
@@ -139,6 +142,26 @@ class AbstractCases implements CasesInterface
|
|||||||
// Number of rows to return
|
// Number of rows to return
|
||||||
private $limit = 15;
|
private $limit = 15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Category Uid value
|
||||||
|
*
|
||||||
|
* @param int $category
|
||||||
|
*/
|
||||||
|
public function setCategoryId(int $category)
|
||||||
|
{
|
||||||
|
$this->categoryId = $category;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Category Id value
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCategoryId()
|
||||||
|
{
|
||||||
|
return $this->categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Category Uid value
|
* Set Category Uid value
|
||||||
*
|
*
|
||||||
@@ -1247,10 +1270,6 @@ class AbstractCases implements CasesInterface
|
|||||||
*/
|
*/
|
||||||
public function setProperties(array $properties)
|
public function setProperties(array $properties)
|
||||||
{
|
{
|
||||||
// Filter by category
|
|
||||||
if (!empty($properties['category'])) {
|
|
||||||
$this->setCategoryUid($properties['category']);
|
|
||||||
}
|
|
||||||
// Filter by process
|
// Filter by process
|
||||||
if (!empty($properties['process'])) {
|
if (!empty($properties['process'])) {
|
||||||
$this->setProcessId($properties['process']);
|
$this->setProcessId($properties['process']);
|
||||||
@@ -1329,6 +1348,10 @@ class AbstractCases implements CasesInterface
|
|||||||
$this->setFinishCaseTo($properties['finishCaseTo']);
|
$this->setFinishCaseTo($properties['finishCaseTo']);
|
||||||
}
|
}
|
||||||
/** Apply filters related to SEARCH */
|
/** Apply filters related to SEARCH */
|
||||||
|
// Filter by category
|
||||||
|
if (get_class($this) === Search::class && !empty($properties['category'])) {
|
||||||
|
$this->setCategoryId($properties['category']);
|
||||||
|
}
|
||||||
// Filter by more than one case statuses like ['DRAFT', 'TO_DO']
|
// Filter by more than one case statuses like ['DRAFT', 'TO_DO']
|
||||||
if (get_class($this) === Search::class && !empty($properties['caseStatuses'])) {
|
if (get_class($this) === Search::class && !empty($properties['caseStatuses'])) {
|
||||||
$this->setCaseStatuses($properties['caseStatuses']);
|
$this->setCaseStatuses($properties['caseStatuses']);
|
||||||
|
|||||||
@@ -67,6 +67,11 @@ class Search extends AbstractCases
|
|||||||
// Add the filter
|
// Add the filter
|
||||||
// $query->title($this->getCaseTitle());
|
// $query->title($this->getCaseTitle());
|
||||||
}
|
}
|
||||||
|
// Filter by category
|
||||||
|
if ($this->getCategoryId()) {
|
||||||
|
// This filter require a join with the process table
|
||||||
|
$query->category($this->getCategoryId());
|
||||||
|
}
|
||||||
// Filter by process
|
// Filter by process
|
||||||
if ($this->getProcessId()) {
|
if ($this->getProcessId()) {
|
||||||
$result = Process::query()->select(['PRO_UID'])
|
$result = Process::query()->select(['PRO_UID'])
|
||||||
|
|||||||
@@ -232,6 +232,19 @@ class Application extends Model
|
|||||||
return $query->whereIn('APPLICATION.APP_STATUS_ID', $statuses);
|
return $query->whereIn('APPLICATION.APP_STATUS_ID', $statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope a query to only include specific category
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param int $category
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeCategory($query, $category)
|
||||||
|
{
|
||||||
|
return $query->where('PROCESS.CATEGORY_ID', $category);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope for query to get the applications by PRO_UID.
|
* Scope for query to get the applications by PRO_UID.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -460,6 +460,7 @@ class Home extends Api
|
|||||||
* @url GET /search
|
* @url GET /search
|
||||||
*
|
*
|
||||||
* @param int $caseNumber
|
* @param int $caseNumber
|
||||||
|
* @param int $category
|
||||||
* @param int $process
|
* @param int $process
|
||||||
* @param int $task
|
* @param int $task
|
||||||
* @param int $user
|
* @param int $user
|
||||||
@@ -482,6 +483,7 @@ class Home extends Api
|
|||||||
*/
|
*/
|
||||||
public function doGetSearchCases(
|
public function doGetSearchCases(
|
||||||
int $caseNumber = 0,
|
int $caseNumber = 0,
|
||||||
|
int $category = 0,
|
||||||
int $process = 0,
|
int $process = 0,
|
||||||
int $task = 0,
|
int $task = 0,
|
||||||
int $user = 0,
|
int $user = 0,
|
||||||
@@ -500,6 +502,7 @@ class Home extends Api
|
|||||||
// Define the filters to apply
|
// Define the filters to apply
|
||||||
$properties = [];
|
$properties = [];
|
||||||
$properties['caseNumber'] = $caseNumber;
|
$properties['caseNumber'] = $caseNumber;
|
||||||
|
$properties['category'] = $category;
|
||||||
$properties['caseTitle'] = $caseTitle;
|
$properties['caseTitle'] = $caseTitle;
|
||||||
$properties['process'] = $process;
|
$properties['process'] = $process;
|
||||||
$properties['task'] = $task;
|
$properties['task'] = $task;
|
||||||
|
|||||||
Reference in New Issue
Block a user