PMCORE-1220
This commit is contained in:
@@ -100,6 +100,14 @@ $factory->state(\ProcessMaker\Model\Application::class, 'completed', function (F
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(\ProcessMaker\Model\Application::class, 'canceled', function (Faker $faker) {
|
||||
return [
|
||||
'APP_NUMBER' => $faker->unique()->numberBetween(1000),
|
||||
'APP_STATUS_ID' => 4,
|
||||
'APP_STATUS' => 'CANCELLED'
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(\ProcessMaker\Model\Application::class, 'draft_minor_case', function (Faker $faker) {
|
||||
$caseNumber = $faker->unique()->numberBetween(1, 1000);
|
||||
return [
|
||||
|
||||
24
database/factories/ConsolidatedFactory.php
Normal file
24
database/factories/ConsolidatedFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\Consolidated::class, function (Faker $faker) {
|
||||
return [
|
||||
'TAS_UID' => G::generateUniqueID(),
|
||||
'DYN_UID' => G::generateUniqueID(),
|
||||
'REP_TAB_UID' => G::generateUniqueID(),
|
||||
'CON_STATUS' => 'ACTIVE',
|
||||
];
|
||||
});
|
||||
|
||||
// Create a consolidated task with the foreign keys
|
||||
$factory->state(\ProcessMaker\Model\Consolidated::class, 'foreign_keys', function (Faker $faker) {
|
||||
$task = factory(\ProcessMaker\Model\Task::class)->create();
|
||||
$dynaform = factory(\ProcessMaker\Model\Dynaform::class)->create();
|
||||
return [
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'DYN_UID' => $dynaform->DYN_UID,
|
||||
'REP_TAB_UID' => G::generateUniqueID(),
|
||||
'CON_STATUS' => 'ACTIVE',
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\BusinessModel\Cases\BatchRouting;
|
||||
use ProcessMaker\Model\Consolidated;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\BatchRouting
|
||||
*/
|
||||
class BatchRoutingTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Method set up.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create consolidated cases factories
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function createConsolidated()
|
||||
{
|
||||
$consolidated = factory(Consolidated::class)->states('foreign_keys')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'TAS_UID' => $consolidated->TAS_UID,
|
||||
]);
|
||||
|
||||
return $delegation;
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in batch routing
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\BatchRouting::getCounter()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_consolidated()
|
||||
{
|
||||
// Create factories related to the consolidated cases
|
||||
$cases = $this->createConsolidated();
|
||||
// Create new Draft object
|
||||
$consolidated = new BatchRouting();
|
||||
$consolidated->setUserId($cases['USR_ID']);
|
||||
$consolidated->setUserUid($cases['USR_UID']);
|
||||
$result = $consolidated->getCounter();
|
||||
$this->assertTrue($result > 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\BusinessModel\Cases\Canceled;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Canceled
|
||||
*/
|
||||
class CanceledTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Method set up.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create inbox cases factories
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function createCanceled()
|
||||
{
|
||||
$application = factory(Application::class)->states('canceled')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'DEL_INDEX' => 1,
|
||||
'USR_UID' => $application->APP_INIT_USER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
]);
|
||||
|
||||
return $delegation;
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in canceled
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Canceled::getCounter()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_completed()
|
||||
{
|
||||
// Create factories related to the canceled cases
|
||||
$cases = $this->createCanceled();
|
||||
// Create new Canceled object
|
||||
$canceled = new Canceled();
|
||||
$canceled->setUserId($cases['USR_ID']);
|
||||
$canceled->setUserUid($cases['USR_UID']);
|
||||
$result = $canceled->getCounter();
|
||||
$this->assertTrue($result > 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\BusinessModel\Cases\CasesList;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\CasesList
|
||||
*/
|
||||
class CasesListTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Method set up.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create cases factories
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function createCases()
|
||||
{
|
||||
$application = factory(Application::class)->states('completed')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'DEL_INDEX' => 1,
|
||||
'USR_UID' => $application->APP_INIT_USER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
]);
|
||||
|
||||
return $delegation;
|
||||
}
|
||||
|
||||
/**
|
||||
* This test getAllCounters
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\CasesList::getAllCounters()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_all_counters()
|
||||
{
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$count = new CasesList();
|
||||
$result = $count->getAllCounters($delegation->USR_UID);
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertArrayHasKey('CASES_INBOX', $result);
|
||||
$this->assertArrayHasKey('CASES_DRAFT', $result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\BusinessModel\Cases\Completed;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Completed
|
||||
*/
|
||||
class CompletedTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Method set up.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create complete cases factories
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function createCompleted()
|
||||
{
|
||||
$application = factory(Application::class)->states('completed')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'DEL_INDEX' => 1,
|
||||
'USR_UID' => $application->APP_INIT_USER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
]);
|
||||
|
||||
return $delegation;
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in completed
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Completed::getCounter()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_completed()
|
||||
{
|
||||
// Create factories related to the completed cases
|
||||
$cases = $this->createCompleted();
|
||||
// Create new Completed object
|
||||
$completed = new Completed();
|
||||
$completed->setUserId($cases['USR_ID']);
|
||||
$completed->setUserUid($cases['USR_UID']);
|
||||
$result = $completed->getCounter();
|
||||
$this->assertTrue($result > 0);
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,7 @@ class DraftTest extends TestCase
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getColumnsView()
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeDraft()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_result_without_filters()
|
||||
|
||||
@@ -89,6 +89,7 @@ class InboxTest extends TestCase
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeInbox()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_result_without_filters()
|
||||
|
||||
@@ -89,6 +89,7 @@ class ParticipatedTest extends TestCase
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeParticipated()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_result_without_filters()
|
||||
|
||||
@@ -196,6 +196,7 @@ class PausedTest extends TestCase
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
|
||||
* @covers \ProcessMaker\Model\Delegation::scopePaused()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_result_without_filters()
|
||||
|
||||
@@ -319,6 +319,7 @@ class UnassignedTest extends TestCase
|
||||
* This ensures get data from self-service-user-assigned without filters
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeSelfService()
|
||||
* @test
|
||||
*/
|
||||
public function it_test_unassigned_by_user_without_filters()
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\Consolidated;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \ProcessMaker\Model\Consolidated
|
||||
*/
|
||||
class ConsolidatedTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Method set up.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create consolidated cases factories
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function createConsolidated()
|
||||
{
|
||||
$consolidated = factory(Consolidated::class)->states('foreign_keys')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'TAS_UID' => $consolidated->TAS_UID,
|
||||
]);
|
||||
|
||||
return $delegation;
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in draft
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Consolidated::getCounterActive()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_consolidated()
|
||||
{
|
||||
// Create factories related to the consolidated
|
||||
$cases = $this->createConsolidated();
|
||||
// Create new Consolidated object
|
||||
$consolidated = new Consolidated();
|
||||
$result = $consolidated->getCounterActive();
|
||||
$this->assertTrue($result > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in consolidated
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Consolidated::getCounterActive()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases()
|
||||
{
|
||||
// Create factories related to the consolidated
|
||||
$cases = $this->createConsolidated();
|
||||
// Create new Consolidated object
|
||||
$consolidated = new Consolidated();
|
||||
$result = $consolidated->getConsolidated();
|
||||
$this->assertTrue($result > 0);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\Model\AppAssignSelfServiceValue;
|
||||
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
|
||||
use ProcessMaker\Model\AppDelay;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\GroupUser;
|
||||
@@ -218,6 +219,22 @@ class DelegationTest extends TestCase
|
||||
$this->assertCount(1, $table->joinApplication()->caseCompleted()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeCaseCanceled
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeCaseCanceled()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_case_canceled()
|
||||
{
|
||||
$application = factory(Application::class)->states('canceled')->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$this->assertCount(1, $table->joinApplication()->caseCanceled()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeStatus
|
||||
*
|
||||
@@ -250,6 +267,70 @@ class DelegationTest extends TestCase
|
||||
$this->assertCount(1, $table->joinApplication()->statusIds([$application->APP_STATUS_ID])->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeStartDateFrom
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeStartDateFrom()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_start_date_from()
|
||||
{
|
||||
$application = factory(Application::class)->states('todo')->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$this->assertCount(1, $table->joinApplication()->startDateFrom($application->APP_CREATE_DATE->format("Y-m-d H:i:s"))->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeStartDateTo
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeStartDateTo()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_start_date_to()
|
||||
{
|
||||
$application = factory(Application::class)->states('todo')->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$this->assertCount(1, $table->joinApplication()->startDateto($application->APP_CREATE_DATE->format("Y-m-d H:i:s"))->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeFinishCaseFrom
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeFinishCaseFrom()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_finish_case_date_from()
|
||||
{
|
||||
$application = factory(Application::class)->states('todo')->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$this->assertCount(1, $table->joinApplication()->finishCaseFrom($application->APP_FINISH_DATE->format("Y-m-d H:i:s"))->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeFinishCaseTo
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeFinishCaseTo()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_finish_case_date_to()
|
||||
{
|
||||
$application = factory(Application::class)->states('todo')->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$this->assertCount(1, $table->joinApplication()->finishCaseTo($application->APP_FINISH_DATE->format("Y-m-d H:i:s"))->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeDelegateDateFrom
|
||||
*
|
||||
@@ -513,7 +594,7 @@ class DelegationTest extends TestCase
|
||||
public function it_return_scope_exclude_tas_types()
|
||||
{
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$this->assertCount(0, $table->excludeTaskTypes(['NORMAL'])->get());
|
||||
$this->assertNotEmpty($table->excludeTaskTypes(['ADHOC'])->get());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -546,6 +627,137 @@ class DelegationTest extends TestCase
|
||||
$this->assertCount(1, $table->appStatusId()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeProcessInList
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeProcessInList()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_process_in_list()
|
||||
{
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$this->assertCount(1, $table->processInList([$table->PRO_ID])->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeJoinCategoryProcess
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeJoinCategoryProcess()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_join_category_process()
|
||||
{
|
||||
$category = factory(ProcessCategory::class)->create();
|
||||
$process = factory(Process::class)->create([
|
||||
'PRO_CATEGORY' => $category->CATEGORY_UID
|
||||
]);
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
$this->assertCount(1, $table->joinCategoryProcess($category->CATEGORY_UID)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeJoinPreviousIndex
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeJoinPreviousIndex()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_join_previous_index()
|
||||
{
|
||||
$previous = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $previous->APP_NUMBER,
|
||||
'DEL_INDEX' => $previous->DEL_INDEX+1,
|
||||
'DEL_PREVIOUS' => $previous->DEL_INDEX
|
||||
]);
|
||||
$this->assertNotEmpty($table->joinPreviousIndex()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeJoinProcess
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeJoinProcess()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_join_process()
|
||||
{
|
||||
$process = factory(Process::class)->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
$this->assertCount(1, $table->joinProcess()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeJoinTask
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeJoinTask()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_join_task()
|
||||
{
|
||||
$task = factory(Task::class)->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'TAS_ID' => $task->TAS_ID
|
||||
]);
|
||||
$this->assertCount(1, $table->joinTask()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeJoinUser
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeJoinUser()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_join_user()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'USR_ID' => $user->USR_ID
|
||||
]);
|
||||
$this->assertCount(1, $table->joinUser()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeJoinApplication
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeJoinApplication()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_join_application()
|
||||
{
|
||||
$application = factory(Application::class)->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
$this->assertCount(1, $table->joinApplication()->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test scopeJoinAppDelay
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeJoinAppDelay()
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeJoinAppDelayUsers()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_scope_join_app_delay_pause()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$delay = factory(AppDelay::class)->create([
|
||||
'APP_TYPE' => 'PAUSE',
|
||||
'APP_DISABLE_ACTION_USER' => '0',
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
]);
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'APP_NUMBER' => $delay->APP_NUMBER,
|
||||
'DEL_INDEX' => $delay->APP_DEL_INDEX
|
||||
]);
|
||||
$this->assertCount(1, $table->joinAppDelay('PAUSE')->joinAppDelayUsers($user->USR_ID)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks to make sure pagination is working properly
|
||||
*
|
||||
@@ -2892,6 +3104,58 @@ class DelegationTest extends TestCase
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the return of thread info
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::getThreadInfo()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_thread_info()
|
||||
{
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$result = Delegation::getThreadInfo($delegation->APP_NUMBER, $delegation->DEL_INDEX);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the return of pending threads
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::getPendingThreads()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_threads_pending()
|
||||
{
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$result = Delegation::getPendingThreads($delegation->APP_NUMBER);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the return of pending task
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::getPendingTask()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_task_pending()
|
||||
{
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$result = Delegation::getPendingTask($delegation->APP_NUMBER);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the return of last thread
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::getLastThread()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_last_thread()
|
||||
{
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$result = Delegation::getLastThread($delegation->APP_NUMBER);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests the getDeltitle() method
|
||||
*
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Model\Consolidated;
|
||||
|
||||
$action = (isset($_REQUEST["action"])) ? $_REQUEST["action"] : "consolidated";
|
||||
$arrayTabItem = array();
|
||||
$arrayTabItem = [];
|
||||
|
||||
$oCriteria = new Criteria("workflow");
|
||||
$oCriteria->add(CaseConsolidatedCorePeer::CON_STATUS, 'ACTIVE');
|
||||
$activeNumRows = CaseConsolidatedCorePeer::doCount($oCriteria);
|
||||
$consolidated = new Consolidated();
|
||||
$activeNumRows = $consolidated->getCounterActive();
|
||||
|
||||
$headPublisher = headPublisher::getSingleton();
|
||||
$usrUid = $_SESSION["USER_LOGGED"];
|
||||
@@ -17,8 +17,8 @@ try {
|
||||
$confCasesList = $conf->getConfiguration("casesList", $action);
|
||||
$generalConfCasesList = $conf->getConfiguration("ENVIRONMENT_SETTINGS", "");
|
||||
} catch (Exception $e) {
|
||||
$confCasesList = array();
|
||||
$generalConfCasesList = array();
|
||||
$confCasesList = [];
|
||||
$generalConfCasesList = [];
|
||||
}
|
||||
|
||||
if (isset($generalConfCasesList["casesListRowNumber"]) && !empty($generalConfCasesList["casesListRowNumber"])) {
|
||||
@@ -27,33 +27,19 @@ if (isset($generalConfCasesList["casesListRowNumber"]) && !empty($generalConfCas
|
||||
$config = getAdditionalFields($action, $confCasesList);
|
||||
$pageSize = intval($config["rowsperpage"]);
|
||||
}
|
||||
// Get a query
|
||||
$results = $consolidated->getConsolidated();
|
||||
|
||||
$criteria = new Criteria();
|
||||
$criteria->addAsColumn('NUMREC', 'COUNT(' . ListInboxPeer::TAS_UID . ')');
|
||||
$criteria->addSelectColumn(ListInboxPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(ProcessPeer::PRO_TITLE);
|
||||
$criteria->addSelectColumn(ListInboxPeer::TAS_UID);
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_TITLE);
|
||||
$criteria->addSelectColumn(CaseConsolidatedCorePeer::DYN_UID);
|
||||
$criteria->addJoin(CaseConsolidatedCorePeer::TAS_UID, ListInboxPeer::TAS_UID, Criteria::LEFT_JOIN);
|
||||
$criteria->addJoin(ListInboxPeer::PRO_UID, ProcessPeer::PRO_UID, Criteria::LEFT_JOIN);
|
||||
$criteria->addJoin(ListInboxPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
|
||||
$criteria->add(ListInboxPeer::USR_UID, $usrUid, Criteria::EQUAL);
|
||||
$criteria->add(ListInboxPeer::APP_STATUS, 'TO_DO', Criteria::EQUAL);
|
||||
$criteria->addGroupByColumn(ListInboxPeer::TAS_UID);
|
||||
$rsSql = CaseConsolidatedCorePeer::doSelectRS($criteria);
|
||||
$rsSql->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsSql->next()) {
|
||||
$row = $rsSql->getRow();
|
||||
|
||||
foreach ($results as $row) {
|
||||
$casesPerTask = count($row);
|
||||
$row = head($row);
|
||||
$processUid = $row['PRO_UID'];
|
||||
$proTitle = $row['PRO_TITLE'];
|
||||
$proTitle = 'PRO_TITLE';
|
||||
$taskUid = $row['TAS_UID'];
|
||||
$taskTitle = $row['TAS_TITLE'];
|
||||
$taskTitle = 'TAS_TITLE';
|
||||
$dynaformUid = $row['DYN_UID'];
|
||||
|
||||
$tabTitle = $taskTitle . " (" . (($activeNumRows > 0) ? $row["NUMREC"] : 0) . ")";
|
||||
$tabTitle = $taskTitle . " (" . (($activeNumRows > 0) ? $casesPerTask : 0) . ")";
|
||||
|
||||
$grdTitle = htmlentities($proTitle . " / " . $tabTitle, ENT_QUOTES, "UTF-8");
|
||||
$tabTitle = htmlentities(substr($proTitle, 0, 25) . ((strlen($proTitle) > 25) ? "..." : null) . " / " . $tabTitle, ENT_QUOTES, "UTF-8");
|
||||
@@ -117,7 +103,7 @@ if (count($arrayTabItem) > 0) {
|
||||
$headPublisher->assign("urlProxy", $urlProxy);
|
||||
$headPublisher->assign('credentials', $clientToken);
|
||||
|
||||
$oHeadPublisher->assign('isIE', Bootstrap::isIE());
|
||||
$headPublisher->assign('isIE', Bootstrap::isIE());
|
||||
|
||||
$headPublisher->addExtJsScript("app/main", true);
|
||||
$headPublisher->addExtJsScript("cases/casesListConsolidated", false); //Adding a JavaScript file .js
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use ProcessMaker\Model\Consolidated;
|
||||
|
||||
class BatchRouting extends AbstractCases
|
||||
{
|
||||
// Columns to see in the cases list
|
||||
public $columnsView = [];
|
||||
|
||||
/**
|
||||
* Get the columns related to the cases list
|
||||
* @return array
|
||||
*/
|
||||
public function getColumnsView()
|
||||
{
|
||||
return $this->columnsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope filters
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function filters($query)
|
||||
{
|
||||
// todo, the list for consolidated cases was not defined for the new HOME
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data of consolidated cases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
// todo, the list for consolidated cases was not defined for the new HOME
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of consolidated cases
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounter()
|
||||
{
|
||||
$query = Consolidated::query()->select();
|
||||
// Scope get the pending consolidated task
|
||||
$query->joinPendingCases();
|
||||
// Get only active
|
||||
$query->active();
|
||||
// Return the number of rows
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use ProcessMaker\Model\Delegation;
|
||||
|
||||
class Canceled extends AbstractCases
|
||||
{
|
||||
// Columns to see in the cases list
|
||||
public $columnsView = [];
|
||||
|
||||
/**
|
||||
* Get the columns related to the cases list
|
||||
* @return array
|
||||
*/
|
||||
public function getColumnsView()
|
||||
{
|
||||
return $this->columnsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope filters
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function filters($query)
|
||||
{
|
||||
// todo, the list for canceled cases was not defined
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data of canceled cases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
// todo, the list for canceled cases was not defined
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of canceled cases
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounter()
|
||||
{
|
||||
// Get base query
|
||||
$query = Delegation::query()->select();
|
||||
// Join with application
|
||||
$query->joinApplication();
|
||||
// Scope that sets the queries for Participated
|
||||
$query->participated($this->getUserId());
|
||||
// Scope that search for the CANCELED
|
||||
$query->caseCanceled();
|
||||
// Scope to set the last thread
|
||||
$query->lastThread();
|
||||
// Return the number of rows
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use ProcessMaker\BusinessModel\Cases\Canceled;
|
||||
use ProcessMaker\BusinessModel\Cases\BatchRouting;
|
||||
use ProcessMaker\BusinessModel\Cases\Draft;
|
||||
use ProcessMaker\BusinessModel\Cases\Inbox;
|
||||
use ProcessMaker\BusinessModel\Cases\Participated;
|
||||
use ProcessMaker\BusinessModel\Cases\Paused;
|
||||
use ProcessMaker\BusinessModel\Cases\Unassigned;
|
||||
use ProcessMaker\Model\User;
|
||||
|
||||
class CasesList
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $mapList;
|
||||
private $batchRouting;
|
||||
private $canceled;
|
||||
private $completed;
|
||||
private $draft;
|
||||
private $inbox;
|
||||
private $participated;
|
||||
private $paused;
|
||||
private $unassigned;
|
||||
|
||||
/**
|
||||
* Counter constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->mapList = [
|
||||
/*----------------------------------********---------------------------------*/
|
||||
'batchRouting' => 'CONSOLIDATED_CASES',
|
||||
/*----------------------------------********---------------------------------*/
|
||||
'canceled' => 'CASES_CANCELLED',
|
||||
'completed' => 'CASES_COMPLETED',
|
||||
'draft' => 'CASES_DRAFT',
|
||||
'inbox' => 'CASES_INBOX',
|
||||
'participated' => 'CASES_SENT',
|
||||
'paused' => 'CASES_PAUSED',
|
||||
];
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$this->batchRouting = new BatchRouting();
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$this->canceled = new Canceled();
|
||||
$this->completed = new Completed();
|
||||
$this->draft = new Draft();
|
||||
$this->inbox = new Inbox();
|
||||
$this->participated = new Participated();
|
||||
$this->paused = new Paused();
|
||||
$this->unassigned = new Unassigned();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count cases by user
|
||||
*
|
||||
* @param string $usrUid
|
||||
* @param bool $format
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllCounters(string $usrUid, bool $format = false)
|
||||
{
|
||||
// Get the usrId key
|
||||
$usrId = User::getId($usrUid);
|
||||
// Get the classes
|
||||
$list = $this->mapList;
|
||||
$response = [];
|
||||
foreach ($list as $listObject => $item) {
|
||||
$this->$listObject->setUserUid($usrUid);
|
||||
$this->$listObject->setUserId($usrId);
|
||||
$total = $this->$listObject->getCounter($usrUid);
|
||||
if ($format) {
|
||||
array_push($response, (['count' => $total, 'item' => $item]));
|
||||
} else {
|
||||
$response[$item] = $total;
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use ProcessMaker\Model\Delegation;
|
||||
|
||||
class Completed extends AbstractCases
|
||||
{
|
||||
// Columns to see in the cases list
|
||||
public $columnsView = [];
|
||||
|
||||
/**
|
||||
* Get the columns related to the cases list
|
||||
* @return array
|
||||
*/
|
||||
public function getColumnsView()
|
||||
{
|
||||
return $this->columnsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope filters
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function filters($query)
|
||||
{
|
||||
// todo, the list for completed cases was defined in participated
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data of completed cases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
// todo, the list for completed cases was defined in participated
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of completed cases
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounter()
|
||||
{
|
||||
// For started by me
|
||||
$participated = new Participated();
|
||||
$participated->setParticipatedStatus('COMPLETED');
|
||||
$participated->setUserUid($this->getUserUid());
|
||||
$participated->setUserId($this->getUserId());
|
||||
$count = $participated->getCounter();
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
98
workflow/engine/src/ProcessMaker/Model/Consolidated.php
Normal file
98
workflow/engine/src/ProcessMaker/Model/Consolidated.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Consolidated extends Model
|
||||
{
|
||||
// Set our table name
|
||||
protected $table = 'CASE_CONSOLIDATED';
|
||||
// Set the PK
|
||||
protected $primaryKey = 'TAS_UID';
|
||||
// No timestamps
|
||||
public $timestamps = false;
|
||||
// Incrementing
|
||||
public $incrementing = false;
|
||||
// Fillable fields
|
||||
protected $fillable = ['TAS_UID', 'DYN_UID ', 'REP_TAB_UID', 'CON_STATUS'];
|
||||
|
||||
/**
|
||||
* Return the task this belongs to
|
||||
*/
|
||||
public function task()
|
||||
{
|
||||
return $this->belongsTo(Task::class, 'TAS_UID', 'TAS_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include active batch routing
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('CON_STATUS', 'ACTIVE');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a join for pending cases
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeJoinPendingCases($query, $statusId = 2)
|
||||
{
|
||||
$query->leftJoin('APP_DELEGATION', function ($join) {
|
||||
$join->on('APP_DELEGATION.TAS_UID', '=', 'CASE_CONSOLIDATED.TAS_UID')
|
||||
->where('APP_DELEGATION.DEL_THREAD_STATUS', 'OPEN');
|
||||
});
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count tasks configured with consolidated
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounterActive()
|
||||
{
|
||||
$query = Consolidated::query()->select();
|
||||
// Apply filters
|
||||
$query->active();
|
||||
// Return the number of rows
|
||||
return $query->count(['CASE_CONSOLIDATED.TAS_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count tasks configured with consolidated
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getConsolidated()
|
||||
{
|
||||
$query = Consolidated::query()->select([
|
||||
'APP_DELEGATION.APP_NUMBER',
|
||||
'APP_DELEGATION.PRO_UID',
|
||||
'CASE_CONSOLIDATED.TAS_UID',
|
||||
'CASE_CONSOLIDATED.DYN_UID',
|
||||
]);
|
||||
// Scope get the pending consolidated task
|
||||
$query->joinPendingCases();
|
||||
// Get only active
|
||||
$query->active();
|
||||
// Get the rows
|
||||
$bachPerTask = [];
|
||||
$results = $query->get();
|
||||
$results->each(function ($item, $key) use (&$bachPerTask) {
|
||||
$res = $item->toArray();
|
||||
$bachPerTask[$item->TAS_UID] = [];
|
||||
$bachPerTask[$item->TAS_UID][] = $res;
|
||||
});
|
||||
// Return
|
||||
return $bachPerTask;
|
||||
}
|
||||
}
|
||||
@@ -179,6 +179,18 @@ class Delegation extends Model
|
||||
return $query->where('APPLICATION.APP_STATUS_ID', Application::STATUS_COMPLETED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the canceled by me
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCaseCanceled($query)
|
||||
{
|
||||
return $query->where('APPLICATION.APP_STATUS_ID', Application::STATUS_CANCELED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get specific status
|
||||
*
|
||||
@@ -700,23 +712,16 @@ class Delegation extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a join with APPLICATION with specific app status
|
||||
* Scope the Process is in list
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $category
|
||||
* @param array $processes
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeJoinCategoryProcess($query, $category = '')
|
||||
public function scopeProcessInList($query, array $processes)
|
||||
{
|
||||
$query->leftJoin('PROCESS', function ($join) use ($category) {
|
||||
$join->on('APP_DELEGATION.PRO_ID', '=', 'PROCESS.PRO_ID');
|
||||
if ($category) {
|
||||
$join->where('PROCESS.PRO_CATEGORY', $category);
|
||||
}
|
||||
});
|
||||
|
||||
return $query;
|
||||
return $query->whereIn('APP_DELEGATION.PRO_ID', $processes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -835,16 +840,20 @@ class Delegation extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope join with user for get the previous user
|
||||
* Scope a join with APPLICATION with specific app status
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $category
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeJoinPreviousUser($query)
|
||||
public function scopeJoinCategoryProcess($query, $category = '')
|
||||
{
|
||||
$query->leftJoin('USERS AS PREVIOUS', function ($leftJoin) {
|
||||
$leftJoin->on('AD.USR_UID', '=', 'PREVIOUS.USR_UID');
|
||||
$query->leftJoin('PROCESS', function ($join) use ($category) {
|
||||
$join->on('APP_DELEGATION.PRO_ID', '=', 'PROCESS.PRO_ID');
|
||||
if ($category) {
|
||||
$join->where('PROCESS.PRO_CATEGORY', $category);
|
||||
}
|
||||
});
|
||||
|
||||
return $query;
|
||||
@@ -914,19 +923,6 @@ class Delegation extends Model
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope the Process is in list
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $processes
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcessInList($query, array $processes)
|
||||
{
|
||||
return $query->whereIn('APP_DELEGATION.PRO_ID', $processes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope join with AppDelay
|
||||
*
|
||||
|
||||
@@ -12,6 +12,7 @@ use Luracast\Restler\RestException;
|
||||
use PmDynaform;
|
||||
use Process as ModelProcess;
|
||||
use ProcessMaker\BusinessModel\Cases as BusinessModelCases;
|
||||
use ProcessMaker\BusinessModel\Cases\CasesList;
|
||||
use ProcessMaker\BusinessModel\DynaForm as BusinessModelDynaForm;
|
||||
use ProcessMaker\BusinessModel\Light as BusinessModelLight;
|
||||
use ProcessMaker\BusinessModel\Lists;
|
||||
@@ -108,35 +109,20 @@ class Light extends Api
|
||||
|
||||
/**
|
||||
* Get list counters
|
||||
* @return array
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /counters
|
||||
* @status 200
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function countersCases()
|
||||
{
|
||||
try {
|
||||
$userId = $this->getUserId();
|
||||
$usrUid = $this->getUserId();
|
||||
$count = new CasesList();
|
||||
$result = $count->getAllCounters($usrUid);
|
||||
$result = $this->parserCountersCases($result);
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if (true) {
|
||||
//In enterprise version this block of code should always be executed
|
||||
//In community version this block of code is deleted and is executed the other
|
||||
$list = new Lists();
|
||||
$arrayListCounter = $list->getCounters($userId);
|
||||
} else {
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$case = new BusinessModelCases();
|
||||
$arrayListCounter = $case->getListCounters(
|
||||
$userId,
|
||||
['to_do', 'draft', 'sent', 'selfservice', 'paused', 'completed', 'cancelled']
|
||||
);
|
||||
/*----------------------------------********---------------------------------*/
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
$result = $this->parserCountersCases($arrayListCounter);
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
|
||||
@@ -1,54 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
use Exception;
|
||||
use Luracast\Restler\RestException;
|
||||
use PMLicensedFeatures;
|
||||
use ProcessMaker\BusinessModel\Cases\CasesList;
|
||||
use ProcessMaker\BusinessModel\DataBaseConnection;
|
||||
use ProcessMaker\BusinessModel\Language;
|
||||
use ProcessMaker\BusinessModel\Skins;
|
||||
use ProcessMaker\Services\Api;
|
||||
|
||||
/**
|
||||
* Pmtable Api Controller
|
||||
*
|
||||
* System class
|
||||
*/
|
||||
class System extends Api
|
||||
{
|
||||
/**
|
||||
* @url GET /db-engines
|
||||
* @status 200
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /db-engines
|
||||
* @protected
|
||||
*/
|
||||
public function doGetDataBaseEngines()
|
||||
{
|
||||
try {
|
||||
$oDBConnection = new \ProcessMaker\BusinessModel\DataBaseConnection();
|
||||
$response = $oDBConnection->getDbEngines();
|
||||
$dbConnection = new DataBaseConnection();
|
||||
$response = $dbConnection->getDbEngines();
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get count for all lists
|
||||
* Get counter for all lists
|
||||
*
|
||||
* @url GET /counters-lists
|
||||
* @status 200
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /counters-lists
|
||||
* @protected
|
||||
*/
|
||||
public function doGetCountersLists()
|
||||
{
|
||||
try {
|
||||
$userId = $this->getUserId();
|
||||
$lists = new \ProcessMaker\BusinessModel\Lists();
|
||||
$response = $lists->getCounters($userId);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
$usrUid = $this->getUserId();
|
||||
$count = new CasesList();
|
||||
$result = $count->getAllCounters($usrUid, true);
|
||||
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -56,49 +62,54 @@ class System extends Api
|
||||
/**
|
||||
* Get a list of the installed languages.
|
||||
*
|
||||
* @category HOR-3209,PROD-181
|
||||
* @return array
|
||||
* @url GET /languages
|
||||
* @status 200
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @public
|
||||
* @category HOR-3209,PROD-181
|
||||
*/
|
||||
public function doGetLanguages()
|
||||
{
|
||||
try {
|
||||
$language = new \ProcessMaker\BusinessModel\Language;
|
||||
$language = new Language;
|
||||
$list = $language->getLanguageList();
|
||||
|
||||
return ["data" => $list];
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @author Gustavo Cruz <gustavo.cruz@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /enabled-features
|
||||
* @status 200
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
public function doGetEnabledFeatures()
|
||||
{
|
||||
try {
|
||||
$enabledFeatures = array();
|
||||
$enabledFeatures = [];
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$keys = array ('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=',
|
||||
$keys = ['zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=',
|
||||
'oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=',
|
||||
'jXsSi94bkRUcVZyRStNVExlTXhEclVadGRRcG9xbjNvTWVFQUF3cklKQVBiVT0=');
|
||||
'jXsSi94bkRUcVZyRStNVExlTXhEclVadGRRcG9xbjNvTWVFQUF3cklKQVBiVT0='];
|
||||
foreach ($keys as $key) {
|
||||
if (\PMLicensedFeatures
|
||||
if (PMLicensedFeatures
|
||||
::getSingleton()
|
||||
->verifyfeature($key)) {
|
||||
$enabledFeatures[] = $key;
|
||||
}
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
return $enabledFeatures;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -107,6 +118,8 @@ class System extends Api
|
||||
* Get the list of installed skins.
|
||||
*
|
||||
* @url GET /skins
|
||||
* @status 200
|
||||
*
|
||||
* @return array
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_FACTORY}
|
||||
@@ -115,12 +128,12 @@ class System extends Api
|
||||
public function doGetSkins()
|
||||
{
|
||||
try {
|
||||
$model = new \ProcessMaker\BusinessModel\Skins();
|
||||
$model = new Skins();
|
||||
$response = $model->getSkins();
|
||||
|
||||
return ["data" => $response];
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user