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_TYPE_DAY' => 1,
|
||||||
'TAS_DURATION' => 1,
|
'TAS_DURATION' => 1,
|
||||||
'TAS_ASSIGN_TYPE' => 'BALANCED',
|
'TAS_ASSIGN_TYPE' => 'BALANCED',
|
||||||
|
'TAS_DEF_TITLE' => $faker->sentence(2),
|
||||||
'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED',
|
'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED',
|
||||||
'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE',
|
'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE',
|
||||||
'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE',
|
'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_TYPE_DAY' => 1,
|
||||||
'TAS_DURATION' => 1,
|
'TAS_DURATION' => 1,
|
||||||
'TAS_ASSIGN_TYPE' => 'BALANCED',
|
'TAS_ASSIGN_TYPE' => 'BALANCED',
|
||||||
|
'TAS_DEF_TITLE' => $faker->sentence(2),
|
||||||
'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED',
|
'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED',
|
||||||
'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE',
|
'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE',
|
||||||
'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE',
|
'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE',
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ class DerivationTest extends TestCase
|
|||||||
];
|
];
|
||||||
$appFields = [
|
$appFields = [
|
||||||
'APP_NUMBER' => $application->APP_NUMBER,
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'DEL_INDEX' => $appDelegation->DEL_INDEX,
|
||||||
'DEL_THREAD' => $appDelegation->DEL_THREAD,
|
'DEL_THREAD' => $appDelegation->DEL_THREAD,
|
||||||
'PRO_UID' => $process->PRO_UID,
|
'PRO_UID' => $process->PRO_UID,
|
||||||
'PRO_ID' => $process->PRO_ID,
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ class CasesTraitTest extends TestCase
|
|||||||
$task2 = $result->task2;
|
$task2 = $result->task2;
|
||||||
|
|
||||||
$processUid = $application->PRO_UID;
|
$processUid = $application->PRO_UID;
|
||||||
$application = $application->APP_UID;
|
$appUid = $application->APP_UID;
|
||||||
$postForm = [
|
$postForm = [
|
||||||
'ROU_TYPE' => 'SEQUENTIAL',
|
'ROU_TYPE' => 'SEQUENTIAL',
|
||||||
'TASKS' => [
|
'TASKS' => [
|
||||||
@@ -229,9 +229,9 @@ class CasesTraitTest extends TestCase
|
|||||||
$userLogged = $user->USR_UID;
|
$userLogged = $user->USR_UID;
|
||||||
|
|
||||||
$cases = new Cases();
|
$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);
|
$this->assertEquals('CLOSED', $result->DEL_THREAD_STATUS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2372,4 +2372,18 @@ class DelegationTest extends TestCase
|
|||||||
$result = Delegation::participation($application->APP_UID, $user->USR_UID);
|
$result = Delegation::participation($application->APP_UID, $user->USR_UID);
|
||||||
$this->assertFalse($result);
|
$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);
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ use ProcessMaker\Cases\CasesTrait;
|
|||||||
use ProcessMaker\ChangeLog\ChangeLog;
|
use ProcessMaker\ChangeLog\ChangeLog;
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
|
use ProcessMaker\Model\Delegation;
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
use ProcessMaker\Util\DateTime;
|
use ProcessMaker\Util\DateTime;
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ class Cases
|
|||||||
public $dir = 'ASC';
|
public $dir = 'ASC';
|
||||||
public $sort = 'APP_MSG_DATE';
|
public $sort = 'APP_MSG_DATE';
|
||||||
public $arrayTriggerExecutionTime = [];
|
public $arrayTriggerExecutionTime = [];
|
||||||
|
public $caseTitle = '';
|
||||||
private $triggerMessageExecution = '';
|
private $triggerMessageExecution = '';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -33,6 +35,27 @@ class Cases
|
|||||||
$this->appSolr = new AppSolr($solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance']);
|
$this->appSolr = new AppSolr($solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Get the caseTitle
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCaseTitle()
|
||||||
|
{
|
||||||
|
return $this->caseTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the caseTitle
|
||||||
|
*
|
||||||
|
* @param string $v
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setCaseTitle(string $v)
|
||||||
|
{
|
||||||
|
$this->caseTitle = $v;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the triggerMessageExecution
|
* Get the triggerMessageExecution
|
||||||
@@ -608,168 +631,36 @@ class Cases
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function loads the label case
|
* Update the thread title
|
||||||
* PROCESO:
|
|
||||||
* If there is a label then it is loaded
|
|
||||||
* To get APP_DELEGATIONS that they are opened in the case
|
|
||||||
* To look for APP_DELEGATIONS wich TASK in it, It has a label defined(CASE_TITLE)
|
|
||||||
* We need to read the last APP_DELEGATION->TASK
|
|
||||||
* @param string $sAppUid
|
|
||||||
* @param string $aAppData
|
|
||||||
* @param string $sLabel
|
|
||||||
* @return $appLabel
|
|
||||||
*/
|
|
||||||
public function refreshCaseLabel($sAppUid, $aAppData, $sLabel)
|
|
||||||
{
|
|
||||||
$getAppLabel = "getApp$sLabel";
|
|
||||||
$getTasDef = "getTasDef$sLabel";
|
|
||||||
$oApplication = new Application;
|
|
||||||
if (!$oApplication->exists($sAppUid)) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
$oApplication->load($sAppUid);
|
|
||||||
$appLabel = $oApplication->$getAppLabel();
|
|
||||||
}
|
|
||||||
$cri = new Criteria;
|
|
||||||
$cri->add(AppDelegationPeer::APP_UID, $sAppUid);
|
|
||||||
$cri->add(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN");
|
|
||||||
$currentDelegations = AppDelegationPeer::doSelect($cri);
|
|
||||||
for ($r = count($currentDelegations) - 1; $r >= 0; $r--) {
|
|
||||||
$task = TaskPeer::retrieveByPk($currentDelegations[$r]->getTasUid());
|
|
||||||
$caseLabel = $task->$getTasDef();
|
|
||||||
if ($caseLabel != '') {
|
|
||||||
$appLabel = G::replaceDataField($caseLabel, $aAppData, 'mysql', false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $appLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optimized for speed. This function loads the title and description label in a case
|
|
||||||
* If there is a label then it is loaded
|
|
||||||
* Get Open APP_DELEGATIONS in the case
|
|
||||||
* To look for APP_DELEGATIONS which TASK in it, It has a label defined(CASE_TITLE)
|
|
||||||
* We need to read the last APP_DELEGATION->TASK
|
|
||||||
*
|
*
|
||||||
* @param string $appUid
|
* @param string $appUid
|
||||||
* @param array $fields
|
* @param int $appNumber
|
||||||
* @param array $lastFieldsCase
|
* @param int $delIndex
|
||||||
|
* @param array $caseData
|
||||||
*
|
*
|
||||||
* @return array
|
* @return void
|
||||||
*
|
*
|
||||||
* @see classes/Cases->startCase()
|
* @see Cases::updateCase()
|
||||||
* @see classes/Cases->updateCase()
|
|
||||||
*/
|
*/
|
||||||
public function newRefreshCaseTitleAndDescription($appUid, $fields, $lastFieldsCase = [])
|
public function updateThreadTitle(string $appUid, int $appNumber, int $delIndex, $caseData = [])
|
||||||
{
|
{
|
||||||
$res = [];
|
$threadTitle = $this->getCaseTitle();
|
||||||
|
if (empty($threadTitle) && !empty($appNumber) && !empty($delIndex)) {
|
||||||
$flagTitle = false;
|
$thread = Delegation::getThreadInfo($appNumber, $delIndex);
|
||||||
$flagDescription = false;
|
$previous = $thread['DEL_PREVIOUS'];
|
||||||
|
$appNumber = $thread['APP_NUMBER'];
|
||||||
$cri = new Criteria;
|
$tasUid = $thread['TAS_UID'];
|
||||||
$cri->clearSelectColumns();
|
if (!empty($tasUid)) {
|
||||||
$cri->addSelectColumn(AppDelegationPeer::TAS_UID);
|
$threadTitle = Delegation::getThreadTitle($tasUid, $appNumber, $previous, $caseData);
|
||||||
$cri->add(AppDelegationPeer::APP_UID, $appUid);
|
|
||||||
$cri->add(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN");
|
|
||||||
if (isset($fields['DEL_INDEX'])) {
|
|
||||||
$cri->add(AppDelegationPeer::DEL_INDEX, $fields['DEL_INDEX']);
|
|
||||||
}
|
|
||||||
$rsCri = AppDelegationPeer::doSelectRS($cri);
|
|
||||||
$rsCri->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
||||||
$rsCri->next();
|
|
||||||
$rowCri = $rsCri->getRow();
|
|
||||||
|
|
||||||
//load only the tas_def fields, because these three or two values are needed
|
|
||||||
while (is_array($rowCri)) {
|
|
||||||
$c = new Criteria();
|
|
||||||
$c->clearSelectColumns();
|
|
||||||
$c->addSelectColumn(TaskPeer::TAS_DEF_TITLE);
|
|
||||||
$c->addSelectColumn(TaskPeer::TAS_DEF_DESCRIPTION);
|
|
||||||
$c->add(TaskPeer::TAS_UID, $rowCri['TAS_UID']);
|
|
||||||
$rs = TaskPeer::doSelectRS($c);
|
|
||||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
||||||
while ($rs->next()) {
|
|
||||||
$row = $rs->getRow();
|
|
||||||
$newValues = [];
|
|
||||||
//Get the case title
|
|
||||||
$tasDefTitle = trim($row['TAS_DEF_TITLE']);
|
|
||||||
if (!empty($tasDefTitle) && !$flagTitle) {
|
|
||||||
$newAppProperty = G::replaceDataField($tasDefTitle, $lastFieldsCase, 'mysql', false);
|
|
||||||
$res['APP_TITLE'] = $newAppProperty;
|
|
||||||
if (!(isset($currentValue) && ($currentValue == $tasDefTitle))) {
|
|
||||||
$newValues['APP_TITLE'] = $newAppProperty;
|
|
||||||
$flagTitle = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Get the case description
|
// Update thread title
|
||||||
$tasDefDescription = trim($row['TAS_DEF_DESCRIPTION']);
|
$rows = [];
|
||||||
if (!empty($tasDefDescription) && !$flagDescription) {
|
$rows['APP_UID'] = $appUid;
|
||||||
$newAppProperty = G::replaceDataField($tasDefDescription, $lastFieldsCase, 'mysql', false);
|
$rows['DEL_INDEX'] = $delIndex;
|
||||||
$res['APP_DESCRIPTION'] = $newAppProperty;
|
$rows['DEL_TITLE'] = $threadTitle;
|
||||||
if (!(isset($currentValue) && ($currentValue == $tasDefDescription))) {
|
$delegation = new AppDelegation();
|
||||||
$newValues['APP_DESCRIPTION'] = $newAppProperty;
|
$delegation->update($rows);
|
||||||
$flagDescription = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($newValues)) {
|
|
||||||
$application = new Application();
|
|
||||||
$newValues['APP_UID'] = $appUid;
|
|
||||||
$application->update($newValues);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$rsCri->next();
|
|
||||||
$rowCri = $rsCri->getRow();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Small function, it uses to return the title from a case
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @name refreshCaseTitle
|
|
||||||
* @param string $sAppUid
|
|
||||||
* @param array $aAppData
|
|
||||||
* @access public
|
|
||||||
* @return $appLabel
|
|
||||||
*/
|
|
||||||
public function refreshCaseTitle($sAppUid, $aAppData)
|
|
||||||
{
|
|
||||||
return $this->refreshCaseLabel($sAppUid, $aAppData, "Title");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Small function, it uses to return the description from a case
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @name refreshCaseDescription
|
|
||||||
* @param string $sAppUid
|
|
||||||
* @param array $aAppData
|
|
||||||
* @access public
|
|
||||||
* @return $appLabel
|
|
||||||
*/
|
|
||||||
public function refreshCaseDescription($sAppUid, $aAppData)
|
|
||||||
{
|
|
||||||
return $this->refreshCaseLabel($sAppUid, $aAppData, "Description");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Small function, it uses to return the code process from a case
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @name refreshCaseDescription
|
|
||||||
* @param string $sAppUid
|
|
||||||
* @param array $aAppData
|
|
||||||
* @access public
|
|
||||||
* @return $appLabel
|
|
||||||
*/
|
|
||||||
public function refreshCaseStatusCode($sAppUid, $aAppData)
|
|
||||||
{
|
|
||||||
return $this->refreshCaseLabel($sAppUid, $aAppData, "ProcCode");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -905,12 +796,10 @@ class Cases
|
|||||||
$appFields['DEL_INDEX'] = $Fields['DEL_INDEX'];
|
$appFields['DEL_INDEX'] = $Fields['DEL_INDEX'];
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the appTitle and appDescription
|
// Update case title
|
||||||
$newTitleOrDescription = $this->newRefreshCaseTitleAndDescription(
|
if (!empty($appUid) && !empty($appFields['APP_NUMBER']) && !empty($appFields['DEL_INDEX'])) {
|
||||||
$appUid,
|
$this->updateThreadTitle($appUid, $appFields['APP_NUMBER'], $appFields['DEL_INDEX'], $appFields['APP_DATA']);
|
||||||
$appFields,
|
}
|
||||||
$appData
|
|
||||||
);
|
|
||||||
|
|
||||||
//Start: Save History --By JHL
|
//Start: Save History --By JHL
|
||||||
if (isset($Fields['CURRENT_DYNAFORM'])) {
|
if (isset($Fields['CURRENT_DYNAFORM'])) {
|
||||||
@@ -1024,7 +913,7 @@ class Cases
|
|||||||
$inbox = new ListInbox();
|
$inbox = new ListInbox();
|
||||||
unset($Fields['DEL_INIT_DATE']);
|
unset($Fields['DEL_INIT_DATE']);
|
||||||
unset($Fields['DEL_DELEGATE_DATE']);
|
unset($Fields['DEL_DELEGATE_DATE']);
|
||||||
$inbox->update(array_merge($Fields, $newTitleOrDescription));
|
$inbox->update($Fields);
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
//Return
|
//Return
|
||||||
@@ -1705,14 +1594,13 @@ class Cases
|
|||||||
* This function creates a new row into APP_DELEGATION
|
* This function creates a new row into APP_DELEGATION
|
||||||
*
|
*
|
||||||
* @name newAppDelegation
|
* @name newAppDelegation
|
||||||
* @param string $sProUid,
|
* @param string $proUid
|
||||||
* @param string $sAppUid,
|
* @param string $appUid
|
||||||
* @param string $sTasUid,
|
* @param string $tasUid
|
||||||
* @param string $sUsrUid
|
* @param string $usrUid
|
||||||
* @param string $sPrevious
|
* @param string $previous
|
||||||
* @param string $iPriority
|
* @param string $priority
|
||||||
* @param string $sDelType
|
* @param int $threadIndex
|
||||||
* @param string $iAppThreadIndex
|
|
||||||
* @param string $nextDel
|
* @param string $nextDel
|
||||||
* @param boolean $flagControl
|
* @param boolean $flagControl
|
||||||
* @param boolean $flagControlMulInstance
|
* @param boolean $flagControlMulInstance
|
||||||
@@ -1720,22 +1608,55 @@ class Cases
|
|||||||
* @param int $appNumber
|
* @param int $appNumber
|
||||||
* @param int $proId
|
* @param int $proId
|
||||||
* @param int $tasId
|
* @param int $tasId
|
||||||
* @return void
|
* @param array $caseData
|
||||||
|
*
|
||||||
|
* @see Cases::reassignCase()
|
||||||
|
* @see Cases::startCase()
|
||||||
|
* @see Cases::unpauseCase()
|
||||||
|
* @see Cases::unCancelCase()
|
||||||
|
* @see Derivation::doDerivation()
|
||||||
|
* @see Derivation::doDerivationStaticMi()
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
* @throw Exception
|
||||||
*/
|
*/
|
||||||
public function newAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sPrevious, $iPriority, $sDelType, $iAppThreadIndex = 1, $nextDel = null, $flagControl = false, $flagControlMulInstance = false, $delPrevious = 0, $appNumber = 0, $proId = 0, $tasId = 0)
|
public function newAppDelegation(
|
||||||
{
|
$proUid,
|
||||||
|
$appUid,
|
||||||
|
$tasUid,
|
||||||
|
$usrUid,
|
||||||
|
$previous,
|
||||||
|
$priority,
|
||||||
|
$threadIndex = 1,
|
||||||
|
$nextDel = null,
|
||||||
|
$flagControl = false,
|
||||||
|
$flagControlMulInstance = false,
|
||||||
|
$delPrevious = 0,
|
||||||
|
$appNumber = 0,
|
||||||
|
$proId = 0,
|
||||||
|
$tasId = 0,
|
||||||
|
$caseData = []
|
||||||
|
){
|
||||||
try {
|
try {
|
||||||
$user = UsersPeer::retrieveByPK($sUsrUid);
|
// Get case title
|
||||||
$appDel = new AppDelegation();
|
$threadTitle = $this->getCaseTitle();
|
||||||
$result = $appDel->createAppDelegation(
|
if (empty($threadTitle)) {
|
||||||
$sProUid,
|
$threadTitle = Delegation::getThreadTitle($tasUid, $appNumber, $previous, $caseData);
|
||||||
$sAppUid,
|
}
|
||||||
$sTasUid,
|
|
||||||
$sUsrUid,
|
$user = UsersPeer::retrieveByPK($usrUid);
|
||||||
$iAppThreadIndex,
|
// Create new delegation
|
||||||
$iPriority,
|
$delegation = new AppDelegation();
|
||||||
|
$delegation->setDelTitle($threadTitle);
|
||||||
|
$result = $delegation->createAppDelegation(
|
||||||
|
$proUid,
|
||||||
|
$appUid,
|
||||||
|
$tasUid,
|
||||||
|
$usrUid,
|
||||||
|
$threadIndex,
|
||||||
|
$priority,
|
||||||
false,
|
false,
|
||||||
$sPrevious,
|
$previous,
|
||||||
$nextDel,
|
$nextDel,
|
||||||
$flagControl,
|
$flagControl,
|
||||||
$flagControlMulInstance,
|
$flagControlMulInstance,
|
||||||
@@ -1745,12 +1666,12 @@ class Cases
|
|||||||
(empty($user)) ? 0 : $user->getUsrId(),
|
(empty($user)) ? 0 : $user->getUsrId(),
|
||||||
$proId
|
$proId
|
||||||
);
|
);
|
||||||
//update searchindex
|
// Update search index
|
||||||
if ($this->appSolr != null) {
|
if ($this->appSolr != null) {
|
||||||
$this->appSolr->updateApplicationSearchIndex($sAppUid);
|
$this->appSolr->updateApplicationSearchIndex($appUid);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
} catch (exception $e) {
|
} catch (Exception $e) {
|
||||||
throw ($e);
|
throw ($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2102,202 +2023,194 @@ class Cases
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function start a case using the task for the user $sUsrUid
|
* This function start a case using the task for the user $usrUid
|
||||||
* With this function we can Start a case
|
* With this function we can Start a case
|
||||||
*
|
*
|
||||||
* @name startCase
|
* @name startCase
|
||||||
* @param string $sTasUid
|
* @param string $tasUid
|
||||||
* @param string $sUsrUid
|
* @param string $usrUid
|
||||||
|
* @param bool $isSubprocess
|
||||||
|
* @param array $previousInfo
|
||||||
|
* @param bool $isSelfService
|
||||||
|
*
|
||||||
* @return Fields
|
* @return Fields
|
||||||
|
* @throw Exception
|
||||||
*/
|
*/
|
||||||
public function startCase($sTasUid, $sUsrUid, $isSubprocess = false, $dataPreviusApplication = array(), $isSelfService = false)
|
public function startCase(string $tasUid, string $usrUid, $isSubprocess = false, $previousInfo = [], $isSelfService = false)
|
||||||
{
|
{
|
||||||
if ($sTasUid != '') {
|
if (!empty($tasUid)) {
|
||||||
try {
|
try {
|
||||||
$task = TaskPeer::retrieveByPK($sTasUid);
|
$task = TaskPeer::retrieveByPK($tasUid);
|
||||||
$user = UsersPeer::retrieveByPK($sUsrUid);
|
$user = UsersPeer::retrieveByPK($usrUid);
|
||||||
|
|
||||||
if (is_null($task)) {
|
if (is_null($task)) {
|
||||||
throw new Exception(G::LoadTranslation("ID_TASK_NOT_EXIST", array("TAS_UID", $sTasUid)));
|
throw new Exception(G::LoadTranslation("ID_TASK_NOT_EXIST", ["TAS_UID", $tasUid]));
|
||||||
}
|
}
|
||||||
|
|
||||||
//To allow Self Service as the first task
|
// To allow Self Service as the first task
|
||||||
$arrayTaskTypeToExclude = array("START-TIMER-EVENT");
|
$tasksTypeToExclude = ["START-TIMER-EVENT"];
|
||||||
|
if (!is_null($task) && !in_array($task->getTasType(), $tasksTypeToExclude) && $task->getTasAssignType() != "SELF_SERVICE" && $usrUid == "") {
|
||||||
if (!is_null($task) && !in_array($task->getTasType(), $arrayTaskTypeToExclude) && $task->getTasAssignType() != "SELF_SERVICE" && $sUsrUid == "") {
|
|
||||||
throw (new Exception('You tried to start a new case without send the USER UID!'));
|
throw (new Exception('You tried to start a new case without send the USER UID!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Process
|
// Load Process
|
||||||
$sProUid = $task->getProUid();
|
$proUid = $task->getProUid();
|
||||||
$this->Process = new Process;
|
$this->Process = new Process;
|
||||||
$proFields = $this->Process->Load($sProUid);
|
$proFields = $this->Process->Load($proUid);
|
||||||
|
|
||||||
//application
|
// Create application
|
||||||
$Application = new Application;
|
$application = new Application;
|
||||||
$sAppUid = $Application->create($sProUid, $sUsrUid);
|
$appUid = $application->create($proUid, $usrUid);
|
||||||
|
$fields = $application->toArray(BasePeer::TYPE_FIELDNAME);
|
||||||
|
|
||||||
//appDelegation
|
// Create appDelegation
|
||||||
$AppDelegation = new AppDelegation;
|
$delIndex = $this->newAppDelegation(
|
||||||
$iAppThreadIndex = 1; // Start Thread
|
$proUid,
|
||||||
$iAppDelPrio = 3; // Priority
|
$appUid,
|
||||||
$iDelIndex = $AppDelegation->createAppDelegation(
|
$tasUid,
|
||||||
$sProUid,
|
$usrUid,
|
||||||
$sAppUid,
|
-1, // previous
|
||||||
$sTasUid,
|
3, // Priority
|
||||||
$sUsrUid,
|
1, // Start Thread
|
||||||
$iAppThreadIndex,
|
null, // Next delegation
|
||||||
$iAppDelPrio,
|
false, // Flag control
|
||||||
$isSubprocess,
|
false, // Flag control multi-instance
|
||||||
-1,
|
0, // Thread previous
|
||||||
null,
|
$application->getAppNumber(),
|
||||||
false,
|
$this->Process->getProId(),
|
||||||
false,
|
|
||||||
0,
|
|
||||||
$Application->getAppNumber(),
|
|
||||||
$task->getTasId(),
|
$task->getTasId(),
|
||||||
(empty($user)) ? 0 : $user->getUsrId(),
|
$fields['APP_DATA']
|
||||||
$this->Process->getProId()
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//appThread
|
// Instance appThread
|
||||||
$AppThread = new AppThread;
|
$thread = new AppThread;
|
||||||
$iAppThreadIndex = $AppThread->createAppThread($sAppUid, $iDelIndex, 0);
|
$threadIndex = $thread->createAppThread($appUid, $delIndex, 0);
|
||||||
|
// Instance Derivation
|
||||||
|
$routing = new Derivation();
|
||||||
|
|
||||||
$oDerivation = new Derivation();
|
// Multiple Instance
|
||||||
|
$aUserFields = [];
|
||||||
//Multiple Instance
|
|
||||||
$aUserFields = array();
|
|
||||||
$taskAssignType = $task->getTasAssignType();
|
$taskAssignType = $task->getTasAssignType();
|
||||||
$nextTaskAssignVariable = $task->getTasAssignVariable();
|
|
||||||
if ($taskAssignType == "MULTIPLE_INSTANCE" || $taskAssignType == "MULTIPLE_INSTANCE_VALUE_BASED") {
|
if ($taskAssignType == "MULTIPLE_INSTANCE" || $taskAssignType == "MULTIPLE_INSTANCE_VALUE_BASED") {
|
||||||
switch ($taskAssignType) {
|
switch ($taskAssignType) {
|
||||||
case 'MULTIPLE_INSTANCE':
|
case 'MULTIPLE_INSTANCE':
|
||||||
$userFields = $oDerivation->getUsersFullNameFromArray($oDerivation->getAllUsersFromAnyTask($sTasUid));
|
$userFields = $routing->getUsersFullNameFromArray($routing->getAllUsersFromAnyTask($tasUid));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw (new Exception('Invalid Task Assignment method'));
|
throw (new Exception('Invalid Task Assignment method'));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$userFields = $oDerivation->getUsersFullNameFromArray($oDerivation->getAllUsersFromAnyTask($sTasUid));
|
$userFields = $routing->getUsersFullNameFromArray($routing->getAllUsersFromAnyTask($tasUid));
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($userFields as $rowUser) {
|
foreach ($userFields as $rowUser) {
|
||||||
if ($rowUser["USR_UID"] != $sUsrUid) {
|
if ($rowUser["USR_UID"] != $usrUid) {
|
||||||
//appDelegation
|
// Create appDelegation
|
||||||
$AppDelegation = new AppDelegation;
|
$delegation = new AppDelegation;
|
||||||
$iAppThreadIndex ++; // Start Thread
|
$threadIndex ++; // Start Thread
|
||||||
$iAppDelPrio = 3; // Priority
|
$priority = 3; // Priority
|
||||||
$user = UsersPeer::retrieveByPK($rowUser["USR_UID"]);
|
$user = UsersPeer::retrieveByPK($rowUser["USR_UID"]);
|
||||||
$iDelIndex1 = $AppDelegation->createAppDelegation(
|
// Create a new delegation
|
||||||
$sProUid,
|
$delIndex1 = $this->newAppDelegation(
|
||||||
$sAppUid,
|
$proUid,
|
||||||
$sTasUid,
|
$appUid,
|
||||||
|
$tasUid,
|
||||||
$rowUser["USR_UID"],
|
$rowUser["USR_UID"],
|
||||||
$iAppThreadIndex,
|
-1, // previous
|
||||||
$iAppDelPrio,
|
$priority, // Priority
|
||||||
$isSubprocess,
|
$threadIndex, // Start Thread
|
||||||
-1,
|
null, // Next delegation
|
||||||
null,
|
false, // Flag control
|
||||||
false,
|
false, // Flag control multi-instance
|
||||||
false,
|
0, // Thread previous
|
||||||
0,
|
$application->getAppNumber(),
|
||||||
$Application->getAppNumber(),
|
$this->Process->getProId(),
|
||||||
$task->getTasId(),
|
$task->getTasId(),
|
||||||
(empty($user)) ? 0 : $user->getUsrId(),
|
$fields['APP_DATA']
|
||||||
$this->Process->getProId()
|
|
||||||
);
|
);
|
||||||
//appThread
|
// Create appThread
|
||||||
$AppThread = new AppThread;
|
$thread = new AppThread;
|
||||||
$iAppThreadIndex = $AppThread->createAppThread($sAppUid, $iDelIndex1, 0);
|
$threadIndex = $thread->createAppThread($appUid, $delIndex1, 0);
|
||||||
//Save Information
|
// Save Information
|
||||||
$aUserFields[$count] = $rowUser;
|
$aUserFields[$count] = $rowUser;
|
||||||
$aUserFields[$count]["DEL_INDEX"] = $iDelIndex1;
|
$aUserFields[$count]["DEL_INDEX"] = $delIndex1;
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//DONE: Al ya existir un delegation, se puede "calcular" el caseTitle.
|
// Update the application
|
||||||
$Fields = $Application->toArray(BasePeer::TYPE_FIELDNAME);
|
$fields = $application->toArray(BasePeer::TYPE_FIELDNAME);
|
||||||
$aApplicationFields = $Fields['APP_DATA'];
|
$fields['DEL_INDEX'] = $delIndex;
|
||||||
$Fields['DEL_INDEX'] = $iDelIndex;
|
$application->update($fields);
|
||||||
$newValues = $this->newRefreshCaseTitleAndDescription($sAppUid, $Fields, $aApplicationFields);
|
// Get current case number
|
||||||
if (!isset($newValues['APP_TITLE'])) {
|
$caseNumber = $fields['APP_NUMBER'];
|
||||||
$newValues['APP_TITLE'] = '';
|
// Update the task last assigned (for web entry and web services)
|
||||||
}
|
$routing->setTasLastAssigned($tasUid, $usrUid);
|
||||||
|
|
||||||
$caseNumber = $Fields['APP_NUMBER'];
|
|
||||||
$Application->update($Fields);
|
|
||||||
|
|
||||||
//Update the task last assigned (for web entry and web services)
|
|
||||||
$oDerivation->setTasLastAssigned($sTasUid, $sUsrUid);
|
|
||||||
|
|
||||||
// Execute Events
|
// Execute Events
|
||||||
require_once 'classes/model/Event.php';
|
require_once 'classes/model/Event.php';
|
||||||
$event = new Event();
|
$event = new Event();
|
||||||
$event->createAppEvents($sProUid, $sAppUid, $iDelIndex, $sTasUid);
|
$event->createAppEvents($proUid, $appUid, $delIndex, $tasUid);
|
||||||
|
|
||||||
//update searchindex
|
// Update solr
|
||||||
if ($this->appSolr != null) {
|
if ($this->appSolr != null) {
|
||||||
$this->appSolr->updateApplicationSearchIndex($sAppUid);
|
$this->appSolr->updateApplicationSearchIndex($appUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
$Fields['TAS_UID'] = $sTasUid;
|
$fields['TAS_UID'] = $tasUid;
|
||||||
$Fields['USR_UID'] = $sUsrUid;
|
$fields['USR_UID'] = $usrUid;
|
||||||
$Fields['DEL_INDEX'] = $iDelIndex;
|
$fields['DEL_INDEX'] = $delIndex;
|
||||||
$Fields['APP_STATUS'] = 'TO_DO';
|
$fields['APP_STATUS'] = 'TO_DO';
|
||||||
$Fields['DEL_DELEGATE_DATE'] = $Fields['APP_INIT_DATE'];
|
$fields['DEL_DELEGATE_DATE'] = $fields['APP_INIT_DATE'];
|
||||||
if (!$isSubprocess) {
|
if (!$isSubprocess) {
|
||||||
$Fields['APP_STATUS'] = 'DRAFT';
|
$fields['APP_STATUS'] = 'DRAFT';
|
||||||
} else {
|
} else {
|
||||||
$Fields['APP_INIT_DATE'] = null;
|
$fields['APP_INIT_DATE'] = null;
|
||||||
}
|
}
|
||||||
$inbox = new ListInbox();
|
$inbox = new ListInbox();
|
||||||
$inbox->newRow($Fields, $sUsrUid, $isSelfService);
|
$inbox->newRow($fields, $usrUid, $isSelfService);
|
||||||
|
|
||||||
//Multiple Instance
|
// Multiple Instance
|
||||||
foreach ($aUserFields as $rowUser) {
|
foreach ($aUserFields as $rowUser) {
|
||||||
$Fields["USR_UID"] = $rowUser["USR_UID"];
|
$fields["USR_UID"] = $rowUser["USR_UID"];
|
||||||
$Fields["DEL_INDEX"] = $rowUser["DEL_INDEX"];
|
$fields["DEL_INDEX"] = $rowUser["DEL_INDEX"];
|
||||||
$inbox = new ListInbox();
|
$inbox = new ListInbox();
|
||||||
$inbox->newRow($Fields, $sUsrUid, $isSelfService);
|
$inbox->newRow($fields, $usrUid, $isSelfService);
|
||||||
}
|
}
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
} catch (exception $e) {
|
} catch (exception $e) {
|
||||||
throw ($e);
|
throw ($e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw (new Exception('You tried to start a new case without send the USER UID or TASK UID!'));
|
throw new Exception('You tried to start a new case without send the USER UID or TASK UID!');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log
|
// Log
|
||||||
$message = 'Create case';
|
$message = 'Create case';
|
||||||
$context = $data = [
|
$context = $data = [
|
||||||
"appUid" => $sAppUid,
|
"appUid" => $appUid,
|
||||||
"usrUid" => $sUsrUid,
|
"usrUid" => $usrUid,
|
||||||
"tasUid" => $sTasUid,
|
"tasUid" => $tasUid,
|
||||||
"isSubprocess" => $isSubprocess,
|
"isSubprocess" => $isSubprocess,
|
||||||
"appNumber" => $caseNumber,
|
"appNumber" => $caseNumber,
|
||||||
"delIndex" => $iDelIndex,
|
"delIndex" => $delIndex,
|
||||||
"appInitDate" => $Fields['APP_INIT_DATE']
|
"appInitDate" => $fields['APP_INIT_DATE']
|
||||||
];
|
];
|
||||||
Log::channel(':CreateCase')->info($message, Bootstrap::context($context));
|
Log::channel(':CreateCase')->info($message, Bootstrap::context($context));
|
||||||
//call plugin
|
// Call plugin
|
||||||
if (class_exists('folderData')) {
|
if (class_exists('folderData')) {
|
||||||
$folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $newValues['APP_TITLE'], $sUsrUid);
|
$folderData = new folderData($proUid, $proFields['PRO_TITLE'], $appUid, '', $usrUid);
|
||||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||||
$oPluginRegistry->executeTriggers(PM_CREATE_CASE, $folderData);
|
$oPluginRegistry->executeTriggers(PM_CREATE_CASE, $folderData);
|
||||||
}
|
}
|
||||||
$this->getExecuteTriggerProcess($sAppUid, 'CREATE');
|
$this->getExecuteTriggerProcess($appUid, 'CREATE');
|
||||||
//end plugin
|
//end plugin
|
||||||
return array(
|
return [
|
||||||
'APPLICATION' => $sAppUid,
|
'APPLICATION' => $appUid,
|
||||||
'INDEX' => $iDelIndex,
|
'INDEX' => $delIndex,
|
||||||
'PROCESS' => $sProUid,
|
'PROCESS' => $proUid,
|
||||||
'CASE_NUMBER' => $caseNumber
|
'CASE_NUMBER' => $caseNumber
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3590,17 +3503,6 @@ class Cases
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the caseTitle from the nextTask and update the caseTitle
|
|
||||||
*/
|
|
||||||
if ($varInAfterRouting) {
|
|
||||||
$this->newRefreshCaseTitleAndDescription(
|
|
||||||
$appUid,
|
|
||||||
['DEL_INDEX' => 0],
|
|
||||||
$fieldsCase
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
if (!empty($foundDisabledCode)) {
|
if (!empty($foundDisabledCode)) {
|
||||||
G::SendTemporalMessage(
|
G::SendTemporalMessage(
|
||||||
@@ -4258,112 +4160,113 @@ class Cases
|
|||||||
* unpause a case
|
* unpause a case
|
||||||
*
|
*
|
||||||
* @name unpauseCase
|
* @name unpauseCase
|
||||||
* @param string $sApplicationUID
|
* @param string $appUid
|
||||||
* @param string $iDelegation
|
* @param int $index
|
||||||
* @param string $sUserUID
|
* @param string $usrUid
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
public function unpauseCase($sApplicationUID, $iDelegation, $sUserUID)
|
public function unpauseCase($appUid, $index, $usrUid)
|
||||||
{
|
{
|
||||||
//Verify status of the case
|
// Verify status of the case
|
||||||
$oDelay = new AppDelay();
|
$delay = new AppDelay();
|
||||||
if (method_exists($oDelay, 'isPaused')) {
|
if (method_exists($delay, 'isPaused')) {
|
||||||
if ($oDelay->isPaused($sApplicationUID, $iDelegation) === false) {
|
if ($delay->isPaused($appUid, $index) === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//get information about current $iDelegation row
|
// Get information about current $index row
|
||||||
$oAppDelegation = new AppDelegation();
|
$delegation = new AppDelegation();
|
||||||
$user = UsersPeer::retrieveByPK($sUserUID);
|
$delRow = $delegation->Load($appUid, $index);
|
||||||
$aFieldsDel = $oAppDelegation->Load($sApplicationUID, $iDelegation);
|
|
||||||
//and creates a new AppDelegation row with the same user, task, process, etc.
|
//and creates a new AppDelegation row with the same user, task, process, etc.
|
||||||
$proUid = $aFieldsDel['PRO_UID'];
|
$proUid = $delRow['PRO_UID'];
|
||||||
$appUid = $aFieldsDel['APP_UID'];
|
$appUid = $delRow['APP_UID'];
|
||||||
$tasUid = $aFieldsDel['TAS_UID'];
|
$tasUid = $delRow['TAS_UID'];
|
||||||
$usrUid = $aFieldsDel['USR_UID'];
|
$usrUid = $delRow['USR_UID'];
|
||||||
$delThread = $aFieldsDel['DEL_THREAD'];
|
// Load Application
|
||||||
$iIndex = $oAppDelegation->createAppDelegation(
|
$application = new Application();
|
||||||
|
$caseFields = $application->Load($appUid);
|
||||||
|
$caseData = unserialize($caseFields['APP_DATA']);
|
||||||
|
|
||||||
|
// Create a new delegation
|
||||||
|
$newIndex = $this->newAppDelegation(
|
||||||
$proUid,
|
$proUid,
|
||||||
$appUid,
|
$appUid,
|
||||||
$tasUid,
|
$tasUid,
|
||||||
$usrUid,
|
$usrUid,
|
||||||
$delThread,
|
-1, // previous
|
||||||
3,
|
3, // Priority
|
||||||
false,
|
1, // Start Thread
|
||||||
-1,
|
null, // Next delegation
|
||||||
null,
|
false, // Flag control
|
||||||
false,
|
false, // Flag control multi-instance
|
||||||
false,
|
0, // Thread previous
|
||||||
0,
|
$delRow['APP_NUMBER'],
|
||||||
$aFieldsDel['APP_NUMBER'],
|
$delRow['PRO_ID'],
|
||||||
$aFieldsDel['TAS_ID'],
|
$delRow['TAS_ID'],
|
||||||
(empty($user)) ? 0 : $user->getUsrId(),
|
$caseData
|
||||||
$aFieldsDel['PRO_ID']
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//update other fields in the recent new appDelegation
|
// Update other fields in the recent new appDelegation
|
||||||
$aData = array();
|
$row = [];
|
||||||
$aData['APP_UID'] = $aFieldsDel['APP_UID'];
|
$row['APP_UID'] = $delRow['APP_UID'];
|
||||||
$aData['DEL_INDEX'] = $iIndex;
|
$row['DEL_INDEX'] = $newIndex;
|
||||||
$aData['DEL_PREVIOUS'] = $aFieldsDel['DEL_PREVIOUS'];
|
$row['DEL_PREVIOUS'] = $delRow['DEL_PREVIOUS'];
|
||||||
$aData['DEL_TYPE'] = $aFieldsDel['DEL_TYPE'];
|
$row['DEL_TYPE'] = $delRow['DEL_TYPE'];
|
||||||
$aData['DEL_PRIORITY'] = $aFieldsDel['DEL_PRIORITY'];
|
$row['DEL_PRIORITY'] = $delRow['DEL_PRIORITY'];
|
||||||
$aData['DEL_DELEGATE_DATE'] = $aFieldsDel['DEL_DELEGATE_DATE'];
|
$row['DEL_DELEGATE_DATE'] = $delRow['DEL_DELEGATE_DATE'];
|
||||||
$aData['DEL_INIT_DATE'] = date('Y-m-d H:i:s');
|
$row['DEL_INIT_DATE'] = date('Y-m-d H:i:s');
|
||||||
$aData['DEL_FINISH_DATE'] = null;
|
$row['DEL_FINISH_DATE'] = null;
|
||||||
$oAppDelegation->update($aData);
|
$delegation->update($row);
|
||||||
|
|
||||||
//get the APP_DELAY row ( with app_uid, del_index and app_type=pause
|
// Get the APP_DELAY row with app_uid, del_index and app_type=pause
|
||||||
$oCriteria = new Criteria('workflow');
|
$criteria = new Criteria('workflow');
|
||||||
$oCriteria->clearSelectColumns();
|
$criteria->clearSelectColumns();
|
||||||
$oCriteria->addSelectColumn(AppDelayPeer::APP_DELAY_UID);
|
$criteria->addSelectColumn(AppDelayPeer::APP_DELAY_UID);
|
||||||
$oCriteria->addSelectColumn(AppDelayPeer::APP_THREAD_INDEX);
|
$criteria->addSelectColumn(AppDelayPeer::APP_THREAD_INDEX);
|
||||||
$oCriteria->addSelectColumn(AppDelayPeer::APP_STATUS);
|
$criteria->addSelectColumn(AppDelayPeer::APP_STATUS);
|
||||||
$oCriteria->add(AppDelayPeer::APP_UID, $sApplicationUID);
|
$criteria->add(AppDelayPeer::APP_UID, $appUid);
|
||||||
$oCriteria->add(AppDelayPeer::APP_DEL_INDEX, $iDelegation);
|
$criteria->add(AppDelayPeer::APP_DEL_INDEX, $index);
|
||||||
$oCriteria->add(AppDelayPeer::APP_TYPE, 'PAUSE');
|
$criteria->add(AppDelayPeer::APP_TYPE, 'PAUSE');
|
||||||
$oCriteria->add(
|
$criteria->add(
|
||||||
$oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL)->addOr(
|
$criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL)->addOr(
|
||||||
$oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL))
|
$criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL))
|
||||||
);
|
);
|
||||||
|
$dataset = AppDelayPeer::doSelectRS($criteria);
|
||||||
|
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
$dataset->next();
|
||||||
|
$rowPaused = $dataset->getRow();
|
||||||
|
|
||||||
$oDataset = AppDelayPeer::doSelectRS($oCriteria);
|
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
||||||
$oDataset->next();
|
|
||||||
$aRow = $oDataset->getRow();
|
|
||||||
|
|
||||||
$oApplication = new Application();
|
$caseFields['APP_STATUS'] = $rowPaused['APP_STATUS'];
|
||||||
$aFields = $oApplication->Load($sApplicationUID);
|
$application->update($caseFields);
|
||||||
$aFields['APP_STATUS'] = $aRow['APP_STATUS'];
|
|
||||||
$oApplication->update($aFields);
|
|
||||||
|
|
||||||
//update the DEL_INDEX ? in APP_THREAD table?
|
// Update the DEL_INDEX ? in APP_THREAD table?
|
||||||
$aUpdate = array(
|
$rowUpdate = [
|
||||||
'APP_UID' => $sApplicationUID,
|
'APP_UID' => $appUid,
|
||||||
'APP_THREAD_INDEX' => $aRow['APP_THREAD_INDEX'],
|
'APP_THREAD_INDEX' => $rowPaused['APP_THREAD_INDEX'],
|
||||||
'DEL_INDEX' => $iIndex
|
'DEL_INDEX' => $newIndex
|
||||||
);
|
];
|
||||||
$oAppThread = new AppThread();
|
$thread = new AppThread();
|
||||||
$oAppThread->update($aUpdate);
|
$thread->update($rowUpdate);
|
||||||
|
|
||||||
$aData['APP_DELAY_UID'] = $aRow['APP_DELAY_UID'];
|
$row['APP_DELAY_UID'] = $rowPaused['APP_DELAY_UID'];
|
||||||
$aData['APP_DISABLE_ACTION_USER'] = $sUserUID;
|
$row['APP_DISABLE_ACTION_USER'] = $usrUid;
|
||||||
$aData['APP_DISABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
|
$row['APP_DISABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
|
||||||
$oAppDelay = new AppDelay();
|
$delay = new AppDelay();
|
||||||
$aFieldsDelay = $oAppDelay->update($aData);
|
$rowDelay = $delay->update($row);
|
||||||
|
|
||||||
//update searchindex
|
// Update searchindex
|
||||||
if ($this->appSolr != null) {
|
if ($this->appSolr != null) {
|
||||||
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
|
$this->appSolr->updateApplicationSearchIndex($appUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getExecuteTriggerProcess($sApplicationUID, "UNPAUSE");
|
$this->getExecuteTriggerProcess($appUid, "UNPAUSE");
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
$aData = array_merge($aFieldsDel, $aData);
|
$row = array_merge($delRow, $row);
|
||||||
$oListPaused = new ListPaused();
|
$listPaused = new ListPaused();
|
||||||
$oListPaused->remove($sApplicationUID, $iDelegation, $aData);
|
$listPaused->remove($appUid, $index, $row);
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4505,28 +4408,26 @@ class Cases
|
|||||||
|
|
||||||
//Get all the threads in the AppDelay
|
//Get all the threads in the AppDelay
|
||||||
foreach ($threadsCanceled as $row){
|
foreach ($threadsCanceled as $row){
|
||||||
//Load the thread CLOSED
|
// Load the thread CLOSED
|
||||||
$appDelegation = new AppDelegation();
|
$appDelegation = new AppDelegation();
|
||||||
$delegationClosed = $appDelegation->Load($appUid, $row['APP_DEL_INDEX']);
|
$delegationClosed = $appDelegation->Load($appUid, $row['APP_DEL_INDEX']);
|
||||||
//Create an appDelegation for each thread
|
// Create an appDelegation for each thread
|
||||||
$appDelegation = new AppDelegation();
|
$delIndex = $this->newAppDelegation(
|
||||||
$delIndex = $appDelegation->createAppDelegation(
|
|
||||||
$delegationClosed['PRO_UID'],
|
$delegationClosed['PRO_UID'],
|
||||||
$delegationClosed['APP_UID'],
|
$delegationClosed['APP_UID'],
|
||||||
$delegationClosed['TAS_UID'],
|
$delegationClosed['TAS_UID'],
|
||||||
$usrUid,
|
$usrUid,
|
||||||
$delegationClosed['DEL_THREAD'],
|
$delegationClosed['DEL_PREVIOUS'], // previous
|
||||||
3,
|
3, // Priority
|
||||||
false,
|
$delegationClosed['DEL_THREAD'], // Start Thread
|
||||||
$delegationClosed['DEL_PREVIOUS'],
|
null, // Next delegation
|
||||||
null,
|
false, // Flag control
|
||||||
false,
|
false, // Flag control multi-instance
|
||||||
false,
|
0, // Thread previous
|
||||||
0,
|
|
||||||
$delegationClosed['APP_NUMBER'],
|
$delegationClosed['APP_NUMBER'],
|
||||||
|
$delegationClosed['PRO_ID'],
|
||||||
$delegationClosed['TAS_ID'],
|
$delegationClosed['TAS_ID'],
|
||||||
$userId,
|
$caseFields['APP_DATA']
|
||||||
$delegationClosed['PRO_ID']
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//Update the appThread
|
//Update the appThread
|
||||||
@@ -4658,23 +4559,29 @@ class Cases
|
|||||||
$user = UsersPeer::retrieveByPK($newUserUid);
|
$user = UsersPeer::retrieveByPK($newUserUid);
|
||||||
$appDelegation = new AppDelegation();
|
$appDelegation = new AppDelegation();
|
||||||
$fieldsDel = $appDelegation->Load($appUid, $delIndex);
|
$fieldsDel = $appDelegation->Load($appUid, $delIndex);
|
||||||
$newDelIndex = $appDelegation->createAppDelegation(
|
|
||||||
|
// Load application
|
||||||
|
$application = new Application();
|
||||||
|
$dataFields = $application->Load($appUid);
|
||||||
|
$caseData = unserialize($dataFields['APP_DATA']);
|
||||||
|
|
||||||
|
// Create a new delegation
|
||||||
|
$newDelIndex = $this->newAppDelegation(
|
||||||
$fieldsDel['PRO_UID'],
|
$fieldsDel['PRO_UID'],
|
||||||
$fieldsDel['APP_UID'],
|
$fieldsDel['APP_UID'],
|
||||||
$fieldsDel['TAS_UID'],
|
$fieldsDel['TAS_UID'],
|
||||||
$newUserUid,
|
$newUserUid,
|
||||||
$fieldsDel['DEL_THREAD'],
|
-1, // previous
|
||||||
3,
|
3, // Priority
|
||||||
false,
|
$fieldsDel['DEL_THREAD'], // Start Thread
|
||||||
-1,
|
null, // Next delegation
|
||||||
null,
|
false, // Flag control
|
||||||
false,
|
false, // Flag control multi-instance
|
||||||
false,
|
0, // Thread previous
|
||||||
0,
|
|
||||||
$fieldsDel['APP_NUMBER'],
|
$fieldsDel['APP_NUMBER'],
|
||||||
|
$fieldsDel['PRO_ID'],
|
||||||
$fieldsDel['TAS_ID'],
|
$fieldsDel['TAS_ID'],
|
||||||
(empty($user)) ? 0 : $user->getUsrId(),
|
$caseData
|
||||||
$fieldsDel['PRO_ID']
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$newData = [];
|
$newData = [];
|
||||||
@@ -4698,9 +4605,7 @@ class Cases
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
//Save in APP_DELAY
|
|
||||||
$application = new Application();
|
|
||||||
$dataFields = $application->Load($appUid);
|
|
||||||
$newData['PRO_UID'] = $fieldsDel['PRO_UID'];
|
$newData['PRO_UID'] = $fieldsDel['PRO_UID'];
|
||||||
$newData['APP_UID'] = $appUid;
|
$newData['APP_UID'] = $appUid;
|
||||||
$newData['APP_THREAD_INDEX'] = $fieldsDel['DEL_THREAD'];
|
$newData['APP_THREAD_INDEX'] = $fieldsDel['DEL_THREAD'];
|
||||||
|
|||||||
@@ -1070,7 +1070,7 @@ class Derivation
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$iNewDelIndex = $this->doDerivation($currentDelegation, $nextDel, $appFields, $aSP);
|
$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']);
|
$verifyApplication = $this->case->loadCase($currentDelegation['APP_UID']);
|
||||||
$appFields['APP_DATA'] = $verifyApplication['APP_DATA'];
|
$appFields['APP_DATA'] = $verifyApplication['APP_DATA'];
|
||||||
//When the users route the case in the same time
|
//When the users route the case in the same time
|
||||||
@@ -1286,7 +1286,6 @@ class Derivation
|
|||||||
$newDelegationUser,
|
$newDelegationUser,
|
||||||
$currentDelegation['DEL_INDEX'],
|
$currentDelegation['DEL_INDEX'],
|
||||||
$nextDel['DEL_PRIORITY'],
|
$nextDel['DEL_PRIORITY'],
|
||||||
$delType,
|
|
||||||
$iAppThreadIndex,
|
$iAppThreadIndex,
|
||||||
$nextDel,
|
$nextDel,
|
||||||
$this->flagControl,
|
$this->flagControl,
|
||||||
@@ -2365,7 +2364,6 @@ class Derivation
|
|||||||
(isset( $aValue['USR_UID'] ) ? $aValue['USR_UID'] : ''),
|
(isset( $aValue['USR_UID'] ) ? $aValue['USR_UID'] : ''),
|
||||||
$currentDelegation['DEL_INDEX'],
|
$currentDelegation['DEL_INDEX'],
|
||||||
$nextDel['DEL_PRIORITY'],
|
$nextDel['DEL_PRIORITY'],
|
||||||
$delType,
|
|
||||||
$iNewAppThreadIndex,
|
$iNewAppThreadIndex,
|
||||||
$nextDel,
|
$nextDel,
|
||||||
$appFields['APP_NUMBER'],
|
$appFields['APP_NUMBER'],
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use G;
|
|||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
|
use ProcessMaker\Model\Task;
|
||||||
|
|
||||||
class Delegation extends Model
|
class Delegation extends Model
|
||||||
{
|
{
|
||||||
@@ -803,6 +804,25 @@ class Delegation extends Model
|
|||||||
return ($query->count() > 0);
|
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
|
* Return the thread related to the specific task-index
|
||||||
*
|
*
|
||||||
@@ -851,4 +871,35 @@ class Delegation extends Model
|
|||||||
|
|
||||||
return $thread;
|
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;
|
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
|
* Get task data
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user