PMCORE-2395
This commit is contained in:
@@ -16,6 +16,7 @@ $factory->define(\ProcessMaker\Model\Task::class, function(Faker $faker) {
|
||||
'TAS_TYPE_DAY' => 1,
|
||||
'TAS_DURATION' => 1,
|
||||
'TAS_ASSIGN_TYPE' => 'BALANCED',
|
||||
'TAS_DEF_TITLE' => $faker->sentence(2),
|
||||
'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED',
|
||||
'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE',
|
||||
'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE',
|
||||
@@ -44,6 +45,7 @@ $factory->state(\ProcessMaker\Model\Task::class, 'foreign_keys', function (Faker
|
||||
'TAS_TYPE_DAY' => 1,
|
||||
'TAS_DURATION' => 1,
|
||||
'TAS_ASSIGN_TYPE' => 'BALANCED',
|
||||
'TAS_DEF_TITLE' => $faker->sentence(2),
|
||||
'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED',
|
||||
'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE',
|
||||
'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE',
|
||||
|
||||
@@ -144,6 +144,7 @@ class DerivationTest extends TestCase
|
||||
];
|
||||
$appFields = [
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => $appDelegation->DEL_INDEX,
|
||||
'DEL_THREAD' => $appDelegation->DEL_THREAD,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
|
||||
@@ -196,7 +196,7 @@ class CasesTraitTest extends TestCase
|
||||
$task2 = $result->task2;
|
||||
|
||||
$processUid = $application->PRO_UID;
|
||||
$application = $application->APP_UID;
|
||||
$appUid = $application->APP_UID;
|
||||
$postForm = [
|
||||
'ROU_TYPE' => 'SEQUENTIAL',
|
||||
'TASKS' => [
|
||||
@@ -229,9 +229,9 @@ class CasesTraitTest extends TestCase
|
||||
$userLogged = $user->USR_UID;
|
||||
|
||||
$cases = new Cases();
|
||||
$cases->routeCase($processUid, $application, $postForm, $status, $flagGmail, $tasUid, $index, $userLogged);
|
||||
$cases->routeCase($processUid, $appUid, $postForm, $status, $flagGmail, $tasUid, $index, $userLogged);
|
||||
|
||||
$result = Delegation::where('APP_UID', '=', $application)->where('DEL_INDEX', '=', $index)->get()->first();
|
||||
$result = Delegation::where('APP_UID', '=', $appUid)->where('DEL_INDEX', '=', $index)->get()->first();
|
||||
|
||||
$this->assertEquals('CLOSED', $result->DEL_THREAD_STATUS);
|
||||
}
|
||||
|
||||
@@ -2372,4 +2372,18 @@ class DelegationTest extends TestCase
|
||||
$result = Delegation::participation($application->APP_UID, $user->USR_UID);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the return of thread title
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::getThreadTitle()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_thread_title()
|
||||
{
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$result = Delegation::getThreadTitle($delegation->TAS_UID, $delegation->APP_NUMBER, $delegation->DEL_INDEX, []);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -172,4 +172,18 @@ class TaskTest extends TestCase
|
||||
|
||||
$this->assertEquals($res, $task->TAS_DEF_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the get case title defined in the task
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Task::taskCaseTitle()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_case_title()
|
||||
{
|
||||
$task = factory(Task::class)->create();
|
||||
$tas = new Task();
|
||||
$result = $tas->taskCaseTitle($task->TAS_UID);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1070,7 +1070,7 @@ class Derivation
|
||||
break;
|
||||
default:
|
||||
$iNewDelIndex = $this->doDerivation($currentDelegation, $nextDel, $appFields, $aSP);
|
||||
//Load Case Data again because the information could be change in method "doDerivation"
|
||||
// Load Case Data again because the information could be change in method "doDerivation"
|
||||
$verifyApplication = $this->case->loadCase($currentDelegation['APP_UID']);
|
||||
$appFields['APP_DATA'] = $verifyApplication['APP_DATA'];
|
||||
//When the users route the case in the same time
|
||||
@@ -1286,7 +1286,6 @@ class Derivation
|
||||
$newDelegationUser,
|
||||
$currentDelegation['DEL_INDEX'],
|
||||
$nextDel['DEL_PRIORITY'],
|
||||
$delType,
|
||||
$iAppThreadIndex,
|
||||
$nextDel,
|
||||
$this->flagControl,
|
||||
@@ -2365,7 +2364,6 @@ class Derivation
|
||||
(isset( $aValue['USR_UID'] ) ? $aValue['USR_UID'] : ''),
|
||||
$currentDelegation['DEL_INDEX'],
|
||||
$nextDel['DEL_PRIORITY'],
|
||||
$delType,
|
||||
$iNewAppThreadIndex,
|
||||
$nextDel,
|
||||
$appFields['APP_NUMBER'],
|
||||
|
||||
@@ -7,6 +7,7 @@ use G;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Model\Task;
|
||||
|
||||
class Delegation extends Model
|
||||
{
|
||||
@@ -803,6 +804,25 @@ class Delegation extends Model
|
||||
return ($query->count() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the task related to the thread
|
||||
*
|
||||
* @param int $appNumber
|
||||
* @param int $index
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getThreadInfo(int $appNumber, int $index)
|
||||
{
|
||||
$query = Delegation::query()->select(['APP_NUMBER', 'TAS_UID', 'TAS_ID', 'DEL_PREVIOUS', 'DEL_TITLE']);
|
||||
$query->where('APP_NUMBER', $appNumber);
|
||||
$query->where('DEL_INDEX', $index);
|
||||
$query->limit(1);
|
||||
$result = $query->get()->toArray();
|
||||
|
||||
return head($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the thread related to the specific task-index
|
||||
*
|
||||
@@ -851,4 +871,35 @@ class Delegation extends Model
|
||||
|
||||
return $thread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the thread title related to the delegation
|
||||
*
|
||||
* @param string $tasUid
|
||||
* @param int $appNumber
|
||||
* @param int $delIndexPrevious
|
||||
* @param array $caseData
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getThreadTitle(string $tasUid, int $appNumber, int $delIndexPrevious, $caseData = [])
|
||||
{
|
||||
// Get task title defined
|
||||
$task = new Task();
|
||||
$taskTitle = $task->taskCaseTitle($tasUid);
|
||||
// If exist we will to replace the variables data
|
||||
if (!empty($taskTitle)) {
|
||||
$threadTitle = G::replaceDataField($taskTitle, $caseData, 'mysql', false);
|
||||
} else {
|
||||
// If is empty get the previous title
|
||||
if ($delIndexPrevious > 0) {
|
||||
$thread = self::getThreadInfo($appNumber, $delIndexPrevious);
|
||||
$threadTitle = $thread['DEL_TITLE'];
|
||||
} else {
|
||||
$threadTitle = '# '. $appNumber;
|
||||
}
|
||||
}
|
||||
|
||||
return $threadTitle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,27 @@ class Task extends Model
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title of the task
|
||||
*
|
||||
* @param string $tasUid
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function taskCaseTitle(string $tasUid)
|
||||
{
|
||||
$query = Task::query()->select(['TAS_DEF_TITLE']);
|
||||
$query->where('TAS_UID', $tasUid);
|
||||
$query->limit(1);
|
||||
$results = $query->get();
|
||||
$title = '';
|
||||
$results->each(function ($item) use (&$title) {
|
||||
$title = $item->TAS_DEF_TITLE;
|
||||
});
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get task data
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user