2015-02-25 13:48:45 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace ProcessMaker\BusinessModel;
|
|
|
|
|
|
2017-08-23 17:26:00 -04:00
|
|
|
use ProcessMaker\BusinessModel\Lists;
|
2015-02-25 13:48:45 -04:00
|
|
|
use G;
|
|
|
|
|
use Criteria;
|
|
|
|
|
use UsersPeer;
|
2018-05-24 09:10:04 -04:00
|
|
|
use AppDelegation;
|
2015-02-25 13:48:45 -04:00
|
|
|
use AppDelegationPeer;
|
|
|
|
|
use AppDelayPeer;
|
2017-08-14 18:46:31 -04:00
|
|
|
use ProcessMaker\Core\System;
|
2016-06-07 12:20:43 -04:00
|
|
|
use ProcessMaker\Util\DateTime;
|
2017-08-11 16:24:12 -04:00
|
|
|
use PmLicenseManager;
|
2017-08-23 12:20:54 -04:00
|
|
|
use Bootstrap;
|
|
|
|
|
use ProcessPeer;
|
|
|
|
|
use BpmnProjectPeer;
|
|
|
|
|
use Propel;
|
|
|
|
|
use ResultSet;
|
|
|
|
|
use Process;
|
|
|
|
|
use Cases;
|
|
|
|
|
use ProcessMaker\BusinessModel\Task as BusinessModelTask;
|
2017-08-30 12:13:50 -04:00
|
|
|
use ProcessMaker\Services\Api\Project\Activity\Step as ActivityStep;
|
2017-08-23 12:20:54 -04:00
|
|
|
use Exception;
|
|
|
|
|
use AppCacheView;
|
|
|
|
|
use database;
|
|
|
|
|
use TaskPeer;
|
|
|
|
|
use StepPeer;
|
|
|
|
|
use GulliverBasePeer;
|
|
|
|
|
use AppDocument;
|
|
|
|
|
use Users;
|
|
|
|
|
use ProcessMaker\BusinessModel\User as BusinessModelUser;
|
|
|
|
|
use ProcessMaker\BusinessModel\Cases as BusinessModelCases;
|
|
|
|
|
use ProcessMaker\Core\RoutingScreen;
|
|
|
|
|
use Configurations;
|
|
|
|
|
use InputDocument;
|
|
|
|
|
use AppFolder;
|
|
|
|
|
use PMmemcached;
|
|
|
|
|
use RBAC;
|
2015-02-25 13:48:45 -04:00
|
|
|
|
|
|
|
|
class Light
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method get list start case
|
|
|
|
|
*
|
|
|
|
|
* @param $userId User id
|
|
|
|
|
* @return array
|
2017-08-23 12:20:54 -04:00
|
|
|
* @throws Exception
|
2015-02-25 13:48:45 -04:00
|
|
|
*/
|
|
|
|
|
public function getProcessListStartCase($userId)
|
|
|
|
|
{
|
|
|
|
|
$response = null;
|
|
|
|
|
try {
|
2016-02-05 11:44:58 -04:00
|
|
|
// getting bpmn projects
|
|
|
|
|
$c = new Criteria('workflow');
|
2017-08-23 12:20:54 -04:00
|
|
|
$c->addSelectColumn(BpmnProjectPeer::PRJ_UID);
|
|
|
|
|
$ds = ProcessPeer::doSelectRS($c, Propel::getDbConnection('workflow_ro'));
|
|
|
|
|
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2016-02-05 11:44:58 -04:00
|
|
|
$bpmnProjects = array();
|
|
|
|
|
|
|
|
|
|
while ($ds->next()) {
|
|
|
|
|
$row = $ds->getRow();
|
|
|
|
|
$bpmnProjects[] = $row['PRJ_UID'];
|
|
|
|
|
}
|
2016-05-19 16:13:56 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$oProcess = new Process();
|
|
|
|
|
$oCase = new Cases();
|
2015-02-25 13:48:45 -04:00
|
|
|
|
|
|
|
|
//Get ProcessStatistics Info
|
2017-08-23 12:20:54 -04:00
|
|
|
$start = 0;
|
|
|
|
|
$limit = '';
|
|
|
|
|
$proData = $oProcess->getAllProcesses($start, $limit, null, null, false, true);
|
2015-02-25 13:48:45 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$processListInitial = $oCase->getStartCasesPerType($userId, 'category');
|
2015-02-25 13:48:45 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$processList = array();
|
2015-02-25 13:48:45 -04:00
|
|
|
foreach ($processListInitial as $key => $procInfo) {
|
2017-08-23 12:20:54 -04:00
|
|
|
if (isset($procInfo['pro_uid'])) {
|
|
|
|
|
if (trim($procInfo['cat']) == "") {
|
2015-02-25 13:48:45 -04:00
|
|
|
$procInfo['cat'] = "_OTHER_";
|
|
|
|
|
}
|
|
|
|
|
$processList[$procInfo['catname']][$procInfo['value']] = $procInfo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
ksort($processList);
|
2015-02-25 13:48:45 -04:00
|
|
|
foreach ($processList as $key => $processInfo) {
|
2017-08-23 12:20:54 -04:00
|
|
|
ksort($processList[$key]);
|
2015-02-25 13:48:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($proData as $key => $proInfo) {
|
|
|
|
|
$proData[$proInfo['PRO_UID']] = $proInfo;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$task = new BusinessModelTask();
|
2015-02-25 13:48:45 -04:00
|
|
|
$task->setFormatFieldNameInUppercase(false);
|
|
|
|
|
$task->setArrayParamException(array("taskUid" => "act_uid", "stepUid" => "step_uid"));
|
2015-08-17 10:03:37 -04:00
|
|
|
|
2017-08-30 12:13:50 -04:00
|
|
|
$step = new ActivityStep();
|
2015-03-04 14:32:11 -04:00
|
|
|
$response = array();
|
2015-02-25 13:48:45 -04:00
|
|
|
foreach ($processList as $key => $processInfo) {
|
2017-08-23 12:20:54 -04:00
|
|
|
$tempTreeChildren = array();
|
2015-02-25 13:48:45 -04:00
|
|
|
foreach ($processList[$key] as $keyChild => $processInfoChild) {
|
2017-02-16 17:49:11 -04:00
|
|
|
if (in_array($processInfoChild['pro_uid'], $bpmnProjects)) {
|
2017-08-23 12:20:54 -04:00
|
|
|
$tempTreeChild['text'] = $keyChild; //ellipsis ( $keyChild, 50 );
|
2015-08-17 10:03:37 -04:00
|
|
|
$tempTreeChild['processId'] = $processInfoChild['pro_uid'];
|
2017-08-23 12:20:54 -04:00
|
|
|
$tempTreeChild['taskId'] = $processInfoChild['uid'];
|
|
|
|
|
list($tempTreeChild['offlineEnabled'], $tempTreeChild['autoRoot']) = $task->getColumnValues($processInfoChild['pro_uid'],
|
|
|
|
|
$processInfoChild['uid'], array('TAS_OFFLINE', 'TAS_AUTO_ROOT'));
|
2017-03-28 09:52:09 -04:00
|
|
|
//Add process category
|
|
|
|
|
$tempTreeChild['categoryName'] = $processInfoChild['catname'];
|
|
|
|
|
$tempTreeChild['categoryId'] = $processInfoChild['cat'];
|
2015-08-17 10:03:37 -04:00
|
|
|
$forms = $task->getSteps($processInfoChild['uid']);
|
|
|
|
|
$newForm = array();
|
|
|
|
|
$c = 0;
|
|
|
|
|
foreach ($forms as $k => $form) {
|
|
|
|
|
if ($form['step_type_obj'] == "DYNAFORM") {
|
2016-05-19 16:13:56 -04:00
|
|
|
$dynaForm = \DynaformPeer::retrieveByPK($form['step_uid_obj']);
|
|
|
|
|
|
2015-08-17 10:03:37 -04:00
|
|
|
$newForm[$c]['formId'] = $form['step_uid_obj'];
|
2016-06-07 12:20:43 -04:00
|
|
|
$newForm[$c]['formUpdateDate'] = DateTime::convertUtcToIso8601($dynaForm->getDynUpdateDate());
|
2017-08-23 12:20:54 -04:00
|
|
|
$newForm[$c]['index'] = $c + 1;
|
2015-08-17 10:03:37 -04:00
|
|
|
$newForm[$c]['title'] = $form['obj_title'];
|
|
|
|
|
$newForm[$c]['description'] = $form['obj_description'];
|
2017-08-23 12:20:54 -04:00
|
|
|
$newForm[$c]['stepId'] = $form["step_uid"];
|
|
|
|
|
$newForm[$c]['stepUidObj'] = $form["step_uid_obj"];
|
|
|
|
|
$newForm[$c]['stepMode'] = $form['step_mode'];
|
2016-10-20 13:15:28 -04:00
|
|
|
$newForm[$c]['stepCondition'] = $form['step_condition'];
|
2015-09-10 16:44:51 -04:00
|
|
|
$newForm[$c]['stepPosition'] = $form['step_position'];
|
2017-08-23 12:20:54 -04:00
|
|
|
$trigger = $this->statusTriggers($step->doGetActivityStepTriggers($form["step_uid"],
|
|
|
|
|
$tempTreeChild['taskId'], $tempTreeChild['processId']));
|
|
|
|
|
$newForm[$c]["triggers"] = $trigger;
|
2015-08-17 10:03:37 -04:00
|
|
|
$c++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$tempTreeChild['forms'] = $newForm;
|
2017-08-23 12:20:54 -04:00
|
|
|
if (isset($proData[$processInfoChild['pro_uid']])) {
|
2015-08-17 10:03:37 -04:00
|
|
|
$tempTreeChildren[] = $tempTreeChild;
|
2015-02-25 13:48:45 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-04 14:32:11 -04:00
|
|
|
$response = array_merge($response, $tempTreeChildren);
|
2015-02-25 13:48:45 -04:00
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
} catch (Exception $e) {
|
2015-02-25 13:48:45 -04:00
|
|
|
throw $e;
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-29 17:31:08 -04:00
|
|
|
/**
|
|
|
|
|
* Get status trigger case
|
|
|
|
|
* @param $triggers
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2015-04-29 17:18:43 -04:00
|
|
|
public function statusTriggers($triggers)
|
|
|
|
|
{
|
2017-08-23 12:20:54 -04:00
|
|
|
$return = array("before" => false, "after" => false);
|
|
|
|
|
foreach ($triggers as $trigger) {
|
|
|
|
|
if ($trigger['st_type'] == "BEFORE") {
|
|
|
|
|
$return["before"] = true;
|
2015-04-29 17:18:43 -04:00
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
if ($trigger['st_type'] == "AFTER") {
|
|
|
|
|
$return["after"] = true;
|
2015-04-29 17:18:43 -04:00
|
|
|
}
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-04-29 17:18:43 -04:00
|
|
|
return $return;
|
|
|
|
|
}
|
2015-06-24 17:30:08 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
/**
|
|
|
|
|
* Get counters each type of list
|
|
|
|
|
* @param $userId
|
|
|
|
|
* @return array
|
2017-08-23 12:20:54 -04:00
|
|
|
* @throws Exception
|
2015-02-25 13:48:45 -04:00
|
|
|
*/
|
|
|
|
|
public function getCounterCase($userId)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2017-08-23 12:20:54 -04:00
|
|
|
$userUid = (isset($userId) && $userId != '') ? $userId : null;
|
|
|
|
|
$oAppCache = new AppCacheView();
|
|
|
|
|
|
|
|
|
|
$aTypes = Array();
|
|
|
|
|
$aTypes['to_do'] = 'toDo';
|
|
|
|
|
$aTypes['draft'] = 'draft';
|
|
|
|
|
$aTypes['cancelled'] = 'cancelled';
|
|
|
|
|
$aTypes['sent'] = 'participated';
|
|
|
|
|
$aTypes['paused'] = 'paused';
|
|
|
|
|
$aTypes['completed'] = 'completed';
|
2015-02-25 13:48:45 -04:00
|
|
|
$aTypes['selfservice'] = 'unassigned';
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$aCount = $oAppCache->getAllCounters(array_keys($aTypes), $userUid);
|
2015-02-25 13:48:45 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$response = Array();
|
2015-02-25 13:48:45 -04:00
|
|
|
foreach ($aCount as $type => $count) {
|
|
|
|
|
$response[$aTypes[$type]] = $count;
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
} catch (Exception $e) {
|
2015-02-25 13:48:45 -04:00
|
|
|
throw $e;
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $sAppUid
|
|
|
|
|
* @return Criteria
|
|
|
|
|
*/
|
|
|
|
|
public function getTransferHistoryCriteria($sAppUid)
|
|
|
|
|
{
|
|
|
|
|
$c = new Criteria('workflow');
|
|
|
|
|
$c->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
|
|
|
|
$c->addSelectColumn(UsersPeer::USR_LASTNAME);
|
|
|
|
|
$c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
|
|
|
|
$c->addSelectColumn(AppDelegationPeer::PRO_UID);
|
|
|
|
|
$c->addSelectColumn(AppDelegationPeer::TAS_UID);
|
|
|
|
|
$c->addSelectColumn(AppDelegationPeer::APP_UID);
|
|
|
|
|
$c->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
|
|
|
|
///-- $c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)");
|
|
|
|
|
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
|
|
|
|
|
if (G::LoadSystemExist($sDataBase)) {
|
2017-02-15 16:26:02 +00:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$oDataBase = new database();
|
2015-02-25 13:48:45 -04:00
|
|
|
$c->addAsColumn('USR_NAME', $oDataBase->concatString("USR_LASTNAME", "' '", "USR_FIRSTNAME"));
|
|
|
|
|
$c->addAsColumn(
|
2017-08-23 12:20:54 -04:00
|
|
|
'DEL_FINISH_DATE',
|
|
|
|
|
$oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'-'", AppDelegationPeer::DEL_FINISH_DATE)
|
2015-02-25 13:48:45 -04:00
|
|
|
);
|
|
|
|
|
$c->addAsColumn(
|
|
|
|
|
'APP_TYPE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'IN_PROGRESS'", AppDelayPeer::APP_TYPE)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
|
|
|
|
|
$c->addSelectColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE);
|
|
|
|
|
$c->addSelectColumn(AppDelayPeer::APP_DISABLE_ACTION_DATE);
|
2017-08-23 12:20:54 -04:00
|
|
|
$c->addSelectColumn(TaskPeer::TAS_TITLE);
|
2015-02-25 13:48:45 -04:00
|
|
|
//APP_DELEGATION LEFT JOIN USERS
|
|
|
|
|
$c->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
|
|
|
|
|
|
|
|
|
|
$del = \DBAdapter::getStringDelimiter();
|
|
|
|
|
$app = array();
|
|
|
|
|
$app[] = array(AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX);
|
|
|
|
|
$app[] = array(AppDelegationPeer::APP_UID, AppDelayPeer::APP_UID);
|
|
|
|
|
$c->addJoinMC($app, Criteria::LEFT_JOIN);
|
|
|
|
|
|
2016-07-18 14:13:01 -04:00
|
|
|
//LEFT JOIN TASK TAS_TITLE
|
2017-08-23 12:20:54 -04:00
|
|
|
$c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
|
2015-02-25 13:48:45 -04:00
|
|
|
|
|
|
|
|
//WHERE
|
|
|
|
|
$c->add(AppDelegationPeer::APP_UID, $sAppUid);
|
|
|
|
|
|
|
|
|
|
//ORDER BY
|
|
|
|
|
$c->clearOrderByColumns();
|
|
|
|
|
$c->addAscendingOrderByColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
|
|
|
|
|
|
|
|
|
|
return $c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GET history of case
|
|
|
|
|
*
|
|
|
|
|
* @param $app_uid
|
|
|
|
|
* @return array
|
2017-08-23 12:20:54 -04:00
|
|
|
* @throws Exception
|
2015-02-25 13:48:45 -04:00
|
|
|
*/
|
|
|
|
|
public function getCasesListHistory($app_uid)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//global $G_PUBLISH;
|
2017-08-23 12:20:54 -04:00
|
|
|
$c = $this->getTransferHistoryCriteria($app_uid);
|
|
|
|
|
$aProcesses = Array();
|
2015-02-25 13:48:45 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$rs = GulliverBasePeer::doSelectRs($c);
|
|
|
|
|
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2015-02-25 13:48:45 -04:00
|
|
|
$rs->next();
|
2017-08-23 12:20:54 -04:00
|
|
|
for ($j = 0; $j < $rs->getRecordCount(); $j++) {
|
|
|
|
|
$result = $rs->getRow();
|
2015-02-25 13:48:45 -04:00
|
|
|
$result["ID_HISTORY"] = $result["PRO_UID"] . '_' . $result["APP_UID"] . '_' . $result["TAS_UID"];
|
2017-08-23 12:20:54 -04:00
|
|
|
$aProcesses[] = $result;
|
2015-02-25 13:48:45 -04:00
|
|
|
$rs->next();
|
|
|
|
|
$processUid = $result["PRO_UID"];
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$process = new Process();
|
2015-02-25 13:48:45 -04:00
|
|
|
|
|
|
|
|
$arrayProcessData = $process->load($processUid);
|
|
|
|
|
|
|
|
|
|
$result = array();
|
|
|
|
|
$result["processName"] = $arrayProcessData["PRO_TITLE"];
|
|
|
|
|
$result['flow'] = $aProcesses;
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* starting one case
|
|
|
|
|
*
|
|
|
|
|
* @param string $userId
|
|
|
|
|
* @param string $proUid
|
|
|
|
|
* @param string $taskUid
|
|
|
|
|
* @return array
|
2017-08-23 12:20:54 -04:00
|
|
|
* @throws Exception
|
2015-02-25 13:48:45 -04:00
|
|
|
*/
|
|
|
|
|
public function startCase($userId = '', $proUid = '', $taskUid = '')
|
|
|
|
|
{
|
|
|
|
|
try {
|
2017-08-23 12:20:54 -04:00
|
|
|
$oCase = new Cases();
|
2015-02-25 13:48:45 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$aData = $oCase->startCase($taskUid, $userId);
|
2015-02-25 13:48:45 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$user = new BusinessModelUser();
|
2016-06-01 13:56:45 -04:00
|
|
|
$arrayUserData = $user->getUserRecordByPk($userId, ['$userUid' => '$userId']);
|
|
|
|
|
|
2015-09-24 15:48:24 -04:00
|
|
|
$_SESSION['APPLICATION'] = $aData['APPLICATION'];
|
|
|
|
|
$_SESSION['INDEX'] = $aData['INDEX'];
|
|
|
|
|
$_SESSION['PROCESS'] = $aData['PROCESS'];
|
|
|
|
|
$_SESSION['TASK'] = $taskUid;
|
|
|
|
|
$_SESSION["USER_LOGGED"] = $userId;
|
2016-06-01 13:56:45 -04:00
|
|
|
$_SESSION['USR_USERNAME'] = $arrayUserData['USR_USERNAME'];
|
2015-09-24 15:48:24 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$aFields = $oCase->loadCase($aData['APPLICATION'], $aData['INDEX']);
|
|
|
|
|
$oCase->updateCase($aData['APPLICATION'], $aFields);
|
2015-09-24 15:48:24 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
$response = array();
|
|
|
|
|
$response['caseId'] = $aData['APPLICATION'];
|
|
|
|
|
$response['caseIndex'] = $aData['INDEX'];
|
|
|
|
|
$response['caseNumber'] = $aData['CASE_NUMBER'];
|
|
|
|
|
|
2016-08-03 10:55:44 -04:00
|
|
|
//Log
|
2017-08-23 12:20:54 -04:00
|
|
|
Bootstrap::registerMonolog('MobileCreateCase', 200, "Create case",
|
2017-10-10 12:33:25 -04:00
|
|
|
['application_uid' => $aData['APPLICATION'], 'usr_uid' => $userId], config("system.workspace"), 'processmaker.log');
|
2015-02-25 13:48:45 -04:00
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$response['status'] = 'failure';
|
|
|
|
|
$response['message'] = $e->getMessage();
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
public function lookinginforContentProcess($sproUid)
|
2015-02-25 13:48:45 -04:00
|
|
|
{
|
|
|
|
|
$oContent = new \Content();
|
|
|
|
|
///we are looking for a pro title for this process $sproUid
|
2017-08-23 12:20:54 -04:00
|
|
|
$oCriteria = new Criteria('workflow');
|
|
|
|
|
$oCriteria->add(ProcessPeer::PRO_UID, $sproUid);
|
|
|
|
|
$oDataset = ProcessPeer::doSelectRS($oCriteria);
|
|
|
|
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2015-02-25 13:48:45 -04:00
|
|
|
$oDataset->next();
|
|
|
|
|
$aRow = $oDataset->getRow();
|
2016-06-28 10:59:43 -04:00
|
|
|
if (!is_array($aRow)) {
|
2017-08-23 12:20:54 -04:00
|
|
|
$oC = new Criteria('workflow');
|
|
|
|
|
$oC->addSelectColumn(TaskPeer::TAS_UID);
|
|
|
|
|
$oC->addSelectColumn(TaskPeer::TAS_TITLE);
|
|
|
|
|
$oC->add(TaskPeer::PRO_UID, $sproUid);
|
|
|
|
|
$oDataset1 = TaskPeer::doSelectRS($oC);
|
|
|
|
|
$oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2015-02-25 13:48:45 -04:00
|
|
|
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']);
|
2015-02-25 13:48:45 -04:00
|
|
|
}
|
2016-06-28 10:59:43 -04:00
|
|
|
$oC2 = new Criteria('workflow');
|
2017-08-23 12:20:54 -04:00
|
|
|
$oC2->addSelectColumn(ProcessPeer::PRO_UID);
|
|
|
|
|
$oC2->addSelectColumn(ProcessPeer::PRO_TITLE);
|
|
|
|
|
$oC2->add(ProcessPeer::PRO_UID, $sproUid);
|
|
|
|
|
$oDataset3 = ProcessPeer::doSelectRS($oC2);
|
|
|
|
|
$oDataset3->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2015-02-25 13:48:45 -04:00
|
|
|
$oDataset3->next();
|
|
|
|
|
$aRow3 = $oDataset3->getRow();
|
2016-06-28 10:59:43 -04:00
|
|
|
\Content::insertContent('PRO_TITLE', '', $aRow3['PRO_UID'], 'en', $aRow3['PRO_TITLE']);
|
2015-02-25 13:48:45 -04:00
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-10 16:44:51 -04:00
|
|
|
/**
|
|
|
|
|
* Execute Trigger case
|
|
|
|
|
*
|
|
|
|
|
*/
|
2016-08-19 16:21:57 -04:00
|
|
|
public function doExecuteTriggerCase($usr_uid, $prj_uid, $act_uid, $cas_uid, $step_uid, $type, $del_index = null)
|
2015-09-10 16:44:51 -04:00
|
|
|
{
|
|
|
|
|
$userData = $this->getUserData($usr_uid);
|
2017-08-23 12:20:54 -04:00
|
|
|
$c = new Criteria();
|
2015-09-10 16:44:51 -04:00
|
|
|
$c->clearSelectColumns();
|
2017-08-23 12:20:54 -04:00
|
|
|
$c->addSelectColumn(StepPeer::STEP_UID);
|
|
|
|
|
$c->addSelectColumn(StepPeer::STEP_UID_OBJ);
|
|
|
|
|
$c->add(StepPeer::TAS_UID, $act_uid);
|
|
|
|
|
$c->add(StepPeer::STEP_TYPE_OBJ, 'DYNAFORM');
|
|
|
|
|
$c->add(StepPeer::STEP_UID, $step_uid);
|
|
|
|
|
$rs = StepPeer::doSelectRS($c);
|
|
|
|
|
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2015-09-10 16:44:51 -04:00
|
|
|
$rs->next();
|
|
|
|
|
$row = $rs->getRow();
|
|
|
|
|
$step_uid_obj = $row['STEP_UID_OBJ'];
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$oCase = new Cases();
|
|
|
|
|
$Fields = $oCase->loadCase($cas_uid);
|
2015-09-10 16:44:51 -04:00
|
|
|
$_SESSION["APPLICATION"] = $cas_uid;
|
|
|
|
|
$_SESSION["PROCESS"] = $prj_uid;
|
|
|
|
|
$_SESSION["TASK"] = $act_uid;
|
|
|
|
|
$_SESSION["USER_LOGGED"] = $usr_uid;
|
2018-01-04 14:36:02 -04:00
|
|
|
$_SESSION["USR_USERNAME"] = $userData['userName'];
|
2016-08-19 16:21:57 -04:00
|
|
|
$_SESSION["INDEX"] = $Fields["DEL_INDEX"] = $del_index !== null ? $del_index : \AppDelegation::getCurrentIndex($cas_uid);
|
2017-08-23 12:20:54 -04:00
|
|
|
$Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants());
|
|
|
|
|
$triggers = $oCase->loadTriggers($act_uid, 'DYNAFORM', $step_uid_obj, strtoupper($type));
|
|
|
|
|
if ($triggers) {
|
|
|
|
|
$Fields['APP_DATA'] = $oCase->ExecuteTriggers($act_uid, 'DYNAFORM', $step_uid_obj, strtoupper($type),
|
|
|
|
|
$Fields['APP_DATA']);
|
2015-09-10 16:44:51 -04:00
|
|
|
}
|
|
|
|
|
$Fields['TAS_UID'] = $act_uid;
|
|
|
|
|
$Fields['CURRENT_DYNAFORM'] = $step_uid_obj;
|
|
|
|
|
$Fields['USER_UID'] = $usr_uid;
|
|
|
|
|
$Fields['PRO_UID'] = $prj_uid;
|
2017-08-23 12:20:54 -04:00
|
|
|
$oCase->updateCase($cas_uid, $Fields);
|
2015-09-10 16:44:51 -04:00
|
|
|
$response = array('status' => 'ok');
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-09-10 16:44:51 -04:00
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-24 17:30:08 -04:00
|
|
|
/**
|
|
|
|
|
* Return Informaction User for derivate
|
|
|
|
|
* assignment Users
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with Task Case
|
|
|
|
|
*/
|
2016-08-13 11:35:24 -04:00
|
|
|
public function getPrepareInformation($usr_uid, $tas_uid, $app_uid, $del_index = null)
|
2015-06-24 17:30:08 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2017-08-23 12:20:54 -04:00
|
|
|
$oCase = new Cases();
|
|
|
|
|
$Fields = $oCase->loadCase($app_uid);
|
|
|
|
|
$_SESSION["APPLICATION"] = $app_uid;
|
|
|
|
|
$_SESSION["PROCESS"] = $Fields['PRO_UID'];
|
|
|
|
|
$_SESSION["TASK"] = $tas_uid;
|
|
|
|
|
$_SESSION["INDEX"] = $del_index;
|
|
|
|
|
$_SESSION["USER_LOGGED"] = $usr_uid;
|
|
|
|
|
$_SESSION["USR_USERNAME"] = isset($Fields['APP_DATA']['USR_USERNAME']) ? $Fields['APP_DATA']['USR_USERNAME'] : '';
|
|
|
|
|
|
|
|
|
|
$triggers = $oCase->loadTriggers($tas_uid, 'ASSIGN_TASK', '-1', 'BEFORE');
|
|
|
|
|
if (isset($triggers)) {
|
|
|
|
|
$Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants());
|
|
|
|
|
$Fields['APP_DATA'] = $oCase->ExecuteTriggers($tas_uid, 'DYNAFORM', '-1', 'BEFORE',
|
|
|
|
|
$Fields['APP_DATA']);
|
|
|
|
|
$oCase->updateCase($app_uid, $Fields);
|
2015-08-03 20:54:10 -04:00
|
|
|
}
|
2015-06-24 17:30:08 -04:00
|
|
|
$oDerivation = new \Derivation();
|
|
|
|
|
$aData = array();
|
|
|
|
|
$aData['APP_UID'] = $app_uid;
|
|
|
|
|
$aData['DEL_INDEX'] = $del_index;
|
|
|
|
|
$aData['USER_UID'] = $usr_uid;
|
2017-08-23 12:20:54 -04:00
|
|
|
$oRoute = new RoutingScreen();
|
2016-08-13 11:35:24 -04:00
|
|
|
$derive = $oRoute->prepareRoutingScreen($aData);
|
2015-06-24 17:30:08 -04:00
|
|
|
$response = array();
|
|
|
|
|
foreach ($derive as $sKey => &$aValues) {
|
|
|
|
|
$sPriority = ''; //set priority value
|
|
|
|
|
if ($derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] != '') {
|
|
|
|
|
//TO DO: review this type of assignment
|
2017-08-23 12:20:54 -04:00
|
|
|
if (isset($aData['APP_DATA'][str_replace('@@', '',
|
|
|
|
|
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])])) {
|
|
|
|
|
$sPriority = $aData['APP_DATA'][str_replace('@@', '',
|
|
|
|
|
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])];
|
2015-06-24 17:30:08 -04:00
|
|
|
}
|
|
|
|
|
} //set priority value
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$taskType = (isset($aValues["NEXT_TASK"]["TAS_TYPE"])) ? $aValues["NEXT_TASK"]["TAS_TYPE"] : false;
|
2015-09-09 15:18:46 -04:00
|
|
|
$taskMessage = "";
|
|
|
|
|
switch ($taskType) {
|
|
|
|
|
case "SCRIPT-TASK":
|
|
|
|
|
$taskMessage = G::LoadTranslation("ID_ROUTE_TO_TASK_SCRIPT_TASK");
|
|
|
|
|
break;
|
|
|
|
|
case "INTERMEDIATE-CATCH-TIMER-EVENT":
|
|
|
|
|
$taskMessage = G::LoadTranslation("ID_ROUTE_TO_TASK_INTERMEDIATE_CATCH_TIMER_EVENT");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-24 17:30:08 -04:00
|
|
|
switch ($aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']) {
|
|
|
|
|
case 'EVALUATE':
|
|
|
|
|
case 'REPORT_TO':
|
|
|
|
|
case 'BALANCED':
|
|
|
|
|
case 'SELF_SERVICE':
|
2015-07-20 09:51:48 -04:00
|
|
|
$taskAss = array();
|
2015-06-29 14:44:04 -04:00
|
|
|
$taskAss['taskId'] = $aValues['NEXT_TASK']['TAS_UID'];
|
|
|
|
|
$taskAss['taskName'] = $aValues['NEXT_TASK']['TAS_TITLE'];
|
2015-06-24 17:30:08 -04:00
|
|
|
$taskAss['taskAssignType'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'];
|
|
|
|
|
$taskAss['taskDefProcCode'] = $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE'];
|
2017-08-23 12:20:54 -04:00
|
|
|
$taskAss['delPriority'] = isset($aValues['NEXT_TASK']['DEL_PRIORITY']) ? $aValues['NEXT_TASK']['DEL_PRIORITY'] : "";
|
2015-06-24 17:30:08 -04:00
|
|
|
$taskAss['taskParent'] = $aValues['NEXT_TASK']['TAS_PARENT'];
|
2017-08-23 12:20:54 -04:00
|
|
|
$taskAss['taskMessage'] = $taskType ? $taskMessage : "";
|
2016-08-05 17:38:31 -04:00
|
|
|
$taskAss['sourceUid'] = $aValues['SOURCE_UID'];
|
2015-06-24 17:30:08 -04:00
|
|
|
$users = array();
|
|
|
|
|
$users['userId'] = $derive[$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_UID'];
|
2015-07-30 12:00:46 -04:00
|
|
|
$users['userFullName'] = strip_tags($derive[$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_FULLNAME']);
|
2017-08-23 12:20:54 -04:00
|
|
|
$taskAss['users'][] = $users;
|
2015-06-24 17:30:08 -04:00
|
|
|
$response[] = $taskAss;
|
|
|
|
|
break;
|
|
|
|
|
case 'MANUAL':
|
2015-11-06 12:28:00 -04:00
|
|
|
case "MULTIPLE_INSTANCE":
|
|
|
|
|
case "MULTIPLE_INSTANCE_VALUE_BASED":
|
2015-07-20 09:51:48 -04:00
|
|
|
$manual = array();
|
2015-06-24 17:30:08 -04:00
|
|
|
$manual['taskId'] = $aValues['NEXT_TASK']['TAS_UID'];
|
2015-06-29 14:44:04 -04:00
|
|
|
$manual['taskName'] = $aValues['NEXT_TASK']['TAS_TITLE'];
|
2015-06-24 17:30:08 -04:00
|
|
|
$manual['taskAssignType'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE'];
|
|
|
|
|
$manual['taskDefProcCode'] = $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE'];
|
2017-08-23 12:20:54 -04:00
|
|
|
$manual['delPriority'] = isset($aValues['NEXT_TASK']['DEL_PRIORITY']) ? $aValues['NEXT_TASK']['DEL_PRIORITY'] : "";
|
2015-06-24 17:30:08 -04:00
|
|
|
$manual['taskParent'] = $aValues['NEXT_TASK']['TAS_PARENT'];
|
2017-08-23 12:20:54 -04:00
|
|
|
$manual['taskMessage'] = $taskType ? $taskMessage : "";
|
2016-08-05 17:38:31 -04:00
|
|
|
$manual['sourceUid'] = $aValues['SOURCE_UID'];
|
2017-08-23 12:20:54 -04:00
|
|
|
$Aux = array();
|
2015-06-24 17:30:08 -04:00
|
|
|
foreach ($aValues['NEXT_TASK']['USER_ASSIGNED'] as $aUser) {
|
|
|
|
|
$Aux[$aUser['USR_UID']] = $aUser['USR_FULLNAME'];
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
asort($Aux);
|
2015-06-24 17:30:08 -04:00
|
|
|
$users = array();
|
|
|
|
|
foreach ($Aux as $id => $fullname) {
|
|
|
|
|
$user['userId'] = $id;
|
|
|
|
|
$user['userFullName'] = $fullname;
|
|
|
|
|
$users[] = $user;
|
|
|
|
|
}
|
|
|
|
|
$manual['users'] = $users;
|
|
|
|
|
$response[] = $manual;
|
|
|
|
|
break;
|
|
|
|
|
case '': //when this task is the Finish process
|
|
|
|
|
case 'nobody':
|
2017-08-23 12:20:54 -04:00
|
|
|
$userFields = $oDerivation->getUsersFullNameFromArray($derive[$sKey]['USER_UID']);
|
2015-12-04 16:22:49 -04:00
|
|
|
$taskAss = array();
|
2015-06-24 17:30:08 -04:00
|
|
|
$taskAss['routeFinishFlag'] = true;
|
|
|
|
|
$user['userId'] = $derive[$sKey]['USER_UID'];
|
|
|
|
|
$user['userFullName'] = $userFields['USR_FULLNAME'];
|
2017-08-23 12:20:54 -04:00
|
|
|
$taskAss['users'][] = $user;
|
2015-06-24 17:30:08 -04:00
|
|
|
$response[] = $taskAss;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
if (empty($response)) {
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_RULE"));
|
2015-06-24 17:30:08 -04:00
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
} catch (Exception $e) {
|
2015-06-24 17:30:08 -04:00
|
|
|
throw $e;
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-06-24 17:30:08 -04:00
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
/**
|
|
|
|
|
* Route Case
|
|
|
|
|
*
|
|
|
|
|
* @param string $applicationUid Unique id of Case
|
|
|
|
|
* @param string $userUid Unique id of User
|
|
|
|
|
* @param string $delIndex
|
2017-12-21 14:23:51 -04:00
|
|
|
* @param string $tasks
|
|
|
|
|
* @param boolean $executeTriggersBeforeAssignment
|
2015-02-25 13:48:45 -04:00
|
|
|
*
|
|
|
|
|
* return array Return an array with Task Case
|
|
|
|
|
*/
|
2017-12-21 14:23:51 -04:00
|
|
|
public function updateRouteCase($applicationUid, $userUid, $delIndex, $tasks, $executeTriggersBeforeAssignment)
|
2015-02-25 13:48:45 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
if (!$delIndex) {
|
|
|
|
|
$delIndex = \AppDelegation::getCurrentIndex($applicationUid);
|
|
|
|
|
}
|
2017-02-14 21:24:08 +00:00
|
|
|
|
2017-08-11 14:10:44 -04:00
|
|
|
$ws = new \WsBase();
|
2017-12-21 14:23:51 -04:00
|
|
|
|
|
|
|
|
$fields = $ws->derivateCase(
|
|
|
|
|
$userUid,
|
|
|
|
|
$applicationUid,
|
|
|
|
|
$delIndex,
|
|
|
|
|
$executeTriggersBeforeAssignment,
|
|
|
|
|
$tasks
|
|
|
|
|
);
|
|
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
$array = json_decode(json_encode($fields), true);
|
2015-09-07 18:13:08 -04:00
|
|
|
$array['message'] = trim(strip_tags($array['message']));
|
2015-02-25 13:48:45 -04:00
|
|
|
if ($array ["status_code"] != 0) {
|
2017-08-23 12:20:54 -04:00
|
|
|
throw (new Exception($array ["message"]));
|
2015-02-25 13:48:45 -04:00
|
|
|
} else {
|
|
|
|
|
unset($array['status_code']);
|
|
|
|
|
unset($array['message']);
|
|
|
|
|
unset($array['timestamp']);
|
|
|
|
|
}
|
2016-08-03 10:55:44 -04:00
|
|
|
|
|
|
|
|
//Log
|
2017-08-23 12:20:54 -04:00
|
|
|
Bootstrap::registerMonolog('MobileRouteCase', 200, 'Route case',
|
2017-10-10 12:33:25 -04:00
|
|
|
['application_uid' => $applicationUid, 'usr_uid' => $userUid], config("system.workspace"), 'processmaker.log');
|
2017-08-23 12:20:54 -04:00
|
|
|
} catch (Exception $e) {
|
2015-02-25 13:48:45 -04:00
|
|
|
throw $e;
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
return $fields;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get user Data
|
|
|
|
|
*
|
|
|
|
|
* @param string $applicationUid Unique id of Case
|
|
|
|
|
* @param string $userUid Unique id of User
|
|
|
|
|
* @param string $delIndex
|
|
|
|
|
* @param string $bExecuteTriggersBeforeAssignment
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with Task Case
|
|
|
|
|
*/
|
|
|
|
|
public function getUserData($userUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$direction = PATH_IMAGES_ENVIRONMENT_USERS . $userUid . ".gif";
|
2017-08-23 12:20:54 -04:00
|
|
|
if (!file_exists($direction)) {
|
2015-02-25 13:48:45 -04:00
|
|
|
$direction = PATH_HOME . 'public_html/images/user.gif';
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
$gestor = fopen($direction, "r");
|
2015-02-25 13:48:45 -04:00
|
|
|
$contenido = fread($gestor, filesize($direction));
|
|
|
|
|
fclose($gestor);
|
2017-05-10 15:05:21 -04:00
|
|
|
$oUser = new \Users();
|
2015-02-25 13:48:45 -04:00
|
|
|
$aUserLog = $oUser->loadDetailed($userUid);
|
2017-08-23 12:20:54 -04:00
|
|
|
$response['userId'] = $aUserLog['USR_UID'];
|
|
|
|
|
$response['userName'] = $aUserLog['USR_USERNAME'];
|
|
|
|
|
$response['firstName'] = $aUserLog['USR_FIRSTNAME'];
|
|
|
|
|
$response['lastName'] = $aUserLog['USR_LASTNAME'];
|
|
|
|
|
$response['fullName'] = $aUserLog['USR_FULLNAME'];
|
|
|
|
|
$response['email'] = $aUserLog['USR_EMAIL'];
|
|
|
|
|
$response['userRole'] = $aUserLog['USR_ROLE_NAME'];
|
|
|
|
|
$response['userPhone'] = $aUserLog['USR_PHONE'];
|
2015-02-25 13:48:45 -04:00
|
|
|
$response['updateDate'] = $aUserLog['USR_UPDATE_DATE'];
|
2017-08-23 12:20:54 -04:00
|
|
|
$response['userPhoto'] = base64_encode($contenido);
|
|
|
|
|
} catch (Exception $e) {
|
2015-02-25 13:48:45 -04:00
|
|
|
throw $e;
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Download files and resize dimensions in file type image
|
|
|
|
|
* if not type image return content file
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with Task Case
|
|
|
|
|
*/
|
|
|
|
|
public function downloadFile($app_uid, $request_data)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2017-08-23 12:20:54 -04:00
|
|
|
$oAppDocument = new AppDocument();
|
2015-02-25 13:48:45 -04:00
|
|
|
$arrayFiles = array();
|
|
|
|
|
foreach ($request_data as $key => $fileData) {
|
2017-08-23 12:20:54 -04:00
|
|
|
if (!isset($fileData['version'])) {
|
2015-02-25 13:48:45 -04:00
|
|
|
//Load last version of the document
|
2017-08-23 12:20:54 -04:00
|
|
|
$docVersion = $oAppDocument->getLastAppDocVersion($fileData['fileId']);
|
2015-02-25 13:48:45 -04:00
|
|
|
} else {
|
|
|
|
|
$docVersion = $fileData['version'];
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
$oAppDocument->Fields = $oAppDocument->load($fileData['fileId'], $docVersion);
|
2015-02-25 13:48:45 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$sAppDocUid = $oAppDocument->getAppDocUid();
|
2015-02-25 13:48:45 -04:00
|
|
|
$iDocVersion = $oAppDocument->getDocVersion();
|
2017-08-23 12:20:54 -04:00
|
|
|
$info = pathinfo($oAppDocument->getAppDocFilename());
|
|
|
|
|
$ext = (isset($info['extension']) ? $info['extension'] : '');//BUG fix: must handle files without any extension
|
2015-02-25 13:48:45 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
//$app_uid = G::getPathFromUID($oAppDocument->Fields['APP_UID']);
|
|
|
|
|
$file = G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
|
2015-02-25 13:48:45 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$realPath = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext;
|
2015-03-17 16:07:31 -04:00
|
|
|
$realPath1 = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '.' . $ext;
|
2015-02-25 13:48:45 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$width = isset($fileData['width']) ? $fileData['width'] : null;
|
|
|
|
|
$height = isset($fileData['height']) ? $fileData['height'] : null;
|
|
|
|
|
if (file_exists($realPath)) {
|
|
|
|
|
switch ($ext) {
|
2015-02-25 13:48:45 -04:00
|
|
|
case 'jpg':
|
|
|
|
|
case 'jpeg':
|
|
|
|
|
case 'gif':
|
|
|
|
|
case 'png':
|
2017-08-23 12:20:54 -04:00
|
|
|
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
|
|
|
|
|
$arrayFiles[$key]['fileContent'] = base64_encode($this->imagesThumbnails($realPath, $ext,
|
|
|
|
|
$width, $height));
|
2015-02-25 13:48:45 -04:00
|
|
|
break;
|
|
|
|
|
default:
|
2017-08-23 12:20:54 -04:00
|
|
|
$fileTmp = fopen($realPath, "r");
|
2015-02-25 13:48:45 -04:00
|
|
|
$content = fread($fileTmp, filesize($realPath));
|
2017-08-23 12:20:54 -04:00
|
|
|
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
|
2015-02-25 13:48:45 -04:00
|
|
|
$arrayFiles[$key]['fileContent'] = base64_encode($content);
|
|
|
|
|
fclose($fileTmp);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
} elseif (file_exists($realPath1)) {
|
|
|
|
|
switch ($ext) {
|
2015-02-25 13:48:45 -04:00
|
|
|
case 'jpg':
|
|
|
|
|
case 'jpeg':
|
|
|
|
|
case 'gif':
|
|
|
|
|
case 'png':
|
2017-08-23 12:20:54 -04:00
|
|
|
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
|
|
|
|
|
$arrayFiles[$key]['fileContent'] = $this->imagesThumbnails($realPath1, $ext, $width,
|
|
|
|
|
$height);
|
2015-02-25 13:48:45 -04:00
|
|
|
break;
|
|
|
|
|
default:
|
2017-08-23 12:20:54 -04:00
|
|
|
$fileTmp = fopen($realPath, "r");
|
2015-02-25 13:48:45 -04:00
|
|
|
$content = fread($fileTmp, filesize($realPath));
|
2017-08-23 12:20:54 -04:00
|
|
|
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
|
2015-02-25 13:48:45 -04:00
|
|
|
$arrayFiles[$key]['fileContent'] = base64_encode($content);
|
|
|
|
|
fclose($fileTmp);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
} catch (Exception $e) {
|
2015-02-25 13:48:45 -04:00
|
|
|
throw $e;
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
return $arrayFiles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* resize image if send width or height
|
|
|
|
|
*
|
|
|
|
|
* @param $path
|
|
|
|
|
* @param $extensions
|
|
|
|
|
* @param null $newWidth
|
|
|
|
|
* @param null $newHeight
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function imagesThumbnails($path, $extensions, $newWidth = null, $newHeight = null)
|
|
|
|
|
{
|
2017-08-23 12:20:54 -04:00
|
|
|
switch ($extensions) {
|
2015-02-25 13:48:45 -04:00
|
|
|
case 'jpg':
|
|
|
|
|
case 'jpeg':
|
2016-04-20 17:24:48 -04:00
|
|
|
ini_set('gd.jpeg_ignore_warning', 1);
|
|
|
|
|
error_reporting(0);
|
|
|
|
|
$imgTmp = @imagecreatefromjpeg($path);
|
2015-02-25 13:48:45 -04:00
|
|
|
break;
|
|
|
|
|
case 'gif':
|
|
|
|
|
$imgTmp = imagecreatefromgif($path);
|
|
|
|
|
break;
|
|
|
|
|
case 'png':
|
|
|
|
|
$imgTmp = imagecreatefrompng($path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$width = imagesx($imgTmp);
|
2015-02-25 13:48:45 -04:00
|
|
|
$height = imagesy($imgTmp);
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$ratio = $width / $height;
|
2015-02-25 13:48:45 -04:00
|
|
|
|
|
|
|
|
$isThumbnails = false;
|
|
|
|
|
if (isset($newWidth) && !isset($newHeight)) {
|
2017-08-23 12:20:54 -04:00
|
|
|
$newwidth = $newWidth;
|
2015-02-25 13:48:45 -04:00
|
|
|
$newheight = round($newwidth / $ratio);
|
|
|
|
|
$isThumbnails = true;
|
|
|
|
|
} elseif (!isset($newWidth) && isset($newHeight)) {
|
|
|
|
|
$newheight = $newHeight;
|
2017-08-23 12:20:54 -04:00
|
|
|
$newwidth = round($newheight / $ratio);
|
2015-02-25 13:48:45 -04:00
|
|
|
$isThumbnails = true;
|
|
|
|
|
} elseif (isset($newWidth) && isset($newHeight)) {
|
2017-08-23 12:20:54 -04:00
|
|
|
$newwidth = $newWidth;
|
2015-02-25 13:48:45 -04:00
|
|
|
$newheight = $newHeight;
|
|
|
|
|
$isThumbnails = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$thumb = $imgTmp;
|
|
|
|
|
if ($isThumbnails) {
|
|
|
|
|
$thumb = imagecreatetruecolor($newwidth, $newheight);
|
|
|
|
|
imagecopyresampled($thumb, $imgTmp, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
|
|
|
|
|
}
|
|
|
|
|
ob_start();
|
2017-08-23 12:20:54 -04:00
|
|
|
switch ($extensions) {
|
2015-02-25 13:48:45 -04:00
|
|
|
case 'jpg':
|
|
|
|
|
case 'jpeg':
|
|
|
|
|
imagejpeg($thumb);
|
|
|
|
|
break;
|
|
|
|
|
case 'gif':
|
|
|
|
|
imagegif($thumb);
|
|
|
|
|
break;
|
|
|
|
|
case 'png':
|
|
|
|
|
imagepng($thumb);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$image = ob_get_clean();
|
|
|
|
|
imagedestroy($thumb);
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
return $image;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function logout($oauthAccessTokenId, $refresh)
|
|
|
|
|
{
|
|
|
|
|
$aFields = array();
|
|
|
|
|
|
|
|
|
|
if (!isset($_GET['u'])) {
|
|
|
|
|
$aFields['URL'] = '';
|
|
|
|
|
} else {
|
|
|
|
|
$aFields['URL'] = htmlspecialchars(addslashes(stripslashes(strip_tags(trim(urldecode($_GET['u']))))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isset($_SESSION['G_MESSAGE'])) {
|
|
|
|
|
$_SESSION['G_MESSAGE'] = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isset($_SESSION['G_MESSAGE_TYPE'])) {
|
|
|
|
|
$_SESSION['G_MESSAGE_TYPE'] = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$msg = $_SESSION['G_MESSAGE'];
|
|
|
|
|
$msgType = $_SESSION['G_MESSAGE_TYPE'];
|
|
|
|
|
|
|
|
|
|
if (!isset($_SESSION['FAILED_LOGINS'])) {
|
|
|
|
|
$_SESSION['FAILED_LOGINS'] = 0;
|
|
|
|
|
$_SESSION["USERNAME_PREVIOUS1"] = "";
|
|
|
|
|
$_SESSION["USERNAME_PREVIOUS2"] = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sFailedLogins = $_SESSION['FAILED_LOGINS'];
|
|
|
|
|
$usernamePrevious1 = $_SESSION["USERNAME_PREVIOUS1"];
|
|
|
|
|
$usernamePrevious2 = $_SESSION["USERNAME_PREVIOUS2"];
|
|
|
|
|
|
|
|
|
|
$aFields['LOGIN_VERIFY_MSG'] = G::loadTranslation('LOGIN_VERIFY_MSG');
|
|
|
|
|
|
|
|
|
|
//start new session
|
|
|
|
|
@session_destroy();
|
|
|
|
|
session_start();
|
|
|
|
|
session_regenerate_id();
|
|
|
|
|
|
2017-10-10 12:33:25 -04:00
|
|
|
setcookie("workspaceSkin", SYS_SKIN, time() + (24 * 60 * 60), "/sys" . config("system.workspace"), null, false, true);
|
2015-02-25 13:48:45 -04:00
|
|
|
|
|
|
|
|
if (strlen($msg) > 0) {
|
|
|
|
|
$_SESSION['G_MESSAGE'] = $msg;
|
|
|
|
|
}
|
|
|
|
|
if (strlen($msgType) > 0) {
|
|
|
|
|
$_SESSION['G_MESSAGE_TYPE'] = $msgType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$_SESSION['FAILED_LOGINS'] = $sFailedLogins;
|
|
|
|
|
$_SESSION["USERNAME_PREVIOUS1"] = $usernamePrevious1;
|
|
|
|
|
$_SESSION["USERNAME_PREVIOUS2"] = $usernamePrevious2;
|
|
|
|
|
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
2017-02-14 21:24:08 +00:00
|
|
|
|
2017-08-11 16:24:12 -04:00
|
|
|
$licenseManager =& PmLicenseManager::getSingleton();
|
2017-08-23 12:20:54 -04:00
|
|
|
if (in_array(md5($licenseManager->result),
|
|
|
|
|
array('38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb'))) {
|
2015-02-25 13:48:45 -04:00
|
|
|
$G_PUBLISH = new \Publisher();
|
|
|
|
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/licenseExpired', '', array(), 'licenseUpdate');
|
|
|
|
|
G::RenderPage('publish');
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$oatoken = new \OauthAccessTokens();
|
|
|
|
|
$result = $oatoken->remove($oauthAccessTokenId);
|
|
|
|
|
|
|
|
|
|
$response["status"] = "OK";
|
|
|
|
|
} catch (Exception $e) {
|
2017-08-23 12:20:54 -04:00
|
|
|
$response["status"] = "ERROR";
|
2015-02-25 13:48:45 -04:00
|
|
|
$response["message"] = $e->getMessage();
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-02-25 13:48:45 -04:00
|
|
|
return $response;
|
|
|
|
|
|
|
|
|
|
}
|
2015-03-03 10:50:51 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get information for status paused and participated or other status
|
|
|
|
|
*
|
|
|
|
|
* @param $userUid
|
|
|
|
|
* @param $type
|
|
|
|
|
* @param $app_uid
|
2017-08-23 12:20:54 -04:00
|
|
|
* @throws Exception
|
2015-03-03 10:50:51 -04:00
|
|
|
*/
|
|
|
|
|
public function getInformation($userUid, $type, $app_uid)
|
|
|
|
|
{
|
2015-03-17 16:07:31 -04:00
|
|
|
$response = array();
|
2015-03-03 10:50:51 -04:00
|
|
|
switch ($type) {
|
2015-03-17 16:07:31 -04:00
|
|
|
case 'unassigned':
|
2015-03-03 10:50:51 -04:00
|
|
|
case 'paused':
|
|
|
|
|
case 'participated':
|
2017-08-23 12:20:54 -04:00
|
|
|
$oCase = new Cases();
|
|
|
|
|
$iDelIndex = $oCase->getCurrentDelegationCase($app_uid);
|
2017-02-23 15:02:41 -04:00
|
|
|
$aFields = $oCase->loadCase($app_uid, $iDelIndex);
|
|
|
|
|
$response = $this->getInfoResume($userUid, $aFields, $type);
|
|
|
|
|
break;
|
|
|
|
|
case 'lastopenindex':
|
|
|
|
|
//Get the last participate from a user
|
2017-08-23 12:20:54 -04:00
|
|
|
$oNewCase = new BusinessModelCases();
|
2017-02-23 15:02:41 -04:00
|
|
|
$iDelIndex = $oNewCase->getLastParticipatedByUser($app_uid, $userUid, 'OPEN');
|
2017-08-23 12:20:54 -04:00
|
|
|
$oCase = new Cases();
|
2017-02-23 15:02:41 -04:00
|
|
|
$aFields = $oCase->loadCase($app_uid, $iDelIndex);
|
|
|
|
|
$aFields['DEL_INDEX'] = $iDelIndex === 0 ? '' : $iDelIndex;
|
|
|
|
|
$aFields['USR_UID'] = $userUid;
|
2015-03-11 15:27:08 -04:00
|
|
|
$response = $this->getInfoResume($userUid, $aFields, $type);
|
2015-03-03 10:50:51 -04:00
|
|
|
break;
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-03-11 15:27:08 -04:00
|
|
|
return $response;
|
2015-03-03 10:50:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* view in html response for status
|
|
|
|
|
*
|
|
|
|
|
* @param $userUid
|
|
|
|
|
* @param $Fields
|
|
|
|
|
* @param $type
|
2017-08-23 12:20:54 -04:00
|
|
|
* @throws Exception
|
2015-03-03 10:50:51 -04:00
|
|
|
*/
|
|
|
|
|
public function getInfoResume($userUid, $Fields, $type)
|
|
|
|
|
{
|
|
|
|
|
/* Prepare page before to show */
|
2017-08-23 12:20:54 -04:00
|
|
|
$objProc = new Process();
|
|
|
|
|
$aProc = $objProc->load($Fields['PRO_UID']);
|
2015-03-03 10:50:51 -04:00
|
|
|
$Fields['PRO_TITLE'] = $aProc['PRO_TITLE'];
|
|
|
|
|
|
|
|
|
|
$objTask = new \Task();
|
|
|
|
|
|
|
|
|
|
if (isset($_SESSION['ACTION']) && ($_SESSION['ACTION'] == 'jump')) {
|
2016-08-22 14:09:23 -04:00
|
|
|
$task = explode('|', $Fields['TAS_UID']);
|
2015-03-03 10:50:51 -04:00
|
|
|
$Fields['TAS_TITLE'] = '';
|
2016-08-22 14:09:23 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
for ($i = 0; $i < sizeof($task) - 1; $i++) {
|
|
|
|
|
$aTask = $objTask->load($task[$i]);
|
2015-03-03 10:50:51 -04:00
|
|
|
$Fields['TAS_TITLE'][] = $aTask['TAS_TITLE'];
|
|
|
|
|
}
|
2016-08-22 14:09:23 -04:00
|
|
|
|
2015-03-03 10:50:51 -04:00
|
|
|
$Fields['TAS_TITLE'] = implode(" - ", array_values($Fields['TAS_TITLE']));
|
2017-02-23 15:02:41 -04:00
|
|
|
} elseif (isset($Fields['TAS_UID']) && !empty($Fields['TAS_UID'])) {
|
|
|
|
|
$aTask = $objTask->load($Fields['TAS_UID']);
|
2015-03-03 10:50:51 -04:00
|
|
|
$Fields['TAS_TITLE'] = $aTask['TAS_TITLE'];
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-11 15:27:08 -04:00
|
|
|
return $Fields;
|
2015-03-03 10:50:51 -04:00
|
|
|
}
|
2015-03-12 16:47:16 -04:00
|
|
|
|
|
|
|
|
/**
|
2017-08-23 12:20:54 -04:00
|
|
|
* First step for upload file
|
2015-03-12 16:47:16 -04:00
|
|
|
* create uid app_document for upload file
|
|
|
|
|
*
|
2017-08-23 12:20:54 -04:00
|
|
|
* @param string $userUid
|
|
|
|
|
* @param string $appUid
|
|
|
|
|
* @param array $requestData
|
|
|
|
|
* @return array $response
|
|
|
|
|
* @throws Exception
|
2015-03-12 16:47:16 -04:00
|
|
|
*/
|
2017-08-23 12:20:54 -04:00
|
|
|
public function postUidUploadFiles($userUid, $appUid, $requestData)
|
2015-03-12 16:47:16 -04:00
|
|
|
{
|
|
|
|
|
$response = array();
|
2017-08-23 12:20:54 -04:00
|
|
|
if (is_array($requestData)) {
|
|
|
|
|
$config = new Configurations();
|
|
|
|
|
$confEnvSetting = $config->getFormats();
|
|
|
|
|
$user = new Users();
|
|
|
|
|
foreach ($requestData as $k => $file) {
|
2017-02-08 16:01:52 -04:00
|
|
|
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
|
2017-08-23 12:20:54 -04:00
|
|
|
if (Bootstrap::getDisablePhpUploadExecution() === 1 && $ext === 'php') {
|
|
|
|
|
$message = G::LoadTranslation('THE_UPLOAD_OF_PHP_FILES_WAS_DISABLED');
|
|
|
|
|
Bootstrap::registerMonologPhpUploadExecution('phpUpload', 550, $message, $file['name']);
|
2017-02-08 16:01:52 -04:00
|
|
|
$response[$k]['error'] = array(
|
|
|
|
|
"code" => "400",
|
|
|
|
|
"message" => $message
|
|
|
|
|
);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
$cases = new Cases();
|
|
|
|
|
$delIndex = $cases->getCurrentDelegation($appUid, $userUid);
|
2016-03-20 11:24:51 -04:00
|
|
|
$docUid = !empty($file['docUid']) ? $file['docUid'] : -1;
|
2016-08-25 09:29:20 -04:00
|
|
|
$folderId = '';
|
2017-08-23 12:20:54 -04:00
|
|
|
if ($docUid !== -1) {
|
|
|
|
|
$inputDocument = new InputDocument();
|
2016-08-25 09:29:20 -04:00
|
|
|
$aInputDocumentData = $inputDocument->load($docUid);
|
2017-08-23 12:20:54 -04:00
|
|
|
$appFolder = new AppFolder();
|
|
|
|
|
$folderId = $appFolder->createFromPath($aInputDocumentData["INP_DOC_DESTINATION_PATH"], $appUid);
|
2016-08-25 09:29:20 -04:00
|
|
|
}
|
2016-03-20 11:24:51 -04:00
|
|
|
$appDocType = !empty($file['appDocType']) ? $file['appDocType'] : "ATTACHED";
|
|
|
|
|
$fieldName = !empty($file['fieldName']) ? $file['fieldName'] : null;
|
2017-08-23 12:20:54 -04:00
|
|
|
$fieldsInput = array(
|
|
|
|
|
"APP_UID" => $appUid,
|
2016-03-20 11:24:51 -04:00
|
|
|
"DEL_INDEX" => $delIndex,
|
|
|
|
|
"USR_UID" => $userUid,
|
|
|
|
|
"DOC_UID" => $docUid,
|
|
|
|
|
"APP_DOC_TYPE" => $appDocType,
|
|
|
|
|
"APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"),
|
|
|
|
|
"APP_DOC_COMMENT" => "",
|
|
|
|
|
"APP_DOC_TITLE" => "",
|
|
|
|
|
"APP_DOC_FILENAME" => $file['name'],
|
2016-08-25 09:29:20 -04:00
|
|
|
"APP_DOC_FIELDNAME" => $fieldName,
|
|
|
|
|
"FOLDER_UID" => $folderId
|
2015-03-12 16:47:16 -04:00
|
|
|
);
|
2017-08-23 12:20:54 -04:00
|
|
|
//We will to create a new version related to the appDocUid
|
|
|
|
|
if (isset($file['appDocUid'])) {
|
|
|
|
|
$fieldsInput['APP_DOC_UID'] = $file['appDocUid'];
|
|
|
|
|
}
|
|
|
|
|
$appDocument = new AppDocument();
|
|
|
|
|
$appDocument->create($fieldsInput);
|
|
|
|
|
//todo, we need to uniform the response format with camelCase
|
|
|
|
|
$response[$k]['appDocUid'] = $appDocUid = $appDocument->getAppDocUid();
|
|
|
|
|
$response[$k]['docVersion'] = $docVersion = $appDocument->getDocVersion();
|
|
|
|
|
$response[$k]['appDocFilename'] = $appDocument->getAppDocFilename();
|
|
|
|
|
$response[$k]['appDocCreateDate'] = $appDocument->getAppDocCreateDate();
|
|
|
|
|
$response[$k]['appDocType'] = $appDocument->getAppDocType();
|
|
|
|
|
$response[$k]['appDocIndex'] = $appDocument->getAppDocIndex();
|
|
|
|
|
//todo, we use this *** in others endpoint for mark that user not exist, but we need to change
|
|
|
|
|
$userInfo = '***';
|
|
|
|
|
if ($userUid !== '-1') {
|
|
|
|
|
$arrayUserData = $user->load($userUid);
|
|
|
|
|
$userInfo = $config->usersNameFormatBySetParameters($confEnvSetting["format"],
|
|
|
|
|
$arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"],
|
|
|
|
|
$arrayUserData["USR_LASTNAME"]);
|
|
|
|
|
}
|
|
|
|
|
$response[$k]['appDocCreateUser'] = $userInfo;
|
2015-03-12 16:47:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-03-12 16:47:16 -04:00
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* second step for upload file
|
|
|
|
|
* upload file in foler app_uid
|
|
|
|
|
*
|
|
|
|
|
* @param $userUid
|
|
|
|
|
* @param $Fields
|
|
|
|
|
* @param $type
|
2017-08-23 12:20:54 -04:00
|
|
|
* @throws Exception
|
2015-03-12 16:47:16 -04:00
|
|
|
*/
|
|
|
|
|
public function documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data)
|
|
|
|
|
{
|
2015-03-16 14:47:08 -04:00
|
|
|
$response = array("status" => "fail");
|
2017-08-23 12:20:54 -04:00
|
|
|
if (isset($_FILES["form"]["name"]) && count($_FILES["form"]["name"]) > 0) {
|
|
|
|
|
$arrayField = array();
|
|
|
|
|
$arrayFileName = array();
|
|
|
|
|
$arrayFileTmpName = array();
|
|
|
|
|
$arrayFileError = array();
|
2015-03-12 16:47:16 -04:00
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
|
|
foreach ($_FILES["form"]["name"] as $fieldIndex => $fieldValue) {
|
2017-08-23 12:20:54 -04:00
|
|
|
if (is_array($fieldValue)) {
|
2015-03-12 16:47:16 -04:00
|
|
|
foreach ($fieldValue as $index => $value) {
|
2017-08-23 12:20:54 -04:00
|
|
|
if (is_array($value)) {
|
2015-03-12 16:47:16 -04:00
|
|
|
foreach ($value as $grdFieldIndex => $grdFieldValue) {
|
|
|
|
|
$arrayField[$i]["grdName"] = $fieldIndex;
|
|
|
|
|
$arrayField[$i]["grdFieldName"] = $grdFieldIndex;
|
|
|
|
|
$arrayField[$i]["index"] = $index;
|
|
|
|
|
|
|
|
|
|
$arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex][$index][$grdFieldIndex];
|
|
|
|
|
$arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex][$index][$grdFieldIndex];
|
|
|
|
|
$arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex][$index][$grdFieldIndex];
|
|
|
|
|
$i = $i + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$arrayField[$i] = $fieldIndex;
|
|
|
|
|
|
|
|
|
|
$arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex];
|
|
|
|
|
$arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex];
|
|
|
|
|
$arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex];
|
|
|
|
|
$i = $i + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
if (count($arrayField) > 0) {
|
|
|
|
|
for ($i = 0; $i <= count($arrayField) - 1; $i++) {
|
2015-03-12 16:47:16 -04:00
|
|
|
if ($arrayFileError[$i] == 0) {
|
|
|
|
|
$indocUid = null;
|
|
|
|
|
$fieldName = null;
|
|
|
|
|
$fileSizeByField = 0;
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$oAppDocument = new AppDocument();
|
2015-03-12 16:47:16 -04:00
|
|
|
$aAux = $oAppDocument->load($app_doc_uid);
|
|
|
|
|
|
|
|
|
|
$iDocVersion = $oAppDocument->getDocVersion();
|
|
|
|
|
$sAppDocUid = $oAppDocument->getAppDocUid();
|
2017-08-23 12:20:54 -04:00
|
|
|
$aInfo = pathinfo($oAppDocument->getAppDocFilename());
|
|
|
|
|
$sExtension = ((isset($aInfo["extension"])) ? $aInfo["extension"] : "");
|
2015-03-12 16:47:16 -04:00
|
|
|
$pathUID = G::getPathFromUID($app_uid);
|
|
|
|
|
$sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
|
|
|
|
|
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
|
2017-08-23 12:20:54 -04:00
|
|
|
G::uploadFile($arrayFileTmpName[$i], $sPathName, $sFileName);
|
2015-03-16 14:47:08 -04:00
|
|
|
$response = array("status" => "ok");
|
2015-03-12 16:47:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
2015-03-16 14:47:08 -04:00
|
|
|
|
|
|
|
|
/**
|
2018-05-24 09:10:04 -04:00
|
|
|
* Claim case
|
2015-03-16 14:47:08 -04:00
|
|
|
*
|
2018-05-24 09:10:04 -04:00
|
|
|
* @param string $userUid
|
|
|
|
|
* @param string $appUid
|
|
|
|
|
* @param integer $delIndex
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
2017-08-23 12:20:54 -04:00
|
|
|
* @throws Exception
|
2015-03-16 14:47:08 -04:00
|
|
|
*/
|
2018-05-24 09:10:04 -04:00
|
|
|
public function claimCaseUser($userUid, $appUid, $delIndex = null)
|
2015-03-16 14:47:08 -04:00
|
|
|
{
|
2018-05-24 09:10:04 -04:00
|
|
|
$response = ['status' => 'fail'];
|
|
|
|
|
$case = new Cases();
|
|
|
|
|
$appDelegation = new AppDelegation();
|
|
|
|
|
if (empty($delIndex)) {
|
|
|
|
|
$delIndex = $case->getCurrentDelegation($appUid, '', true);
|
|
|
|
|
}
|
2015-03-16 14:47:08 -04:00
|
|
|
|
2018-05-24 09:10:04 -04:00
|
|
|
$delegation = $appDelegation->Load($appUid, $delIndex);
|
2015-03-16 14:47:08 -04:00
|
|
|
|
|
|
|
|
//if there are no user in the delegation row, this case is still in selfservice
|
2018-05-24 09:10:04 -04:00
|
|
|
if (empty($delegation['USR_UID'])) {
|
|
|
|
|
$case->setCatchUser($appUid, $delIndex, $userUid);
|
|
|
|
|
$response['status'] = 'ok';
|
2015-03-16 14:47:08 -04:00
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-03-16 14:47:08 -04:00
|
|
|
return $response;
|
|
|
|
|
}
|
2015-04-29 17:18:43 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GET return array category
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2017-08-23 12:20:54 -04:00
|
|
|
public function getCategoryList()
|
2015-04-29 17:18:43 -04:00
|
|
|
{
|
2017-08-23 12:20:54 -04:00
|
|
|
$category = array();
|
|
|
|
|
$category[] = array("", G::LoadTranslation("ID_ALL_CATEGORIES"));
|
2015-04-29 17:18:43 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$criteria = new Criteria('workflow');
|
|
|
|
|
$criteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_UID);
|
|
|
|
|
$criteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
|
|
|
|
|
$criteria->addAscendingOrderByColumn(ProcessCategoryPeer::CATEGORY_NAME);
|
2015-04-29 17:18:43 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$dataset = ProcessCategoryPeer::doSelectRS($criteria);
|
|
|
|
|
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2015-04-29 17:18:43 -04:00
|
|
|
$dataset->next();
|
|
|
|
|
|
|
|
|
|
while ($row = $dataset->getRow()) {
|
2017-08-23 12:20:54 -04:00
|
|
|
$category[] = array($row['CATEGORY_UID'], $row['CATEGORY_NAME']);
|
2015-04-29 17:18:43 -04:00
|
|
|
$dataset->next();
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-04-29 17:18:43 -04:00
|
|
|
return $category;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $action
|
|
|
|
|
* @param $categoryUid
|
|
|
|
|
* @param $userUid
|
|
|
|
|
* @return array
|
2017-08-23 12:20:54 -04:00
|
|
|
* @throws PropelException
|
2015-04-29 17:18:43 -04:00
|
|
|
*/
|
2017-08-23 12:20:54 -04:00
|
|
|
public function getProcessList($action, $categoryUid, $userUid)
|
2015-04-29 17:18:43 -04:00
|
|
|
{
|
|
|
|
|
//$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : null;
|
|
|
|
|
//$categoryUid = isset( $_REQUEST['CATEGORY_UID'] ) ? $_REQUEST['CATEGORY_UID'] : null;
|
|
|
|
|
//$userUid = (isset( $_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '') ? $_SESSION['USER_LOGGED'] : null;
|
|
|
|
|
|
|
|
|
|
// global $oAppCache;
|
2017-08-23 12:20:54 -04:00
|
|
|
$oAppCache = new AppCacheView();
|
|
|
|
|
$processes = array();
|
|
|
|
|
$processes[] = array('', G::LoadTranslation('ID_ALL_PROCESS'));
|
2015-04-29 17:18:43 -04:00
|
|
|
|
|
|
|
|
//get the list based in the action provided
|
|
|
|
|
switch ($action) {
|
|
|
|
|
case 'draft':
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess = $oAppCache->getDraftListCriteria($userUid); //fast enough
|
2015-04-29 17:18:43 -04:00
|
|
|
break;
|
|
|
|
|
case 'sent':
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess = $oAppCache->getSentListProcessCriteria($userUid); // fast enough
|
2015-04-29 17:18:43 -04:00
|
|
|
break;
|
|
|
|
|
case 'simple_search':
|
|
|
|
|
case 'search':
|
|
|
|
|
//in search action, the query to obtain all process is too slow, so we need to query directly to
|
|
|
|
|
//process and content tables, and for that reason we need the current language in AppCacheView.
|
2017-02-14 21:24:08 +00:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$oConf = new Configurations();
|
|
|
|
|
$oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', '');
|
2015-04-29 17:18:43 -04:00
|
|
|
$appCacheViewEngine = $oConf->aConfig;
|
2017-08-23 12:20:54 -04:00
|
|
|
$lang = isset($appCacheViewEngine['LANG']) ? $appCacheViewEngine['LANG'] : 'en';
|
2015-04-29 17:18:43 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess = new Criteria('workflow');
|
2015-04-29 17:18:43 -04:00
|
|
|
$cProcess->clearSelectColumns();
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess->addSelectColumn(ProcessPeer::PRO_UID);
|
|
|
|
|
$cProcess->addSelectColumn(ProcessPeer::PRO_TITLE);
|
2015-04-29 17:18:43 -04:00
|
|
|
if ($categoryUid) {
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess->add(ProcessPeer::PRO_CATEGORY, $categoryUid);
|
2015-04-29 17:18:43 -04:00
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess->add(ProcessPeer::PRO_STATUS, 'ACTIVE');
|
|
|
|
|
$cProcess->addAscendingOrderByColumn(ProcessPeer::PRO_TITLE);
|
2015-04-29 17:18:43 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$oDataset = ProcessPeer::doSelectRS($cProcess);
|
|
|
|
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2015-04-29 17:18:43 -04:00
|
|
|
$oDataset->next();
|
|
|
|
|
|
|
|
|
|
while ($aRow = $oDataset->getRow()) {
|
2017-08-23 12:20:54 -04:00
|
|
|
$processes[] = array($aRow['PRO_UID'], $aRow['PRO_TITLE']);
|
2015-04-29 17:18:43 -04:00
|
|
|
$oDataset->next();
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
|
|
|
|
return print G::json_encode($processes);
|
2015-04-29 17:18:43 -04:00
|
|
|
break;
|
|
|
|
|
case 'unassigned':
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess = $oAppCache->getUnassignedListCriteria($userUid);
|
2015-04-29 17:18:43 -04:00
|
|
|
break;
|
|
|
|
|
case 'paused':
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess = $oAppCache->getPausedListCriteria($userUid);
|
2015-04-29 17:18:43 -04:00
|
|
|
break;
|
|
|
|
|
case 'to_revise':
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess = $oAppCache->getToReviseListCriteria($userUid);
|
2015-04-29 17:18:43 -04:00
|
|
|
break;
|
|
|
|
|
case 'to_reassign':
|
|
|
|
|
$cProcess = $oAppCache->getToReassignListCriteria($userUid);
|
|
|
|
|
break;
|
|
|
|
|
case 'gral':
|
|
|
|
|
$cProcess = $oAppCache->getGeneralListCriteria();
|
|
|
|
|
break;
|
|
|
|
|
case 'todo':
|
|
|
|
|
default:
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess = $oAppCache->getToDoListCriteria($userUid); //fast enough
|
2015-04-29 17:18:43 -04:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//get the processes for this user in this action
|
|
|
|
|
$cProcess->clearSelectColumns();
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess->addSelectColumn(AppCacheViewPeer::PRO_UID);
|
|
|
|
|
$cProcess->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE);
|
|
|
|
|
$cProcess->setDistinct(AppCacheViewPeer::PRO_UID);
|
2015-04-29 17:18:43 -04:00
|
|
|
if ($categoryUid) {
|
|
|
|
|
require_once 'classes/model/Process.php';
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess->addAlias('CP', 'PROCESS');
|
|
|
|
|
$cProcess->add('CP.PRO_CATEGORY', $categoryUid, Criteria::EQUAL);
|
|
|
|
|
$cProcess->addJoin(AppCacheViewPeer::PRO_UID, 'CP.PRO_UID', Criteria::LEFT_JOIN);
|
|
|
|
|
$cProcess->addAsColumn('CATEGORY_UID', 'CP.PRO_CATEGORY');
|
2015-04-29 17:18:43 -04:00
|
|
|
}
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$cProcess->addAscendingOrderByColumn(AppCacheViewPeer::APP_PRO_TITLE);
|
2015-04-29 17:18:43 -04:00
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$oDataset = AppCacheViewPeer::doSelectRS($cProcess, Propel::getDbConnection('workflow_ro'));
|
|
|
|
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2015-04-29 17:18:43 -04:00
|
|
|
$oDataset->next();
|
|
|
|
|
|
|
|
|
|
while ($aRow = $oDataset->getRow()) {
|
2017-08-23 12:20:54 -04:00
|
|
|
$processes[] = array(
|
|
|
|
|
$aRow['PRO_UID'],
|
|
|
|
|
$aRow['APP_PRO_TITLE']
|
2015-04-29 17:18:43 -04:00
|
|
|
);
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-04-29 17:18:43 -04:00
|
|
|
return $processes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* lista de usuarios a reasignar
|
|
|
|
|
*/
|
|
|
|
|
public function getUsersToReassign($usr_uid, $task_uid)
|
|
|
|
|
{
|
2017-02-14 21:24:08 +00:00
|
|
|
|
2017-10-10 12:33:25 -04:00
|
|
|
$memcache = PMmemcached::getSingleton(config("system.workspace"));
|
2017-08-23 12:20:54 -04:00
|
|
|
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
2015-04-29 17:18:43 -04:00
|
|
|
$RBAC->sSystem = 'PROCESSMAKER';
|
|
|
|
|
$RBAC->initRBAC();
|
|
|
|
|
$memKey = 'rbacSession' . session_id();
|
2017-08-23 12:20:54 -04:00
|
|
|
if (($RBAC->aUserInfo = $memcache->get($memKey)) === false) {
|
|
|
|
|
$RBAC->loadUserRolePermission($RBAC->sSystem, $usr_uid);
|
|
|
|
|
$memcache->set($memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS);
|
2015-04-29 17:18:43 -04:00
|
|
|
}
|
|
|
|
|
$GLOBALS['RBAC'] = $RBAC;
|
|
|
|
|
|
|
|
|
|
$task = new \Task();
|
|
|
|
|
$tasks = $task->load($task_uid);
|
2017-08-23 12:20:54 -04:00
|
|
|
$case = new Cases();
|
2015-04-29 17:18:43 -04:00
|
|
|
$result = new \stdclass();
|
|
|
|
|
$result->data = $case->getUsersToReassign($task_uid, $usr_uid, $tasks['PRO_UID']);
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-04-29 17:18:43 -04:00
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function reassignCase($usr_uid, $app_uid, $TO_USR_UID)
|
|
|
|
|
{
|
2017-08-23 12:20:54 -04:00
|
|
|
$cases = new Cases();
|
2015-04-29 17:18:43 -04:00
|
|
|
$user = new \Users();
|
|
|
|
|
$app = new \Application();
|
|
|
|
|
$result = new \stdclass();
|
|
|
|
|
|
|
|
|
|
try {
|
2017-08-23 12:20:54 -04:00
|
|
|
$iDelIndex = $cases->getCurrentDelegation($app_uid, $usr_uid);
|
2015-04-29 17:18:43 -04:00
|
|
|
$cases->reassignCase($app_uid, $iDelIndex, $usr_uid, $TO_USR_UID);
|
|
|
|
|
$caseData = $app->load($app_uid);
|
|
|
|
|
$userData = $user->load($TO_USR_UID);
|
|
|
|
|
$data['APP_NUMBER'] = $caseData['APP_NUMBER'];
|
|
|
|
|
$data['USER'] = $userData['USR_LASTNAME'] . ' ' . $userData['USR_FIRSTNAME']; //TODO change with the farmated username from environment conf
|
|
|
|
|
$result->status = 0;
|
|
|
|
|
$result->msg = G::LoadTranslation('ID_REASSIGNMENT_SUCCESS', SYS_LANG, $data);
|
2017-08-23 12:20:54 -04:00
|
|
|
} catch (Exception $e) {
|
2015-04-29 17:18:43 -04:00
|
|
|
$result->status = 1;
|
|
|
|
|
$result->msg = $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function pauseCase($usr_uid, $app_uid, $request_data)
|
|
|
|
|
{
|
|
|
|
|
$result = new \stdclass();
|
|
|
|
|
|
|
|
|
|
try {
|
2017-08-23 12:20:54 -04:00
|
|
|
$oCase = new Cases();
|
|
|
|
|
$iDelIndex = $oCase->getCurrentDelegation($app_uid, $usr_uid);
|
2015-04-29 17:18:43 -04:00
|
|
|
// Save the note pause reason
|
|
|
|
|
if ($request_data['noteContent'] != '') {
|
|
|
|
|
$request_data['noteContent'] = G::LoadTranslation('ID_CASE_PAUSE_LABEL_NOTE') . ' ' . $request_data['noteContent'];
|
|
|
|
|
$appNotes = new \AppNotes();
|
|
|
|
|
$noteContent = addslashes($request_data['noteContent']);
|
|
|
|
|
$appNotes->postNewNote($app_uid, $usr_uid, $noteContent, $request_data['notifyUser']);
|
|
|
|
|
}
|
|
|
|
|
// End save
|
|
|
|
|
|
2015-11-24 10:34:35 -04:00
|
|
|
$oCase->pauseCase($app_uid, $iDelIndex, $usr_uid, $request_data['unpauseDate']);
|
2015-04-29 17:18:43 -04:00
|
|
|
$app = new \Application();
|
|
|
|
|
$caseData = $app->load($app_uid);
|
|
|
|
|
$data['APP_NUMBER'] = $caseData['APP_NUMBER'];
|
2015-11-24 10:34:35 -04:00
|
|
|
$data['UNPAUSE_DATE'] = $request_data['unpauseDate'];
|
2015-04-29 17:18:43 -04:00
|
|
|
|
|
|
|
|
$result->success = true;
|
|
|
|
|
$result->msg = G::LoadTranslation('ID_CASE_PAUSED_SUCCESSFULLY', SYS_LANG, $data);
|
2017-08-23 12:20:54 -04:00
|
|
|
} catch (Exception $e) {
|
2015-04-29 17:18:43 -04:00
|
|
|
throw $e;
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-04-29 17:18:43 -04:00
|
|
|
return $result;
|
|
|
|
|
}
|
2015-04-30 17:08:24 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get configuration
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2016-04-15 12:18:50 -04:00
|
|
|
public function getConfiguration($params)
|
2015-04-30 17:08:24 -04:00
|
|
|
{
|
2017-10-10 12:33:25 -04:00
|
|
|
$sysConf = Bootstrap::getSystemConfiguration('', '', config("system.workspace"));
|
2016-03-23 10:59:49 -04:00
|
|
|
$multiTimeZone = false;
|
|
|
|
|
//Set Time Zone
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
if (\PMLicensedFeatures::getSingleton()->verifyfeature
|
|
|
|
|
('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
|
|
|
|
$multiTimeZone = (int)($sysConf['system_utc_time_zone']) == 1;
|
|
|
|
|
}
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
2017-08-23 12:20:54 -04:00
|
|
|
$tz = isset($_SESSION['USR_TIME_ZONE']) ? $_SESSION['USR_TIME_ZONE'] : $sysConf['time_zone'];
|
|
|
|
|
$offset = timezone_offset_get(new \DateTimeZone($tz), new \DateTime());
|
|
|
|
|
$response['timeZone'] = sprintf("GMT%s%02d:%02d", ($offset >= 0) ? '+' : '-', abs($offset / 3600),
|
|
|
|
|
abs(($offset % 3600) / 60));
|
2016-03-23 10:59:49 -04:00
|
|
|
$response['multiTimeZone'] = $multiTimeZone;
|
2017-08-14 16:37:50 -04:00
|
|
|
$fields = System::getSysInfo();
|
2015-05-29 17:31:08 -04:00
|
|
|
$response['version'] = $fields['PM_VERSION'];
|
2015-06-15 15:32:29 -04:00
|
|
|
|
2015-10-22 16:42:30 -04:00
|
|
|
$buildType = 'Community';
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
$buildType = 'Enterprise';
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
$response['buildType'] = $buildType;
|
|
|
|
|
|
2017-08-23 12:20:54 -04:00
|
|
|
$conf = new Configurations();
|
2015-09-25 09:02:04 -04:00
|
|
|
$confEnvironment = $conf->getFormats();
|
|
|
|
|
|
|
|
|
|
$response['environment'] = array();
|
2017-08-23 12:20:54 -04:00
|
|
|
if (is_array($confEnvironment)) {
|
|
|
|
|
$response['environment']['format'] = isset($confEnvironment['format']) ? $confEnvironment['format'] : '';
|
|
|
|
|
$response['environment']['dateFormat'] = isset($confEnvironment['dateFormat']) ? $confEnvironment['dateFormat'] : '';
|
|
|
|
|
$response['environment']['casesListDateFormat'] = isset($confEnvironment['casesListDateFormat']) ? $confEnvironment['casesListDateFormat'] : '';
|
2015-09-25 09:02:04 -04:00
|
|
|
}
|
|
|
|
|
|
2015-06-15 15:32:29 -04:00
|
|
|
$Translations = new \Translation;
|
|
|
|
|
$translationsTable = $Translations->getTranslationEnvironments();
|
2017-08-23 12:20:54 -04:00
|
|
|
$languagesList = array();
|
2015-06-15 15:32:29 -04:00
|
|
|
|
|
|
|
|
foreach ($translationsTable as $locale) {
|
|
|
|
|
$LANG_ID = $locale['LOCALE'];
|
|
|
|
|
if ($locale['COUNTRY'] != '.') {
|
2017-08-23 12:20:54 -04:00
|
|
|
$LANG_NAME = $locale['LANGUAGE'] . ' (' . (ucwords(strtolower($locale['COUNTRY']))) . ')';
|
2015-06-15 15:32:29 -04:00
|
|
|
} else {
|
|
|
|
|
$LANG_NAME = $locale['LANGUAGE'];
|
|
|
|
|
}
|
2015-06-24 14:36:06 -04:00
|
|
|
$languages["L10n"] = $LANG_ID;
|
|
|
|
|
$languages["label"] = $LANG_NAME;
|
|
|
|
|
$languagesList[] = $languages;
|
2015-06-15 15:32:29 -04:00
|
|
|
}
|
|
|
|
|
$response['listLanguage'] = $languagesList;
|
2016-04-28 11:09:58 -04:00
|
|
|
if (isset($params['fileLimit']) && $params['fileLimit']) {
|
2016-05-04 10:30:40 -04:00
|
|
|
$postMaxSize = $this->return_bytes(ini_get('post_max_size'));
|
|
|
|
|
$uploadMaxFileSize = $this->return_bytes(ini_get('upload_max_filesize'));
|
2017-08-23 12:20:54 -04:00
|
|
|
if ($postMaxSize < $uploadMaxFileSize) {
|
2016-05-04 10:30:40 -04:00
|
|
|
$uploadMaxFileSize = $postMaxSize;
|
|
|
|
|
}
|
|
|
|
|
$response['fileLimit'] = $uploadMaxFileSize;
|
2016-04-15 12:18:50 -04:00
|
|
|
}
|
2016-04-28 11:09:58 -04:00
|
|
|
if (isset($params['tz']) && $params['tz']) {
|
2017-08-23 12:20:54 -04:00
|
|
|
$response['tz'] = isset($_SESSION['USR_TIME_ZONE']) ? $_SESSION['USR_TIME_ZONE'] : $sysConf['time_zone'];
|
2016-04-28 11:09:58 -04:00
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-04-30 17:08:24 -04:00
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-15 12:18:50 -04:00
|
|
|
public function return_bytes($size_str)
|
|
|
|
|
{
|
|
|
|
|
switch (substr($size_str, -1)) {
|
|
|
|
|
case 'M':
|
|
|
|
|
case 'm':
|
|
|
|
|
return (int)$size_str * 1048576;
|
|
|
|
|
case 'K':
|
|
|
|
|
case 'k':
|
|
|
|
|
return (int)$size_str * 1024;
|
|
|
|
|
case 'G':
|
|
|
|
|
case 'g':
|
|
|
|
|
return (int)$size_str * 1073741824;
|
|
|
|
|
default:
|
|
|
|
|
return $size_str;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-07 18:13:08 -04:00
|
|
|
public function getInformationDerivatedCase($app_uid, $del_index)
|
|
|
|
|
{
|
2017-08-23 12:20:54 -04:00
|
|
|
$oCriteria = new Criteria('workflow');
|
|
|
|
|
$children = array();
|
2015-09-07 18:13:08 -04:00
|
|
|
$oCriteria->clearSelectColumns();
|
2017-08-23 12:20:54 -04:00
|
|
|
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
|
|
|
|
$oCriteria->addSelectColumn(AppDelegationPeer::PRO_UID);
|
|
|
|
|
$oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID);
|
|
|
|
|
$oCriteria->addSelectColumn(AppDelegationPeer::USR_UID);
|
|
|
|
|
$oCriteria->add(AppDelegationPeer::APP_UID, $app_uid);
|
|
|
|
|
$oCriteria->add(AppDelegationPeer::DEL_PREVIOUS, $del_index);
|
|
|
|
|
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
|
|
|
|
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2015-09-07 18:13:08 -04:00
|
|
|
$oDataset->next();
|
|
|
|
|
while ($row = $oDataset->getRow()) {
|
|
|
|
|
$children[] = $row;
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
}
|
2017-08-23 12:20:54 -04:00
|
|
|
|
2015-09-07 18:13:08 -04:00
|
|
|
return $children;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 17:26:00 -04:00
|
|
|
/**
|
|
|
|
|
* This function check if the $data are in the corresponding cases list
|
|
|
|
|
* @param string $userUid
|
|
|
|
|
* @param array $data
|
|
|
|
|
* @param string $listName
|
|
|
|
|
* @param string $action
|
|
|
|
|
* @return array $response
|
|
|
|
|
*/
|
|
|
|
|
public function getListCheck($userUid, $data, $listName = 'inbox', $action = 'todo')
|
|
|
|
|
{
|
|
|
|
|
$casesToCheck = [];
|
|
|
|
|
foreach ($data as $key => $val) {
|
|
|
|
|
array_push($casesToCheck, $val['caseId']);
|
|
|
|
|
}
|
|
|
|
|
$dataList = [];
|
|
|
|
|
$dataList['appUidCheck'] = $casesToCheck;
|
|
|
|
|
$dataList['userId'] = $userUid;
|
|
|
|
|
$dataList['action'] = $action;
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
if (true) {
|
|
|
|
|
//In enterprise version this block of code should always be executed
|
|
|
|
|
//In community version this block of code is deleted and is executed the other
|
|
|
|
|
$list = new Lists();
|
|
|
|
|
$response = $list->getList($listName, $dataList);
|
|
|
|
|
} else {
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
$case = new Cases();
|
|
|
|
|
$response = $case->getList($dataList);
|
|
|
|
|
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
}
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
$result = [];
|
|
|
|
|
foreach ($data as $key => $val) {
|
|
|
|
|
$flagRemoved = true;
|
|
|
|
|
foreach ($response['data'] as $row) {
|
|
|
|
|
$row = array_change_key_case($row,CASE_UPPER);
|
|
|
|
|
if (isset($row['APP_UID']) && isset($row['DEL_INDEX'])) {
|
|
|
|
|
if ($val['caseId'] === $row['APP_UID'] && $val['delIndex'] === $row['DEL_INDEX'] ) {
|
|
|
|
|
$flagRemoved = false;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if ($flagRemoved) {
|
|
|
|
|
$result[] = [
|
|
|
|
|
'caseId' => $val['caseId'],
|
|
|
|
|
'delIndex' => $val['delIndex']
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
2015-02-25 13:48:45 -04:00
|
|
|
}
|