Merged in release/3.3.4 (pull request #6782)

Release/3.3.4

Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
Paula Quispe
2019-02-14 12:45:43 +00:00
25 changed files with 1445 additions and 560 deletions

View File

@@ -3484,8 +3484,19 @@ class Cases
* @param string $stepUidObj
* @param string $triggerType
* @param string $labelAssignment
* @param bool $useGlobal, needs to have the value true if the same case in execution is affected with this trigger
*
* @return array
*
* @see Cases::executeTriggers()
* @see Cases::getExecuteTriggerProcess()
* @see WsBase::executeTriggerFromDerivate()
* @see ScriptTask::execScriptByActivityUid()
*
* @link https://wiki.processmaker.com/3.2/Triggers#Custom_Trigger
* @link https://wiki.processmaker.com/3.2/Triggers#When_action_cases
* @link https://wiki.processmaker.com/3.1/Triggers
* @link https://wiki.processmaker.com/3.1/Tasks#ScriptTask
*/
public function executeTriggerFromList(
array $triggersList,
@@ -3493,17 +3504,23 @@ class Cases
$stepType,
$stepUidObj,
$triggerType,
$labelAssignment = ''
$labelAssignment = '',
$useGlobal = true
)
{
if (count($triggersList) > 0) {
global $oPMScript;
if ($useGlobal) {
/**
* The global $oPMScript is necessary when the trigger can be update the appData related to the case
* in execution
*/
global $oPMScript;
}
$this->addTriggerMessageExecution("<br /><b>" . $labelAssignment . "</b><br />");
if (!isset($oPMScript)) {
$oPMScript = new PMScript();
}
$oPMScript->setFields($fieldsCase);
/*----------------------------------********---------------------------------*/
$cs = new CodeScanner(config("system.workspace"));
@@ -3520,6 +3537,7 @@ class Cases
}
/*----------------------------------********---------------------------------*/
$oPMScript->setFields($fieldsCase);
$execute = true;
//Check if the trigger has conditions for the execution
if (!empty($trigger['ST_CONDITION'])) {
@@ -3550,9 +3568,19 @@ class Cases
//Other thread execution can be changed the variables
$appUid = !empty($fieldsCase['APPLICATION']) ? $fieldsCase['APPLICATION'] : '';
if (!empty($appUid)) {
$lastFieldsCase = $this->loadCase($appUid)['APP_DATA'];
//Update $fieldsCase with the last appData
$fieldsCase = $this->loadCase($appUid)['APP_DATA'];
$fieldsCase = array_merge($fieldsCase, $lastFieldsCase);
}
//Update the case with the fields changed in the trigger
if (!empty($fieldsTrigger)) {
$appFieldsTrigger = [];
$appFieldsTrigger['APP_DATA'] = $fieldsTrigger;
//Update the case
$this->updateCase($appUid, $appFieldsTrigger);
}
//Merge the appData with variables changed
$fieldsCase = array_merge($fieldsCase, $fieldsTrigger);
} else {
@@ -4338,14 +4366,15 @@ class Cases
* @param string $appUid
* @param integer $delIndex
* @param string $usrUid
* @param bool $executeSameCase
*
* @see Ajax::cancelCase()
* @see cases_Ajax
* @see WsBase::cancelCase()
*
* @return boolean|string
*/
public function cancelCase($appUid, $delIndex = null, $usrUid = null)
public function cancelCase($appUid, $delIndex = null, $usrUid = null, $executeSameCase = true)
{
/** Execute a trigger when a case is cancelled */
$this->getExecuteTriggerProcess($appUid, 'CANCELED');
$caseFields = $this->loadCase($appUid);
$appStatusCurrent = $caseFields['APP_STATUS'];
@@ -4374,6 +4403,9 @@ class Cases
);
$delay->create($rowDelay);
/** Execute a trigger when a case is cancelled */
$this->getExecuteTriggerProcess($appUid, 'CANCELED', $executeSameCase);
/*----------------------------------********---------------------------------*/
$dataList = [
'APP_UID' => $appUid,
@@ -7249,40 +7281,56 @@ class Cases
return $response;
}
public function getExecuteTriggerProcess($appUid, $action)
/**
* Execute triggers when committing an action in cases
*
* @param string $appUid
* @param string $action, can be [OPEN, CANCELED, PAUSED, REASSIGNED, DELETED, CREATE, UNPAUSE]
* @param bool $executeSameCase
*
* @return bool
*
* @see cases_Open.php
* @see cancelCase/Cases.php pauseCase/Cases.php reassignCase/Cases.php removeCase/Cases.php unpauseCase/Cases.php on
* @link https://wiki.processmaker.com/3.2/Triggers#When_action_cases
*/
public function getExecuteTriggerProcess($appUid, $action, $executeSameCase = true)
{
if ((!isset($appUid) && $appUid == '') || (!isset($action) && $action == '')) {
if (empty($appUid) || empty($action)) {
return false;
}
$aFields = $this->loadCase($appUid);
$proUid = $aFields['PRO_UID'];
require_once("classes/model/Process.php");
$fieldsCase = $this->loadCase($appUid);
$proUid = $fieldsCase['PRO_UID'];
//Set some global system variables
$fieldsCase['APP_DATA']['APPLICATION'] = $appUid;
$fieldsCase['APP_DATA']['PROCESS'] = $proUid;
//Get the trigger configured in the process action
$appProcess = new Process();
$arrayWebBotTrigger = $appProcess->getTriggerWebBotProcess($proUid, $action);
$triggersList = $appProcess->getTriggerWebBotProcess($proUid, $action);
if ($arrayWebBotTrigger['TRI_WEBBOT'] != false && $arrayWebBotTrigger['TRI_WEBBOT'] != '') {
global $oPMScript;
$aFields['APP_DATA']['APPLICATION'] = $appUid;
$aFields['APP_DATA']['PROCESS'] = $proUid;
$oPMScript = new PMScript();
$oPMScript->setDataTrigger($arrayWebBotTrigger);
$oPMScript->setFields($aFields['APP_DATA']);
$oPMScript->setScript($arrayWebBotTrigger['TRI_WEBBOT']);
$oPMScript->setExecutedOn(PMScript::PROCESS_ACTION);
$oPMScript->execute();
if (!empty($triggersList)){
//Execute the trigger defined in the process action
$fieldsCase['APP_DATA'] = $this->executeTriggerFromList(
$triggersList,
$fieldsCase['APP_DATA'],
'PROCESS_ACTION',
'',
'',
'',
$executeSameCase
);
$aFields['APP_DATA'] = array_merge($aFields['APP_DATA'], $oPMScript->aFields);
unset($aFields['APP_STATUS']);
unset($aFields['APP_PROC_STATUS']);
unset($aFields['APP_PROC_CODE']);
unset($aFields['APP_PIN']);
$this->updateCase($aFields['APP_UID'], $aFields);
//Update the case
$this->updateCase($appUid, $fieldsCase);
return true;
} else {
return false;
}
return false;
}
/**

View File

@@ -4211,21 +4211,37 @@ class ProcessMap
}
}
public function downloadFile($sProcessUID, $sMainDirectory, $sCurrentDirectory, $sFile)
/**
* Stream a file from "mailTemplates" or "public" directory thats belongs to a process
*
* @param string $processUid
* @param string $mainDirectory
* @param string $currentDirectory
* @param string $file
*/
public function downloadFile($processUid, $mainDirectory, $currentDirectory, $file)
{
switch ($sMainDirectory) {
// Validate directory and file requested
$filter = new InputFilter();
$currentDirectory = $filter->validatePath($currentDirectory);
$file = $filter->validatePath($file);
// Validate the main directory
switch ($mainDirectory) {
case 'mailTemplates':
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . ($sCurrentDirectory != '' ? $sCurrentDirectory . PATH_SEP : '');
$sDirectory = PATH_DATA_MAILTEMPLATES . $processUid . PATH_SEP . ($currentDirectory != '' ? $currentDirectory . PATH_SEP : '');
break;
case 'public':
$sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . ($sCurrentDirectory != '' ? $sCurrentDirectory . PATH_SEP : '');
$sDirectory = PATH_DATA_PUBLIC . $processUid . PATH_SEP . ($currentDirectory != '' ? $currentDirectory . PATH_SEP : '');
break;
default:
die();
break;
}
if (file_exists($sDirectory . $sFile)) {
G::streamFile($sDirectory . $sFile, true);
// Stream the file if path exists
if (file_exists($sDirectory . $file)) {
G::streamFile($sDirectory . $file, true);
}
}

View File

@@ -11,6 +11,7 @@ class WsBase
{
public $stored_system_variables; //boolean
public $wsSessionId; //web service session id, if the wsbase function is used from a WS request
private $flagSameCase = true;
public function __construct($params = null)
{
@@ -23,6 +24,28 @@ class WsBase
}
}
/**
* Get the flagSameCase
*
* @return boolean
*/
public function getFlagSameCase()
{
return $this->flagSameCase;
}
/**
* Set the flagSameCase
*
* @param boolean $var
*
* @return void
*/
public function setFlagSameCase($var)
{
$this->flagSameCase = $var;
}
/**
* function to start a web services session in ProcessMaker
*
@@ -2071,57 +2094,72 @@ class WsBase
}
/**
* creates a new case impersonating a user who has the proper privileges to create new cases
* Creates a new case impersonating a user who has the proper privileges to create new cases
*
* @param string $processId
* @param string $userId
* @param string $variables
* @param string $taskId , must be in the starting group.
* @param array $variables, that are set in the new case
* @param string $taskId, must be in the starting group.
*
* @return $result will return an object
* @return object
*
* @see PMFNewCaseImpersonate/class.pmFunctions.php on
* @link https://wiki.processmaker.com/3.1/ProcessMaker_Functions#PMFNewCaseImpersonate.28.29
*
* @see doPostCaseImpersonate/Api/Cases on
* @link https://wiki.processmaker.com/3.2/REST_API_Cases/Cases#New_Case_Impersonate_User:_POST_.2Fcases.2Fimpersonate
*
* @see NewCaseImpersonate/soap2.php on
* @link https://wiki.processmaker.com/3.0/ProcessMaker_WSDL_Web_Services#newCaseImpersonate.28.29
*/
public function newCaseImpersonate($processId, $userId, $variables, $taskId = '')
{
try {
if (is_array($variables)) {
if (count($variables) > 0) {
$c = count($variables);
$Fields = $variables;
} else {
if ($c == 0) {
$result = new WsResponse(10, G::loadTranslation('ID_ARRAY_VARIABLES_EMPTY'));
$g = new G();
$g->sessionVarSave();
return $result;
}
$c = count($variables);
if (is_array($variables)) {
if ($c > 0) {
$fieldsVariables = $variables;
} elseif ($c === 0) {
$result = new WsResponse(10, G::loadTranslation('ID_ARRAY_VARIABLES_EMPTY'));
$g->sessionVarRestore();
return $result;
}
} else {
$result = new WsResponse(10, G::loadTranslation('ID_VARIABLES_PARAM_NOT_ARRAY'));
$g->sessionVarRestore();
return $result;
}
$processes = new Processes();
if (!$processes->processExists($processId)) {
$result = new WsResponse(11, G::loadTranslation('ID_INVALID_PROCESS') . " " . $processId . "!!");
$g->sessionVarRestore();
return $result;
}
$user = new Users();
if (!$user->userExists($userId)) {
$result = new WsResponse(11, G::loadTranslation('ID_USER_NOT_REGISTERED') . " " . $userId . "!!");
$g->sessionVarRestore();
return $result;
} else {
$user->load($userId);
$userName = $user->getUsrUsername();
}
$oCase = new Cases();
$caseInstance = new Cases();
$numTasks = 0;
if ($taskId != '') {
$aTasks = $processes->getStartingTaskForUser($processId, null);
foreach ($aTasks as $task) {
if (!empty($taskId)) {
$startTasks = $processes->getStartingTaskForUser($processId, null);
foreach ($startTasks as $task) {
if ($task['TAS_UID'] == $taskId) {
$arrayTask[0]['TAS_UID'] = $taskId;
$numTasks = 1;
@@ -2132,38 +2170,47 @@ class WsBase
$numTasks = count($arrayTask);
}
if ($numTasks == 1) {
$case = $oCase->startCase($arrayTask[0]['TAS_UID'], $userId);
$caseId = $case['APPLICATION'];
$caseNumber = $case['CASE_NUMBER'];
if ($numTasks === 1) {
//@todo Find a better way to define session variables
$_SESSION["PROCESS"] = $processId;
$_SESSION["TASK"] = $arrayTask[0]['TAS_UID'];
$_SESSION["USER_LOGGED"] = $userId;
$_SESSION["INDEX"] = 1;
$_SESSION["USR_USERNAME"] = $userName;
$oldFields = $oCase->loadCase($caseId);
$oldFields['APP_DATA'] = array_merge($oldFields['APP_DATA'], $Fields);
$up_case = $oCase->updateCase($caseId, $oldFields);
//Create a newCase
$infoCase = $caseInstance->startCase($arrayTask[0]['TAS_UID'], $userId);
$_SESSION["APPLICATION"] = $caseId = $infoCase['APPLICATION'];
$oldFields = $caseInstance->loadCase($caseId);
//Merge the data with the $fieldsVariables that are set in the new case
$oldFields['APP_DATA'] = array_merge($oldFields['APP_DATA'], $fieldsVariables);
//Update the case
$res = $caseInstance->updateCase($caseId, $oldFields);
$result = new WsResponse(0, G::loadTranslation('ID_COMMAND_EXECUTED_SUCCESSFULLY'));
$result->caseId = $caseId;
$result->caseNumber = $caseNumber;
$result->caseNumber = $infoCase['CASE_NUMBER'];
$g->sessionVarRestore();
return $result;
} else {
if ($numTasks == 0) {
if ($numTasks === 0) {
$result = new WsResponse(12, G::loadTranslation('ID_NO_STARTING_TASK'));
$g->sessionVarRestore();
return $result;
}
if ($numTasks > 1) {
$result = new WsResponse(13, G::loadTranslation('ID_MULTIPLE_STARTING_TASKS'));
$g->sessionVarRestore();
return $result;
}
}
} catch (Exception $e) {
$result = new WsResponse(100, $e->getMessage());
$g->sessionVarRestore();
return $result;
}
@@ -2182,6 +2229,8 @@ class WsBase
* @param string $labelAssignment , label related to the triggerType
*
* @return string $varTriggers updated
*
* @see WsBase::derivateCase()
*/
public function executeTriggerFromDerivate(
$appUid,
@@ -2247,10 +2296,14 @@ class WsBase
*
* @param string $userId
* @param string $caseId
* @param string $delIndex
* @param array $tasks
* @param integer $delIndex
* @param bool $bExecuteTriggersBeforeAssignment
* @param array $tasks
*
* @return $result will return an object
*
* @see PMFDerivateCase()/class.pmFunctions.php on
* @link https://wiki.processmaker.com/3.2/ProcessMaker_Functions/Case_Routing_Functions#PMFDerivateCase.28.29
*/
public function derivateCase($userId, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks = [])
{
@@ -3065,6 +3118,10 @@ class WsBase
public function cancelCase($caseUid, $delIndex, $userUid)
{
$g = new G();
//We will to review if the current case in execution will be execute the same
if (isset($_SESSION["APPLICATION"]) && $_SESSION["APPLICATION"] !== $caseUid){
$this->setFlagSameCase(false);
}
try {
$g->sessionVarSave();
@@ -3090,7 +3147,7 @@ class WsBase
/** If those parameters are null we will to force the cancelCase */
if (is_null($delIndex) && is_null($userUid)) {
/*----------------------------------********---------------------------------*/
$case->cancelCase($caseUid, null, null);
$case->cancelCase($caseUid, null, null, $this->getFlagSameCase());
$result = self::messageExecuteSuccessfully();
$g->sessionVarRestore();
@@ -3127,7 +3184,7 @@ class WsBase
/** Cancel case */
$case->cancelCase($caseUid, (int)$delIndex, $userUid);
$case->cancelCase($caseUid, (int)$delIndex, $userUid, $this->getFlagSameCase());
//Define the result of the cancelCase
$result = self::messageExecuteSuccessfully();
@@ -3150,7 +3207,12 @@ class WsBase
* @param string userUid : The unique ID of the user who will pause the case.
* @param string unpauseDate : Optional parameter. The date in the format "yyyy-mm-dd" indicating when to unpause
* the case.
*
*
* @see workflow/engine/classes/class.pmFunctions.php::PMFPauseCase()
* @see workflow/engine/methods/services/soap2.php::pauseCase()
*
* @link https://wiki.processmaker.com/3.3/ProcessMaker_Functions/Case_Functions#PMFPauseCase.28.29
*
* @return $result will return an object
*/
public function pauseCase($caseUid, $delIndex, $userUid, $unpauseDate = null)
@@ -3186,6 +3248,22 @@ class WsBase
return $result;
}
//Validate if status is closed
$appDelegation = new AppDelegation();
$rows = $appDelegation->LoadParallel($caseUid, $delIndex);
if (empty($rows)) {
$result = new WsResponse(100, G::LoadTranslation('ID_CASE_DELEGATION_ALREADY_CLOSED'));
$g->sessionVarRestore();
return $result;
}
//Validate if the case is paused
$appDelay = new AppDelay();
$sw = $appDelay->isPaused($caseUid, $delIndex);
if ($sw === true) {
$result = new WsResponse(19, G::LoadTranslation('ID_CASE_IN_STATUS') . " " . AppDelay::APP_TYPE_PAUSE);
$g->sessionVarRestore();
return $result;
}
if (strlen($unpauseDate) >= 10) {
if (!preg_match("/^\d{4}-\d{2}-\d{2}| \d{2}:\d{2}:\d{2}$/", $unpauseDate)) {
$result = new WsResponse(100, G::LoadTranslation("ID_INVALID_DATA") . " $unpauseDate");

View File

@@ -2825,7 +2825,7 @@ function PMFPauseCase ($caseUid, $delIndex, $userUid, $unpauseDate = null)
{
$ws = new WsBase();
$result = $ws->pauseCase($caseUid, $delIndex, $userUid, $unpauseDate);
$result = (object) $result;
if ($result->status_code == 0) {
if (isset($_SESSION['APPLICATION']) && isset($_SESSION['INDEX'])) {
if ($_SESSION['APPLICATION'] == $caseUid && $_SESSION['INDEX'] == $delIndex) {

View File

@@ -281,15 +281,22 @@ class PMScript
self::AFTER_EXTERNAL_STEP : self::UNDEFINED_ORIGIN;
break;
case 'ASSIGN_TASK':
$stepUidObj = (int)$stepUidObj;
if ($stepUidObj === -1) {
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_ASSIGNMENT : self::UNDEFINED_ORIGIN;
} elseif ($stepUidObj === -2) {
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_ROUTING : $triggerType === 'AFTER' ?
self::AFTER_ROUTING : self::UNDEFINED_ORIGIN;
$executedOn = $triggerType === 'BEFORE' ? self::BEFORE_ROUTING : ($triggerType === 'AFTER' ?
self::AFTER_ROUTING : self::UNDEFINED_ORIGIN);
} else {
$executedOn = self::UNDEFINED_ORIGIN;
}
break;
case 'PROCESS_ACTION':
$executedOn = self::PROCESS_ACTION;
break;
case 'SCRIPT_TASK':
$executedOn = self::SCRIPT_TASK;
break;
default:
$executedOn = self::UNDEFINED_ORIGIN;
break;

View File

@@ -775,11 +775,22 @@ class Process extends BaseProcess
return $aProc;
}
/**
* Get the trigger configured in committing an action in cases
*
* @param string $proUid
* @param string $action
*
* @return mixed
*
* @see Cases::getExecuteTriggerProcess()
* @link https://wiki.processmaker.com/3.2/Triggers#When_action_cases
*/
public function getTriggerWebBotProcess($proUid, $action)
{
require_once("classes/model/Triggers.php");
if ((! isset($proUid) && $proUid == '') || (! isset($action) && $action == '')) {
if (empty($proUid) || empty($action)){
return false;
}
@@ -788,40 +799,41 @@ class Process extends BaseProcess
switch ($action) {
case 'CREATE':
$var = ProcessPeer::PRO_TRI_CREATE;
$columnName = ProcessPeer::PRO_TRI_CREATE;
break;
case 'OPEN':
$var = ProcessPeer::PRO_TRI_OPEN;
$columnName = ProcessPeer::PRO_TRI_OPEN;
break;
case 'DELETED':
$var = ProcessPeer::PRO_TRI_DELETED;
$columnName = ProcessPeer::PRO_TRI_DELETED;
break;
case 'CANCELED':
$var = ProcessPeer::PRO_TRI_CANCELED;
$columnName = ProcessPeer::PRO_TRI_CANCELED;
break;
case 'PAUSED':
$var = ProcessPeer::PRO_TRI_PAUSED;
$columnName = ProcessPeer::PRO_TRI_PAUSED;
break;
case 'REASSIGNED':
$var = ProcessPeer::PRO_TRI_REASSIGNED;
$columnName = ProcessPeer::PRO_TRI_REASSIGNED;
break;
case "UNPAUSE":
$var = ProcessPeer::PRO_TRI_UNPAUSED;
$columnName = ProcessPeer::PRO_TRI_UNPAUSED;
break;
}
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn($var);
$oCriteria->addSelectColumn(TriggersPeer::TRI_UID);
$oCriteria->addSelectColumn(TriggersPeer::TRI_WEBBOT);
$oCriteria->addJoin($var, TriggersPeer::TRI_UID, Criteria::LEFT_JOIN);
$oCriteria->add(ProcessPeer::PRO_UID, $proUid);
$oDataSet = ProcessPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro'));
$criteria = new Criteria('workflow');
$criteria->addSelectColumn($columnName);
$criteria->addSelectColumn(TriggersPeer::TRI_UID);
$criteria->addSelectColumn(TriggersPeer::TRI_WEBBOT);
$criteria->addSelectColumn(TriggersPeer::TRI_TITLE);
$criteria->addJoin($columnName, TriggersPeer::TRI_UID, Criteria::LEFT_JOIN);
$criteria->add(ProcessPeer::PRO_UID, $proUid);
$criteria->add($columnName, '', Criteria::NOT_EQUAL);
$dataSet = ProcessPeer::doSelectRS($criteria, Propel::getDbConnection('workflow_ro'));
$dataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($oDataSet->next()) {
$row = $oDataSet->getRow();
$arrayWebBotTrigger = ['TRI_UID' => $row['TRI_UID'], 'TRI_WEBBOT' => $row['TRI_WEBBOT']];
if ($dataSet->next()) {
$arrayWebBotTrigger[] = $dataSet->getRow();
}
//Return

View File

@@ -152,5 +152,29 @@ class SubApplication extends BaseSubApplication
return $result;
}
/**
* Load all cases with the same parent case
*
* @param $appUid
*
* @return array
*/
public function loadByAppUidParent($appUid)
{
$criteria = new Criteria('workflow');
$criteria->add(SubApplicationPeer::APP_PARENT, $appUid);
$dataSet = SubApplicationPeer::doSelectRS($criteria);
$dataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$result = [];
while ($dataSet->next()) {
$result[] = $dataSet->getRow();
}
return $result;
}
}

View File

@@ -3,82 +3,110 @@
use ProcessMaker\Util\DateTime;
switch ($RBAC->userCanAccess('PM_CASES')) {
case - 2:
case -2:
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
G::header('location: ../login/login');
die();
break;
case - 1:
case -1:
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
die();
break;
}
$oCase = new Cases();
$Fields = $oCase->loadCase($_SESSION['APPLICATION'], $_SESSION['INDEX']);
/* Render page */
/** Render page */
require_once 'classes/model/Process.php';
require_once 'classes/model/Task.php';
//Get information about the case
$case = new Cases();
$fieldsCase = $case->loadCase($_SESSION['APPLICATION'], $_SESSION['INDEX']);
//Get the user logged
$userLogged = isset($RBAC->aUserInfo['USER_INFO']['USR_UID']) ? $RBAC->aUserInfo['USER_INFO']['USR_UID'] : '';
//Check the authorization
$objCase = new \ProcessMaker\BusinessModel\Cases();
$userCanAccess = $objCase->userAuthorization(
$userLogged,
$fieldsCase['PRO_UID'],
$fieldsCase['APP_UID'],
['PM_ALLCASES'],
['SUMMARY_FORM' => 'VIEW']
);
$objProc = new Process();
$aProc = $objProc->load($Fields['PRO_UID']);
$Fields['PRO_TITLE'] = $aProc['PRO_TITLE'];
$fieldsProcess = $objProc->load($fieldsCase['PRO_UID']);
$fieldsCase['PRO_TITLE'] = $fieldsProcess['PRO_TITLE'];
$objTask = new Task();
$aTask = $objTask->load($Fields['TAS_UID']);
$Fields['TAS_TITLE'] = $aTask['TAS_TITLE'];
if (
isset($fieldsProcess['PRO_DYNAFORMS']['PROCESS']) &&
!empty($fieldsProcess['PRO_DYNAFORMS']['PROCESS']) &&
$userCanAccess['objectPermissions']['SUMMARY_FORM'] &&
$objProc->isBpmnProcess($fieldsCase['PRO_UID'])
) {
/**We will to show the custom summary form only for BPMN process*/
$_REQUEST['APP_UID'] = $fieldsCase['APP_UID'];
$_REQUEST['DEL_INDEX'] = $fieldsCase['DEL_INDEX'];
$_REQUEST['DYN_UID'] = $fieldsProcess['PRO_DYNAFORMS']['PROCESS'];
require_once(PATH_METHODS . 'cases' . PATH_SEP . 'summary.php');
exit();
} else {
/**We will to show the default claim case form*/
$objTask = new Task();
$fieldsTask = $objTask->load($fieldsCase['TAS_UID']);
$fieldsCase['TAS_TITLE'] = $fieldsTask['TAS_TITLE'];
$fieldsCase['STATUS'] .= ' ( ' . G::LoadTranslation('ID_UNASSIGNED') . ' )';
$Fields['STATUS'] .= ' ( ' . G::LoadTranslation('ID_UNASSIGNED') . ' )';
//Now getting information about the PREVIOUS task. If is the first task then no previous, use 1
$appDelegation = new AppDelegation();
$appDelegation->Load(
$fieldsCase['APP_UID'],
($fieldsCase['DEL_PREVIOUS'] == 0 ? $fieldsCase['DEL_PREVIOUS'] = 1 : $fieldsCase['DEL_PREVIOUS'])
);
$fieldsDelegation = $appDelegation->toArray(BasePeer::TYPE_FIELDNAME);
//now getting information about the PREVIOUS task. If is the first task then no preious, use 1
$oAppDel = new AppDelegation();
$oAppDel->Load($Fields['APP_UID'], ($Fields['DEL_PREVIOUS'] == 0 ? $Fields['DEL_PREVIOUS'] = 1 : $Fields['DEL_PREVIOUS']));
try {
$userInfo = new Users();
$userInfo->load($fieldsDelegation['USR_UID']);
$fieldsCase['PREVIOUS_USER'] = $userInfo->getUsrFirstname() . ' ' . $userInfo->getUsrLastname();
} catch (Exception $error) {
$fieldsCase['PREVIOUS_USER'] = G::LoadTranslation('ID_NO_PREVIOUS_USR_UID');
}
$aAppDel = $oAppDel->toArray(BasePeer::TYPE_FIELDNAME);
try {
$oCurUser = new Users();
$oCurUser->load($aAppDel['USR_UID']);
$Fields['PREVIOUS_USER'] = $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname();
} catch (Exception $oError) {
$Fields['PREVIOUS_USER'] = G::LoadTranslation('ID_NO_PREVIOUS_USR_UID');
}
$objTask = new Task();
$aTask = $objTask->load($aAppDel['TAS_UID']);
$Fields['PREVIOUS_TASK'] = $aTask['TAS_TITLE'];
//To enable information (dynaforms, steps) before claim a case
$_SESSION['bNoShowSteps'] = true;
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'caseOptions';
$G_ID_MENU_SELECTED = 'CASES';
$G_ID_SUB_MENU_SELECTED = '_';
$oHeadPublisher = headPublisher::getSingleton();
$oHeadPublisher->addScriptCode("
if (typeof parent != 'undefined') {
if (parent.showCaseNavigatorPanel) {
parent.showCaseNavigatorPanel('{$Fields['APP_STATUS']}');
}
}");
$oHeadPublisher->addScriptCode('
var Cse = {};
Cse.panels = {};
var leimnud = new maborak();
leimnud.make();
leimnud.Package.Load("rpc,drag,drop,panel,app,validator,fx,dom,abbr",{Instance:leimnud,Type:"module"});
leimnud.Package.Load("cases",{Type:"file",Absolute:true,Path:"/jscore/cases/core/cases.js"});
leimnud.Package.Load("cases_Step",{Type:"file",Absolute:true,Path:"/jscore/cases/core/cases_Step.js"});
leimnud.Package.Load("processmap",{Type:"file",Absolute:true,Path:"/jscore/processmap/core/processmap.js"});
leimnud.exec(leimnud.fix.memoryLeak);
//To enable information (dynaforms, steps) before claim a case
$_SESSION['bNoShowSteps'] = true;
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'caseOptions';
$G_ID_MENU_SELECTED = 'CASES';
$G_ID_SUB_MENU_SELECTED = '_';
$headPublisher = headPublisher::getSingleton();
$headPublisher->addScriptCode("
if (typeof parent != 'undefined') {
if (parent.showCaseNavigatorPanel) {
parent.showCaseNavigatorPanel('{$fieldsCase['APP_STATUS']}');
}
}
");
$headPublisher->addScriptCode('
var Cse = {};
Cse.panels = {};
var leimnud = new maborak();
leimnud.make();
leimnud.Package.Load("rpc,drag,drop,panel,app,validator,fx,dom,abbr",{Instance:leimnud,Type:"module"});
leimnud.Package.Load("cases",{Type:"file",Absolute:true,Path:"/jscore/cases/core/cases.js"});
leimnud.Package.Load("cases_Step",{Type:"file",Absolute:true,Path:"/jscore/cases/core/cases_Step.js"});
leimnud.Package.Load("processmap",{Type:"file",Absolute:true,Path:"/jscore/processmap/core/processmap.js"});
leimnud.exec(leimnud.fix.memoryLeak);
');
$oHeadPublisher = headPublisher::getSingleton();
$oHeadPublisher->addScriptFile('/jscore/cases/core/cases_Step.js');
$headPublisher = headPublisher::getSingleton();
$headPublisher->addScriptFile('/jscore/cases/core/cases_Step.js');
$Fields['isIE'] = Bootstrap::isIE();
$fieldsCase['isIE'] = Bootstrap::isIE();
$G_PUBLISH = new Publisher();
$Fields = DateTime::convertUtcToTimeZone($Fields);
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_CatchSelfService.xml', '', $Fields, 'cases_CatchExecute');
G::RenderPage('publish', 'blank');
$G_PUBLISH = new Publisher();
$fieldsCase = DateTime::convertUtcToTimeZone($fieldsCase);
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_CatchSelfService.xml', '', $fieldsCase, 'cases_CatchExecute');
G::RenderPage('publish', 'blank');
}

View File

@@ -1,32 +1,4 @@
<?php
/**
* open.php Open Case main processor
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
/**
*
* @author Erik Amaru Ortiz <erik@colosa.com>
* @date Jan 3th, 2010
*/
$tBarGmail = false;
if (isset($_GET['gmail']) && $_GET['gmail'] == 1) {
@@ -121,22 +93,29 @@ if (isset($_GET['actionFromList']) && ($_GET['actionFromList'] === 'to_revise'))
$script = 'cases_Open?';
}
// getting bpmn projects
$c = new Criteria('workflow');
$c->addSelectColumn(BpmnProjectPeer::PRJ_UID);
$ds = ProcessPeer::doSelectRS($c);
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$bpmnProjects = array();
$process = new Process();
$fields = $process->load($case['PRO_UID']);
$isBpmn = $fields['PRO_BPMN'] === 1 ? true : false;
while ($ds->next()) {
$row = $ds->getRow();
$bpmnProjects[] = $row['PRJ_UID'];
$showCustomForm = false;
/*----------------------------------********---------------------------------*/
$respView = $oCase->getAllObjectsFrom($case['PRO_UID'], $appUid, $case['TAS_UID'], $_SESSION['USER_LOGGED'], 'VIEW');
$viewSummaryForm = isset($respView['SUMMARY_FORM']) && $respView['SUMMARY_FORM'] === 1 ? true : false;
$isNoEmpty = isset($fields['PRO_DYNAFORMS']['PROCESS']) && !empty($fields['PRO_DYNAFORMS']['PROCESS']);
if ($isBpmn && $viewSummaryForm && $isNoEmpty) {
$showCustomForm = true;
}
/*----------------------------------********---------------------------------*/
$oStep = new Step();
$oStep = $oStep->loadByProcessTaskPosition($case['PRO_UID'], $case['TAS_UID'], 1);
$oHeadPublisher->assign('uri', $script . $uri);
$oHeadPublisher->assign('_APP_NUM', '#: ' . $case['APP_NUMBER']);
$oHeadPublisher->assign('_PROJECT_TYPE', in_array($case['PRO_UID'], $bpmnProjects) ? 'bpmn' : 'classic');
$oHeadPublisher->assign('_PROJECT_TYPE', $isBpmn ? 'bpmn' : 'classic');
$oHeadPublisher->assign('_PRO_UID', $case['PRO_UID']);
$oHeadPublisher->assign('_APP_UID', $appUid);
$oHeadPublisher->assign('_ENV_CURRENT_DATE', $conf->getSystemDate(date('Y-m-d')));
@@ -144,6 +123,7 @@ $oHeadPublisher->assign('_ENV_CURRENT_DATE_NO_FORMAT', date('Y-m-d-h-i-A'));
$oHeadPublisher->assign('idfirstform', is_null($oStep) ? '-1' : $oStep->getStepUidObj());
$oHeadPublisher->assign('appStatus', $case['APP_STATUS']);
$oHeadPublisher->assign('tbarGmail', $tBarGmail);
$oHeadPublisher->assign('showCustomForm', $showCustomForm);
if (!isset($_SESSION['APPLICATION']) || !isset($_SESSION['TASK']) || !isset($_SESSION['INDEX'])) {
$_SESSION['PROCESS'] = $case['PRO_UID'];

View File

@@ -1,7 +1,14 @@
<?php
/**
* Method defined and copied from processmaker/workflow/engine/classes/class.configuration.php
* Get default configuration for Cases List.
*
* @param string $action
* @param int $translation
* @return array
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function casesListDefaultFieldsAndConfig($action, $translation = 1)
{
@@ -322,6 +329,16 @@ function casesListDefaultFieldsAndConfig($action, $translation = 1)
return array("caseColumns" => $caseColumns, "caseReaderFields" => $caseReaderFields, "rowsperpage" => 20, "dateformat" => "M d, Y");
}
/**
* Get default configuration and verify if casesListDefaultFieldsAndConfig method exist.
*
* @param string $action
* @param int $translation
* @return array
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function getDefaultConfig($action, $translation)
{
$config = new Configurations();
@@ -335,6 +352,16 @@ function getDefaultConfig($action, $translation)
return $arrayConfig;
}
/**
* Get default fields configuration.
*
* @param string $action
* @param int $translation
* @return array
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function getDefaultFields($action, $translation)
{
$config = new Configurations();
@@ -405,6 +432,16 @@ function getDefaultFields($action, $translation)
return $arrayField;
}
/**
* Set available fields.
*
* @param array $arrayAvailableField
* @param array $arrayField
* @return array
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function setAvailableFields($arrayAvailableField, $arrayField)
{
$i = 0;
@@ -427,6 +464,16 @@ function setAvailableFields($arrayAvailableField, $arrayField)
return $arrayFieldResult;
}
/**
* Set Cases List fields.
*
* @param array $arrayCasesListField
* @param array $arrayField
* @return array
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function setCasesListFields($arrayCasesListField, $arrayField)
{
$i = 0;
@@ -462,32 +509,56 @@ function setCasesListFields($arrayCasesListField, $arrayField)
return $arrayFieldResult;
}
/**
* Get the Custom Case List configuration data.
*
* @global string $action
* @global array $confCasesList
* @global string $tabUid
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function fieldSet()
{
global $conf;
global $confCasesList;
global $action;
global $confCasesList;
global $tabUid;
if (is_array($confCasesList)) {
$validConfig = isset($confCasesList["first"]) && isset($confCasesList["second"]);
} else {
$validConfig = false;
$arrayField = getDefaultFields($action, 0);
$arrayConfig = getDefaultConfig($action, 0);
$result = genericJsonResponse($tabUid, [], $arrayField, $arrayConfig["rowsperpage"], $arrayConfig["dateformat"]);
$result['first']['data'] = getFieldsByTabUid($tabUid);
$confCasesList = (array) $confCasesList;
if (!empty($confCasesList)) {
if (!empty($tabUid) && empty($confCasesList['PMTable'])) {
$confCasesList['PMTable'] = $tabUid;
$confCasesList['first']['data'] = getFieldsByTabUid($tabUid);
}
if (!empty($confCasesList['PMTable']) && empty($tabUid)) {
$result = $confCasesList;
}
}
if (!$validConfig) {
$arrayField = getDefaultFields($action, 0);
$arrayConfig = getDefaultConfig($action, 0);
$result = genericJsonResponse("", array(), $arrayField, $arrayConfig["rowsperpage"], $arrayConfig["dateformat"]);
$conf->saveObject($result, "casesList", $action, "", "", "");
echo G::json_encode($result);
} else {
echo G::json_encode($confCasesList);
if (is_array($result) && isset($result['second']['data'])) {
foreach ($result['second']['data'] as $key => $value) {
$result['second']['data'][$key]['align_label'] = $result['second']['data'][$key]['align'];
}
}
echo G::json_encode($result);
}
/**
* Reset fields configuration.
*
* @global string $action
* @param int $translation
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function fieldReset($translation)
{
global $action;
@@ -500,6 +571,15 @@ function fieldReset($translation)
echo G::json_encode($result);
}
/**
* Complete a field.
*
* @global string $action
* @param int $translation
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function fieldComplete($translation)
{
@@ -565,6 +645,15 @@ function fieldComplete($translation)
echo G::json_encode($result);
}
/**
* Reset field label.
*
* @global string $action
* @param int $translation
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function fieldLabelReset($translation)
{
@@ -604,6 +693,15 @@ function fieldLabelReset($translation)
echo G::json_encode($result);
}
/**
* Save a field.
*
* @global object $conf
* @global string $action
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function fieldSave()
{
@@ -690,11 +788,6 @@ try {
switch ($xaction) {
case "FIELD_SET":
if (is_array($confCasesList) && isset($confCasesList['second']['data'])) {
foreach ($confCasesList['second']['data'] as $key => $value) {
$confCasesList['second']['data'][$key]['align_label'] = $confCasesList['second']['data'][$key]['align'];
}
}
fieldSet();
break;
case "FIELD_RESET":
@@ -722,14 +815,20 @@ try {
G::outRes( G::json_encode( G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) ) );
}
/**
* set the generic Json Response, using two array for the grid stores and a string for the pmtable name
* @param string $pmtable
* @param array $first
* @param array $second
* @return $response a json string
*/
function genericJsonResponse($pmtable, $first, $second, $rowsperpage, $dateFormat)
/**
* Set the generic Json Response, using two array for the grid stores and a string for the pmtable name.
*
* @param string $pmtable
* @param array $first
* @param array $second
* @param array $rowsPerPage
* @param string $dateFormat
* @return array
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function genericJsonResponse($pmtable, $first, $second, $rowsPerPage, $dateFormat)
{
$firstGrid['totalCount'] = count($first);
$firstGrid['data'] = $first;
@@ -739,54 +838,72 @@ function genericJsonResponse($pmtable, $first, $second, $rowsperpage, $dateForma
$result['first'] = $firstGrid;
$result['second'] = $secondGrid;
$result['PMTable'] = isset($pmtable) ? $pmtable : '';
$result['rowsperpage'] = isset($rowsperpage) ? $rowsperpage : 20;
$result['rowsperpage'] = isset($rowsPerPage) ? $rowsPerPage : 20;
$result['dateformat'] = isset($dateFormat) && $dateFormat != '' ? $dateFormat : 'M d, Y';
return $result;
}
/**
* Get row from PM Table.
*
* @param string $tabUid
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function xgetFieldsFromPMTable($tabUid)
{
$rows = array();
$result = array();
// $rows[] = array ( 'name' => 'val 1', 'gridIndex' => '21', 'fieldType' => 'PM Table' );
// $rows[] = array ( 'name' => 'val 2', 'gridIndex' => '22', 'fieldType' => 'PM Table' );
// $rows[] = array ( 'name' => 'val 3', 'gridIndex' => '23', 'fieldType' => 'PM Table' );
//$result['success'] = true;
//$result['totalCount'] = count($rows);
$oCriteria = new Criteria('workflow');
$oCriteria->clearSelectColumns ( );
$oCriteria->setDistinct();
$oCriteria->addSelectColumn ( FieldsPeer::FLD_NAME );
$oCriteria->addSelectColumn ( FieldsPeer::FLD_UID );
$oCriteria->addSelectColumn ( FieldsPeer::FLD_INDEX );
$oCriteria->add (FieldsPeer::ADD_TAB_UID, $tabUid , CRITERIA::EQUAL );
$oCriteria->add (FieldsPeer::FLD_NAME, 'APP_UID' , CRITERIA::NOT_EQUAL );
$oCriteria->addAnd (FieldsPeer::FLD_NAME, 'APP_NUMBER' , CRITERIA::NOT_EQUAL );
$oCriteria->addDescendingOrderByColumn('FLD_INDEX');
$oDataset = FieldsPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$index = count($rows);
while ($aRow = $oDataset->getRow()) {
$aRow['index'] = ++$index;
$aTempRow['name'] = $aRow['FLD_NAME'];
$aTempRow['gridIndex'] = $aRow['index'];
$aTempRow['fieldType'] = 'PM Table';
$rows[] = $aTempRow;
$oDataset->next();
}
$result['data'] = $rows;
print G::json_encode( $result ) ;
$result = [];
$result['data'] = getFieldsByTabUid($tabUid);
print G::json_encode($result);
}
/**
*
* @param Array $fields
* @return Array
*
*/
/**
* Get rows from Fields table.
*
* @param string $tabUid
* @return array
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function getFieldsByTabUid($tabUid)
{
$rows = [];
$criteria = new Criteria('workflow');
$criteria->clearSelectColumns();
$criteria->setDistinct();
$criteria->addSelectColumn(FieldsPeer::FLD_NAME);
$criteria->addSelectColumn(FieldsPeer::FLD_UID);
$criteria->addSelectColumn(FieldsPeer::FLD_INDEX);
$criteria->add(FieldsPeer::ADD_TAB_UID, $tabUid, CRITERIA::EQUAL);
$criteria->add(FieldsPeer::FLD_NAME, 'APP_UID', CRITERIA::NOT_EQUAL);
$criteria->addAnd(FieldsPeer::FLD_NAME, 'APP_NUMBER', CRITERIA::NOT_EQUAL);
$criteria->addDescendingOrderByColumn('FLD_INDEX');
$dataSet = FieldsPeer::doSelectRS($criteria);
$dataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataSet->next();
$index = 0;
while ($row = $dataSet->getRow()) {
$row['index'] = ++$index;
$tempRow['name'] = $row['FLD_NAME'];
$tempRow['gridIndex'] = $row['index'];
$tempRow['fieldType'] = 'PM Table';
$rows[] = $tempRow;
$dataSet->next();
}
return $rows;
}
/**
* Calculate Grid index.
*
* @param array $fields
* @return array
*
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
function calculateGridIndex($fields)
{
for ($i=0; $i<count( $fields ); $i++) {

View File

@@ -1,28 +1,22 @@
<?php
/**
* processes_Ajax.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
try {
// Validate the access to the actions of this file
if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'load') {
// Validate if exists the session variable "PROCESS", this action is requested from case tracker and running cases
$cannotAccess = empty($_SESSION['PROCESS']);
} else {
// Validate PM_FACTORY permission
global $RBAC;
$cannotAccess = $RBAC->userCanAccess('PM_FACTORY') !== 1;
}
if ($cannotAccess) {
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'Location: ../login/login' );
die();
}
$filter = new InputFilter();
$_GET = $filter->xssFilterHard($_GET);
$_POST = $filter->xssFilterHard($_POST);
@@ -693,41 +687,38 @@ try {
$_REQUEST['filename'] = $filter->xssFilterHard($_REQUEST['filename']);
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
global $RBAC;
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
$app = new Processes();
if (!$app->processExists($_REQUEST['pro_uid'])) {
echo G::LoadTranslation('ID_PROCESS_UID_NOT_DEFINED');
die;
}
$sDir = "";
if (isset($_REQUEST['MAIN_DIRECTORY'])) {
$_REQUEST['MAIN_DIRECTORY'] = $filter->xssFilterHard($_REQUEST['MAIN_DIRECTORY']);
$sDir = $_REQUEST['MAIN_DIRECTORY'];
}
switch ($sDir) {
case 'mailTemplates':
$sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename'];
G::auditLog('ProcessFileManager', 'Save template (' . $_REQUEST['filename'] . ') in process "' . $resultProcess['PRO_TITLE'] . '"');
break;
case 'public':
$sDirectory = PATH_DATA_PUBLIC . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename'];
G::auditLog('ProcessFileManager', 'Save public template (' . $_REQUEST['filename'] . ') in process "' . $resultProcess['PRO_TITLE'] . '"');
break;
default:
$sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename'];
break;
}
$fp = fopen($sDirectory, 'w');
$content = stripslashes($_REQUEST['fcontent']);
$content = str_replace("@amp@", "&", $content);
$content = base64_decode($content);
fwrite($fp, $content);
fclose($fp);
$sDirectory = $filter->xssFilterHard($sDirectory);
echo 'saved: ' . $sDirectory;
$app = new Processes();
if (!$app->processExists($_REQUEST['pro_uid'])) {
echo G::LoadTranslation('ID_PROCESS_UID_NOT_DEFINED');
die;
}
$sDir = "";
if (isset($_REQUEST['MAIN_DIRECTORY'])) {
$_REQUEST['MAIN_DIRECTORY'] = $filter->xssFilterHard($_REQUEST['MAIN_DIRECTORY']);
$sDir = $_REQUEST['MAIN_DIRECTORY'];
}
switch ($sDir) {
case 'mailTemplates':
$sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename'];
G::auditLog('ProcessFileManager', 'Save template (' . $_REQUEST['filename'] . ') in process "' . $resultProcess['PRO_TITLE'] . '"');
break;
case 'public':
$sDirectory = PATH_DATA_PUBLIC . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename'];
G::auditLog('ProcessFileManager', 'Save public template (' . $_REQUEST['filename'] . ') in process "' . $resultProcess['PRO_TITLE'] . '"');
break;
default:
$sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename'];
break;
}
$fp = fopen($sDirectory, 'w');
$content = stripslashes($_REQUEST['fcontent']);
$content = str_replace("@amp@", "&", $content);
$content = base64_decode($content);
fwrite($fp, $content);
fclose($fp);
$sDirectory = $filter->xssFilterHard($sDirectory);
echo 'saved: ' . $sDirectory;
break;
case 'getSessid':
if (isset($_SESSION['USER_LOGGED'])) {

View File

@@ -4,14 +4,11 @@ $RBAC->allows(basename(__FILE__), $_GET['MAIN_DIRECTORY']);
$mainDirectory = !empty($_GET['MAIN_DIRECTORY']) ? $_GET['MAIN_DIRECTORY'] : '';
$proUid = !empty($_GET['PRO_UID']) ? $_GET['PRO_UID'] : '';
$currentDirectory = !empty($_GET['CURRENT_DIRECTORY']) ? realpath($_GET['CURRENT_DIRECTORY']) . PATH_SEP : '';
$file = !empty($_GET['FILE']) ? realpath($_GET['FILE']) : '';
$currentDirectory = !empty($_GET['CURRENT_DIRECTORY']) ? $_GET['CURRENT_DIRECTORY'] . PATH_SEP : '';
$file = !empty($_GET['FILE']) ? $_GET['FILE'] : '';
$extension = (!empty($_GET['sFilextension']) && $_GET['sFilextension'] === 'javascript') ? '.js' : '';
//validated process exists, return throw if not exists.
$process = new Process();
$process->load($proUid);
// Validate the main directory
switch ($mainDirectory) {
case 'mailTemplates':
$directory = PATH_DATA_MAILTEMPLATES;
@@ -24,9 +21,20 @@ switch ($mainDirectory) {
break;
}
// Validate if process exists, an exception is throwed if not exists
$process = new Process();
$process->load($proUid);
// Validate directory and file requested
$filter = new InputFilter();
$currentDirectory = $filter->validatePath($currentDirectory);
$file = $filter->validatePath($file);
// Build requested path
$directory .= $proUid . PATH_SEP . $currentDirectory;
$file .= $extension;
// Stream the file if path exists
if (file_exists($directory . $file)) {
G::streamFile($directory . $file, true);
}

View File

@@ -1603,3 +1603,73 @@ padding:3px 3px 3px 5px;
white-space:normal;
}
.cancelSummary {
color: #333;
background: #fff;
border:1px #ccc solid;
}
.claimCaseSummary {
color: #ffffff;
background-color: #337ab7;
border:1px #2e6da4 solid;
}
.claimCaseSummary .x-btn-text {
color: #fff;
padding: 6px 6px 6px 6px;
height: 28px !important;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
}
.cancelSummary .x-btn-text {
padding: 6px 6px 6px 6px;
height: 25px !important;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
}
.claimCaseSummary td {
color: #ffffff;
background: #337ab7;
border-color: #2e6da4;
}
.claimCaseSummary tbody:hover td {
color: #ffffff;
background: #286090;
border-color: #204d74;
}
.cancelSummary td {
color: #333;
background: #fff;
}
.cancelSummary tbody:hover td {
color: #333333;
background: #e6e6e6;
border-color: #adadad;
}
.cancelSummary .claimCaseSummary {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 12px !important;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.navPanelBottom .x-toolbar-cell {
clear: both;
height: 50px;
}

View File

@@ -1795,3 +1795,73 @@ white-space:normal;
-moz-border-radius: 5px;
vertical-align: middle;
}
.cancelSummary {
color: #333;
background: #fff;
border:1px #ccc solid;
}
.claimCaseSummary {
color: #ffffff;
background-color: #337ab7;
border:1px #2e6da4 solid;
}
.claimCaseSummary .x-btn-text {
color: #fff;
padding: 6px 6px 6px 6px;
height: 28px !important;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
}
.cancelSummary .x-btn-text {
padding: 6px 6px 6px 6px;
height: 25px !important;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
}
.claimCaseSummary td {
color: #ffffff;
background-color: #337ab7;
border-color: #2e6da4;
}
.claimCaseSummary tbody:hover td {
color: #ffffff;
background-color: #286090;
border-color: #204d74;
}
.cancelSummary td {
color: #333;
background: #fff;
}
.cancelSummary tbody:hover td {
color: #333333;
background-color: #e6e6e6;
border-color: #adadad;
}
.cancelSummary .claimCaseSummary {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 12px !important;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.navPanelBottom .x-toolbar-cell {
clear: both;
height: 50px;
}

View File

@@ -1631,3 +1631,74 @@ td.x-cnotes-label {
color:#848484;
text-decoration: none;
}
.cancelSummary {
color: #333;
background: #fff;
border:1px #ccc solid;
}
.claimCaseSummary {
color: #ffffff;
background-color: #337ab7;
border:1px #2e6da4 solid;
}
.claimCaseSummary .x-btn-text {
color: #fff;
padding: 6px 6px 6px 6px;
height: 28px !important;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
}
.cancelSummary .x-btn-text {
padding: 6px 6px 6px 6px;
height: 25px !important;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
}
.claimCaseSummary td {
color: #ffffff;
background: #337ab7;
border-color: #2e6da4;
}
.claimCaseSummary tbody:hover td {
color: #ffffff;
background: #286090;
border-color: #204d74;
}
.cancelSummary td {
color: #333;
background: #fff;
}
.cancelSummary tbody:hover td {
color: #333333;
background: #e6e6e6;
border-color: #adadad;
}
.cancelSummary .claimCaseSummary {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 12px !important;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.navPanelBottom .x-toolbar-cell {
clear: both;
height: 50px;
}

View File

@@ -1176,3 +1176,74 @@ td.x-cnotes-label {
font: 11px arial,tahoma,helvetica,sans-serif;
color: #465070;
}
.cancelSummary {
color: #333;
background: #fff;
border:1px #ccc solid;
}
.claimCaseSummary {
color: #ffffff;
background-color: #337ab7;
border:1px #2e6da4 solid;
}
.claimCaseSummary .x-btn-text {
color: #fff;
padding: 6px 6px 6px 6px;
height: 28px !important;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
}
.cancelSummary .x-btn-text {
padding: 6px 6px 6px 6px;
height: 25px !important;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
}
.claimCaseSummary td {
color: #ffffff;
background: #337ab7;
border-color: #2e6da4;
}
.claimCaseSummary tbody:hover td {
color: #ffffff;
background: #286090;
border-color: #204d74;
}
.cancelSummary td {
color: #333;
background: #fff;
}
.cancelSummary tbody:hover td {
color: #333333;
background: #e6e6e6;
border-color: #adadad;
}
.cancelSummary .claimCaseSummary {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 12px !important;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.navPanelBottom .x-toolbar-cell {
clear: both;
height: 50px;
}

View File

@@ -61,6 +61,8 @@ class Cases
{
private $formatFieldNameInUppercase = true;
private $messageResponse = [];
private $solr = null;
private $solrEnv = null;
const MB_IN_KB = 1024;
const UNIT_MB = 'MB';
@@ -237,26 +239,11 @@ class Cases
public function getListCounters($userUid, array $arrayType)
{
try {
$solrEnabled = false;
$solrConf = System::solrEnv();
if ($solrConf !== false) {
$ApplicationSolrIndex = new AppSolr(
$solrConf['solr_enabled'],
$solrConf['solr_host'],
$solrConf['solr_instance']
);
if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
$solrEnabled = true;
}
}
$appCacheView = new AppCacheView();
if ($solrEnabled) {
if ($this->isSolrEnabled()) {
$arrayListCounter = array_merge(
$ApplicationSolrIndex->getCasesCount($userUid),
$this->solr->getCasesCount($userUid),
$appCacheView->getAllCounters(['completed', 'cancelled'], $userUid)
);
} else {
@@ -422,6 +409,28 @@ class Cases
return $response;
}
/**
* Verify if Solr is Enabled
*
* @return bool
*/
private function isSolrEnabled()
{
$solrEnabled = false;
$this->solrEnv = !empty($this->solrEnv) ? $this->solrEnv : System::solrEnv();
if ($this->solrEnv !== false) {
$this->solr = !empty($this->solr) ? $this->solr : new AppSolr(
$this->solrEnv['solr_enabled'],
$this->solrEnv['solr_host'],
$this->solrEnv['solr_instance']
);
if ($this->solr->isSolrEnabled() && $this->solrEnv["solr_enabled"] == true) {
$solrEnabled = true;
}
}
return $solrEnabled;
}
/**
* Get data of a Case
*
@@ -434,21 +443,11 @@ class Cases
public function getCaseInfo($applicationUid, $userUid)
{
try {
$solrEnabled = 0;
if (($solrEnv = System::solrEnv()) !== false) {
$appSolr = new AppSolr(
$solrEnv["solr_enabled"],
$solrEnv["solr_host"],
$solrEnv["solr_instance"]
);
if ($appSolr->isSolrEnabled() && $solrEnv["solr_enabled"] == true) {
//Check if there are missing records to reindex and reindex them
$appSolr->synchronizePendingApplications();
$solrEnabled = 1;
}
}
if ($solrEnabled == 1) {
if ($this->isSolrEnabled()) {
try {
//Check if there are missing records to reindex and reindex them
$this->solr->synchronizePendingApplications();
$arrayData = array();
$delegationIndexes = array();
$columsToInclude = array("APP_UID");
@@ -464,7 +463,7 @@ class Cases
$columsToIncludeFinal = array_merge($columsToInclude, $delegationIndexes);
$solrRequestData = EntitySolrRequestData::createForRequestPagination(
array(
"workspace" => $solrEnv["solr_instance"],
"workspace" => $this->solrEnv["solr_instance"],
"startAfter" => 0,
"pageSize" => 1000,
"searchText" => $solrSearchText,
@@ -476,7 +475,7 @@ class Cases
)
);
//Use search index to return list of cases
$searchIndex = new BpmnEngineServicesSearchIndex($appSolr->isSolrEnabled(), $solrEnv["solr_host"]);
$searchIndex = new BpmnEngineServicesSearchIndex($this->solr->isSolrEnabled(), $this->solrEnv["solr_host"]);
//Execute query
$solrQueryResult = $searchIndex->getDataTablePaginatedList($solrRequestData);
//Get the missing data from database
@@ -484,7 +483,7 @@ class Cases
foreach ($solrQueryResult->aaData as $i => $data) {
$arrayApplicationUid[] = $data["APP_UID"];
}
$aaappsDBData = $appSolr->getListApplicationDelegationData($arrayApplicationUid);
$aaappsDBData = $this->solr->getListApplicationDelegationData($arrayApplicationUid);
foreach ($solrQueryResult->aaData as $i => $data) {
//Initialize array
$delIndexes = array(); //Store all the delegation indexes
@@ -513,7 +512,7 @@ class Cases
$aRow["APP_UID"] = $data["APP_UID"];
//Get delegation data from DB
//Filter data from db
$indexes = $appSolr->aaSearchRecords($aaappsDBData, array(
$indexes = $this->solr->aaSearchRecords($aaappsDBData, array(
"APP_UID" => $applicationUid,
"DEL_INDEX" => $delIndex
));
@@ -662,6 +661,31 @@ class Cases
}
}
/**
* Get data of a sub-process case
*
* @param string $applicationUid Unique Case Id
* @param string $userUid Unique User Id
*
* @return array Return an array with information of Cases
* @throws Exception
*/
public function getCaseInfoSubProcess($applicationUid, $userUid)
{
try {
$response = [];
$subApplication = new SubApplication();
$data = $subApplication->loadByAppUidParent($applicationUid);
foreach ($data as $item) {
$response[] = $this->getCaseInfo($item['APP_UID'], $userUid);
}
return $response;
} catch (Exception $e) {
throw $e;
}
}
/**
* Get data Task Case
*

View File

@@ -415,6 +415,7 @@ class Light
$oCase = new Cases();
$Fields = $oCase->loadCase($cas_uid);
//@todo Find a better way to define session variables
$_SESSION["APPLICATION"] = $cas_uid;
$_SESSION["PROCESS"] = $prj_uid;
$_SESSION["TASK"] = $act_uid;
@@ -453,6 +454,7 @@ class Light
try {
$oCase = new Cases();
$Fields = $oCase->loadCase($app_uid);
//@todo Find a better way to define session variables
$_SESSION["APPLICATION"] = $app_uid;
$_SESSION["PROCESS"] = $Fields['PRO_UID'];
$_SESSION["TASK"] = $tas_uid;

View File

@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel;
use AdditionalTables;
use AdditionalTablesPeer;
use Configurations;
use G;
use Exception;
@@ -328,6 +329,11 @@ class ReportTable
*
* @param array $arrayData
* @param bool $flagAlterTable
*
* @see pmTablesProxy->save()
* @see ProcessMaker\BusinessModel\ReportTable->createStructureOfTables()
* @see Table->validateTableBeforeUpdate()
* @link https://wiki.processmaker.com/3.1/Report_Tables
*
* @return object
*/
@@ -560,6 +566,7 @@ class ReportTable
//Delete Report Table
$resultDeleteReportTable = $pmTablesProxy->delete($obj);
}
$this->updateConfigurationCaseList($additionalTableUid, $columns);
} catch (Exception $e) {
$buildResult = ob_get_contents();
@@ -578,11 +585,126 @@ class ReportTable
$result->trace = $e->getTraceAsString();
}
//Return
return $result;
}
/**
* Update the Custom Case List fields configuration.
*
* @param array $columns
*
* @see ProcessMaker\BusinessModel\ReportTable->saveStructureOfTable()
* @link https://wiki.processmaker.com/3.1/Report_Tables
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
public function updateConfigurationCaseList($addTabUid, $columns)
{
$actions = [
"todo", "draft", "sent", "unassigned", "paused", "completed", "cancelled"
];
$conf = new Configurations();
foreach ($actions as $action) {
$confCasesList = $conf->loadObject("casesList", $action, "", "", "");
$sw = is_array($confCasesList) && !empty($confCasesList) && !empty($confCasesList['PMTable']) && $confCasesList['PMTable'] === $addTabUid;
if ($sw) {
$this->addFieldsToCustomCaseList($confCasesList['first']['data'], $confCasesList['second']['data'], $columns);
$this->removeFieldsFromCustomCaseList($confCasesList['first']['data'], $columns);
$this->removeFieldsFromCustomCaseList($confCasesList['second']['data'], $columns);
$conf->saveObject($confCasesList, "casesList", $action);
}
}
}
/**
* Add fields to Custom Case List.
* @param array $data1
* @param array $data2
* @param array $columns
*
* @see ProcessMaker\BusinessModel\ReportTable->saveStructureOfTable()
* @link https://wiki.processmaker.com/3.1/Report_Tables
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
public function addFieldsToCustomCaseList(&$data1, $data2, $columns)
{
$all = [];
$type = 'PM Table';
$this->loadFieldTypeValues($data1, $all, $type);
$this->loadFieldTypeValues($data2, $all, $type);
foreach ($all as $value) {
foreach ($columns as $index => $column) {
if ($value['name'] === $column->field_name) {
unset($columns[$index]);
break;
}
}
}
$defaults = ["APP_UID", "APP_NUMBER", "APP_STATUS"];
foreach ($defaults as $value) {
foreach ($columns as $index => $column) {
if ($value === $column->field_name) {
unset($columns[$index]);
break;
}
}
}
foreach ($columns as $value) {
$data1[] = [
"name" => $column->field_name,
"fieldType" => $type
];
}
}
/**
* Load field type values.
*
* @param array $fields
* @param array $all
* @param string $type
*/
private function loadFieldTypeValues($fields, array &$all, $type)
{
foreach ($fields as $value) {
if ($value['fieldType'] === $type) {
$all[] = $value;
}
}
}
/**
* Remove fields from Custom Cases List.
*
* @param array $data
* @param array $columns
*
* @see ProcessMaker\BusinessModel\ReportTable->saveStructureOfTable()
* @link https://wiki.processmaker.com/3.1/Report_Tables
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
*/
public function removeFieldsFromCustomCaseList(&$data, $columns)
{
$n = count($data);
for ($key = 0; $key < $n; $key++) {
if ($data[$key]['fieldType'] === 'PM Table') {
$remove = true;
foreach ($columns as $column) {
if ($data[$key]['name'] === $column->field_name) {
$remove = false;
break;
}
}
if ($remove === true) {
unset($data[$key]);
$data = array_values($data);
$key = 0;
$n = count($data);
}
}
}
}
/**
* Create the structure of tables
*

View File

@@ -10,6 +10,7 @@ use PMScript;
use ResultSet;
use ScriptTaskPeer;
use TaskPeer;
use Triggers as ModelTriggers;
use TriggersPeer;
class ScriptTask
@@ -602,13 +603,16 @@ class ScriptTask
}
/**
* Execute Script
* Execute the trigger related to the script task
*
* @param string $activityUid Unique id of task
* @param array $arrayApplicationData Case data
*
* @return array
* @throws Exception
*
* @see Derivation::derivate()
* @link https://wiki.processmaker.com/3.1/Tasks#ScriptTask
*/
public function execScriptByActivityUid($activityUid, array $arrayApplicationData)
{
@@ -625,34 +629,35 @@ class ScriptTask
if ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$scriptTasObjUid = $row["SCRTAS_OBJ_UID"];
$trigger = TriggersPeer::retrieveByPK($scriptTasObjUid);
$trigger = new ModelTriggers();
$triggersList[] = $trigger->load($scriptTasObjUid);
if (!is_null($trigger)) {
//We will be update the status before execute the trigger related to the script task
if (!empty($triggersList)){
$case = new ClassesCases();
$result = $case->updateCase($arrayApplicationData["APP_UID"], $arrayApplicationData);
//We will be update the status before execute the trigger related to the script task
$case->updateCase($arrayApplicationData["APP_UID"], $arrayApplicationData);
//Some Pmf functions uses this global variable $oPMScript for review the aFields defined
global $oPMScript;
$oPMScript = new PMScript();
$oPMScript->setDataTrigger($trigger->toArray(BasePeer::TYPE_FIELDNAME));
$oPMScript->setFields($arrayApplicationData["APP_DATA"]);
$oPMScript->setScript($trigger->getTriWebbot());
$oPMScript->setExecutedOn(PMScript::SCRIPT_TASK);
$oPMScript->execute();
//Execute the trigger defined in the script task
$arrayApplicationData['APP_DATA'] = $case->executeTriggerFromList(
$triggersList,
$arrayApplicationData['APP_DATA'],
'SCRIPT_TASK',
'',
''
);
if (isset($oPMScript->aFields["__ERROR__"])) {
G::log("Case Uid: " . $arrayApplicationData["APP_UID"] . ", Error: " . $oPMScript->aFields["__ERROR__"],
$case->updateCase($arrayApplicationData['APP_UID'], $arrayApplicationData);
if (isset($arrayApplicationData['APP_DATA']['__ERROR__'])) {
G::log("Case Uid: " . $arrayApplicationData["APP_UID"] . ", Error: " . $arrayApplicationData['APP_DATA']['__ERROR__'],
PATH_DATA, "ScriptTask.log");
}
$arrayApplicationData["APP_DATA"] = $oPMScript->aFields;
$result = $case->updateCase($arrayApplicationData["APP_UID"], $arrayApplicationData);
}
}
}
//Return
return $arrayApplicationData["APP_DATA"];
return $arrayApplicationData['APP_DATA'];
} catch (Exception $e) {
throw $e;
}

View File

@@ -1427,4 +1427,31 @@ class Cases extends Api
return $response;
}
/**
* Return information for sub process cases
*
* @url GET /:app_uid/sub-process-cases
*
* @param string $app_uid {@min 32}{@max 32}
*
* @return array
* @throws Exception
*
* @access protected
* @class AccessControl {@permission PM_CASES}
*/
public function doGetCaseSubProcess($app_uid)
{
try {
$case = new BmCases();
$case->setFormatFieldNameInUppercase(false);
$caseInfo = $case->getCaseInfoSubProcess($app_uid, $this->getUserId());
$caseInfo = DateTime::convertUtcToIso8601($caseInfo, $this->arrayFieldIso8601);
return $caseInfo;
} catch (Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
}

View File

@@ -1038,6 +1038,7 @@ class Light extends Api
}
$userUid = $this->getUserId();
//@todo Find a better way to define session variables
$_SESSION["APPLICATION"] = $app_uid;
$_SESSION["PROCESS"] = $pro_uid;
//$_SESSION["TASK"] = "";
@@ -2009,6 +2010,7 @@ class Light extends Api
if ($alreadyRouted) {
throw (new RestException(Api::STAT_APP_EXCEPTION, G::LoadTranslation('ID_CASE_DELEGATION_ALREADY_CLOSED')));
}
//@todo Find a better way to define session variables
$_SESSION["APPLICATION"] = $app_uid;
$_SESSION["PROCESS"] = $pro_uid;
$_SESSION["INDEX"] = $app_index;

View File

@@ -309,6 +309,7 @@ function pauseCase(date){
buttons: [{
text: _('ID_OK'),
handler: function(){
this.setDisabled(true);
if (Ext.getCmp('noteReason').getValue() != '') {
var noteReasonTxt = _('ID_CASE_PAUSE_LABEL_NOTE') + ' ' + Ext.getCmp('noteReason').getValue();
} else {

View File

@@ -64,7 +64,7 @@ Ext.onReady(function () {
success: function (response, opts)
{
var dataResponse = eval("(" + response.responseText + ")"); //json
var dataResponse = Ext.util.JSON.decode(response.responseText);
switch (option) {
case "FIELD_SET":
@@ -85,8 +85,11 @@ Ext.onReady(function () {
break;
case "FIELD_SAVE":
configDefaultResponseText = response.responseText;
Ext.Msg.alert(_("ID_INFO"), _("ID_SAVED"));
location.reload(true);
var windowAlert = Ext.Msg.alert(_("ID_INFO"), _("ID_SAVED"));
fieldSet(dataResponse);
setTimeout(function () {
windowAlert.getDialog().close();
}, 500);
break;
}
},
@@ -150,75 +153,55 @@ Ext.onReady(function () {
{name: 'align', mapping : 'align'}
];
//Dropdown to select the PMTable
var PmTableStore = new Ext.data.JsonStore({
root : 'data',
url : 'proxyPMTablesList',
totalProperty : 'totalCount',
idProperty : 'gridIndex',
remoteSort : false, //true,
autoLoad : false,
fields : [
'ADD_TAB_UID', 'ADD_TAB_NAME'
],
listeners : {load: function() {
tabs.setActiveTab(tabIndex);
}}
});
// create the Data Store to list PMTables in the dropdown
var pmTablesDropdown = new Ext.form.ComboBox ({
width : '180',
xtype : 'combo',
emptyText: _("ID_EMPTY_PMTABLE"),
displayField : 'ADD_TAB_NAME',
valueField : 'ADD_TAB_UID',
triggerAction: 'all',
store : PmTableStore,
listeners: {
'select': function() {
var tableUid = this.value;
Ext.Ajax.request({
url: 'proxyPMTablesFieldList',
success: function(response) {
var dataResponse = Ext.util.JSON.decode(response.responseText);
var rec = Ext.data.Record.create(pmFields);
//alert(firstGrid.store);
var index;
var record;
var count = firstGrid.store.getTotalCount();
// removing all the PM Table fields from the first grid
do {
index = firstGrid.store.find('fieldType','PM Table');
record = firstGrid.store.getAt(index);
if (index>=0) {
firstGrid.store.remove(record);
}
} while (index>=0);
// removing all the PM Table fields from the second grid
do {
index = secondGrid.store.find('fieldType','PM Table');
record = secondGrid.store.getAt(index);
if (index>=0) {
secondGrid.store.remove(record);
}
} while (index>=0);
for (var i = 0; i <= dataResponse.data.length-1; i++) {
var d = new rec( dataResponse.data[i] );
firstGrid.store.add(d);
//Dropdown to select the PMTable
var PmTableStore = new Ext.data.JsonStore({
root: 'data',
url: 'proxyPMTablesList',
totalProperty: 'totalCount',
idProperty: 'gridIndex',
remoteSort: false, //true,
autoLoad: false,
fields: [
'ADD_TAB_UID', 'ADD_TAB_NAME'
],
listeners: {
load: function () {
tabs.setActiveTab(tabIndex);
}
firstGrid.store.commitChanges();
},
failure: function(){},
params: {xaction: 'getFieldsFromPMTable', table: tableUid }
});
}
});
}
}
});
// create the Data Store to list PMTables in the dropdown
var pmTablesDropdown = new Ext.form.ComboBox({
width: '180',
xtype: 'combo',
emptyText: _("ID_EMPTY_PMTABLE"),
displayField: 'ADD_TAB_NAME',
valueField: 'ADD_TAB_UID',
triggerAction: 'all',
store: PmTableStore,
listeners: {
focus: function(){
PmTableStore.load();
},
'select': function () {
var tableUid = this.value;
Ext.Ajax.request({
url: 'proxyPMTablesFieldList',
params: {
xaction: 'FIELD_SET',
action: currentAction,
table: tableUid
},
success: function (response) {
var dataResponse = Ext.util.JSON.decode(response.responseText);
fieldSet(dataResponse);
},
failure: function () {}
});
}
}
});
// COMPONENT DEPRECATED remove it in the next revision of the enterprise plugin
// create the Dropdown for rows per page
@@ -501,6 +484,20 @@ Ext.onReady(function () {
height : screen.height-245,
layout : 'hbox',
layoutConfig : {align : 'stretch'},
listeners: {
render: function (target) {
var el;
if (target.container && target.container.dom) {
el = target.container.dom;
el.style.cssText = 'overflow:hidden;position:absolute;top:28px;bottom:0px;left:0px;right:0px;';
target.setHeight(el.clientHeight);
Ext.EventManager.onWindowResize(function () {
mainPanel.setHeight(el.clientHeight);
mainPanel.doLayout();
});
}
}
},
tbar : new Ext.Toolbar({
items: [
_("ID_PM_TABLE"),
@@ -573,7 +570,7 @@ Ext.onReady(function () {
text: _("ID_RESET"),
handler: function ()
{
var dataResponse = eval("(" + configDefaultResponseText + ")"); //json
var dataResponse = Ext.util.JSON.decode(configDefaultResponseText);
fieldSet(dataResponse);
}

View File

@@ -1,11 +1,14 @@
var Actions = {};
var showCaseNavigatorPanel;
var hideCaseNavigatorPanel;
var informationMenu;
var caseMenuOpen = false;
var menuSelectedTitle = [];
var _ENV_CURRENT_DATE;
var winTree;
var Actions = {},
hideCaseNavigatorPanel,
informationMenu,
caseMenuOpen = false,
menuSelectedTitle = [],
_ENV_CURRENT_DATE,
winTree,
buttonCancel,
buttonClaimCase,
navPanelBottom,
navPanel;
historyGridListChangeLogGlobal = {};
historyGridListChangeLogGlobal.idHistory = '';
@@ -351,109 +354,217 @@ Ext.onReady(function(){
setNode(idfirstform);
}
var navPanelWest = {
id: 'navPanelWest',
region: 'west',
xtype:'panel',
width: 250,
height: 500,
maxSize: 400,
split: true,
collapsible: false,
margins: '0 0 0 0',
items:[casesStepTree]
}
var fnChangeStatus =function(){
alert('loaded');
}
var screenWidth = (PMExt.getBrowser().screen.width-140).toString() + 'px';
var navPanelCenter = {
id: 'navPanelCenter',
region: 'center', layout:'fit',forceLayout: true,
xtype:'panel',
items:[{
xtype:"tabpanel",
id: 'caseTabPanel',
deferredRender:false,
defaults:{autoScroll: true},
defaultType:"iframepanel",
activeTab: 0,
enableTabScroll: true,
//defaults: Ext.apply({}, Ext.isGecko? {style:{position:'absolute'},hideMode:'visibility'}:false),
items:[{
id: 'casesTab',
title: _('ID_CASE') +' ' + _APP_NUM,
frameConfig:{name:'openCaseFrame', id:'openCaseFrame'},
defaultSrc : uri,
loadMask:{msg: _('ID_LOADING_GRID') },
bodyStyle:{height: (PMExt.getBrowser().screen.height-60) + 'px', overflow:'hidden'},
width:screenWidth
}
],
listeners: {
tabchange: function(panel){
panel.ownerCt.doLayout();
},
render : function(panel){
Ext.each([this.el, this[this.collapseEl]] ,
function( elm ) {
elm.setVisibilityMode(Ext.Element.VISIBILITY).originalDisplay ='visible';
});
}
}
}]
};
var navPanel = {
id: 'navPanel',
region: 'center',
layout: 'border',
items:[navPanelWest, navPanelCenter],
tbar:[{
id: 'stepsMenu',
text: '&nbsp;&nbsp;'+_('ID_STEPS'),
pressed: false,
enableToggle:true,
tooltip: {
title: _('ID_CASES_STEPS'),
text:_('ID_SHOW_HIDE_CASES_STEPS')
},
iconCls: 'ICON_STEPS',
toggleHandler: togglePreview,
disabled: true
}, {
id: 'informationMenu',
text: _('ID_INFORMATION'),
menu: []
}, {
id: 'actionMenu',
text: _('ID_ACTIONS'),
menu: []
}, {
id: 'caseNotes',
pressed: false,
enableToggle:true,
text: '&nbsp;&nbsp;'+_('ID_CASES_NOTES'),
iconCls: 'button_menu_ext ICON_CASES_NOTES',
tooltip: {
title: _('ID_CASES_NOTES'),
text:_('ID_SHOW_CASES_NOTES')
},
toggleHandler:function(btn, pressed){
if(pressed){
openCaseNotesWindow();
}else{
closeCaseNotesWindow();
}
var navPanelWest = {
id: 'navPanelWest',
region: 'west',
xtype:'panel',
width: 250,
height: 500,
maxSize: 400,
split: true,
collapsible: false,
margins: '0 0 0 0',
items:[casesStepTree]
}
}]
}
var fnChangeStatus =function(){
alert('loaded');
}
var screenWidth = (PMExt.getBrowser().screen.width-140).toString() + 'px';
var navPanelCenter = {
id: 'navPanelCenter',
region: 'center', layout:'fit',forceLayout: true,
xtype:'panel',
items:[{
xtype:"tabpanel",
id: 'caseTabPanel',
deferredRender:false,
defaults:{autoScroll: true},
defaultType:"iframepanel",
activeTab: 0,
enableTabScroll: true,
//defaults: Ext.apply({}, Ext.isGecko? {style:{position:'absolute'},hideMode:'visibility'}:false),
items:[{
id: 'casesTab',
title: _('ID_CASE') +' ' + _APP_NUM,
frameConfig:{name:'openCaseFrame', id:'openCaseFrame'},
defaultSrc : uri,
loadMask:{msg: _('ID_LOADING_GRID') },
bodyStyle:{height: (PMExt.getBrowser().screen.height-60) + 'px', overflow:'hidden'},
width:screenWidth
}
],
listeners: {
tabchange: function(panel){
panel.ownerCt.doLayout();
},
render : function(panel){
Ext.each([this.el, this[this.collapseEl]] ,
function( elm ) {
elm.setVisibilityMode(Ext.Element.VISIBILITY).originalDisplay ='visible';
});
}
}
}]
};
buttonCancel = new Ext.Button({
buttonAlign: 'center',
text: 'Cancel',
handler: redirectHistory,
cls: 'cancelSummary',
width: '100px',
flex: 1,
style: "height:36px"
});
buttonClaimCase = new Ext.Button({
buttonAlign: 'center',
ui: 'round',
text: 'Claim this case',
handler: claimCase,
cls: 'claimCaseSummary',
width: '120px',
flex: 1,
style: "height:36px"
});
navPanelBottom = {
id: 'navPanelBottom',
name: 'navPanelBottom',
cls: 'navPanelBottom',
region: 'south',
layout: 'column',
dock: 'bottom',
border: false,
margin: '0 0 0 0',
split: false,
collapsible: false,
hidden: false,
buttonAlign: 'center',
buttonHeight: 200,
buttons: [buttonCancel, buttonClaimCase]
};
/**
* Claim the case.
*/
function claimCase() {
Ext.Ajax.request({
url: 'cases_CatchExecute',
success: function (response, opts) {
Ext.Ajax.request({
url: 'ajaxListener',
params: {action : 'steps'},
success: function (response, opts) {
Ext.getCmp('navPanelBottom').hide();
Ext.getCmp('navPanel').doLayout();
//Reload frame pmDynaform
if (isBrowserIE()) {
document.getElementById('openCaseFrame').contentWindow.location.reload(true);
} else {
Ext.getCmp('navPanelCenter').getUpdater().getEl().update();
}
}
});
}
});
}
/**
* Redirect to unassigned inbox.
*/
function redirectHistory() {
if (isBrowserIE()) {
if (top.opener) {
//Is open the claim case in another tab
top.opener.location.reload();
top.close();
} else {
//When isIE with ux skin is not open another tab
javascript:history.back();
}
} else {
javascript:history.back();
}
}
navPanel = {
id: 'navPanel',
region: 'center',
layout: 'border',
items: [navPanelWest, navPanelCenter],
tbar: [{
id: 'stepsMenu',
text: '&nbsp;&nbsp;' + _('ID_STEPS'),
pressed: false,
enableToggle: true,
tooltip: {
title: _('ID_CASES_STEPS'),
text: _('ID_SHOW_HIDE_CASES_STEPS')
},
iconCls: 'ICON_STEPS',
toggleHandler: togglePreview,
disabled: true
}, {
id: 'informationMenu',
text: _('ID_INFORMATION'),
menu: []
}, {
id: 'actionMenu',
text: _('ID_ACTIONS'),
menu: []
}, {
id: 'caseNotes',
pressed: false,
enableToggle: true,
text: '&nbsp;&nbsp;' + _('ID_CASES_NOTES'),
iconCls: 'button_menu_ext ICON_CASES_NOTES',
tooltip: {
title: _('ID_CASES_NOTES'),
text: _('ID_SHOW_CASES_NOTES')
},
toggleHandler: function (btn, pressed) {
if (pressed) {
openCaseNotesWindow();
} else {
closeCaseNotesWindow();
}
}
}]
};
/**
* Get Parameters from URL
* @returns {*}
*/
function getParameterURL() {
var item,
key = false,
result = {},
url = location.search.substring(1),
regExp = /([^&=]+)=([^&]*)/g;
if (arguments.length > 0 && arguments[0].length > 1) {
key = arguments[0];
}
while (item = regExp.exec(url)) {
if (key !== false && decodeURIComponent(item[1]) === key) {
return decodeURIComponent(item[2]);
}
else if (key === false) {
result[decodeURIComponent(item[1])] = decodeURIComponent(item[2]);
}
}
return key === false ? result : null;
}
if (this.showCustomForm && this.showCustomForm === true && getParameterURL('action') === 'unassigned') {
navPanel.items[navPanel.items.length] = navPanelBottom;
}
var viewport = new Ext.Viewport({
layout: 'border',
@@ -1359,6 +1470,7 @@ Ext.onReady(function(){
Actions.pauseCase = function()
{
Ext.getCmp('submitPauseCase').setDisabled(true);
Ext.Ajax.request({
url : 'ajaxListener' ,
params : {action : 'verifySession'},
@@ -1390,6 +1502,7 @@ Ext.onReady(function(){
var paramsNote = '&NOTE_REASON=' + noteReasonTxt + '&NOTIFY_PAUSE=' + notifyReasonVal;
var unpauseDate = Ext.getCmp('unpauseDate').getValue();
if( unpauseDate == '') {
Ext.getCmp('submitPauseCase').setDisabled(false);
return;
} else {
unpauseDate = unpauseDate.format('Y-m-d');
@@ -1420,6 +1533,7 @@ Ext.onReady(function(){
},
failure: function ( res, req) {
PMExt.error(_('ID_ERROR'), req.result.msg);
Ext.getCmp('submitPauseCase').setDisabled(false);
}
});
}
@@ -1428,6 +1542,7 @@ Ext.onReady(function(){
if (typeof(result.responseText) != 'undefined') {
Ext.MessageBox.alert( _('ID_FAILED'), result.responseText);
}
Ext.getCmp('submitPauseCase').setDisabled(false);
}
});
}
@@ -1892,4 +2007,3 @@ Ext.onReady(function(){
node.select();
}