PMCORE-1464

This commit is contained in:
Paula.Quispe
2022-04-04 14:26:02 -04:00
parent e71f32e4f6
commit 55d3094e34
2 changed files with 34 additions and 47 deletions

View File

@@ -808,7 +808,7 @@ class AppDelegation extends BaseAppDelegation
return $rs->getRow();
}
public function getCurrentIndex($appUid)
public static function getCurrentIndex($appUid)
{
$oCriteria = new Criteria();
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);

View File

@@ -16,6 +16,8 @@ use G;
use ObjectPermissionPeer;
use ProcessMaker\BusinessModel\Cases AS BusinessModelCases;
use ProcessMaker\BusinessModel\ProcessSupervisor;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Validation\ValidationUploadedFiles;
use ProcessUserPeer;
@@ -769,7 +771,7 @@ class InputDocument
/**
* Get data of Cases InputDocument
*
* @param string $applicationUid
* @param string $appUid
* @param string $taskUid
* @param string $appDocComment
* @param string $inputDocumentUid
@@ -778,7 +780,7 @@ class InputDocument
* @return array Return an array with data of an InputDocument
* @throws Exception
*/
public function addCasesInputDocument($applicationUid, $taskUid, $appDocComment, $inputDocumentUid, $userUid, $runningWorkflow = true)
public function addCasesInputDocument($appUid, $taskUid, $appDocComment, $inputDocumentUid, $userUid, $runningWorkflow = true)
{
try {
if ((isset( $_FILES['form'] )) && ($_FILES['form']['error'] != 0)) {
@@ -818,49 +820,35 @@ class InputDocument
$appDocUid = G::generateUniqueID();
$docVersion = '';
$appDocType = 'INPUT';
$delIndex = AppDelegation::getCurrentIndex($appUid);
$case = new Cases();
$delIndex = AppDelegation::getCurrentIndex($applicationUid);
if ($runningWorkflow) {
$case->thisIsTheCurrentUser($applicationUid, $delIndex, $userUid, 'REDIRECT', 'casesListExtJs');
$case->thisIsTheCurrentUser($appUid, $delIndex, $userUid, 'REDIRECT', 'casesListExtJs');
} else {
$criteria = new Criteria('workflow');
$criteria->add(AppDelegationPeer::APP_UID, $applicationUid);
$criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex);
$criteria->add(AppDelegationPeer::USR_UID, $userUid);
$rsCriteria = ProcessUserPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
$case2 = new BusinessModelCases();
$arrayApplicationData = $case2->getApplicationRecordByPk($applicationUid, [], false);
$appInfo = Application::getCase($appUid);
$proUid = $appInfo['PRO_UID'];
$appNumber = $appInfo['APP_NUMBER'];
$msg = '';
// Check the current user
$currentUser = Delegation::getCurrentUser($appNumber, $delIndex);
if ($currentUser !== $userUid) {
// Review if is a supervisor
$supervisor = new ProcessSupervisor();
$flagps = $supervisor->isUserProcessSupervisor($arrayApplicationData['PRO_UID'], $userUid);
if ($flagps == false) {
$msg = G::LoadTranslation('ID_USER_NOT_IT_BELONGS_CASE_OR_NOT_SUPERVISOR');
}
if ($msg == '') {
$isSupervisor = $supervisor->isUserProcessSupervisor($proUid, $userUid);
if ($isSupervisor) {
$criteria = new Criteria('workflow');
$criteria->add(StepSupervisorPeer::PRO_UID, $arrayApplicationData['PRO_UID'], Criteria::EQUAL);
$criteria->add(StepSupervisorPeer::PRO_UID, $proUid, Criteria::EQUAL);
$criteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, 'INPUT_DOCUMENT', Criteria::EQUAL);
$criteria->add(StepSupervisorPeer::STEP_UID_OBJ, $inputDocumentUid, Criteria::EQUAL);
$rsCriteria = StepSupervisorPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
$msg = G::LoadTranslation('ID_USER_IS_SUPERVISOR_DOES_NOT_ASSOCIATED_INPUT_DOCUMENT');
}
} else {
$msg = G::LoadTranslation('ID_USER_NOT_IT_BELONGS_CASE_OR_NOT_SUPERVISOR');
}
if ($msg != '') {
}
if (!empty($msg)) {
if ($runningWorkflow) {
G::SendMessageText($msg, 'ERROR');
$backUrlObj = explode('sys' . config("system.workspace"), $_SERVER['HTTP_REFERER']);
@@ -872,10 +860,9 @@ class InputDocument
}
}
}
}
//Load the fields
$arrayField = $case->loadCase($applicationUid);
$arrayField = $case->loadCase($appUid);
$arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], G::getSystemConstants());
//Validate Process Uid and Input Document Process Uid
$inputDocumentInstance = new \InputDocument();
@@ -900,7 +887,7 @@ class InputDocument
$appDocType,
$appDocComment,
'',
$applicationUid,
$appUid,
$delIndex,
$taskUid,
$userUid,
@@ -910,7 +897,7 @@ class InputDocument
$_FILES["form"]["tmp_name"]);
}
//Trigger - Execute after - Start
$arrayField["APP_DATA"] = $case->executeTriggers ($taskUid,
$arrayField["APP_DATA"] = $case->executeTriggers($taskUid,
"INPUT_DOCUMENT",
$inputDocumentUid,
"AFTER",
@@ -923,8 +910,8 @@ class InputDocument
$arrayData["APP_DATA"] = $arrayField["APP_DATA"];
$arrayData["DEL_INDEX"] = $delIndex;
$arrayData["TAS_UID"] = $taskUid;
$case->updateCase($applicationUid, $arrayData);
return($this->getCasesInputDocument($applicationUid, $userUid, $appDocUid));
$case->updateCase($appUid, $arrayData);
return($this->getCasesInputDocument($appUid, $userUid, $appDocUid));
} catch (Exception $e) {
throw $e;
}