Merged in bugfix/PMCORE-3053 (pull request #8015)
PMCORE-3053 Rest Services: Improve API related to home order to get the Custom cases list Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
ec7b157c00
26
database/factories/CaseListFactory.php
Normal file
26
database/factories/CaseListFactory.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\CaseList::class, function (Faker $faker) {
|
||||
return [
|
||||
'CAL_ID' => $faker->unique()->numberBetween(1, 2000),
|
||||
'CAL_TYPE' => 'inbox',
|
||||
'CAL_NAME' => $faker->title,
|
||||
'CAL_DESCRIPTION' => $faker->text,
|
||||
'ADD_TAB_UID' => function () {
|
||||
$table = factory(\ProcessMaker\Model\AdditionalTables::class)->create();
|
||||
return $table->ADD_TAB_UID;
|
||||
},
|
||||
'CAL_COLUMNS' => '[]',
|
||||
'USR_ID' => function () {
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
return $user->USR_ID;
|
||||
},
|
||||
'CAL_ICON_LIST' => 'deafult.png',
|
||||
'CAL_ICON_COLOR' => 'red',
|
||||
'CAL_ICON_COLOR_SCREEN' => 'blue',
|
||||
'CAL_CREATE_DATE' => $faker->dateTime(),
|
||||
'CAL_UPDATE_DATE' => $faker->dateTime()
|
||||
];
|
||||
});
|
||||
@@ -5,7 +5,9 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\BusinessModel\Cases\Draft;
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\CaseList;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\User;
|
||||
@@ -719,4 +721,49 @@ class DraftTest extends TestCase
|
||||
$res = $draft->getCountersByRange(null, '2021-05-20', '2021-05-22');
|
||||
$this->assertCount(3, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests the getCustomListCount() method.
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCustomListCount()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_getCustomListCount_method()
|
||||
{
|
||||
$cases = $this->createManyDraft(3);
|
||||
|
||||
$additionalTables = factory(AdditionalTables::class)->create();
|
||||
$query = ""
|
||||
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
|
||||
. "`APP_UID` varchar(32) NOT NULL,"
|
||||
. "`APP_NUMBER` int(11) NOT NULL,"
|
||||
. "`APP_STATUS` varchar(10) NOT NULL,"
|
||||
. "`VAR1` varchar(255) DEFAULT NULL,"
|
||||
. "`VAR2` varchar(255) DEFAULT NULL,"
|
||||
. "`VAR3` varchar(255) DEFAULT NULL,"
|
||||
. "PRIMARY KEY (`APP_UID`),"
|
||||
. "KEY `indexTable` (`APP_UID`))";
|
||||
DB::statement($query);
|
||||
|
||||
$caseList = factory(CaseList::class)->create([
|
||||
'CAL_TYPE' => 'draft',
|
||||
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
|
||||
'USR_ID' => $cases->USR_ID
|
||||
]);
|
||||
|
||||
$draft = new Draft();
|
||||
$draft->setUserId($cases->USR_ID);
|
||||
$draft->setUserUid($cases->USR_UID);
|
||||
|
||||
$res = $draft->getCustomListCount($caseList->CAL_ID, 'draft');
|
||||
|
||||
//assertions
|
||||
$this->assertArrayHasKey('label', $res);
|
||||
$this->assertArrayHasKey('name', $res);
|
||||
$this->assertArrayHasKey('description', $res);
|
||||
$this->assertArrayHasKey('tableName', $res);
|
||||
$this->assertArrayHasKey('total', $res);
|
||||
|
||||
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
|
||||
$this->assertEquals(3, $res['total']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\BusinessModel\Cases\Inbox;
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\CaseList;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
@@ -612,4 +614,49 @@ class InboxTest extends TestCase
|
||||
$res = $inbox->getCountersByRange(null, '2021-05-20', '2021-05-23');
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests the getCustomListCount() method.
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCustomListCount()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_getCustomListCounts_method()
|
||||
{
|
||||
$cases = $this->createMultipleInbox(3);
|
||||
|
||||
$additionalTables = factory(AdditionalTables::class)->create();
|
||||
$query = ""
|
||||
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
|
||||
. "`APP_UID` varchar(32) NOT NULL,"
|
||||
. "`APP_NUMBER` int(11) NOT NULL,"
|
||||
. "`APP_STATUS` varchar(10) NOT NULL,"
|
||||
. "`VAR1` varchar(255) DEFAULT NULL,"
|
||||
. "`VAR2` varchar(255) DEFAULT NULL,"
|
||||
. "`VAR3` varchar(255) DEFAULT NULL,"
|
||||
. "PRIMARY KEY (`APP_UID`),"
|
||||
. "KEY `indexTable` (`APP_UID`))";
|
||||
DB::statement($query);
|
||||
|
||||
$caseList = factory(CaseList::class)->create([
|
||||
'CAL_TYPE' => 'inbox',
|
||||
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
|
||||
'USR_ID' => $cases->USR_ID
|
||||
]);
|
||||
|
||||
$inbox = new Inbox();
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
$inbox->setUserUid($cases->USR_UID);
|
||||
|
||||
$res = $inbox->getCustomListCount($caseList->CAL_ID, 'inbox');
|
||||
|
||||
//assertions
|
||||
$this->assertArrayHasKey('label', $res);
|
||||
$this->assertArrayHasKey('name', $res);
|
||||
$this->assertArrayHasKey('description', $res);
|
||||
$this->assertArrayHasKey('tableName', $res);
|
||||
$this->assertArrayHasKey('total', $res);
|
||||
|
||||
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
|
||||
$this->assertEquals(3, $res['total']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\BusinessModel\Cases\Paused;
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AppDelay;
|
||||
use ProcessMaker\Model\CaseList;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
@@ -606,4 +608,49 @@ class PausedTest extends TestCase
|
||||
$res = $paused->getCountersByRange(null, '2021-05-20', '2021-05-23');
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests the getCustomListCount() method.
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCustomListCount()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_getCustomListCounts_method()
|
||||
{
|
||||
$cases = $this->createMultiplePaused(3);
|
||||
|
||||
$additionalTables = factory(AdditionalTables::class)->create();
|
||||
$query = ""
|
||||
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
|
||||
. "`APP_UID` varchar(32) NOT NULL,"
|
||||
. "`APP_NUMBER` int(11) NOT NULL,"
|
||||
. "`APP_STATUS` varchar(10) NOT NULL,"
|
||||
. "`VAR1` varchar(255) DEFAULT NULL,"
|
||||
. "`VAR2` varchar(255) DEFAULT NULL,"
|
||||
. "`VAR3` varchar(255) DEFAULT NULL,"
|
||||
. "PRIMARY KEY (`APP_UID`),"
|
||||
. "KEY `indexTable` (`APP_UID`))";
|
||||
DB::statement($query);
|
||||
|
||||
$caseList = factory(CaseList::class)->create([
|
||||
'CAL_TYPE' => 'paused',
|
||||
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
|
||||
'USR_ID' => $cases->USR_ID
|
||||
]);
|
||||
|
||||
$paused = new Paused();
|
||||
$paused->setUserId($cases->USR_ID);
|
||||
$paused->setUserUid($cases->USR_UID);
|
||||
|
||||
$res = $paused->getCustomListCount($caseList->CAL_ID, 'paused');
|
||||
|
||||
//assertions
|
||||
$this->assertArrayHasKey('label', $res);
|
||||
$this->assertArrayHasKey('name', $res);
|
||||
$this->assertArrayHasKey('description', $res);
|
||||
$this->assertArrayHasKey('tableName', $res);
|
||||
$this->assertArrayHasKey('total', $res);
|
||||
|
||||
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
|
||||
$this->assertEquals(3, $res['total']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\BusinessModel\Cases\Unassigned;
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Model\AppAssignSelfServiceValue;
|
||||
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\CaseList;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\GroupUser;
|
||||
use ProcessMaker\Model\Groupwf;
|
||||
@@ -657,4 +659,68 @@ class UnassignedTest extends TestCase
|
||||
$res = $unassigned->getCountersByRange(null, '2021-05-20', '2021-05-23');
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getCustomListCount() method
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCustomListCount()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_getCustomListCount_method()
|
||||
{
|
||||
$cases = $this->createMultipleUnassigned(0);
|
||||
|
||||
$additionalTables = factory(AdditionalTables::class)->create();
|
||||
$query = ""
|
||||
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
|
||||
. "`APP_UID` varchar(32) NOT NULL,"
|
||||
. "`APP_NUMBER` int(11) NOT NULL,"
|
||||
. "`APP_STATUS` varchar(10) NOT NULL,"
|
||||
. "`VAR1` varchar(255) DEFAULT NULL,"
|
||||
. "`VAR2` varchar(255) DEFAULT NULL,"
|
||||
. "`VAR3` varchar(255) DEFAULT NULL,"
|
||||
. "PRIMARY KEY (`APP_UID`),"
|
||||
. "KEY `indexTable` (`APP_UID`))";
|
||||
DB::statement($query);
|
||||
|
||||
$caseList = factory(CaseList::class)->create([
|
||||
'CAL_TYPE' => 'unassigned',
|
||||
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
|
||||
'USR_ID' => $cases->USR_ID
|
||||
]);
|
||||
|
||||
$unassigned = new Unassigned();
|
||||
$unassigned->setUserId($cases->USR_ID);
|
||||
$unassigned->setUserUid($cases->USR_UID);
|
||||
|
||||
$res = $unassigned->getCustomListCount($caseList->CAL_ID, 'unassigned');
|
||||
|
||||
//assertions
|
||||
$this->assertArrayHasKey('label', $res);
|
||||
$this->assertArrayHasKey('name', $res);
|
||||
$this->assertArrayHasKey('description', $res);
|
||||
$this->assertArrayHasKey('tableName', $res);
|
||||
$this->assertArrayHasKey('total', $res);
|
||||
|
||||
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
|
||||
$this->assertEquals(0, $res['total']);
|
||||
|
||||
//for user or group
|
||||
$cases = $this->createSelfServiceUserOrGroup();
|
||||
|
||||
$unassigned = new Unassigned();
|
||||
$unassigned->setUserUid($cases['taskUser']->USR_UID);
|
||||
$unassigned->setUserId($cases['delegation']->USR_ID);
|
||||
|
||||
$res = $unassigned->getCustomListCount($caseList->CAL_ID, 'unassigned');
|
||||
|
||||
//assertions
|
||||
$this->assertArrayHasKey('label', $res);
|
||||
$this->assertArrayHasKey('name', $res);
|
||||
$this->assertArrayHasKey('description', $res);
|
||||
$this->assertArrayHasKey('tableName', $res);
|
||||
$this->assertArrayHasKey('total', $res);
|
||||
|
||||
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
|
||||
$this->assertEquals(0, $res['total']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use G;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\CaseList;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\User;
|
||||
|
||||
@@ -166,4 +167,44 @@ class Draft extends AbstractCases
|
||||
// Return the number of rows
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total cases of the custom draft list.
|
||||
* @param int $id
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
public function getCustomListCount(int $id, string $type): array
|
||||
{
|
||||
$caseList = CaseList::where('CAL_ID', '=', $id)
|
||||
->where('CAL_TYPE', '=', $type)
|
||||
->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
|
||||
->select([
|
||||
'CASE_LIST.*',
|
||||
'ADDITIONAL_TABLES.ADD_TAB_NAME'
|
||||
])
|
||||
->get()
|
||||
->first();
|
||||
|
||||
$query = Delegation::query()->select();
|
||||
$query->draft($this->getUserId());
|
||||
|
||||
$name = '';
|
||||
$description = '';
|
||||
$tableName = '';
|
||||
if (!is_null($caseList)) {
|
||||
$name = $caseList->CAL_NAME;
|
||||
$description = $caseList->CAL_DESCRIPTION;
|
||||
$tableName = $caseList->ADD_TAB_NAME;
|
||||
$query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
|
||||
}
|
||||
$count = $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
return [
|
||||
'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_DRAFT') . $count,
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'tableName' => $tableName,
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use G;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\CaseList;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\User;
|
||||
|
||||
@@ -179,4 +180,44 @@ class Inbox extends AbstractCases
|
||||
// Return the number of rows
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total cases of the custom inbox list.
|
||||
* @param int $id
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
public function getCustomListCount(int $id, string $type): array
|
||||
{
|
||||
$caseList = CaseList::where('CAL_ID', '=', $id)
|
||||
->where('CAL_TYPE', '=', $type)
|
||||
->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
|
||||
->select([
|
||||
'CASE_LIST.*',
|
||||
'ADDITIONAL_TABLES.ADD_TAB_NAME'
|
||||
])
|
||||
->get()
|
||||
->first();
|
||||
|
||||
$query = Delegation::query()->select();
|
||||
$query->inbox($this->getUserId());
|
||||
|
||||
$name = '';
|
||||
$description = '';
|
||||
$tableName = '';
|
||||
if (!is_null($caseList)) {
|
||||
$name = $caseList->CAL_NAME;
|
||||
$description = $caseList->CAL_DESCRIPTION;
|
||||
$tableName = $caseList->ADD_TAB_NAME;
|
||||
$query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
|
||||
}
|
||||
$count = $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
return [
|
||||
'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_INBOX') . $count,
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'tableName' => $tableName,
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use G;
|
||||
use ProcessMaker\Model\CaseList;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\User;
|
||||
|
||||
@@ -173,4 +174,44 @@ class Paused extends AbstractCases
|
||||
// Return the number of rows
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total cases of the custom paused list.
|
||||
* @param int $id
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
public function getCustomListCount(int $id, string $type): array
|
||||
{
|
||||
$caseList = CaseList::where('CAL_ID', '=', $id)
|
||||
->where('CAL_TYPE', '=', $type)
|
||||
->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
|
||||
->select([
|
||||
'CASE_LIST.*',
|
||||
'ADDITIONAL_TABLES.ADD_TAB_NAME'
|
||||
])
|
||||
->get()
|
||||
->first();
|
||||
|
||||
$query = Delegation::query()->select();
|
||||
$query->paused($this->getUserId());
|
||||
|
||||
$name = '';
|
||||
$description = '';
|
||||
$tableName = '';
|
||||
if (!is_null($caseList)) {
|
||||
$name = $caseList->CAL_NAME;
|
||||
$description = $caseList->CAL_DESCRIPTION;
|
||||
$tableName = $caseList->ADD_TAB_NAME;
|
||||
$query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
|
||||
}
|
||||
$count = $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
return [
|
||||
'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_PAUSED') . $count,
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'tableName' => $tableName,
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use G;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\CaseList;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\User;
|
||||
|
||||
@@ -181,4 +182,44 @@ class Unassigned extends AbstractCases
|
||||
// Return the number of rows
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total cases of the custom unassigned list.
|
||||
* @param int $id
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
public function getCustomListCount(int $id, string $type): array
|
||||
{
|
||||
$caseList = CaseList::where('CAL_ID', '=', $id)
|
||||
->where('CAL_TYPE', '=', $type)
|
||||
->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
|
||||
->select([
|
||||
'CASE_LIST.*',
|
||||
'ADDITIONAL_TABLES.ADD_TAB_NAME'
|
||||
])
|
||||
->get()
|
||||
->first();
|
||||
|
||||
$query = Delegation::query()->select();
|
||||
$query->selfService($this->getUserId());
|
||||
|
||||
$name = '';
|
||||
$description = '';
|
||||
$tableName = '';
|
||||
if (!is_null($caseList)) {
|
||||
$name = $caseList->CAL_NAME;
|
||||
$description = $caseList->CAL_DESCRIPTION;
|
||||
$tableName = $caseList->ADD_TAB_NAME;
|
||||
$query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
|
||||
}
|
||||
$count = $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
return [
|
||||
'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_UNASSIGNED') . $count,
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'tableName' => $tableName,
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,9 +173,10 @@ class CaseList extends Model
|
||||
* @param string $search
|
||||
* @param int $offset
|
||||
* @param int $limit
|
||||
* @param bool $paged
|
||||
* @return array
|
||||
*/
|
||||
public static function getSetting(string $type, string $search, int $offset, int $limit): array
|
||||
public static function getSetting(string $type, string $search, int $offset, int $limit, bool $paged = true): array
|
||||
{
|
||||
$order = 'asc';
|
||||
$model = CaseList::where('CAL_TYPE', '=', $type)
|
||||
@@ -198,7 +199,11 @@ class CaseList extends Model
|
||||
|
||||
$count = $model->count();
|
||||
|
||||
$data = $model->offset($offset)->limit($limit)->get();
|
||||
if ($paged === true) {
|
||||
$model->offset($offset)->limit($limit);
|
||||
}
|
||||
$data = $model->get();
|
||||
|
||||
$data->transform(function ($item, $key) {
|
||||
if (is_null($item->CAL_COLUMNS)) {
|
||||
$item->CAL_COLUMNS = '[]';
|
||||
|
||||
@@ -14,6 +14,7 @@ use ProcessMaker\BusinessModel\Cases\Paused;
|
||||
use ProcessMaker\BusinessModel\Cases\Search;
|
||||
use ProcessMaker\BusinessModel\Cases\Supervising;
|
||||
use ProcessMaker\BusinessModel\Cases\Unassigned;
|
||||
use ProcessMaker\Model\CaseList;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\ProcessCategory;
|
||||
@@ -609,6 +610,30 @@ class Home extends Api
|
||||
if ($menuInstance->Id[$i] === 'ID_CASE_ARCHIVE_SEARCH') {
|
||||
$option->icon = "fas fa-archive";
|
||||
}
|
||||
//custom cases list
|
||||
if (in_array($menuInstance->Id[$i], $optionsWithCounter)) {
|
||||
$mapKeys = [
|
||||
'CASES_INBOX' => 'inbox',
|
||||
'CASES_DRAFT' => 'draft',
|
||||
'CASES_SELFSERVICE' => 'unassigned',
|
||||
'CASES_PAUSED' => 'paused'
|
||||
];
|
||||
$option->customCasesList = [];
|
||||
$result = CaseList::getSetting($mapKeys[$menuInstance->Id[$i]], '', 0, 10, false);
|
||||
foreach ($result['data'] as $value) {
|
||||
$option->customCasesList[] = [
|
||||
"href" => "casesListExtJs?action=" . $mapKeys[$menuInstance->Id[$i]],
|
||||
"id" => $value['id'],
|
||||
"title" => $value['name'],
|
||||
"description" => $value['description'],
|
||||
"icon" => $value['iconList'],
|
||||
"badge" => [
|
||||
"text" => "0",
|
||||
"class" => "badge-custom"
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
// Add option to the menu
|
||||
$menuHome[] = $option;
|
||||
}
|
||||
@@ -727,10 +752,48 @@ class Home extends Api
|
||||
$result = [];
|
||||
$result['label'] = $text . $count;
|
||||
$result['total'] = $count;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get task counters for inbox, draft, paused, and unassigned for custom case lists.
|
||||
* @url GET /:task/counter/caseList/:id
|
||||
* @param string $task
|
||||
* @param int $id
|
||||
* @return array
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_CASES}
|
||||
*/
|
||||
public function getCustomCaseListCounter(string $task, int $id)
|
||||
{
|
||||
try {
|
||||
$usrUid = $this->getUserId();
|
||||
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
|
||||
switch ($task) {
|
||||
case 'inbox':
|
||||
$taskList = new Inbox();
|
||||
break;
|
||||
case 'draft':
|
||||
$taskList = new Draft();
|
||||
break;
|
||||
case 'paused':
|
||||
$taskList = new Paused();
|
||||
break;
|
||||
case 'unassigned':
|
||||
$taskList = new Unassigned();
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
$taskList->setUserUid($usrUid);
|
||||
$taskList->setUserId($usrId);
|
||||
$result = $taskList->getCustomListCount($id, $task);
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tasks counters for todo, draft, paused and unassigned
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user