2012-10-22 12:15:52 -04:00
|
|
|
<?php
|
2017-02-15 16:26:02 +00:00
|
|
|
|
2019-10-07 09:57:25 -04:00
|
|
|
/**
|
|
|
|
|
* casesStartPage_Ajax.php
|
|
|
|
|
*
|
|
|
|
|
* This page define some functions used in the start new case
|
|
|
|
|
*
|
|
|
|
|
* @link https://wiki.processmaker.com/3.1/Cases#New_Case
|
2020-10-26 22:14:48 +00:00
|
|
|
* @link https://wiki.processmaker.com/3.2/Web_Entry
|
2019-10-07 09:57:25 -04:00
|
|
|
*/
|
2017-08-01 12:16:06 -04:00
|
|
|
use ProcessMaker\Plugins\PluginRegistry;
|
|
|
|
|
|
2015-03-17 15:25:49 -04:00
|
|
|
$filter = new InputFilter();
|
|
|
|
|
$_POST = $filter->xssFilterHard($_POST);
|
|
|
|
|
$_REQUEST = $filter->xssFilterHard($_REQUEST);
|
2017-03-09 16:42:41 -04:00
|
|
|
|
2013-06-03 18:13:38 -04:00
|
|
|
if (!isset($_SESSION['USER_LOGGED'])) {
|
|
|
|
|
$res = new stdclass();
|
|
|
|
|
$res->message = G::LoadTranslation('ID_LOGIN_AGAIN');
|
|
|
|
|
$res->lostSession = true;
|
|
|
|
|
$res->success = true;
|
|
|
|
|
print G::json_encode( $res );
|
|
|
|
|
die();
|
|
|
|
|
}
|
2012-10-22 12:15:52 -04:00
|
|
|
if (! isset( $_REQUEST['action'] )) {
|
|
|
|
|
$res['success'] = 'failure';
|
2013-03-14 15:15:04 -04:00
|
|
|
$res['message'] = G::LoadTranslation( 'ID_REQUEST_ACTION' );
|
2012-10-22 12:15:52 -04:00
|
|
|
print G::json_encode( $res );
|
|
|
|
|
die();
|
|
|
|
|
}
|
2013-10-30 20:01:43 -04:00
|
|
|
if (! function_exists( $_REQUEST['action'] ) || !G::isUserFunction($_REQUEST['action'])) {
|
2012-10-22 12:15:52 -04:00
|
|
|
$res['success'] = 'failure';
|
2013-03-14 15:15:04 -04:00
|
|
|
$res['message'] = G::LoadTranslation( 'ID_REQUEST_ACTION_NOT_EXIST' );
|
2012-10-22 12:15:52 -04:00
|
|
|
print G::json_encode( $res );
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-24 17:55:41 +00:00
|
|
|
|
2012-10-22 12:15:52 -04:00
|
|
|
$functionName = $_REQUEST['action'];
|
|
|
|
|
$functionParams = isset( $_REQUEST['params'] ) ? $_REQUEST['params'] : array ();
|
|
|
|
|
|
|
|
|
|
$functionName( $functionParams );
|
|
|
|
|
|
|
|
|
|
function getProcessList ()
|
|
|
|
|
{
|
|
|
|
|
$calendar = new Calendar();
|
|
|
|
|
$oProcess = new Process();
|
|
|
|
|
$oCase = new Cases();
|
|
|
|
|
|
2012-10-18 16:05:43 +00:00
|
|
|
//Get ProcessStatistics Info
|
2012-10-22 12:15:52 -04:00
|
|
|
$start = 0;
|
|
|
|
|
$limit = '';
|
|
|
|
|
$proData = $oProcess->getAllProcesses( $start, $limit, null, null, false, true );
|
|
|
|
|
|
|
|
|
|
$bCanStart = $oCase->canStartCase( $_SESSION['USER_LOGGED'] );
|
|
|
|
|
if ($bCanStart) {
|
|
|
|
|
$processListInitial = $oCase->getStartCasesPerType( $_SESSION['USER_LOGGED'], 'category' );
|
|
|
|
|
$processList = array ();
|
|
|
|
|
foreach ($processListInitial as $key => $procInfo) {
|
|
|
|
|
if (isset( $procInfo['pro_uid'] )) {
|
|
|
|
|
if (trim( $procInfo['cat'] ) == "") {
|
|
|
|
|
$procInfo['cat'] = "_OTHER_";
|
|
|
|
|
}
|
|
|
|
|
$processList[$procInfo['catname']][$procInfo['value']] = $procInfo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ksort( $processList );
|
|
|
|
|
foreach ($processList as $key => $processInfo) {
|
|
|
|
|
ksort( $processList[$key] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! isset( $_REQUEST['node'] )) {
|
|
|
|
|
$node = 'root';
|
|
|
|
|
} else {
|
|
|
|
|
$node = $_REQUEST['node'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($proData as $key => $proInfo) {
|
|
|
|
|
$proData[$proInfo['PRO_UID']] = $proInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$processListTree = array ();
|
2017-05-19 16:16:16 -04:00
|
|
|
foreach ($processList as $key => $processInfo) {
|
|
|
|
|
$tempTree['text'] = $key;
|
|
|
|
|
$tempTree['id'] = G::encryptOld($key);
|
|
|
|
|
$tempTree['cls'] = 'folder';
|
|
|
|
|
$tempTree['draggable'] = true;
|
|
|
|
|
$tempTree['optionType'] = "category";
|
|
|
|
|
$tempTree['singleClickExpand'] = true;
|
|
|
|
|
if ($key != "No Category") {
|
|
|
|
|
$tempTree['expanded'] = true;
|
|
|
|
|
} else {
|
|
|
|
|
$tempTree['expanded'] = true;
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
2017-05-19 16:16:16 -04:00
|
|
|
$tempTreeChildren = array();
|
|
|
|
|
foreach ($processList[$key] as $keyChild => $processInfoChild) {
|
|
|
|
|
$tempTreeChild['text'] = $keyChild;
|
|
|
|
|
$tempTreeChild['id'] = G::encryptOld($keyChild);
|
|
|
|
|
$tempTreeChild['draggable'] = true;
|
|
|
|
|
$tempTreeChild['leaf'] = true;
|
|
|
|
|
$tempTreeChild['icon'] = '/images/icon.trigger.png';
|
|
|
|
|
$tempTreeChild['allowChildren'] = false;
|
|
|
|
|
$tempTreeChild['optionType'] = "startProcess";
|
|
|
|
|
$tempTreeChild['pro_uid'] = $processInfoChild['pro_uid'];
|
|
|
|
|
$tempTreeChild['tas_uid'] = $processInfoChild['uid'];
|
|
|
|
|
$processInfoChild['myInbox'] = 0;
|
|
|
|
|
$processInfoChild['totalInbox'] = 0;
|
|
|
|
|
if (isset($proData[$processInfoChild['pro_uid']])) {
|
|
|
|
|
$tempTreeChild['otherAttributes'] = array_merge($processInfoChild, $proData[$processInfoChild['pro_uid']], $calendar->getCalendarFor($_SESSION['USER_LOGGED'], $processInfoChild['pro_uid'], $processInfoChild['uid']));
|
|
|
|
|
$tempTreeChild['otherAttributes']['PRO_TAS_TITLE'] = str_replace(")", "", str_replace("(", "", trim(str_replace($tempTreeChild['otherAttributes']['PRO_TITLE'], "", $tempTreeChild['otherAttributes']["value"]))));
|
|
|
|
|
$tempTreeChild['qtip'] = $tempTreeChild['otherAttributes']['PRO_DESCRIPTION'];
|
|
|
|
|
$tempTreeChildren[] = $tempTreeChild;
|
|
|
|
|
}
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
2017-05-19 16:16:16 -04:00
|
|
|
$tempTree['children'] = $tempTreeChildren;
|
|
|
|
|
$processListTree[] = $tempTree;
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
2017-05-19 16:16:16 -04:00
|
|
|
|
2012-10-22 12:15:52 -04:00
|
|
|
$processList = $processListTree;
|
|
|
|
|
} else {
|
|
|
|
|
$processList['success'] = 'failure';
|
2013-03-14 15:15:04 -04:00
|
|
|
$processList['message'] = G::LoadTranslation('ID_USER_PROCESS_NOT_START');
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
|
|
|
|
print G::json_encode( $processList );
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ellipsis ($text, $numb)
|
|
|
|
|
{
|
|
|
|
|
$text = html_entity_decode( $text, ENT_QUOTES );
|
|
|
|
|
if (strlen( $text ) > $numb) {
|
|
|
|
|
$text = substr( $text, 0, $numb );
|
|
|
|
|
$text = substr( $text, 0, strrpos( $text, " " ) );
|
2012-10-18 16:05:43 +00:00
|
|
|
//This strips the full stop:
|
2012-10-22 12:15:52 -04:00
|
|
|
if ((substr( $text, - 1 )) == ".") {
|
|
|
|
|
$text = substr( $text, 0, (strrpos( $text, "." )) );
|
|
|
|
|
}
|
|
|
|
|
$etc = "...";
|
|
|
|
|
$text = $text . $etc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function lookinginforContentProcess ($sproUid)
|
|
|
|
|
{
|
|
|
|
|
$oContent = new Content();
|
2011-02-16 22:28:15 +00:00
|
|
|
///we are looking for a pro title for this process $sproUid
|
2012-10-22 12:15:52 -04:00
|
|
|
$oCriteria = new Criteria( 'workflow' );
|
2016-07-18 14:13:01 -04:00
|
|
|
$oCriteria->add( ProcessPeer::PRO_UID, $sproUid );
|
|
|
|
|
$oDataset = ProcessPeer::doSelectRS( $oCriteria );
|
2012-10-22 12:15:52 -04:00
|
|
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
$aRow = $oDataset->getRow();
|
|
|
|
|
if (! is_array( $aRow )) {
|
|
|
|
|
|
|
|
|
|
$oC = new Criteria( 'workflow' );
|
|
|
|
|
$oC->addSelectColumn( TaskPeer::TAS_UID );
|
2016-06-28 10:59:43 -04:00
|
|
|
$oC->addSelectColumn( TaskPeer::TAS_TITLE );
|
2012-10-22 12:15:52 -04:00
|
|
|
$oC->add( TaskPeer::PRO_UID, $sproUid );
|
|
|
|
|
$oDataset1 = TaskPeer::doSelectRS( $oC );
|
|
|
|
|
$oDataset1->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
|
|
|
|
|
while ($oDataset1->next()) {
|
|
|
|
|
$aRow1 = $oDataset1->getRow();
|
2016-06-28 10:59:43 -04:00
|
|
|
Content::insertContent( 'TAS_TITLE', '', $aRow1['TAS_UID'], 'en', $aRow1['TAS_TITLE'] );
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
|
|
|
|
$oC2 = new Criteria( 'workflow' );
|
2016-06-28 10:59:43 -04:00
|
|
|
$oC2->addSelectColumn(ProcessPeer::PRO_UID);
|
|
|
|
|
$oC2->addSelectColumn(ProcessPeer::PRO_TITLE);
|
|
|
|
|
$oC2->add( ProcessPeer::PRO_UID, $sproUid );
|
|
|
|
|
$oDataset3 = ProcessPeer::doSelectRS( $oC2 );
|
2012-10-22 12:15:52 -04:00
|
|
|
$oDataset3->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$oDataset3->next();
|
|
|
|
|
$aRow3 = $oDataset3->getRow();
|
|
|
|
|
|
2016-06-28 10:59:43 -04:00
|
|
|
Content::insertContent( 'PRO_TITLE', '', $aRow3['PRO_UID'], 'en', $aRow3['PRO_TITLE'] );
|
2012-10-22 12:15:52 -04:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-26 22:14:48 +00:00
|
|
|
/**
|
|
|
|
|
* Start a case and get the next step
|
|
|
|
|
*/
|
|
|
|
|
function startCase()
|
2012-10-22 12:15:52 -04:00
|
|
|
{
|
2015-03-17 15:25:49 -04:00
|
|
|
$filter = new InputFilter();
|
|
|
|
|
$_POST = $filter->xssFilterHard($_POST);
|
|
|
|
|
$_REQUEST = $filter->xssFilterHard($_REQUEST);
|
2012-10-22 12:15:52 -04:00
|
|
|
|
2020-10-26 22:14:48 +00:00
|
|
|
// Unset any variable, because we are starting a new case
|
|
|
|
|
if (isset($_SESSION['APPLICATION'])) {
|
|
|
|
|
unset($_SESSION['APPLICATION']);
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
2020-10-26 22:14:48 +00:00
|
|
|
if (isset($_SESSION['PROCESS'])) {
|
|
|
|
|
unset($_SESSION['PROCESS']);
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
2020-10-26 22:14:48 +00:00
|
|
|
if (isset($_SESSION['TASK'])) {
|
|
|
|
|
unset($_SESSION['TASK']);
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
2020-10-26 22:14:48 +00:00
|
|
|
if (isset($_SESSION['INDEX'])) {
|
|
|
|
|
unset($_SESSION['INDEX']);
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
2020-10-26 22:14:48 +00:00
|
|
|
if (isset($_SESSION['STEP_POSITION'])) {
|
|
|
|
|
unset($_SESSION['STEP_POSITION']);
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2020-10-26 22:14:48 +00:00
|
|
|
// Initializing variables
|
|
|
|
|
$sequenceType = (!empty($_REQUEST['actionFrom']) && $_REQUEST['actionFrom'] === 'webEntry') ? AppSequence::APP_TYPE_WEB_ENTRY : AppSequence::APP_TYPE_NORMAL;
|
|
|
|
|
// Update CONTENT table
|
|
|
|
|
lookinginforContentProcess($_POST['processId']);
|
2012-10-22 12:15:52 -04:00
|
|
|
|
2020-10-26 22:14:48 +00:00
|
|
|
// Create the new case
|
|
|
|
|
$casesInstance = new Cases();
|
|
|
|
|
$newCase = $casesInstance->startCase($_REQUEST['taskId'], $_SESSION['USER_LOGGED'], false, [], false, $sequenceType);
|
2012-10-22 12:15:52 -04:00
|
|
|
|
2020-10-26 22:14:48 +00:00
|
|
|
// Set session variables
|
|
|
|
|
$_SESSION['APPLICATION'] = $newCase['APPLICATION'];
|
|
|
|
|
$_SESSION['INDEX'] = $newCase['INDEX'];
|
|
|
|
|
$_SESSION['PROCESS'] = $newCase['PROCESS'];
|
2012-10-22 12:15:52 -04:00
|
|
|
$_SESSION['TASK'] = $_REQUEST['taskId'];
|
|
|
|
|
$_SESSION['STEP_POSITION'] = 0;
|
|
|
|
|
$_SESSION['CASES_REFRESH'] = true;
|
|
|
|
|
|
2020-10-26 22:14:48 +00:00
|
|
|
// Get the first step for the new case
|
|
|
|
|
$casesInstance = new Cases();
|
|
|
|
|
$nextStep = $casesInstance->getNextStep($_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'],
|
|
|
|
|
$_SESSION['STEP_POSITION']);
|
|
|
|
|
$nextStep['PAGE'] = 'open?APP_UID=' . $newCase['APPLICATION'] . '&DEL_INDEX=' . $newCase['INDEX'] . '&action=draft';
|
|
|
|
|
$_SESSION['BREAKSTEP']['NEXT_STEP'] = $nextStep;
|
2012-10-22 12:15:52 -04:00
|
|
|
|
2020-10-26 22:14:48 +00:00
|
|
|
// Complete required information
|
|
|
|
|
$newCase['openCase'] = $nextStep;
|
|
|
|
|
$newCase['status'] = 'success';
|
2012-10-22 12:15:52 -04:00
|
|
|
|
2020-10-26 22:14:48 +00:00
|
|
|
// Print JSON response
|
2025-04-24 17:55:41 +00:00
|
|
|
ob_end_clean();
|
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
print (json_encode($newCase));
|
2012-10-22 12:15:52 -04:00
|
|
|
} catch (Exception $e) {
|
2020-10-26 22:14:48 +00:00
|
|
|
$newCase['status'] = 'failure';
|
|
|
|
|
$newCase['message'] = $e->getMessage();
|
2025-04-24 17:55:41 +00:00
|
|
|
print_r(json_encode($newCase));
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getRegisteredDashboards ()
|
|
|
|
|
{
|
2017-08-01 12:16:06 -04:00
|
|
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
2012-10-22 12:15:52 -04:00
|
|
|
$dashBoardPages = $oPluginRegistry->getDashboardPages();
|
|
|
|
|
print_r( G::json_encode( $dashBoardPages ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getDefaultDashboard ()
|
|
|
|
|
{
|
|
|
|
|
$defaultDashboard['defaultTab'] = "mainDashboard";
|
|
|
|
|
if (isset( $_SESSION['__currentTabDashboard'] )) {
|
|
|
|
|
$defaultDashboard['defaultTab'] = $_SESSION['__currentTabDashboard'];
|
|
|
|
|
}
|
|
|
|
|
print_r( G::json_encode( $defaultDashboard ) );
|
|
|
|
|
}
|
|
|
|
|
|