2012-10-19 14:38:15 -04:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* cases_Open.php
|
|
|
|
|
*
|
|
|
|
|
* ProcessMaker Open Source Edition
|
|
|
|
|
* Copyright (C) 2004 - 2008 Colosa Inc.
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2015-11-09 11:01:11 -04:00
|
|
|
if(isset( $_GET['gmail']) && $_GET['gmail'] == 1){
|
2017-03-07 16:59:04 -04:00
|
|
|
$_SESSION['gmail'] = 1;
|
2015-11-09 11:01:11 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 14:38:15 -04:00
|
|
|
/* Permissions */
|
|
|
|
|
if ($RBAC->userCanAccess( 'PM_CASES' ) != 1) {
|
|
|
|
|
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
|
|
|
|
|
case - 2:
|
|
|
|
|
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
|
|
|
|
|
G::header( 'location: ../login/login' );
|
|
|
|
|
break;
|
|
|
|
|
case - 1:
|
|
|
|
|
default:
|
|
|
|
|
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
|
|
|
|
G::header( 'location: ../login/login' );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-07 12:01:42 -04:00
|
|
|
$caseInstance = new Cases();
|
2012-10-19 14:38:15 -04:00
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
//cleaning the case session data
|
2012-10-19 14:38:15 -04:00
|
|
|
Cases::clearCaseSessionData();
|
|
|
|
|
|
|
|
|
|
try {
|
2012-10-18 15:42:36 +00:00
|
|
|
//Loading data for a Jump request
|
2017-03-07 16:59:04 -04:00
|
|
|
if (!isset($_GET['APP_UID']) && isset($_GET['APP_NUMBER'])) {
|
2018-09-07 12:01:42 -04:00
|
|
|
$_GET['APP_UID'] = $caseInstance->getApplicationUIDByNumber( $_GET['APP_NUMBER'] );
|
|
|
|
|
$_GET['DEL_INDEX'] = $caseInstance->getCurrentDelegation( $_GET['APP_UID'], $_SESSION['USER_LOGGED'] );
|
2012-10-19 14:38:15 -04:00
|
|
|
|
2012-10-18 15:42:36 +00:00
|
|
|
//if the application doesn't exist
|
2017-03-07 16:59:04 -04:00
|
|
|
if (is_null($_GET['APP_UID'])) {
|
2012-10-19 14:38:15 -04:00
|
|
|
G::SendMessageText( G::LoadTranslation( 'ID_CASE_DOES_NOT_EXISTS' ), 'info' );
|
|
|
|
|
G::header( 'location: casesListExtJs' );
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:42:36 +00:00
|
|
|
//if the application exists but the
|
2017-03-07 16:59:04 -04:00
|
|
|
if (is_null($_GET['DEL_INDEX'])) {
|
2012-10-19 14:38:15 -04:00
|
|
|
G::SendMessageText( G::LoadTranslation( 'ID_CASE_IS_CURRENTLY_WITH_ANOTHER_USER' ), 'info' );
|
|
|
|
|
G::header( 'location: casesListExtJs' );
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sAppUid = $_GET['APP_UID'];
|
|
|
|
|
$iDelIndex = $_GET['DEL_INDEX'];
|
2017-03-07 16:59:04 -04:00
|
|
|
$_action = isset($_GET['action']) ? $_GET['action'] : '';
|
2012-10-19 14:38:15 -04:00
|
|
|
|
2012-10-18 15:42:36 +00:00
|
|
|
//loading application data
|
2018-09-07 12:01:42 -04:00
|
|
|
$aFields = $caseInstance->loadCase( $sAppUid, $iDelIndex );
|
2017-03-07 16:59:04 -04:00
|
|
|
|
2015-02-12 16:08:51 -04:00
|
|
|
if (!isset($_SESSION['CURRENT_TASK'])) {
|
2017-03-07 16:59:04 -04:00
|
|
|
$_SESSION['CURRENT_TASK'] = $aFields['TAS_UID'];
|
|
|
|
|
} elseif ($_SESSION['CURRENT_TASK'] == '') {
|
|
|
|
|
$_SESSION['CURRENT_TASK'] = $aFields['TAS_UID'];
|
2015-02-11 16:56:27 -04:00
|
|
|
}
|
2017-03-07 16:59:04 -04:00
|
|
|
|
2017-07-12 15:55:02 -04:00
|
|
|
unset($_SESSION['ACTION']);
|
|
|
|
|
$flagJump = '';
|
|
|
|
|
if ($_action == 'jump') {
|
|
|
|
|
$_SESSION['ACTION'] = 'jump';
|
|
|
|
|
$flagJump = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-19 14:38:15 -04:00
|
|
|
switch ($aFields['APP_STATUS']) {
|
|
|
|
|
case 'DRAFT':
|
|
|
|
|
case 'TO_DO':
|
2017-03-07 16:59:04 -04:00
|
|
|
//Check if the case is in pause, check a valid record in table APP_DELAY
|
2017-05-09 16:28:46 -04:00
|
|
|
$isPaused = AppDelay::isPaused($sAppUid, $iDelIndex);
|
|
|
|
|
|
|
|
|
|
//Check if the case is a waiting for a SYNCHRONOUS subprocess
|
|
|
|
|
$subAppData = new \SubApplication();
|
|
|
|
|
$caseSubprocessPending = $subAppData->isSubProcessWithCasePending($sAppUid, $iDelIndex);
|
|
|
|
|
|
|
|
|
|
if ($isPaused || $caseSubprocessPending) {
|
2012-10-18 15:42:36 +00:00
|
|
|
//the case is paused show only the resume
|
2012-10-19 14:38:15 -04:00
|
|
|
$_SESSION['APPLICATION'] = $sAppUid;
|
|
|
|
|
$_SESSION['INDEX'] = $iDelIndex;
|
|
|
|
|
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
|
|
|
|
|
$_SESSION['TASK'] = - 1;
|
|
|
|
|
$_SESSION['STEP_POSITION'] = 0;
|
2014-06-18 11:51:39 -04:00
|
|
|
$_SESSION['CURRENT_TASK'] = $aFields['TAS_UID'];
|
2012-10-19 14:38:15 -04:00
|
|
|
|
|
|
|
|
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-07-15 09:27:51 -04:00
|
|
|
* these routine is to verify if the case was acceded from advanced search list
|
2012-10-19 14:38:15 -04:00
|
|
|
*/
|
2014-05-05 13:06:22 -04:00
|
|
|
|
2012-10-19 14:38:15 -04:00
|
|
|
if ($_action == 'search') {
|
2014-07-15 09:27:51 -04:00
|
|
|
//verify if the case is with the current user
|
2017-05-09 16:28:46 -04:00
|
|
|
$aData = AppDelegation::getCurrentUsers($sAppUid, $iDelIndex);
|
|
|
|
|
if ($aData['USR_UID'] !== $_SESSION['USER_LOGGED'] && !empty($aData['USR_UID'])) {
|
2012-10-19 14:38:15 -04:00
|
|
|
//distinct "" for selfservice
|
2012-10-18 15:42:36 +00:00
|
|
|
//so we show just the resume
|
2012-10-19 14:38:15 -04:00
|
|
|
$_SESSION['alreadyDerivated'] = true;
|
|
|
|
|
$_SESSION['APPLICATION'] = $sAppUid;
|
|
|
|
|
$_SESSION['INDEX'] = $iDelIndex;
|
|
|
|
|
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
|
|
|
|
|
$_SESSION['TASK'] = - 1;
|
|
|
|
|
$_SESSION['STEP_POSITION'] = 0;
|
|
|
|
|
|
|
|
|
|
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2016-07-26 14:25:02 -04:00
|
|
|
|
2012-10-19 14:38:15 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 15:42:36 +00:00
|
|
|
//proceed and try to open the case
|
2012-10-19 14:38:15 -04:00
|
|
|
$oAppDelegation = new AppDelegation();
|
|
|
|
|
$aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex );
|
|
|
|
|
|
2012-10-18 15:42:36 +00:00
|
|
|
//if there are no user in the delegation row, this case is in selfservice
|
2017-03-07 16:59:04 -04:00
|
|
|
if ($aDelegation['USR_UID'] == "") {
|
2012-10-19 14:38:15 -04:00
|
|
|
$_SESSION['APPLICATION'] = $sAppUid;
|
|
|
|
|
$_SESSION['INDEX'] = $iDelIndex;
|
|
|
|
|
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
|
|
|
|
|
$_SESSION['TASK'] = - 1;
|
|
|
|
|
$_SESSION['STEP_POSITION'] = 0;
|
|
|
|
|
$_SESSION['CURRENT_TASK'] = $aFields['TAS_UID'];
|
|
|
|
|
|
2012-10-18 15:42:36 +00:00
|
|
|
//if the task is in the valid selfservice tasks for this user, then catch the case, else just view the resume
|
2018-09-07 12:01:42 -04:00
|
|
|
if ($caseInstance->isSelfService($_SESSION['USER_LOGGED'], $aFields['TAS_UID'], $sAppUid)) {
|
|
|
|
|
require_once(PATH_METHODS . 'cases' . PATH_SEP . 'cases_CatchSelfService.php');
|
2012-10-19 14:38:15 -04:00
|
|
|
} else {
|
2018-09-07 12:01:42 -04:00
|
|
|
require_once(PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
|
2012-10-19 14:38:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-07 16:59:04 -04:00
|
|
|
//If the current users is in the AppDelegation row, then open the case
|
2012-10-19 14:38:15 -04:00
|
|
|
if (($aDelegation['USR_UID'] == $_SESSION['USER_LOGGED']) && $_action != 'sent') {
|
|
|
|
|
$_SESSION['APPLICATION'] = $sAppUid;
|
|
|
|
|
$_SESSION['INDEX'] = $iDelIndex;
|
|
|
|
|
|
|
|
|
|
if (is_null( $aFields['DEL_INIT_DATE'] )) {
|
2018-09-07 12:01:42 -04:00
|
|
|
$caseInstance->setDelInitDate( $sAppUid, $iDelIndex );
|
|
|
|
|
$aFields = $caseInstance->loadCase( $sAppUid, $iDelIndex );
|
2012-10-19 14:38:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
|
|
|
|
|
$_SESSION['TASK'] = $aFields['TAS_UID'];
|
|
|
|
|
$_SESSION['STEP_POSITION'] = 0;
|
|
|
|
|
|
|
|
|
|
/* Redirect to next step */
|
|
|
|
|
unset( $_SESSION['bNoShowSteps'] );
|
2017-03-07 16:59:04 -04:00
|
|
|
|
2015-06-30 11:28:53 -04:00
|
|
|
/* Execute Before Triggers for first Task*/
|
2018-09-07 12:01:42 -04:00
|
|
|
$caseInstance->getExecuteTriggerProcess($sAppUid, 'OPEN');
|
2015-06-30 11:28:53 -04:00
|
|
|
/*end Execute Before Triggers for first Task*/
|
2017-03-07 16:59:04 -04:00
|
|
|
|
2018-09-07 12:01:42 -04:00
|
|
|
$aNextStep = $caseInstance->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
|
2012-10-19 14:38:15 -04:00
|
|
|
$sPage = $aNextStep['PAGE'];
|
|
|
|
|
G::header( 'location: ' . $sPage );
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$_SESSION['APPLICATION'] = $sAppUid;
|
2017-03-07 16:59:04 -04:00
|
|
|
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
|
|
|
|
|
$_SESSION['TASK'] = - 1;
|
|
|
|
|
$_SESSION['bNoShowSteps'] = 1;
|
|
|
|
|
$_SESSION['STEP_POSITION'] = 0;
|
|
|
|
|
|
|
|
|
|
//When the case have another user or current user doesn't have rights to this self-service,
|
|
|
|
|
//Just view the case Resume
|
|
|
|
|
if ($_action === 'search' || $_action === 'to_reassign') {
|
|
|
|
|
//We need to use the index sent with the corresponding record
|
2014-05-09 16:12:49 -04:00
|
|
|
$_SESSION['INDEX'] = $iDelIndex;
|
|
|
|
|
} else {
|
2017-03-07 16:59:04 -04:00
|
|
|
//Get DEL_INDEX
|
|
|
|
|
$criteria = new Criteria('workflow');
|
|
|
|
|
$criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
|
|
|
|
$criteria->add(AppDelegationPeer::APP_UID, $sAppUid);
|
|
|
|
|
$criteria->add(AppDelegationPeer::DEL_LAST_INDEX , 1);
|
|
|
|
|
$rs = AppDelegationPeer::doSelectRS($criteria);
|
|
|
|
|
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$rs->next();
|
|
|
|
|
$row = $rs->getRow();
|
2014-05-09 16:12:49 -04:00
|
|
|
$_SESSION['INDEX'] = $row['DEL_INDEX'];
|
|
|
|
|
}
|
2017-03-07 16:59:04 -04:00
|
|
|
|
2018-09-07 12:01:42 -04:00
|
|
|
$Fields = $caseInstance->loadCase($_SESSION['APPLICATION'], $_SESSION['INDEX'], $flagJump);
|
2017-03-07 16:59:04 -04:00
|
|
|
|
2012-10-19 14:38:15 -04:00
|
|
|
$_SESSION['CURRENT_TASK'] = $Fields['TAS_UID'];
|
|
|
|
|
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
|
2014-07-15 09:27:51 -04:00
|
|
|
|
2012-10-19 14:38:15 -04:00
|
|
|
}
|
|
|
|
|
break;
|
2017-03-07 16:59:04 -04:00
|
|
|
default: //APP_STATUS IS COMPLETED OR CANCELLED
|
2012-10-19 14:38:15 -04:00
|
|
|
$_SESSION['APPLICATION'] = $sAppUid;
|
2018-09-07 12:01:42 -04:00
|
|
|
$_SESSION['INDEX'] = $caseInstance->getCurrentDelegationCase( $_GET['APP_UID'] );
|
2012-10-19 14:38:15 -04:00
|
|
|
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
|
|
|
|
|
$_SESSION['TASK'] = - 1;
|
|
|
|
|
$_SESSION['STEP_POSITION'] = 0;
|
2018-09-07 12:01:42 -04:00
|
|
|
$Fields = $caseInstance->loadCase($_SESSION['APPLICATION'], $_SESSION['INDEX'], $flagJump);
|
2014-06-18 11:13:46 -04:00
|
|
|
$_SESSION['CURRENT_TASK'] = $Fields['TAS_UID'];
|
2012-10-19 14:38:15 -04:00
|
|
|
|
|
|
|
|
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$aMessage = array ();
|
|
|
|
|
$aMessage['MESSAGE'] = $e->getMessage();
|
|
|
|
|
$G_PUBLISH = new Publisher();
|
|
|
|
|
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
|
|
|
|
|
G::RenderPage( 'publishBlank', 'blank' );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 15:42:36 +00:00
|
|
|
|