Merged in bugfix/PMCORE-3435 (pull request #8225)
PMCORE-3435 Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
a2879e56fe
@@ -69,4 +69,30 @@ class ConsolidatedTest extends TestCase
|
||||
$result = $consolidated->getConsolidated();
|
||||
$this->assertTrue($result > 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests the scopeJoinProcess
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Consolidated::scopeJoinProcess()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_scope_join_process()
|
||||
{
|
||||
$query = factory(Consolidated::class)->states('foreign_keys')->create();
|
||||
$consolidated = new Consolidated();
|
||||
$this->assertCount(1, $consolidated->scopeJoinProcess($query)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests the scopeJoinTask
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Consolidated::scopeJoinTask()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_scope_join_task()
|
||||
{
|
||||
$query = factory(Consolidated::class)->states('foreign_keys')->create();
|
||||
$consolidated = new Consolidated();
|
||||
$this->assertCount(1, $consolidated->scopeJoinTask($query)->get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ foreach ($results as $row) {
|
||||
$casesPerTask = count($row);
|
||||
$row = head($row);
|
||||
$processUid = $row['PRO_UID'];
|
||||
$proTitle = 'PRO_TITLE';
|
||||
$proTitle = $row['PRO_TITLE'];
|
||||
$taskUid = $row['TAS_UID'];
|
||||
$taskTitle = 'TAS_TITLE';
|
||||
$taskTitle = $row['TAS_TITLE'];
|
||||
$dynaformUid = $row['DYN_UID'];
|
||||
|
||||
$tabTitle = $taskTitle . " (" . (($activeNumRows > 0) ? $casesPerTask : 0) . ")";
|
||||
|
||||
@@ -45,7 +45,7 @@ class Consolidated extends Model
|
||||
*/
|
||||
public function scopeJoinPendingCases($query, $statusId = 2)
|
||||
{
|
||||
$query->leftJoin('APP_DELEGATION', function ($join) {
|
||||
$query->join('APP_DELEGATION', function ($join) {
|
||||
$join->on('APP_DELEGATION.TAS_UID', '=', 'CASE_CONSOLIDATED.TAS_UID')
|
||||
->where('APP_DELEGATION.DEL_THREAD_STATUS', 'OPEN');
|
||||
});
|
||||
@@ -53,6 +53,32 @@ class Consolidated extends Model
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a join with PROCESS table
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeJoinProcess($query)
|
||||
{
|
||||
$query->join('PROCESS', 'PROCESS.PRO_ID', '=', 'APP_DELEGATION.PRO_ID');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a join with TASK table
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeJoinTask($query)
|
||||
{
|
||||
$query->join('TASK', 'TASK.TAS_UID', '=', 'CASE_CONSOLIDATED.TAS_UID');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count tasks configured with consolidated
|
||||
*
|
||||
@@ -79,11 +105,15 @@ class Consolidated extends Model
|
||||
'APP_DELEGATION.PRO_UID',
|
||||
'CASE_CONSOLIDATED.TAS_UID',
|
||||
'CASE_CONSOLIDATED.DYN_UID',
|
||||
'PROCESS.PRO_TITLE',
|
||||
'TASK.TAS_TITLE'
|
||||
]);
|
||||
// Scope get the pending consolidated task
|
||||
$query->joinPendingCases();
|
||||
// Get only active
|
||||
$query->active();
|
||||
$query->joinProcess();
|
||||
$query->joinTask();
|
||||
// Get the rows
|
||||
$bachPerTask = [];
|
||||
$results = $query->get();
|
||||
|
||||
Reference in New Issue
Block a user