PMCORE-3369

This commit is contained in:
Paula Quispe
2021-09-24 13:55:09 -04:00
parent a1ddfe3b4d
commit 27c3bc4f6c
2 changed files with 11 additions and 6 deletions

View File

@@ -410,10 +410,11 @@ class Process extends Model
* @param string $category * @param string $category
* @param int $offset * @param int $offset
* @param int $limit * @param int $limit
* @param bool $paged
* *
* @return array * @return array
*/ */
public static function getProcessesForHome($text = null, $category = null, $offset = null, $limit = null) public static function getProcessesForHome($text = null, $category = null, $offset = null, $limit = null, $paged = true)
{ {
// Get base query // Get base query
$query = Process::query()->select(['PRO_ID', 'PRO_TITLE']); $query = Process::query()->select(['PRO_ID', 'PRO_TITLE']);
@@ -431,12 +432,15 @@ class Process extends Model
// Set "PRO_STATUS" condition // Set "PRO_STATUS" condition
$query->status('ACTIVE'); $query->status('ACTIVE');
// Set pagination if offset and limit are sent if ($paged) {
if (!is_null($offset) && !is_null($limit)) { // Set pagination if offset and limit are sent
$query->offset($offset); if (!is_null($offset) && !is_null($limit)) {
$query->limit($limit); $query->offset($offset);
$query->limit($limit);
}
} }
// Order by "PRO_TITLE" // Order by "PRO_TITLE"
$query->orderBy('PRO_TITLE'); $query->orderBy('PRO_TITLE');

View File

@@ -861,6 +861,7 @@ class Home extends Api
* @param string $category * @param string $category
* @param int $offset * @param int $offset
* @param int $limit * @param int $limit
* @param bool $paged
* *
* @return array * @return array
* *
@@ -869,7 +870,7 @@ class Home extends Api
* @access protected * @access protected
* @class AccessControl {@permission PM_CASES} * @class AccessControl {@permission PM_CASES}
*/ */
public function getProcesses($text = null, $category = null, int $offset = 0, int $limit = 15) public function getProcesses($text = null, $category = null, int $offset = 0, int $limit = 15, $paged = true)
{ {
try { try {
return Process::getProcessesForHome($text, $category, $offset, $limit); return Process::getProcessesForHome($text, $category, $offset, $limit);