First commit on ProcessMaker CORE Engine and Jeaqueline's changes
This commit is contained in:
@@ -52,7 +52,7 @@ class Derivation
|
||||
*
|
||||
* @param array $aData
|
||||
* @return $taskInfo
|
||||
*/
|
||||
*/
|
||||
function prepareInformation($aData)
|
||||
{
|
||||
$oTask = new Task();
|
||||
@@ -134,7 +134,7 @@ class Derivation
|
||||
else {
|
||||
//3. load the task information of normal NEXT_TASK
|
||||
$aDerivation['NEXT_TASK'] = $oTask->load( $aDerivation['ROU_NEXT_TASK'] );//print $aDerivation['ROU_NEXT_TASK']." **** ".$aDerivation['NEXT_TASK']['TAS_TYPE']."<hr>";
|
||||
|
||||
|
||||
if ($aDerivation['NEXT_TASK']['TAS_TYPE'] === 'SUBPROCESS') {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(SubProcessPeer::PRO_PARENT, $aDerivation['PRO_UID']);
|
||||
@@ -340,8 +340,8 @@ class Derivation
|
||||
|
||||
/* get next assigned user
|
||||
*
|
||||
* @param Array $tasInfo
|
||||
* @return Array $userFields
|
||||
* @param Array $tasInfo
|
||||
* @return Array $userFields
|
||||
*/
|
||||
function getNextAssignedUser( $tasInfo ){
|
||||
$oUser = new Users();
|
||||
@@ -401,9 +401,9 @@ class Derivation
|
||||
}
|
||||
}
|
||||
else
|
||||
throw ( new Exception("Task doesn't have a valid user in variable $variable or this variable doesn't exist.") ) ;
|
||||
throw ( new Exception("Task doesn't have a valid user in variable $variable or this variable doesn't exists.") ) ;
|
||||
break;
|
||||
|
||||
|
||||
case 'REPORT_TO' :
|
||||
//default error user when the reportsTo is not assigned to that user
|
||||
//look for USR_REPORTS_TO to this user
|
||||
@@ -413,7 +413,7 @@ class Derivation
|
||||
$userFields['USR_FIRSTNAME'] = '';
|
||||
$userFields['USR_LASTNAME'] = '';
|
||||
$userFields['USR_EMAIL'] = '';
|
||||
|
||||
|
||||
//look for USR_REPORTS_TO to this user
|
||||
$useruid = $this->getDenpendentUser($tasInfo['USER_UID']);
|
||||
if ( isset ( $useruid ) ) {
|
||||
@@ -432,7 +432,7 @@ class Derivation
|
||||
$userFields = "ERROR";
|
||||
//throw ( new Exception("The current user does not have a valid Reports To user. Please contact administrator.") ) ;
|
||||
break;
|
||||
|
||||
|
||||
case 'SELF_SERVICE' :
|
||||
//look for USR_REPORTS_TO to this user
|
||||
$userFields['USR_UID'] = '';
|
||||
@@ -452,30 +452,30 @@ class Derivation
|
||||
/* getDenpendentUser
|
||||
*
|
||||
* @param string $USR_UID
|
||||
* @return string $aRow['USR_REPORTS_TO']
|
||||
* @return string $aRow['USR_REPORTS_TO']
|
||||
*/
|
||||
function getDenpendentUser($USR_UID)
|
||||
{
|
||||
//require_once 'classes/model/Users.php';
|
||||
//here the uid to next Users
|
||||
$oC=new Criteria();
|
||||
$oC->addSelectColumn(UsersPeer::USR_REPORTS_TO);
|
||||
$oC->addSelectColumn(UsersPeer::USR_REPORTS_TO);
|
||||
$oC->add(UsersPeer::USR_UID,$USR_UID);
|
||||
$oDataset=UsersPeer::doSelectRS($oC);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
return $aRow['USR_REPORTS_TO'];
|
||||
}
|
||||
|
||||
/* setTasLastAssigned
|
||||
/* setTasLastAssigned
|
||||
*
|
||||
* @param string $tasUid
|
||||
* @param string $usrUid
|
||||
* @throws Exception $e
|
||||
* @return void
|
||||
*/
|
||||
function setTasLastAssigned ( $tasUid, $usrUid )
|
||||
function setTasLastAssigned ( $tasUid, $usrUid )
|
||||
{
|
||||
try {
|
||||
$oTask = TaskPeer::retrieveByPk( $tasUid );
|
||||
@@ -486,7 +486,7 @@ class Derivation
|
||||
throw ( $e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* derivate
|
||||
*
|
||||
* @param array $currentDelegation
|
||||
@@ -495,6 +495,7 @@ class Derivation
|
||||
*/
|
||||
function derivate($currentDelegation=array(), $nextDelegations =array())
|
||||
{
|
||||
//define this...
|
||||
if ( !defined('TASK_FINISH_PROCESS')) define('TASK_FINISH_PROCESS',-1);
|
||||
if ( !defined('TASK_FINISH_TASK')) define('TASK_FINISH_TASK', -2);
|
||||
|
||||
@@ -507,7 +508,7 @@ class Derivation
|
||||
//Count how many tasks should be derivated.
|
||||
//$countNextTask = count($nextDelegations);
|
||||
foreach($nextDelegations as $nextDel) {
|
||||
//subprocesses??
|
||||
//subprocesses??
|
||||
if ($nextDel['TAS_PARENT'] != '') {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(SubProcessPeer::PRO_PARENT, $appFields['PRO_UID']);
|
||||
@@ -531,14 +532,13 @@ class Derivation
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//get TAS_ASSIGN_TYPE for current Delegation
|
||||
$oTask = TaskPeer::retrieveByPk( $currentDelegation['TAS_UID'] );
|
||||
$aTask = $oTask->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$oTask = new Task();
|
||||
$aTask = $oTask->load($currentDelegation['TAS_UID']);
|
||||
$currentDelegation['TAS_ASSIGN_TYPE'] = $aTask['TAS_ASSIGN_TYPE'];
|
||||
$currentDelegation['TAS_MI_COMPLETE_VARIABLE'] = isset($aTask['TAS_MI_COMPLETE_VARIABLE']) ? $aTask['TAS_MI_COMPLETE_VARIABLE'] : '';
|
||||
$currentDelegation['TAS_MI_INSTANCE_VARIABLE'] = isset($aTask['TAS_MI_INSTANCE_VARIABLE']) ? $aTask['TAS_MI_INSTANCE_VARIABLE'] : '';
|
||||
|
||||
$currentDelegation['TAS_MI_COMPLETE_VARIABLE'] = $aTask['TAS_MI_COMPLETE_VARIABLE'];
|
||||
$currentDelegation['TAS_MI_INSTANCE_VARIABLE'] = $aTask['TAS_MI_INSTANCE_VARIABLE'];
|
||||
|
||||
//get open threads
|
||||
$openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] );
|
||||
//if we are derivating to finish process but there are no more open thread then we are finishing only the task, we are not finishing the whole process
|
||||
@@ -559,92 +559,91 @@ class Derivation
|
||||
default:
|
||||
// get all siblingThreads
|
||||
//if($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI')
|
||||
switch ($currentDelegation['TAS_ASSIGN_TYPE']) {
|
||||
switch ($currentDelegation['TAS_ASSIGN_TYPE']) {
|
||||
case 'CANCEL_MI':
|
||||
case 'STATIC_MI':
|
||||
$siblingThreads = $this->case->GetAllOpenDelegation($currentDelegation);
|
||||
$aData = $this->case->loadCase($currentDelegation['APP_UID']);
|
||||
|
||||
if (isset($aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'])]))
|
||||
$sMIinstanceVar = $aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'])];
|
||||
else
|
||||
$sMIinstanceVar = $aData['APP_DATA']['TAS_MI_INSTANCE_VARIABLE'];
|
||||
|
||||
if (isset($aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'])]))
|
||||
$sMIcompleteVar = $aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'])];
|
||||
else
|
||||
$sMIcompleteVar = $aData['APP_DATA']['TAS_MI_COMPLETE_VARIABLE'];
|
||||
$discriminateThread = $sMIinstanceVar - $sMIcompleteVar;
|
||||
// -1 because One App Delegation is closed by above Code
|
||||
if($discriminateThread == count($siblingThreads))
|
||||
$canDerivate =true;
|
||||
else
|
||||
$canDerivate =false;
|
||||
break;
|
||||
default:
|
||||
if ( $currentDelegation['ROU_TYPE'] == 'SEC-JOIN') {
|
||||
$siblingThreads = $this->case->getOpenSiblingThreads($nextDel['TAS_UID'], $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'], $currentDelegation['TAS_UID'],$currentDelegation['ROU_TYPE']);
|
||||
$canDerivate = count($siblingThreads) == 0;
|
||||
}
|
||||
else if($currentDelegation['ROU_TYPE'] == 'DISCRIMINATOR')
|
||||
{
|
||||
//First get the total threads of Next Task where route type='Discriminator'
|
||||
$siblingThreads = $this->case->getOpenSiblingThreads($nextDel['TAS_UID'], $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'], $currentDelegation['TAS_UID'],$currentDelegation['ROU_TYPE']);
|
||||
$siblingThreadsCount = count($siblingThreads);
|
||||
$discriminateThread = $currentDelegation['ROU_CONDITION'];
|
||||
//$checkThread = count($totalThreads) - $cond;
|
||||
if($discriminateThread == $siblingThreadsCount)
|
||||
$canDerivate = true;
|
||||
else
|
||||
$canDerivate = false;
|
||||
}
|
||||
else {
|
||||
$canDerivate = true;
|
||||
}
|
||||
$siblingThreads = $this->case->GetAllOpenDelegation($currentDelegation);
|
||||
$aData = $this->case->loadCase($currentDelegation['APP_UID']);
|
||||
|
||||
if (isset($aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'])]))
|
||||
$sMIinstanceVar = $aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'])];
|
||||
else
|
||||
$sMIinstanceVar = $aData['APP_DATA']['TAS_MI_INSTANCE_VARIABLE'];
|
||||
|
||||
if (isset($aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'])]))
|
||||
$sMIcompleteVar = $aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'])];
|
||||
else
|
||||
$sMIcompleteVar = $aData['APP_DATA']['TAS_MI_COMPLETE_VARIABLE'];
|
||||
$discriminateThread = $sMIinstanceVar - $sMIcompleteVar;
|
||||
// -1 because One App Delegation is closed by above Code
|
||||
if($discriminateThread == count($siblingThreads))
|
||||
$canDerivate =true;
|
||||
else
|
||||
$canDerivate =false;
|
||||
break;
|
||||
default:
|
||||
if ( $currentDelegation['ROU_TYPE'] == 'SEC-JOIN') {
|
||||
$siblingThreads = $this->case->getOpenSiblingThreads($nextDel['TAS_UID'], $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'], $currentDelegation['TAS_UID'],$currentDelegation['ROU_TYPE']);
|
||||
$canDerivate = count($siblingThreads) == 0;
|
||||
}
|
||||
else if($currentDelegation['ROU_TYPE'] == 'DISCRIMINATOR')
|
||||
{
|
||||
//First get the total threads of Next Task where route type='Discriminator'
|
||||
$siblingThreads = $this->case->getOpenSiblingThreads($nextDel['TAS_UID'], $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'], $currentDelegation['TAS_UID'],$currentDelegation['ROU_TYPE']);
|
||||
$siblingThreadsCount = count($siblingThreads);
|
||||
$discriminateThread = $currentDelegation['ROU_CONDITION'];
|
||||
//$checkThread = count($totalThreads) - $cond;
|
||||
if($discriminateThread == $siblingThreadsCount)
|
||||
$canDerivate = true;
|
||||
else
|
||||
$canDerivate = false;
|
||||
}
|
||||
else {
|
||||
$canDerivate = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $canDerivate ) {
|
||||
$iAppThreadIndex = $appFields['DEL_THREAD'];
|
||||
$delType = 'NORMAL';
|
||||
$iAppThreadIndex = $appFields['DEL_THREAD'];
|
||||
$delType = 'NORMAL';
|
||||
switch ( $nextDel['TAS_ASSIGN_TYPE'] ) {
|
||||
case 'CANCEL_MI':
|
||||
case 'STATIC_MI':
|
||||
// Create new delegation depending on the no of users in the group
|
||||
$iNewAppThreadIndex = $appFields['DEL_THREAD'];
|
||||
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
|
||||
foreach($nextDel['NEXT_TASK']['USER_ASSIGNED'] as $key=>$aValue){
|
||||
//Incrementing the Del_thread First so that new delegation has new del_thread
|
||||
$iNewAppThreadIndex += 1;
|
||||
//Creating new delegation according to users in group
|
||||
$iMIDelIndex = $this->case->newAppDelegation( $appFields['PRO_UID'],$currentDelegation['APP_UID'],$nextDel['TAS_UID'],
|
||||
(isset($aValue['USR_UID']) ? $aValue['USR_UID'] : ''),
|
||||
$currentDelegation['DEL_INDEX'],
|
||||
$nextDel['DEL_PRIORITY'],
|
||||
$delType,
|
||||
$iNewAppThreadIndex);
|
||||
case 'CANCEL_MI':
|
||||
case 'STATIC_MI':
|
||||
// Create new delegation depending on the no of users in the group
|
||||
$iNewAppThreadIndex = $appFields['DEL_THREAD'];
|
||||
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
|
||||
foreach($nextDel['NEXT_TASK']['USER_ASSIGNED'] as $key=>$aValue){
|
||||
//Incrementing the Del_thread First so that new delegation has new del_thread
|
||||
$iNewAppThreadIndex += 1;
|
||||
//Creating new delegation according to users in group
|
||||
$iMIDelIndex = $this->case->newAppDelegation( $appFields['PRO_UID'],$currentDelegation['APP_UID'],$nextDel['TAS_UID'],
|
||||
(isset($aValue['USR_UID']) ? $aValue['USR_UID'] : ''),
|
||||
$currentDelegation['DEL_INDEX'],
|
||||
$nextDel,
|
||||
$delType,
|
||||
$iNewAppThreadIndex);
|
||||
|
||||
$iNewThreadIndex = $this->case->newAppThread ( $currentDelegation['APP_UID'], $iMIDelIndex, $iAppThreadIndex );
|
||||
|
||||
//Setting the del Index for Updating the AppThread delIndex
|
||||
if($key == 0)
|
||||
$iNewDelIndex = $iMIDelIndex -1;
|
||||
}
|
||||
break;
|
||||
case 'BALANCED' :
|
||||
$this->setTasLastAssigned ($nextDel['TAS_UID'], $nextDel['USR_UID']);
|
||||
//No Break, need no execute the default ones....
|
||||
default:
|
||||
// Create new delegation
|
||||
$iNewDelIndex = $this->case->newAppDelegation(
|
||||
$appFields['PRO_UID'], $currentDelegation['APP_UID'], $nextDel['TAS_UID'],
|
||||
(isset($nextDel['USR_UID']) ? $nextDel['USR_UID'] : ''),
|
||||
$currentDelegation['DEL_INDEX'],
|
||||
$nextDel['DEL_PRIORITY'],
|
||||
$delType,
|
||||
$iAppThreadIndex);
|
||||
break;
|
||||
}
|
||||
$iNewThreadIndex = $this->case->newAppThread ( $currentDelegation['APP_UID'], $iMIDelIndex, $iAppThreadIndex );
|
||||
|
||||
//Setting the del Index for Updating the AppThread delIndex
|
||||
if($key == 0)
|
||||
$iNewDelIndex = $iMIDelIndex -1;
|
||||
}
|
||||
break;
|
||||
case 'BALANCED' :
|
||||
$this->setTasLastAssigned ($nextDel['TAS_UID'], $nextDel['USR_UID']);
|
||||
//No Break, need no execute the default ones....
|
||||
default:
|
||||
// Create new delegation
|
||||
$iNewDelIndex = $this->case->newAppDelegation( $appFields['PRO_UID'],$currentDelegation['APP_UID'],$nextDel['TAS_UID'],
|
||||
(isset($nextDel['USR_UID']) ? $nextDel['USR_UID'] : ''),
|
||||
$currentDelegation['DEL_INDEX'],
|
||||
$nextDel,
|
||||
$delType,
|
||||
$iAppThreadIndex);
|
||||
break;
|
||||
}
|
||||
$iAppThreadIndex = $appFields['DEL_THREAD'];
|
||||
switch ( $currentDelegation['ROU_TYPE'] ) {
|
||||
case 'PARALLEL' :
|
||||
@@ -652,20 +651,21 @@ class Derivation
|
||||
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
|
||||
$iNewThreadIndex = $this->case->newAppThread ( $currentDelegation['APP_UID'], $iNewDelIndex, $iAppThreadIndex );
|
||||
$this->case->updateAppDelegation ( $currentDelegation['APP_UID'], $iNewDelIndex, $iNewThreadIndex );
|
||||
//print " this->case->updateAppDelegation ( " . $currentDelegation['APP_UID'] .", " . $iNewDelIndex ." , " . $iNewThreadIndex . " )<br>";
|
||||
break;
|
||||
case 'DISCRIMINATOR':
|
||||
case 'DISCRIMINATOR':
|
||||
if($currentDelegation['ROU_OPTIONAL'] == 'TRUE')
|
||||
{
|
||||
$this->case->discriminateCases($currentDelegation);
|
||||
} //No Break, executing Default Condition
|
||||
default :
|
||||
switch ($currentDelegation['TAS_ASSIGN_TYPE']) {
|
||||
case 'CANCEL_MI':
|
||||
case 'CANCEL_MI':
|
||||
$this->case->discriminateCases($currentDelegation);
|
||||
} //No Break, executing updateAppThread
|
||||
} //No Break, executing updateAppThread
|
||||
$this->case->updateAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex, $iNewDelIndex );
|
||||
}//switch
|
||||
|
||||
|
||||
//if there are subprocess to create
|
||||
if (isset($aSP)) {
|
||||
//Create the new case in the sub-process
|
||||
@@ -732,7 +732,7 @@ class Derivation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else { //when the task doesnt generate a new AppDelegation
|
||||
$iAppThreadIndex = $appFields['DEL_THREAD'];
|
||||
@@ -777,7 +777,7 @@ class Derivation
|
||||
* @param string $sApplicationUID
|
||||
* @return void
|
||||
*/
|
||||
function verifyIsCaseChild($sApplicationUID)
|
||||
function verifyIsCaseChild($sApplicationUID)
|
||||
{
|
||||
//Obtain the related row in the table SUB_APPLICATION
|
||||
$oCriteria = new Criteria('workflow');
|
||||
@@ -836,7 +836,7 @@ class Derivation
|
||||
$aDeriveTask['NEXT_TASK']['USER_ASSIGNED'] = $selectedUser;
|
||||
$myLabels = array ( $aDeriveTask['NEXT_TASK']['TAS_TITLE'], $aParentCase['APP_NUMBER'], $selectedUser['USR_USERNAME'], $selectedUser['USR_FIRSTNAME'], $selectedUser['USR_LASTNAME'] );
|
||||
G::SendTemporalMessage( 'ID_TASK_WAS_ASSIGNED_TO_USER', 'warning', 'labels', 10, null, $myLabels);
|
||||
|
||||
|
||||
}
|
||||
$nextDelegations2[] = array(
|
||||
'TAS_UID' => $aDeriveTask['NEXT_TASK']['TAS_UID'],
|
||||
@@ -861,16 +861,16 @@ class Derivation
|
||||
}
|
||||
}
|
||||
|
||||
/* getDerivatedCases
|
||||
/* getDerivatedCases
|
||||
* get all derivated cases and subcases from any task,
|
||||
* this function is useful to know who users have been assigned and what task they do.
|
||||
*
|
||||
* @param string $sParentUid
|
||||
* @param string $sDelIndexParent
|
||||
* @return array $derivation
|
||||
*
|
||||
*
|
||||
*/
|
||||
function getDerivatedCases ( $sParentUid, $sDelIndexParent )
|
||||
function getDerivatedCases ( $sParentUid, $sDelIndexParent )
|
||||
{
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$cases = array();
|
||||
|
||||
Reference in New Issue
Block a user