Merged in feature/HOR-4570 (pull request #6477)
HOR-4570 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \ProcessMaker\BusinessModel\WebEntryEvent;
|
use ProcessMaker\BusinessModel\User as BusinessModelUser;
|
||||||
|
use ProcessMaker\BusinessModel\WebEntryEvent;
|
||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Cases object where you can do start, load, update, refresh about cases
|
* A Cases object where you can do start, load, update, refresh about cases
|
||||||
* This object is applied to Task
|
* This object is applied to Task
|
||||||
@@ -4196,11 +4198,11 @@ class Cases
|
|||||||
$dataList = [];
|
$dataList = [];
|
||||||
$rowDelay = AppDelay::buildAppDelayRow(
|
$rowDelay = AppDelay::buildAppDelayRow(
|
||||||
$caseFields['PRO_UID'],
|
$caseFields['PRO_UID'],
|
||||||
$caseFields['PRO_ID'],
|
isset($caseFields['PRO_ID']) ? $caseFields['PRO_ID'] : 0,
|
||||||
$appUid,
|
$appUid,
|
||||||
$caseFields['APP_NUMBER'],
|
$caseFields['APP_NUMBER'],
|
||||||
$value['DEL_INDEX'],
|
|
||||||
$value['DEL_THREAD'],
|
$value['DEL_THREAD'],
|
||||||
|
$value['DEL_INDEX'],
|
||||||
AppDelay::APP_TYPE_CANCEL,
|
AppDelay::APP_TYPE_CANCEL,
|
||||||
Application::APP_STATUS_CANCELLED,
|
Application::APP_STATUS_CANCELLED,
|
||||||
is_null($usrUid) ? '' : $usrUid
|
is_null($usrUid) ? '' : $usrUid
|
||||||
@@ -4247,7 +4249,7 @@ class Cases
|
|||||||
/** Close the specific delIndex in APP_DELEGATION and APP_THREAD */
|
/** Close the specific delIndex in APP_DELEGATION and APP_THREAD */
|
||||||
$this->CloseCurrentDelegation($appUid, $delIndex);
|
$this->CloseCurrentDelegation($appUid, $delIndex);
|
||||||
$resultDelegation = $delegation->Load($appUid, $delIndex);
|
$resultDelegation = $delegation->Load($appUid, $delIndex);
|
||||||
$this->closeAppThread($appUid, $result['DEL_THREAD']);
|
$this->closeAppThread($appUid, $resultDelegation['DEL_THREAD']);
|
||||||
$result[] = $resultDelegation;
|
$result[] = $resultDelegation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4257,114 +4259,114 @@ class Cases
|
|||||||
/**
|
/**
|
||||||
* Un cancel case
|
* Un cancel case
|
||||||
*
|
*
|
||||||
* @param string $caseUID
|
* @param string $appUid
|
||||||
* @param string $userUID
|
* @param string $usrUid
|
||||||
* @return int
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function unCancelCase($appUID, $userUID)
|
public function unCancelCase($appUid, $usrUid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$oUser = new \ProcessMaker\BusinessModel\User();
|
$user = new BusinessModelUser();
|
||||||
if (!$oUser->checkPermission($userUID, 'PM_UNCANCELCASE')) {
|
/** Review if the user has the permission PM_UNCANCELCASE */
|
||||||
|
if (!$user->checkPermission($usrUid, 'PM_UNCANCELCASE')) {
|
||||||
throw new Exception(G::LoadTranslation('ID_YOU_DO_NOT_HAVE_PERMISSION'));
|
throw new Exception(G::LoadTranslation('ID_YOU_DO_NOT_HAVE_PERMISSION'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$application = new Application();
|
$caseFields = $this->loadCase($appUid);
|
||||||
$rowApplication = $application->load($appUID);
|
/** Review if the case has the status CANCELLED */
|
||||||
if ($rowApplication["APP_STATUS"] !== "CANCELLED") {
|
if ($caseFields["APP_STATUS"] !== Application::APP_STATUS_CANCELLED) {
|
||||||
throw new Exception(G::LoadTranslation('ID_THE_APPLICATION_IS_NOT_CANCELED', [$appUID]));
|
throw new Exception(G::LoadTranslation('ID_THE_APPLICATION_IS_NOT_CANCELED', [$appUid]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$criteriaAppDelay = new Criteria('workflow');
|
//Load the USR_ID
|
||||||
$criteriaAppDelay->add(AppDelayPeer::APP_UID, $appUID);
|
$u = new Users();
|
||||||
$criteriaAppDelay->add(AppDelayPeer::APP_STATUS, 'CANCELLED');
|
$userId = $u->load($usrUid)['USR_ID'];
|
||||||
$criteriaAppDelay->add(AppDelayPeer::PRO_UID, $rowApplication['PRO_UID']);
|
|
||||||
$criteriaAppDelay->addDescendingOrderByColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE);
|
|
||||||
$resultSetAppDelay = AppDelayPeer::doSelectRS($criteriaAppDelay);
|
|
||||||
$resultSetAppDelay->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
||||||
$resultSetAppDelay->next();
|
|
||||||
$rowAppDelay = $resultSetAppDelay->getRow();
|
|
||||||
if (!isset($rowAppDelay['APP_STATUS'])) {
|
|
||||||
throw new Exception(G::LoadTranslation('ID_THREAD_STATUS_DOES_NOT_EXIST_FOR_THE_APPLICATION.', [$appUID]));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Application
|
//Get the list of thread that close with the CancelCase
|
||||||
$rowApplication['APP_STATUS'] = 'TO_DO';
|
$appDelay = new AppDelay();
|
||||||
$rowApplication['APP_UPDATE_DATE'] = date('Y-m-d H:i:s');
|
$threadsCanceled = $appDelay->getThreadByStatus($appUid, Application::APP_STATUS_CANCELLED);
|
||||||
$application->update($rowApplication);
|
|
||||||
|
|
||||||
//AppDelegation
|
//Get all the threads in the AppDelay
|
||||||
|
foreach ($threadsCanceled as $row){
|
||||||
|
//Load the thread CLOSED
|
||||||
$appDelegation = new AppDelegation();
|
$appDelegation = new AppDelegation();
|
||||||
$rowAppDelegation = $appDelegation->Load($appUID, $rowAppDelay['APP_DEL_INDEX']);
|
$delegationClosed = $appDelegation->Load($appUid, $row['APP_DEL_INDEX']);
|
||||||
|
//Create an appDelegation for each thread
|
||||||
$appDelegation = new AppDelegation();
|
$appDelegation = new AppDelegation();
|
||||||
$delIndex = $appDelegation->createAppDelegation($rowAppDelegation['PRO_UID'], $rowAppDelegation['APP_UID'], $rowAppDelegation['TAS_UID'], $userUID, $rowAppDelay['APP_THREAD_INDEX']);
|
$delIndex = $appDelegation->createAppDelegation(
|
||||||
|
$delegationClosed['PRO_UID'],
|
||||||
|
$delegationClosed['APP_UID'],
|
||||||
|
$delegationClosed['TAS_UID'],
|
||||||
|
$usrUid,
|
||||||
|
$delegationClosed['DEL_THREAD'],
|
||||||
|
3,
|
||||||
|
false,
|
||||||
|
$delegationClosed['DEL_PREVIOUS'],
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
$delegationClosed['APP_NUMBER'],
|
||||||
|
$delegationClosed['TAS_ID'],
|
||||||
|
$userId,
|
||||||
|
$delegationClosed['PRO_ID']
|
||||||
|
);
|
||||||
|
|
||||||
//AppThread
|
//Update the appThread
|
||||||
$dataAppThread = [
|
$dataAppThread = [
|
||||||
'APP_UID' => $rowApplication['APP_UID'],
|
'APP_UID' => $row['APP_UID'],
|
||||||
'APP_THREAD_INDEX' => $rowAppDelay['APP_THREAD_INDEX'],
|
'APP_THREAD_INDEX' => $delegationClosed['DEL_THREAD'],
|
||||||
'APP_THREAD_STATUS' => 'OPEN',
|
'APP_THREAD_STATUS' => 'OPEN',
|
||||||
'DEL_INDEX' => $delIndex
|
'DEL_INDEX' => $delIndex
|
||||||
];
|
];
|
||||||
$appThread = new AppThread();
|
$appThread = new AppThread();
|
||||||
$appThread->update($dataAppThread);
|
$res = $appThread->update($dataAppThread);
|
||||||
|
|
||||||
//AppDelay
|
//New register in AppDelay
|
||||||
$dataAppDelay = [
|
$newAppDelay = AppDelay::buildAppDelayRow(
|
||||||
'PRO_UID' => $rowApplication['PRO_UID'],
|
$row['PRO_UID'],
|
||||||
'APP_UID' => $rowApplication['APP_UID'],
|
$delegationClosed['PRO_ID'],
|
||||||
'APP_THREAD_INDEX' => $rowAppDelay['APP_THREAD_INDEX'],
|
$row['APP_UID'],
|
||||||
'APP_DELINDEX' => $delIndex,
|
$delegationClosed['APP_NUMBER'],
|
||||||
'APP_TYPE' => 'UNCANCEL',
|
$row['APP_THREAD_INDEX'],
|
||||||
'APP_STATUS' => $rowApplication['APP_STATUS'],
|
$delIndex,
|
||||||
'APP_NEXT_TASK' => 0,
|
AppDelay::APP_TYPE_UNCANCEL,
|
||||||
'APP_DELEGATION_USER' => $userUID,
|
Application::APP_STATUS_TODO,
|
||||||
'APP_ENABLE_ACTION_USER' => $userUID,
|
$usrUid,
|
||||||
'APP_ENABLE_ACTION_DATE' => date('Y-m-d H:i:s'),
|
$userId
|
||||||
'APP_DISABLE_ACTION_USER' => 0
|
);
|
||||||
];
|
$appDelay->create($newAppDelay);
|
||||||
$appDelay = new AppDelay();
|
|
||||||
$appDelay->create($dataAppDelay);
|
|
||||||
|
|
||||||
//ListCanceled
|
//New register in the listInbox
|
||||||
$criteriaListCanceled = new Criteria("workflow");
|
$newDelegation = array_merge($newAppDelay, $delegationClosed);
|
||||||
$criteriaListCanceled->add(ListCanceledPeer::APP_UID, $appUID);
|
$newDelegation['USR_UID'] = $usrUid;
|
||||||
$resultSetListCanceled = ListCanceledPeer::doSelectRS($criteriaListCanceled);
|
$newDelegation['DEL_INDEX'] = $delIndex;
|
||||||
$resultSetListCanceled->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$newDelegation['APP_STATUS'] = Application::APP_STATUS_TODO;
|
||||||
$resultSetListCanceled->next();
|
$inbox = new ListInbox();
|
||||||
$rowListCanceled = $resultSetListCanceled->getRow();
|
//Get the previous user
|
||||||
ListCanceledPeer::doDelete($criteriaListCanceled);
|
//When the status of the case is DRAFT we does not have a previous thread
|
||||||
|
$previousUser = '';
|
||||||
|
if ($delegationClosed['DEL_PREVIOUS'] != 0){
|
||||||
|
$appDelegation = new AppDelegation();
|
||||||
|
$delegationPrevious = $appDelegation->Load($appUid, $delegationClosed['DEL_PREVIOUS']);
|
||||||
|
$previousUser = $delegationPrevious['USR_UID'];
|
||||||
|
}
|
||||||
|
|
||||||
//ListInbox
|
$inbox->newRow($newDelegation, $previousUser);
|
||||||
$rowListCanceled['DEL_PREVIOUS_USR_USERNAME'] = $rowListCanceled['DEL_CURRENT_USR_USERNAME'];
|
}
|
||||||
$rowListCanceled['DEL_PREVIOUS_USR_FIRSTNAME'] = $rowListCanceled['DEL_CURRENT_USR_FIRSTNAME'];
|
|
||||||
$rowListCanceled['DEL_PREVIOUS_USR_LASTNAME'] = $rowListCanceled['DEL_CURRENT_USR_LASTNAME'];
|
|
||||||
$rowListCanceled['APP_STATUS'] = 'TO_DO';
|
|
||||||
$rowListCanceled['APP_UPDATE_DATE'] = date('Y-m-d H:i:s');
|
|
||||||
$rowListCanceled['DEL_RISK_DATE'] = date('Y-m-d H:i:s');
|
|
||||||
$rowListCanceled['DEL_INDEX'] = $delIndex;
|
|
||||||
unset($rowListCanceled['DEL_CURRENT_USR_USERNAME']);
|
|
||||||
unset($rowListCanceled['DEL_CURRENT_USR_FIRSTNAME']);
|
|
||||||
unset($rowListCanceled['DEL_CURRENT_USR_LASTNAME']);
|
|
||||||
unset($rowListCanceled['APP_CANCELED_DATE']);
|
|
||||||
|
|
||||||
$this->putCaseInInboxList($rowListCanceled, $userUID);
|
//Update the status of the case
|
||||||
|
$caseFields['APP_STATUS'] = Application::APP_STATUS_TODO;
|
||||||
|
$this->updateCase($appUid, $caseFields);
|
||||||
|
|
||||||
//ListParticipatedLast
|
//Remove the case from the list Canceled
|
||||||
$criteriaListParticipatedLast = new Criteria("workflow");
|
$listCanceled = new ListCanceled();
|
||||||
$criteriaListParticipatedLast->add(ListParticipatedLastPeer::APP_UID, $appUID);
|
$listCanceled->removeAll($appUid);
|
||||||
$resultSetListParticipatedLast = ListParticipatedLastPeer::doSelectRS($criteriaListParticipatedLast);
|
|
||||||
$resultSetListParticipatedLast->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
} catch (Exception $exception) {
|
||||||
$resultSetListParticipatedLast->next();
|
throw $exception;
|
||||||
$rowListParticipatedLast = $resultSetListParticipatedLast->getRow();
|
|
||||||
$rowListParticipatedLast['APP_STATUS'] = 'TO_DO';
|
|
||||||
$rowListParticipatedLast['DEL_THREAD_STATUS'] = 'OPEN';
|
|
||||||
$rowListParticipatedLast['DEL_INIT_DATE'] = null;
|
|
||||||
$listParticipatedLast = new ListParticipatedLast();
|
|
||||||
$listParticipatedLast->update($rowListParticipatedLast);
|
|
||||||
} catch (Exception $oException) {
|
|
||||||
throw $oException;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2767,6 +2767,7 @@ function PMFCancelCase ($caseUid, $delIndex, $userUid)
|
|||||||
{
|
{
|
||||||
$ws = new WsBase();
|
$ws = new WsBase();
|
||||||
$result = $ws->cancelCase($caseUid, $delIndex, $userUid);
|
$result = $ws->cancelCase($caseUid, $delIndex, $userUid);
|
||||||
|
$result = (object)$result;
|
||||||
|
|
||||||
if ($result->status_code == 0) {
|
if ($result->status_code == 0) {
|
||||||
if (isset($_SESSION['APPLICATION']) && isset($_SESSION['INDEX'])) {
|
if (isset($_SESSION['APPLICATION']) && isset($_SESSION['INDEX'])) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
class AppDelay extends BaseAppDelay
|
class AppDelay extends BaseAppDelay
|
||||||
{
|
{
|
||||||
const APP_TYPE_CANCEL = 'CANCEL';
|
const APP_TYPE_CANCEL = 'CANCEL';
|
||||||
|
const APP_TYPE_UNCANCEL = 'UNCANCEL';
|
||||||
const APP_TYPE_PAUSE = 'PAUSE';
|
const APP_TYPE_PAUSE = 'PAUSE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,6 +162,7 @@ class AppDelay extends BaseAppDelay
|
|||||||
* @param string $appType
|
* @param string $appType
|
||||||
* @param string $appStatus
|
* @param string $appStatus
|
||||||
* @param string $usrUid
|
* @param string $usrUid
|
||||||
|
* @param integer $usrId
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -173,11 +175,11 @@ class AppDelay extends BaseAppDelay
|
|||||||
$delIndex = 0,
|
$delIndex = 0,
|
||||||
$appType = 'CANCEL',
|
$appType = 'CANCEL',
|
||||||
$appStatus = 'CANCELLED',
|
$appStatus = 'CANCELLED',
|
||||||
$usrUid = ''
|
$usrUid = '',
|
||||||
|
$usrId = 0
|
||||||
) {
|
) {
|
||||||
$row = [];
|
$row = [];
|
||||||
$row['PRO_UID'] = $proUid;
|
$row['PRO_UID'] = $proUid;
|
||||||
$row['PRO_ID'] = $proId;
|
|
||||||
$row['APP_UID'] = $appUid;
|
$row['APP_UID'] = $appUid;
|
||||||
$row['APP_NUMBER'] = $appNumber;
|
$row['APP_NUMBER'] = $appNumber;
|
||||||
$row['APP_THREAD_INDEX'] = $appThreadIndex;
|
$row['APP_THREAD_INDEX'] = $appThreadIndex;
|
||||||
@@ -186,15 +188,56 @@ class AppDelay extends BaseAppDelay
|
|||||||
$row['APP_STATUS'] = $appStatus;
|
$row['APP_STATUS'] = $appStatus;
|
||||||
$row['APP_ENABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
|
$row['APP_ENABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
//Load the PRO_ID if does not exit
|
||||||
|
if (empty($proId) || $proId === 0) {
|
||||||
|
$u = new Process();
|
||||||
|
$proId = $u->load($proUid)['PRO_ID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$row['PRO_ID'] = $proId;
|
||||||
//Define the user that execute the insert
|
//Define the user that execute the insert
|
||||||
if (empty($usrUid)) {
|
if (empty($usrUid)) {
|
||||||
global $RBAC;
|
global $RBAC;
|
||||||
$usrUid = $RBAC->aUserInfo['USER_INFO']['USR_UID'];
|
$usrUid = $RBAC->aUserInfo['USER_INFO']['USR_UID'];
|
||||||
|
$u = new Users();
|
||||||
|
$usrId = $u->load($usrUid)['USR_ID'];
|
||||||
}
|
}
|
||||||
$row['APP_DELEGATION_USER'] = $usrUid;
|
$row['APP_DELEGATION_USER'] = $usrUid;
|
||||||
$row['APP_ENABLE_ACTION_USER'] = $usrUid;
|
$row['APP_ENABLE_ACTION_USER'] = $usrUid;
|
||||||
|
$row['APP_DELEGATION_USER_ID'] = $usrId;
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all threads with the status canceled
|
||||||
|
*
|
||||||
|
* @param string $appUid
|
||||||
|
* @param string $status
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function getThreadByStatus($appUid, $status)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$criteria = new Criteria('workflow');
|
||||||
|
$criteria->add(AppDelayPeer::APP_UID, $appUid);
|
||||||
|
$criteria->add(AppDelayPeer::APP_STATUS, $status);
|
||||||
|
$criteria->addDescendingOrderByColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE);
|
||||||
|
$dataset = AppDelayPeer::doSelectRS($criteria);
|
||||||
|
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
$dataset->next();
|
||||||
|
$result = [];
|
||||||
|
while ($row = $dataset->getRow()) {
|
||||||
|
$result[] = $row;
|
||||||
|
$dataset->next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
} catch (Exception $error) {
|
||||||
|
throw $error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class Application extends BaseApplication
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const APP_STATUS_CANCELLED = 'CANCELLED';
|
const APP_STATUS_CANCELLED = 'CANCELLED';
|
||||||
|
const APP_STATUS_TODO = 'TO_DO';
|
||||||
public static $app_status_values = ['DRAFT' => 1, 'TO_DO' => 2, 'COMPLETED' => 3, 'CANCELLED' => 4];
|
public static $app_status_values = ['DRAFT' => 1, 'TO_DO' => 2, 'COMPLETED' => 3, 'CANCELLED' => 4];
|
||||||
protected $app_title_content = '';
|
protected $app_title_content = '';
|
||||||
protected $app_description_content = '';
|
protected $app_description_content = '';
|
||||||
|
|||||||
@@ -190,6 +190,25 @@ class ListCanceled extends BaseListCanceled implements ListInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all records related to the APP_UID
|
||||||
|
*
|
||||||
|
* @param string $appUid
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function removeAll($appUid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$criteria = new Criteria("workflow");
|
||||||
|
$criteria->add(ListCanceledPeer::APP_UID, $appUid);
|
||||||
|
ListCanceledPeer::doDelete($criteria);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function loadFilters(&$criteria, $filters)
|
public function loadFilters(&$criteria, $filters)
|
||||||
{
|
{
|
||||||
$filter = isset($filters['filter']) ? $filters['filter'] : "";
|
$filter = isset($filters['filter']) ? $filters['filter'] : "";
|
||||||
|
|||||||
Reference in New Issue
Block a user