Merge branch 'develop' of https://bitbucket.org/colosa/processmaker into feature/PMCORE-1444
This commit is contained in:
94
workflow/engine/methods/cases/casesShowCaseNotes.php
Normal file
94
workflow/engine/methods/cases/casesShowCaseNotes.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Download documents related to the cases notes
|
||||
*/
|
||||
|
||||
use ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
if (empty($_SESSION['USER_LOGGED'])) {
|
||||
G::SendMessageText(G::LoadTranslation('ID_LOGIN_TO_SEE_OUTPUTDOCS'), "WARNING");
|
||||
G::header('Location: /errors/error403.php?url=' . urlencode($_SERVER['REQUEST_URI']));
|
||||
die();
|
||||
}
|
||||
|
||||
$appDocument = new AppDocument();
|
||||
|
||||
if (empty($_GET['a'])) {
|
||||
G::header('Location: /errors/error403.php');
|
||||
die();
|
||||
}
|
||||
|
||||
if (empty($_GET['v'])) {
|
||||
//Load last version of the document
|
||||
$docVersion = $appDocument->getLastAppDocVersion($_GET['a']);
|
||||
} else {
|
||||
$docVersion = $_GET['v'];
|
||||
}
|
||||
|
||||
$appDocument->fields = $appDocument->load($_GET['a'], $docVersion);
|
||||
|
||||
//Check if the document is a case note document
|
||||
if ($appDocument->fields['APP_DOC_TYPE'] != 'CASE_NOTE') {
|
||||
G::header('Location: /errors/error403.php');
|
||||
die();
|
||||
}
|
||||
|
||||
//Check if the user can be download the input Document
|
||||
//Send the parameter v = Version
|
||||
//Send the parameter a = Case UID
|
||||
if ($RBAC->userCanAccess('PM_FOLDERS_ALL') != 1 && defined('DISABLE_DOWNLOAD_DOCUMENTS_SESSION_VALIDATION') && DISABLE_DOWNLOAD_DOCUMENTS_SESSION_VALIDATION == 0) {
|
||||
if (!$appDocument->canDownloadInput($_SESSION['USER_LOGGED'], $_GET['a'], $docVersion)) {
|
||||
G::header('Location: /errors/error403.php');
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
//Create the Cases object
|
||||
$case = new Cases();
|
||||
//Get the case information to get the processUid
|
||||
$processUid = $case->getCaseInfo($appDocument->fields['APP_UID'], $_SESSION['USER_LOGGED'])->pro_uid;
|
||||
//Get the user authorization
|
||||
$userCanAccess = $case->userAuthorization(
|
||||
$_SESSION['USER_LOGGED'],
|
||||
$processUid,
|
||||
$appDocument->fields['APP_UID'],
|
||||
['PM_ALLCASES'],
|
||||
['CASES_NOTES' => 'VIEW']
|
||||
);
|
||||
|
||||
//Check if the user has the Case Notes permissions
|
||||
if ($userCanAccess['objectPermissions']['CASES_NOTES'] != 1) {
|
||||
G::header('Location: /errors/error403.php');
|
||||
die();
|
||||
}
|
||||
|
||||
$appDocUid = $appDocument->getAppDocUid();
|
||||
$docVersionInformation = $appDocument->getDocVersion();
|
||||
$info = pathinfo($appDocument->getAppDocFilename());
|
||||
$ext = (isset($info['extension']) ? $info['extension'] : '');
|
||||
|
||||
$download = true;
|
||||
|
||||
//Get the document path
|
||||
$appUid = G::getPathFromUID($appDocument->fields['APP_UID']);
|
||||
$file = G::getPathFromFileUID($appDocument->fields['APP_UID'], $appDocUid);
|
||||
|
||||
$realPath = PATH_DOCUMENT . $appUid . '/' . $file[0] . $file[1] . '_' . $docVersionInformation . '.' . $ext;
|
||||
$realPath1 = PATH_DOCUMENT . $appUid . '/' . $file[0] . $file[1] . '.' . $ext;
|
||||
$sw_file_exists = false;
|
||||
if (file_exists($realPath)) {
|
||||
$sw_file_exists = true;
|
||||
} elseif (file_exists($realPath1)) {
|
||||
$sw_file_exists = true;
|
||||
$realPath = $realPath1;
|
||||
}
|
||||
|
||||
if (!$sw_file_exists) {
|
||||
$error_message = G::LoadTranslation('ID_ERROR_STREAMING_FILE');
|
||||
G::SendMessageText($error_message, "ERROR");
|
||||
G::header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
die();
|
||||
} else {
|
||||
$nameFile = $appDocument->fields['APP_DOC_FILENAME'];
|
||||
G::streamFile($realPath, $download, $nameFile); //download
|
||||
}
|
||||
@@ -1,37 +1,41 @@
|
||||
<?php
|
||||
|
||||
use App\Jobs\RouteCase;
|
||||
use ProcessMaker\Core\JobsManager;
|
||||
|
||||
/**
|
||||
* cases_Derivate.php
|
||||
*
|
||||
*/
|
||||
|
||||
if (!isset($_SESSION['USER_LOGGED'])) {
|
||||
G::SendTemporalMessage('ID_LOGIN_AGAIN', 'warning', 'labels');
|
||||
die('<script type="text/javascript">
|
||||
var olink = document.location.href;
|
||||
olink = ( olink.search("gmail") == -1 ) ? parent.document.location.href : olink;
|
||||
if(olink.search("gmail") == -1){
|
||||
parent.location = "../cases/casesStartPage?action=startCase";
|
||||
} else {
|
||||
var data = olink.split("?");
|
||||
var odata = data[1].split("&");
|
||||
var appUid = odata[0].split("=");
|
||||
$script = '
|
||||
<script type="text/javascript">
|
||||
var olink = document.location.href;
|
||||
olink = ( olink.search("gmail") == -1 ) ? parent.document.location.href : olink;
|
||||
if(olink.search("gmail") == -1){
|
||||
parent.location = "../cases/casesStartPage?action=startCase";
|
||||
} else {
|
||||
var data = olink.split("?");
|
||||
var odata = data[1].split("&");
|
||||
var appUid = odata[0].split("=");
|
||||
|
||||
var dataToSend = {
|
||||
"action": "credentials",
|
||||
"operation": "refreshPmSession",
|
||||
"type": "processCall",
|
||||
"funParams": [
|
||||
appUid[1],
|
||||
""
|
||||
],
|
||||
"expectReturn": false
|
||||
};
|
||||
var x = parent.postMessage(JSON.stringify(dataToSend), "*");
|
||||
if (x == undefined){
|
||||
x = parent.parent.postMessage(JSON.stringify(dataToSend), "*");
|
||||
}
|
||||
}
|
||||
</script>');
|
||||
var dataToSend = {
|
||||
"action": "credentials",
|
||||
"operation": "refreshPmSession",
|
||||
"type": "processCall",
|
||||
"funParams": [
|
||||
appUid[1],
|
||||
""
|
||||
],
|
||||
"expectReturn": false
|
||||
};
|
||||
var x = parent.postMessage(JSON.stringify(dataToSend), "*");
|
||||
if (x == undefined){
|
||||
x = parent.parent.postMessage(JSON.stringify(dataToSend), "*");
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
die($script);
|
||||
}
|
||||
|
||||
/* Permissions */
|
||||
@@ -53,6 +57,7 @@ switch ($RBAC->userCanAccess('PM_CASES')) {
|
||||
if (!isset($_POST['form'])) {
|
||||
$_POST['form'] = [];
|
||||
}
|
||||
$postForm = $_POST['form'];
|
||||
|
||||
/* GET , POST & $_SESSION Vars */
|
||||
/* Process the info */
|
||||
@@ -61,15 +66,11 @@ $sStatus = 'TO_DO';
|
||||
try {
|
||||
//Load Session variables
|
||||
$processUid = isset($_SESSION['PROCESS']) ? $_SESSION['PROCESS'] : '';
|
||||
//load data
|
||||
$oCase = new Cases();
|
||||
// check if a task was already derivated
|
||||
if (isset($_SESSION["APPLICATION"])
|
||||
&& isset($_SESSION["INDEX"])) {
|
||||
$_SESSION['LAST_DERIVATED_APPLICATION'] = isset($_SESSION['LAST_DERIVATED_APPLICATION'])?$_SESSION['LAST_DERIVATED_APPLICATION']:'';
|
||||
$_SESSION['LAST_DERIVATED_INDEX'] = isset($_SESSION['LAST_DERIVATED_INDEX'])?$_SESSION['LAST_DERIVATED_INDEX']:'';
|
||||
if ($_SESSION["APPLICATION"] === $_SESSION['LAST_DERIVATED_APPLICATION']
|
||||
&& $_SESSION["INDEX"] === $_SESSION['LAST_DERIVATED_INDEX']) {
|
||||
if (isset($_SESSION["APPLICATION"]) && isset($_SESSION["INDEX"])) {
|
||||
$_SESSION['LAST_DERIVATED_APPLICATION'] = isset($_SESSION['LAST_DERIVATED_APPLICATION']) ? $_SESSION['LAST_DERIVATED_APPLICATION'] : '';
|
||||
$_SESSION['LAST_DERIVATED_INDEX'] = isset($_SESSION['LAST_DERIVATED_INDEX']) ? $_SESSION['LAST_DERIVATED_INDEX'] : '';
|
||||
if ($_SESSION["APPLICATION"] === $_SESSION['LAST_DERIVATED_APPLICATION'] && $_SESSION["INDEX"] === $_SESSION['LAST_DERIVATED_INDEX']) {
|
||||
throw new Exception(G::LoadTranslation('ID_INVALID_APPLICATION_ID_MSG', [G::LoadTranslation('ID_REOPEN')]));
|
||||
} else {
|
||||
$appDel = new AppDelegation();
|
||||
@@ -84,116 +85,6 @@ try {
|
||||
throw new Exception(G::LoadTranslation('ID_INVALID_APPLICATION_ID_MSG', [G::LoadTranslation('ID_REOPEN')]));
|
||||
}
|
||||
|
||||
//warning: we are not using the result value of function thisIsTheCurrentUser, so I'm commenting to optimize speed.
|
||||
//$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'casesListExtJs');
|
||||
$appFields = $oCase->loadCase($_SESSION['APPLICATION']);
|
||||
$appFields['APP_DATA'] = array_merge($appFields['APP_DATA'], G::getSystemConstants());
|
||||
//cleaning debug variables
|
||||
$_SESSION['TRIGGER_DEBUG']['DATA'] = [];
|
||||
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = [];
|
||||
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = [];
|
||||
$_SESSION['TRIGGER_DEBUG']['TRIGGERS_EXECUTION_TIME'] = [];
|
||||
|
||||
$triggers = $oCase->loadTriggers($_SESSION['TASK'], 'ASSIGN_TASK', -2, 'BEFORE');
|
||||
|
||||
//if there are some triggers to execute
|
||||
if (sizeof($triggers) > 0) {
|
||||
//Execute triggers before derivation
|
||||
$appFields['APP_DATA'] = $oCase->ExecuteTriggers($_SESSION['TASK'], 'ASSIGN_TASK', -2, 'BEFORE',
|
||||
$appFields['APP_DATA']);
|
||||
|
||||
//save trigger variables for debugger
|
||||
$_SESSION['TRIGGER_DEBUG']['info'][0]['NUM_TRIGGERS'] = sizeof($triggers);
|
||||
$_SESSION['TRIGGER_DEBUG']['info'][0]['TIME'] = G::toUpper(G::loadTranslation('ID_BEFORE'));
|
||||
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = array_column($triggers, 'TRI_TITLE');
|
||||
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_VALUES'] = $triggers;
|
||||
$_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_EXECUTION_TIME'] = $oCase->arrayTriggerExecutionTime;
|
||||
}
|
||||
|
||||
unset($appFields['APP_STATUS']);
|
||||
unset($appFields['APP_PROC_STATUS']);
|
||||
unset($appFields['APP_PROC_CODE']);
|
||||
unset($appFields['APP_PIN']);
|
||||
|
||||
$appFields["DEL_INDEX"] = $_SESSION["INDEX"];
|
||||
$appFields["TAS_UID"] = $_SESSION["TASK"];
|
||||
$appFields["USER_UID"] = $_SESSION["USER_LOGGED"];
|
||||
$appFields["CURRENT_DYNAFORM"] = "-2";
|
||||
$appFields["OBJECT_TYPE"] = "ASSIGN_TASK";
|
||||
|
||||
$oCase->updateCase($_SESSION["APPLICATION"], $appFields); //Save data
|
||||
|
||||
//Prepare information for the derivation
|
||||
$oDerivation = new Derivation();
|
||||
$aCurrentDerivation = [
|
||||
'APP_UID' => $_SESSION['APPLICATION'],
|
||||
'DEL_INDEX' => $_SESSION['INDEX'],
|
||||
'APP_STATUS' => $sStatus,
|
||||
'TAS_UID' => $_SESSION['TASK'],
|
||||
'ROU_TYPE' => $_POST['form']['ROU_TYPE']
|
||||
];
|
||||
$aDataForPrepareInfo = [
|
||||
'USER_UID' => $_SESSION['USER_LOGGED'],
|
||||
'APP_UID' => $_SESSION['APPLICATION'],
|
||||
'DEL_INDEX' => $_SESSION['INDEX']
|
||||
];
|
||||
|
||||
//We define some parameters in the before the derivation
|
||||
//Then this function will be route the case
|
||||
$arrayDerivationResult = $oDerivation->beforeDerivate(
|
||||
$aDataForPrepareInfo,
|
||||
$_POST['form']['TASKS'],
|
||||
$_POST['form']['ROU_TYPE'],
|
||||
$aCurrentDerivation
|
||||
);
|
||||
|
||||
if (!empty($arrayDerivationResult)) {
|
||||
foreach ($_POST['form']['TASKS'] as $key => $value) {
|
||||
if (isset($value['TAS_UID'])) {
|
||||
foreach ($arrayDerivationResult as $value2) {
|
||||
if ($value2['TAS_UID'] == $value['TAS_UID']) {
|
||||
$_POST['form']['TASKS'][$key]['DEL_INDEX'] = $value2['DEL_INDEX'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$appFields = $oCase->loadCase($_SESSION['APPLICATION']); //refresh appFields, because in derivations should change some values
|
||||
$triggers = $oCase->loadTriggers($_SESSION['TASK'], 'ASSIGN_TASK', -2,
|
||||
'AFTER'); //load the triggers after derivation
|
||||
if (sizeof($triggers) > 0) {
|
||||
$appFields['APP_DATA'] = $oCase->ExecuteTriggers($_SESSION['TASK'], 'ASSIGN_TASK', -2, 'AFTER',
|
||||
$appFields['APP_DATA']); //Execute triggers after derivation
|
||||
|
||||
|
||||
$_SESSION['TRIGGER_DEBUG']['info'][1]['NUM_TRIGGERS'] = sizeof($triggers);
|
||||
$_SESSION['TRIGGER_DEBUG']['info'][1]['TIME'] = G::toUpper(G::loadTranslation('ID_AFTER'));
|
||||
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_NAMES'] = array_column($triggers, 'TRI_TITLE');
|
||||
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_VALUES'] = $triggers;
|
||||
$_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_EXECUTION_TIME'] = $oCase->arrayTriggerExecutionTime;
|
||||
}
|
||||
unset($appFields['APP_STATUS']);
|
||||
unset($appFields['APP_PROC_STATUS']);
|
||||
unset($appFields['APP_PROC_CODE']);
|
||||
unset($appFields['APP_PIN']);
|
||||
|
||||
$appFields["DEL_INDEX"] = $_SESSION["INDEX"];
|
||||
$appFields["TAS_UID"] = $_SESSION["TASK"];
|
||||
$appFields["USER_UID"] = $_SESSION["USER_LOGGED"];
|
||||
$appFields["CURRENT_DYNAFORM"] = "-2";
|
||||
$appFields["OBJECT_TYPE"] = "ASSIGN_TASK";
|
||||
|
||||
$oCase->updateCase($_SESSION['APPLICATION'], $appFields);
|
||||
|
||||
// Send notifications - Start
|
||||
$oUser = new Users();
|
||||
$aUser = $oUser->load($_SESSION['USER_LOGGED']);
|
||||
$fromName = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'];
|
||||
|
||||
$sFromData = $fromName . ($aUser['USR_EMAIL'] != '' ? ' <' . $aUser['USR_EMAIL'] . '>' : '');
|
||||
|
||||
$flagGmail = false;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$licensedFeatures = PMLicensedFeatures::getSingleton();
|
||||
@@ -201,127 +92,58 @@ try {
|
||||
$pmGoogle = new PmGoogleApi();
|
||||
if ($pmGoogle->getServiceGmailStatus()) {
|
||||
$flagGmail = true;
|
||||
|
||||
$appDel = new AppDelegation();
|
||||
$actualThread = $appDel->Load($_SESSION ['APPLICATION'], $_SESSION ['INDEX']);
|
||||
|
||||
$appDelPrev = $appDel->LoadParallel($_SESSION ['APPLICATION']);
|
||||
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
|
||||
foreach ($appDelPrev as $app) {
|
||||
if (($app ['DEL_INDEX'] != $_SESSION ['INDEX']) && ($app ['DEL_PREVIOUS'] != $actualThread ['DEL_PREVIOUS'])) {
|
||||
$Pmgmail->gmailsIfSelfServiceValueBased($_SESSION ['APPLICATION'], $app ['DEL_INDEX'], $_POST ['form'] ['TASKS'], $appFields ['APP_DATA']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
try {
|
||||
$oCase->sendNotifications(
|
||||
$_SESSION['TASK'],
|
||||
$_POST['form']['TASKS'],
|
||||
$appFields['APP_DATA'],
|
||||
$_SESSION['APPLICATION'],
|
||||
$_SESSION['INDEX'],
|
||||
$sFromData
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
G::SendTemporalMessage(G::loadTranslation('ID_NOTIFICATION_ERROR') . ' - ' . $e->getMessage(), 'warning',
|
||||
'string', null, '100%');
|
||||
}
|
||||
// Send notifications - End
|
||||
// Events - Start
|
||||
$oEvent = new Event();
|
||||
$application = $_SESSION['APPLICATION'];
|
||||
$tasUid = $_SESSION['TASK'];
|
||||
$index = $_SESSION["INDEX"];
|
||||
$userLogged = $_SESSION["USER_LOGGED"];
|
||||
|
||||
// Now we dispatch the derivation of the case through Jobs Laravel.
|
||||
$closure = function() use ($processUid, $application, $postForm, $sStatus, $flagGmail, $tasUid, $index, $userLogged) {
|
||||
$cases = new Cases();
|
||||
$cases->routeCase($processUid, $application, $postForm, $sStatus, $flagGmail, $tasUid, $index, $userLogged);
|
||||
};
|
||||
JobsManager::getSingleton()->dispatch(RouteCase::class, $closure);
|
||||
|
||||
$oEvent->closeAppEvents($processUid, $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['TASK']);
|
||||
$oCurrentAppDel = AppDelegationPeer::retrieveByPk($_SESSION['APPLICATION'], $_SESSION['INDEX'] + 1);
|
||||
$multipleDelegation = false;
|
||||
// check if there are multiple derivations
|
||||
if (count($_POST['form']['TASKS']) > 1) {
|
||||
$multipleDelegation = true;
|
||||
}
|
||||
// If the case has been delegated
|
||||
if (isset($oCurrentAppDel)) {
|
||||
// if there is just a single derivation the TASK_UID can be set by the delegation data
|
||||
if (!$multipleDelegation) {
|
||||
$aCurrentAppDel = $oCurrentAppDel->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$oEvent->createAppEvents($aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'],
|
||||
$aCurrentAppDel['DEL_INDEX'], $aCurrentAppDel['TAS_UID']);
|
||||
} else {
|
||||
// else we need to check every task and create the events if it have any
|
||||
foreach ($_POST['form']['TASKS'] as $taskDelegated) {
|
||||
$aCurrentAppDel = $oCurrentAppDel->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$oEvent->createAppEvents($aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'],
|
||||
$aCurrentAppDel['DEL_INDEX'], $taskDelegated['TAS_UID']);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Events - End
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
// Set users drive - start
|
||||
$licensedFeatures = PMLicensedFeatures::getSingleton();
|
||||
if ($licensedFeatures->verifyfeature('AhKNjBEVXZlWUFpWE8wVTREQ0FObmo0aTdhVzhvalFic1M=')) {
|
||||
$drive = new AppDocumentDrive();
|
||||
if ($drive->getStatusDrive()) {
|
||||
//add users email next task
|
||||
$drive->addUsersDocumentDrive($appFields['APP_UID']);
|
||||
}
|
||||
}
|
||||
// Set users drive - End
|
||||
/*----------------------------------********---------------------------------*/
|
||||
//We close the related threads.
|
||||
$cases = new Cases();
|
||||
$cases->CloseCurrentDelegation($application, $index);
|
||||
|
||||
$debuggerAvailable = true;
|
||||
|
||||
$casesRedirector = 'casesListExtJsRedirector';
|
||||
if (isset ($_SESSION ['user_experience']) && $flagGmail === false) {
|
||||
$aNextStep ['PAGE'] = $casesRedirector . '?ux=' . $_SESSION ['user_experience'];
|
||||
$nextStep = [];
|
||||
if (isset($_SESSION['user_experience']) && $flagGmail === false) {
|
||||
$nextStep['PAGE'] = $casesRedirector . '?ux=' . $_SESSION['user_experience'];
|
||||
$debuggerAvailable = false;
|
||||
} else {
|
||||
if ($flagGmail === true) {
|
||||
$aNextStep ['PAGE'] = $casesRedirector . '?gmail=1';
|
||||
$nextStep['PAGE'] = $casesRedirector . '?gmail=1';
|
||||
} else {
|
||||
$aNextStep ['PAGE'] = $casesRedirector;
|
||||
$nextStep['PAGE'] = $casesRedirector;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION['PMDEBUGGER']) && $_SESSION['PMDEBUGGER'] && $debuggerAvailable) {
|
||||
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
|
||||
$loc = 'cases_Step?' . 'breakpoint=triggerdebug';
|
||||
} else {
|
||||
$loc = $aNextStep['PAGE'];
|
||||
}
|
||||
$loc = $nextStep['PAGE'];
|
||||
|
||||
//Triggers After
|
||||
$isIE = Bootstrap::isIE();
|
||||
|
||||
if (isset($_SESSION['TRIGGER_DEBUG']['ISSET']) && !$isIE) {
|
||||
if ($_SESSION['TRIGGER_DEBUG']['ISSET'] == 1) {
|
||||
$oTemplatePower = new TemplatePower(PATH_TPL . 'cases/cases_Step.html');
|
||||
$oTemplatePower->prepare();
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent('template', '', '', '', $oTemplatePower);
|
||||
$_POST['NextStep'] = $loc;
|
||||
$G_PUBLISH->AddContent('view', 'cases/showDebugFrameLoader');
|
||||
$G_PUBLISH->AddContent('view', 'cases/showDebugFrameBreaker');
|
||||
$_SESSION['TRIGGER_DEBUG']['ISSET'] == 0;
|
||||
G::RenderPage('publish', 'blank');
|
||||
exit();
|
||||
} else {
|
||||
unset($_SESSION['TRIGGER_DEBUG']);
|
||||
}
|
||||
}
|
||||
unset($_SESSION['TRIGGER_DEBUG']);
|
||||
|
||||
//close tab only if IE11 add a validation was added if the current skin is uxs
|
||||
if ($isIE && !isset($_SESSION['__OUTLOOK_CONNECTOR__']) && SYS_SKIN !== "uxs") {
|
||||
$script = "<script type='text/javascript'>
|
||||
try {
|
||||
if(top.opener) {
|
||||
top.opener.location.reload();
|
||||
}
|
||||
top.close();
|
||||
} catch(e) {
|
||||
}
|
||||
</script>";
|
||||
$script = "
|
||||
<script type='text/javascript'>
|
||||
try {
|
||||
if(top.opener) {
|
||||
top.opener.location.reload();
|
||||
}
|
||||
top.close();
|
||||
} catch(e) {
|
||||
}
|
||||
</script>";
|
||||
die($script);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
* @see workflow/engine/methods/services/ActionsByEmailDataForm.php
|
||||
* @link https://wiki.processmaker.com/3.3/Actions_by_Email#Link_to_Fill_a_Form
|
||||
*/
|
||||
|
||||
use ProcessMaker\BusinessModel\Cases\InputDocument;
|
||||
use ProcessMaker\ChangeLog\ChangeLog;
|
||||
use App\Jobs\ActionByEmail;
|
||||
use ProcessMaker\Core\JobsManager;
|
||||
use ProcessMaker\Validation\ValidationUploadedFiles;
|
||||
|
||||
if (PMLicensedFeatures::getSingleton()
|
||||
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=')) {
|
||||
|
||||
$featureEnable = PMLicensedFeatures::getSingleton()
|
||||
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=');
|
||||
if ($featureEnable) {
|
||||
|
||||
/**
|
||||
* To do: The following evaluation must be moved after saving the data (so as not to lose the data entered in the form).
|
||||
* It only remains because it is an old behavior, which must be defined by "Product Owner".
|
||||
@@ -22,7 +22,7 @@ if (PMLicensedFeatures::getSingleton()
|
||||
G::SendMessageText($validator->getMessage(), "ERROR");
|
||||
$url = explode("sys" . config("system.workspace"), $_SERVER['HTTP_REFERER']);
|
||||
G::header("location: " . "/sys" . config("system.workspace") . $url[1]);
|
||||
die();
|
||||
return;
|
||||
}
|
||||
|
||||
$G_PUBLISH = new Publisher();
|
||||
@@ -53,111 +53,23 @@ if (PMLicensedFeatures::getSingleton()
|
||||
$aber = G::decrypt($_REQUEST['ABER'], URL_KEY);
|
||||
$dynUid = G::decrypt($_REQUEST['DYN_UID'], URL_KEY);
|
||||
$forms = isset($_REQUEST['form']) ? $_REQUEST['form'] : [];
|
||||
$remoteAddr = $_SERVER['REMOTE_ADDR'];
|
||||
$files = $_FILES;
|
||||
|
||||
//Load data related to the case
|
||||
$case = new Cases();
|
||||
$casesFields = $case->loadCase($appUid, $delIndex);
|
||||
|
||||
// Check if the current thread is not finished
|
||||
if (!is_null($casesFields['DEL_FINISH_DATE'])) {
|
||||
throw new Exception(G::loadTranslation('ID_ABE_FORM_ALREADY_FILLED'));
|
||||
}
|
||||
// Merge the data
|
||||
$casesFields['APP_DATA'] = array_merge($casesFields['APP_DATA'], $forms);
|
||||
|
||||
//Get current user info
|
||||
$delegation = new AppDelegation();
|
||||
$currentUsrUid = $delegation->getUserAssignedInThread($appUid, $delIndex);
|
||||
if (!is_null($currentUsrUid)) {
|
||||
$users = new Users();
|
||||
$userInfo = $users->loadDetails($currentUsrUid);
|
||||
$casesFields["APP_DATA"]["USER_LOGGED"] = $currentUsrUid;
|
||||
$casesFields["APP_DATA"]["USR_USERNAME"] = $userInfo['USR_USERNAME'];
|
||||
}
|
||||
|
||||
foreach ($casesFields["APP_DATA"] as $index => $value) {
|
||||
$_SESSION[$index] = $value;
|
||||
}
|
||||
|
||||
$casesFields['CURRENT_DYNAFORM'] = $dynUid;
|
||||
$casesFields['USER_UID'] = $casesFields['CURRENT_USER_UID'];
|
||||
|
||||
ChangeLog::getChangeLog()
|
||||
->getUsrIdByUsrUid($casesFields['USER_UID'], true)
|
||||
->setSourceId(ChangeLog::FromABE);
|
||||
|
||||
//Update case info
|
||||
$case->updateCase($appUid, $casesFields);
|
||||
if (isset($_FILES ['form'])) {
|
||||
if (isset($_FILES["form"]["name"]) && count($_FILES["form"]["name"]) > 0) {
|
||||
$oInputDocument = new InputDocument();
|
||||
$oInputDocument->uploadFileCase($_FILES, $case, $casesFields, $currentUsrUid, $appUid, $delIndex);
|
||||
}
|
||||
}
|
||||
$wsBaseInstance = new WsBase();
|
||||
$result = $wsBaseInstance->derivateCase(
|
||||
$casesFields['CURRENT_USER_UID'], $appUid, $delIndex, true
|
||||
);
|
||||
$code = (is_array($result) ? $result['status_code'] : $result->status_code);
|
||||
|
||||
$dataResponses = array();
|
||||
$dataResponses['ABE_REQ_UID'] = $aber;
|
||||
$dataResponses['ABE_RES_CLIENT_IP'] = $_SERVER['REMOTE_ADDR'];
|
||||
$dataResponses['ABE_RES_DATA'] = serialize($forms);
|
||||
$dataResponses['ABE_RES_STATUS'] = 'PENDING';
|
||||
$dataResponses['ABE_RES_MESSAGE'] = '';
|
||||
|
||||
try {
|
||||
require_once 'classes/model/AbeResponses.php';
|
||||
|
||||
$abeAbeResponsesInstance = new AbeResponses();
|
||||
$dataResponses['ABE_RES_UID'] = $abeAbeResponsesInstance->createOrUpdate($dataResponses);
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
|
||||
if ($code == 0) {
|
||||
//Save Cases Notes
|
||||
$dataAbeRequests = loadAbeRequest($aber);
|
||||
$dataAbeConfiguration = loadAbeConfiguration($dataAbeRequests['ABE_UID']);
|
||||
|
||||
if ($dataAbeConfiguration['ABE_CASE_NOTE_IN_RESPONSE'] == 1) {
|
||||
$response = new stdclass();
|
||||
$response->usrUid = $casesFields['APP_DATA']['USER_LOGGED'];
|
||||
$response->appUid = $appUid;
|
||||
$response->delIndex = $delIndex;
|
||||
$response->noteText = "Check the information that was sent for the receiver: " . $dataAbeRequests['ABE_REQ_SENT_TO'];
|
||||
postNote($response);
|
||||
}
|
||||
|
||||
$dataAbeRequests['ABE_REQ_ANSWERED'] = 1;
|
||||
$code == 0 ? uploadAbeRequest($dataAbeRequests) : '';
|
||||
|
||||
$assign = $result['message'];
|
||||
$aMessage['MESSAGE'] = '<strong>' . G::loadTranslation('ID_ABE_INFORMATION_SUBMITTED') . '</strong>';
|
||||
} else {
|
||||
throw new Exception('An error occurred while the application was being processed.<br /><br />
|
||||
Error code: ' . $result->status_code . '<br />
|
||||
Error message: ' . $result->message . '<br /><br />');
|
||||
}
|
||||
|
||||
// Update
|
||||
$dataResponses['ABE_RES_STATUS'] = ($code == 0 ? 'SENT' : 'ERROR');
|
||||
$dataResponses['ABE_RES_MESSAGE'] = ($code == 0 ? '-' : $result->message);
|
||||
|
||||
try {
|
||||
$abeAbeResponsesInstance = new AbeResponses();
|
||||
$abeAbeResponsesInstance->createOrUpdate($dataResponses);
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
//Now we dispatch the derivation of the case through Jobs Laravel.
|
||||
$closure = function() use ($appUid, $delIndex, $aber, $dynUid, $forms, $remoteAddr, $files) {
|
||||
$cases = new Cases();
|
||||
$cases->routeCaseActionByEmail($appUid, $delIndex, $aber, $dynUid, $forms, $remoteAddr, $files);
|
||||
};
|
||||
JobsManager::getSingleton()->dispatch(ActionByEmail::class, $closure);
|
||||
|
||||
$message = [];
|
||||
$message['MESSAGE'] = '<strong>' . G::loadTranslation('ID_ABE_INFORMATION_SUBMITTED') . '</strong>';
|
||||
$_SESSION = unserialize($backupSession);
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showInfo', '', $aMessage);
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showInfo', '', $message);
|
||||
} catch (Exception $error) {
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', array('MESSAGE' => $error->getMessage() . ' Please contact to your system administrator.'));
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', ['MESSAGE' => $error->getMessage() . ' Please contact to your system administrator.']);
|
||||
}
|
||||
$_SESSION = unserialize($backupSession);
|
||||
G::RenderPage('publish', 'blank');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user