Merge with develop: solving conflicts
This commit is contained in:
@@ -172,7 +172,9 @@ class AuditLog
|
||||
"GSuiteConnect" => G::LoadTranslation("ID_G_SUITE_CONNECT"),
|
||||
"GSuiteDisconnect" => G::LoadTranslation("ID_G_SUITE_DISCONNECT"),
|
||||
"GSuiteLoadGroups" => G::LoadTranslation("ID_G_SUITE_LOAD_GROUPS"),
|
||||
"GSuiteSyncUsers" => G::LoadTranslation("ID_G_SUITE_SYNC_USERS")
|
||||
"GSuiteSyncUsers" => G::LoadTranslation("ID_G_SUITE_SYNC_USERS"),
|
||||
"SamlEnable" => G::LoadTranslation("ID_SAML_ENABLE"),
|
||||
"SamlProvider" => G::LoadTranslation("ID_SAML_PROVIDER")
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ use ProcessMaker\BusinessModel\Task as BmTask;
|
||||
use ProcessMaker\BusinessModel\User as BmUser;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Exception\UploadException;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
use ProcessMaker\Services\OAuth2\Server;
|
||||
use ProcessMaker\Util\DateTime as UtilDateTime;
|
||||
@@ -2438,6 +2439,14 @@ class Cases
|
||||
*
|
||||
* @return array Return an array with status info Case, array empty otherwise
|
||||
* @throws Exception
|
||||
*
|
||||
* @see workflow/engine/methods/cases/main_init.php
|
||||
* @see workflow/engine/methods/cases/opencase.php
|
||||
* @see ProcessMaker\BusinessModel\Cases->setCaseVariables()
|
||||
* @see ProcessMaker\BusinessModel\Cases\InputDocument->getCasesInputDocuments()
|
||||
* @see ProcessMaker\BusinessModel\Cases\InputDocument->throwExceptionIfHaventPermissionToDelete()
|
||||
* @see ProcessMaker\BusinessModel\Cases\OutputDocument->throwExceptionIfCaseNotIsInInbox()
|
||||
* @see ProcessMaker\BusinessModel\Cases\OutputDocument->throwExceptionIfHaventPermissionToDelete()
|
||||
*/
|
||||
public function getStatusInfo($applicationUid, $delIndex = 0, $userUid = "")
|
||||
{
|
||||
@@ -2598,19 +2607,7 @@ class Cases
|
||||
}
|
||||
|
||||
//Status is PARTICIPATED
|
||||
$criteria2 = clone $criteria;
|
||||
|
||||
$criteria2->setDistinct();
|
||||
$criteria2->clearSelectColumns();
|
||||
$criteria2->addSelectColumn($delimiter . 'PARTICIPATED' . $delimiter . ' AS APP_STATUS');
|
||||
$criteria2->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
$criteria2->addSelectColumn(ApplicationPeer::APP_UID);
|
||||
$criteria2->addSelectColumn(ApplicationPeer::PRO_UID);
|
||||
|
||||
$rsCriteria2 = ApplicationPeer::doSelectRS($criteria2);
|
||||
$rsCriteria2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$arrayData = $this->__getStatusInfoDataByRsCriteria($rsCriteria2);
|
||||
$arrayData = Delegation::getParticipatedInfo($applicationUid);
|
||||
|
||||
if (!empty($arrayData)) {
|
||||
return $arrayData;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use G;
|
||||
use OutputDocument as ClassesOutputDocument;
|
||||
use PEAR;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
|
||||
@@ -592,21 +595,31 @@ class OutputDocument
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Generate the output document
|
||||
* @param string $sUID
|
||||
* @param array $aFields
|
||||
* @param string $sPath
|
||||
* @return variant
|
||||
*
|
||||
* @param string $outDocUid
|
||||
* @param array $caseFields
|
||||
* @param string $path
|
||||
* @param string $filename
|
||||
* @param string $content
|
||||
* @param bool $landscape
|
||||
* @param string $typeDocsToGen
|
||||
* @param array $properties
|
||||
* @param string $application
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @see this->addCasesOutputDocument()
|
||||
*/
|
||||
public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array(), $sApplication)
|
||||
public function generate($outDocUid, $caseFields, $path, $filename, $content, $landscape = false, $typeDocsToGen = 'BOTH', $properties = [], $application = '')
|
||||
{
|
||||
if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
|
||||
$sContent = \G::replaceDataGridField($sContent, $aFields);
|
||||
\G::verifyPath($sPath, true);
|
||||
if (($outDocUid != '') && is_array($caseFields) && ($path != '')) {
|
||||
$content = G::replaceDataGridField($content, $caseFields, true, true);
|
||||
G::verifyPath($path, true);
|
||||
//Start - Create .doc
|
||||
$oFile = fopen($sPath . $sFilename . '.doc', 'wb');
|
||||
$size = array();
|
||||
$fp = fopen($path . $filename . '.doc', 'wb');
|
||||
$size = [];
|
||||
$size["Letter"] = "216mm 279mm";
|
||||
$size["Legal"] = "216mm 357mm";
|
||||
$size["Executive"] = "184mm 267mm";
|
||||
@@ -627,6 +640,7 @@ class OutputDocument
|
||||
$size["Screenshot640"] = "640mm 480mm";
|
||||
$size["Screenshot800"] = "800mm 600mm";
|
||||
$size["Screenshot1024"] = "1024mm 768mm";
|
||||
$sizeLandscape = [];
|
||||
$sizeLandscape["Letter"] = "279mm 216mm";
|
||||
$sizeLandscape["Legal"] = "357mm 216mm";
|
||||
$sizeLandscape["Executive"] = "267mm 184mm";
|
||||
@@ -647,31 +661,31 @@ class OutputDocument
|
||||
$sizeLandscape["Screenshot640"] = "480mm 640mm";
|
||||
$sizeLandscape["Screenshot800"] = "600mm 800mm";
|
||||
$sizeLandscape["Screenshot1024"] = "768mm 1024mm";
|
||||
if (!isset($aProperties['media'])) {
|
||||
$aProperties['media'] = 'Letter';
|
||||
if (!isset($properties['media'])) {
|
||||
$properties['media'] = 'Letter';
|
||||
}
|
||||
if ($sLandscape) {
|
||||
$media = $sizeLandscape[$aProperties['media']];
|
||||
if ($landscape) {
|
||||
$media = $sizeLandscape[$properties['media']];
|
||||
} else {
|
||||
$media = $size[$aProperties['media']];
|
||||
$media = $size[$properties['media']];
|
||||
}
|
||||
$marginLeft = '15';
|
||||
if (isset($aProperties['margins']['left'])) {
|
||||
$marginLeft = $aProperties['margins']['left'];
|
||||
if (isset($properties['margins']['left'])) {
|
||||
$marginLeft = $properties['margins']['left'];
|
||||
}
|
||||
$marginRight = '15';
|
||||
if (isset($aProperties['margins']['right'])) {
|
||||
$marginRight = $aProperties['margins']['right'];
|
||||
if (isset($properties['margins']['right'])) {
|
||||
$marginRight = $properties['margins']['right'];
|
||||
}
|
||||
$marginTop = '15';
|
||||
if (isset($aProperties['margins']['top'])) {
|
||||
$marginTop = $aProperties['margins']['top'];
|
||||
if (isset($properties['margins']['top'])) {
|
||||
$marginTop = $properties['margins']['top'];
|
||||
}
|
||||
$marginBottom = '15';
|
||||
if (isset($aProperties['margins']['bottom'])) {
|
||||
$marginBottom = $aProperties['margins']['bottom'];
|
||||
if (isset($properties['margins']['bottom'])) {
|
||||
$marginBottom = $properties['margins']['bottom'];
|
||||
}
|
||||
fwrite($oFile, '<html xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
fwrite($fp, '<html xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
xmlns:w="urn:schemas-microsoft-com:office:word"
|
||||
xmlns="http://www.w3.org/TR/REC-html40">
|
||||
@@ -716,40 +730,40 @@ class OutputDocument
|
||||
</head>
|
||||
<body>
|
||||
<div class=WordSection1>');
|
||||
fwrite($oFile, $sContent);
|
||||
fwrite($oFile, "\n</div></body></html>\n\n");
|
||||
fclose($oFile);
|
||||
fwrite($fp, $content);
|
||||
fwrite($fp, "\n</div></body></html>\n\n");
|
||||
fclose($fp);
|
||||
/* End - Create .doc */
|
||||
if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') {
|
||||
$oFile = fopen($sPath . $sFilename . '.html', 'wb');
|
||||
fwrite($oFile, $sContent);
|
||||
fclose($oFile);
|
||||
if ($typeDocsToGen == 'BOTH' || $typeDocsToGen == 'PDF') {
|
||||
$fp = fopen($path . $filename . '.html', 'wb');
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
/* Start - Create .pdf */
|
||||
if (isset($aProperties['report_generator'])) {
|
||||
switch ($aProperties['report_generator']) {
|
||||
if (isset($properties['report_generator'])) {
|
||||
switch ($properties['report_generator']) {
|
||||
case 'TCPDF':
|
||||
$o = new \OutputDocument();
|
||||
if (strlen($sContent) == 0) {
|
||||
$o = new ClassesOutputDocument();
|
||||
if (strlen($content) == 0) {
|
||||
libxml_use_internal_errors(true);
|
||||
$o->generateTcpdf($sUID, $aFields, $sPath, $sFilename, ' ', $sLandscape, $aProperties);
|
||||
$o->generateTcpdf($outDocUid, $caseFields, $path, $filename, ' ', $landscape, $properties);
|
||||
libxml_use_internal_errors(false);
|
||||
} else {
|
||||
$o->generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
|
||||
$o->generateTcpdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
|
||||
}
|
||||
break;
|
||||
case 'HTML2PDF':
|
||||
default:
|
||||
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties, $sApplication);
|
||||
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties, $application);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
|
||||
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
|
||||
}
|
||||
}
|
||||
//end if $sTypeDocToGener
|
||||
//end if $typeDocsToGen
|
||||
/* End - Create .pdf */
|
||||
} else {
|
||||
return \PEAR::raiseError(
|
||||
return PEAR::raiseError(
|
||||
null,
|
||||
G_ERROR_USER_UID,
|
||||
null,
|
||||
|
||||
@@ -17,9 +17,9 @@ use ProcessMaker\Core\System;
|
||||
|
||||
class PushMessageAndroid
|
||||
{
|
||||
private $url = 'https://android.googleapis.com/gcm/send';
|
||||
private $serverApiKey = "AIzaSyBO-VLXGhjf0PPlwmPFTPQEKIBfVDydLAk";
|
||||
private $devices = array();
|
||||
private $url = 'https://fcm.googleapis.com/fcm/send';
|
||||
private $serverApiKey = "AAAAMvip2iU:APA91bHFAvHmCsSh0zbRaC9Xo2EPIbbRYzehkFAKUdXmj_ZVBOOO52npae183LYUONHjNPHaKo1MqT4BWiEuTF7HVEMfwn05XOA-h1LQ_bJ0ezAA35l-wADPq5VtKDiHT1VFGW1oeU7L";
|
||||
private $devices = [];
|
||||
private $numberDevices = 0;
|
||||
|
||||
/**
|
||||
@@ -78,24 +78,24 @@ class PushMessageAndroid
|
||||
}
|
||||
|
||||
if (!is_null($data)) {
|
||||
$fields = array(
|
||||
$fields = [
|
||||
'registration_ids' => $this->devices,
|
||||
'data' => array(
|
||||
"message" => $message,
|
||||
"data" => $data
|
||||
),
|
||||
);
|
||||
'notification' => [
|
||||
"body" => $message,
|
||||
"data" => $data,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$fields = array(
|
||||
$fields = [
|
||||
'registration_ids' => $this->devices,
|
||||
'data' => array("message" => $message),
|
||||
);
|
||||
'data' => ["message" => $message],
|
||||
];
|
||||
}
|
||||
|
||||
$headers = array(
|
||||
$headers = [
|
||||
'Authorization: key=' . $this->serverApiKey,
|
||||
'Content-Type: application/json'
|
||||
);
|
||||
];
|
||||
// Open connection
|
||||
$ch = curl_init();
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AppAssignSelfServiceValue extends Model
|
||||
{
|
||||
protected $table = 'APP_ASSIGN_SELF_SERVICE_VALUE';
|
||||
protected $primaryKey = 'ID';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AppAssignSelfServiceValueGroup extends Model
|
||||
{
|
||||
protected $table = 'APP_ASSIGN_SELF_SERVICE_VALUE_GROUP';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
||||
55
workflow/engine/src/ProcessMaker/Model/Application.php
Normal file
55
workflow/engine/src/ProcessMaker/Model/Application.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Application extends Model
|
||||
{
|
||||
protected $table = "APPLICATION";
|
||||
// No timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
public function delegations()
|
||||
{
|
||||
return $this->hasMany(Delegation::class, 'APP_UID', 'APP_UID');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->hasOne(Application::class, 'APP_PARENT', 'APP_UID');
|
||||
}
|
||||
|
||||
public function currentUser()
|
||||
{
|
||||
return $this->hasOne(User::class, 'APP_CUR_USER', 'USR_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Applications by PRO_UID, ordered by APP_NUMBER.
|
||||
* @param string $proUid
|
||||
* @return object
|
||||
* @see ReportTables->populateTable()
|
||||
*/
|
||||
public static function getByProUid($proUid)
|
||||
{
|
||||
$query = Application::query()
|
||||
->select()
|
||||
->proUid($proUid)
|
||||
->orderBy('APP_NUMBER', 'ASC');
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for query to get the applications by PRO_UID.
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $proUid
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProUid($query, $proUid)
|
||||
{
|
||||
$result = $query->where('PRO_UID', '=', $proUid);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
392
workflow/engine/src/ProcessMaker/Model/Delegation.php
Normal file
392
workflow/engine/src/ProcessMaker/Model/Delegation.php
Normal file
@@ -0,0 +1,392 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use G;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Delegation extends Model
|
||||
{
|
||||
protected $table = "APP_DELEGATION";
|
||||
|
||||
// We don't have our standard timestamp columns
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Returns the application this delegation belongs to
|
||||
*/
|
||||
public function application()
|
||||
{
|
||||
return $this->belongsTo(Application::class, 'APP_UID', 'APP_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user this delegation belongs to
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'USR_ID', 'USR_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the process task this belongs to
|
||||
*/
|
||||
public function task()
|
||||
{
|
||||
return $this->belongsTo(Task::class, 'TAS_ID', 'TAS_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the process this delegation belongs to
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
return $this->belongsTo(Process::class, 'PRO_ID', 'PRO_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the delegations from a case by APP_UID
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $appUid
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeAppUid($query, $appUid)
|
||||
{
|
||||
return $query->where('APP_UID', '=', $appUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for delegations which match certain criteria
|
||||
*
|
||||
* The query is related to advanced search with different filters
|
||||
* We can search by process, status of case, category of process, users, delegate date from and to
|
||||
*
|
||||
* @param integer $userId The USR_ID to search for (Note, this is no longer the USR_UID)
|
||||
* @param integer $start for the pagination
|
||||
* @param integer $limit for the pagination
|
||||
* @param string $search
|
||||
* @param integer $process the pro_id
|
||||
* @param integer $status of the case
|
||||
* @param string $dir if the order is DESC or ASC
|
||||
* @param string $sort name of column by sort, can be:
|
||||
* [APP_NUMBER, APP_TITLE, APP_PRO_TITLE, APP_TAS_TITLE, APP_CURRENT_USER, APP_UPDATE_DATE, DEL_DELEGATE_DATE, DEL_TASK_DUE_DATE, APP_STATUS_LABEL]
|
||||
* @param string $category uid for the process
|
||||
* @param date $dateFrom
|
||||
* @param date $dateTo
|
||||
* @param string $filterBy name of column for a specific search, can be: [APP_NUMBER, APP_TITLE, TAS_TITLE]
|
||||
* @return array $result result of the query
|
||||
*/
|
||||
|
||||
public static function search(
|
||||
$userId = null,
|
||||
// Default pagination values
|
||||
$start = 0,
|
||||
$limit = 25,
|
||||
$search = null,
|
||||
$process = null,
|
||||
$status = null,
|
||||
$dir = null,
|
||||
$sort = null,
|
||||
$category = null,
|
||||
$dateFrom = null,
|
||||
$dateTo = null,
|
||||
$filterBy = 'APP_TITLE'
|
||||
) {
|
||||
$search = trim($search);
|
||||
|
||||
// Start the query builder, selecting our base attributes
|
||||
$selectColumns = [
|
||||
'APPLICATION.APP_NUMBER',
|
||||
'APPLICATION.APP_UID',
|
||||
'APPLICATION.APP_STATUS',
|
||||
'APPLICATION.APP_STATUS AS APP_STATUS_LABEL',
|
||||
'APPLICATION.PRO_UID',
|
||||
'APPLICATION.APP_CREATE_DATE',
|
||||
'APPLICATION.APP_FINISH_DATE',
|
||||
'APPLICATION.APP_UPDATE_DATE',
|
||||
'APPLICATION.APP_TITLE',
|
||||
'APP_DELEGATION.USR_UID',
|
||||
'APP_DELEGATION.TAS_UID',
|
||||
'APP_DELEGATION.USR_ID',
|
||||
'APP_DELEGATION.PRO_ID',
|
||||
'APP_DELEGATION.DEL_INDEX',
|
||||
'APP_DELEGATION.DEL_LAST_INDEX',
|
||||
'APP_DELEGATION.DEL_DELEGATE_DATE',
|
||||
'APP_DELEGATION.DEL_INIT_DATE',
|
||||
'APP_DELEGATION.DEL_FINISH_DATE',
|
||||
'APP_DELEGATION.DEL_TASK_DUE_DATE',
|
||||
'APP_DELEGATION.DEL_RISK_DATE',
|
||||
'APP_DELEGATION.DEL_THREAD_STATUS',
|
||||
'APP_DELEGATION.DEL_PRIORITY',
|
||||
'APP_DELEGATION.DEL_DURATION',
|
||||
'APP_DELEGATION.DEL_QUEUE_DURATION',
|
||||
'APP_DELEGATION.DEL_STARTED',
|
||||
'APP_DELEGATION.DEL_DELAY_DURATION',
|
||||
'APP_DELEGATION.DEL_FINISHED',
|
||||
'APP_DELEGATION.DEL_DELAYED',
|
||||
'APP_DELEGATION.DEL_DELAY_DURATION',
|
||||
'TASK.TAS_TITLE AS APP_TAS_TITLE',
|
||||
'TASK.TAS_TYPE AS APP_TAS_TYPE',
|
||||
];
|
||||
$query = DB::table('APP_DELEGATION')->select(DB::raw(implode(',', $selectColumns)));
|
||||
|
||||
// Add join for task, filtering for task title if needed
|
||||
// It doesn't make sense for us to search for any delegations that match tasks that are events or web entry
|
||||
$query->join('TASK', function ($join) use ($filterBy, $search) {
|
||||
$join->on('APP_DELEGATION.TAS_ID', '=', 'TASK.TAS_ID')
|
||||
->whereNotIn('TASK.TAS_TYPE', [
|
||||
'WEBENTRYEVENT',
|
||||
'END-MESSAGE-EVENT',
|
||||
'START-MESSAGE-EVENT',
|
||||
'INTERMEDIATE-THROW',
|
||||
]);
|
||||
if ($filterBy == 'TAS_TITLE' && $search) {
|
||||
$join->where('TASK.TAS_TITLE', 'LIKE', "%${search}%");
|
||||
}
|
||||
});
|
||||
|
||||
// Add join for application, taking care of status and filtering if necessary
|
||||
$query->join('APPLICATION', function ($join) use ($filterBy, $search, $status, $query) {
|
||||
$join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER');
|
||||
if ($filterBy == 'APP_TITLE' && $search) {
|
||||
$join->where('APPLICATION.APP_TITLE', 'LIKE', "%${search}%");
|
||||
}
|
||||
// Based on the below, we can further limit the join so that we have a smaller data set based on join criteria
|
||||
switch ($status) {
|
||||
case 1: //DRAFT
|
||||
$join->where('APPLICATION.APP_STATUS_ID', 1);
|
||||
break;
|
||||
case 2: //TO_DO
|
||||
$join->where('APPLICATION.APP_STATUS_ID', 2);
|
||||
break;
|
||||
case 3: //COMPLETED
|
||||
$join->where('APPLICATION.APP_STATUS_ID', 3);
|
||||
break;
|
||||
case 4: //CANCELLED
|
||||
$join->where('APPLICATION.APP_STATUS_ID', 4);
|
||||
break;
|
||||
case "PAUSED":
|
||||
$join->where('APPLICATION.APP_STATUS', 'TO_DO');
|
||||
break;
|
||||
default: //All status
|
||||
// Don't do anything here, we'll need to do the more advanced where below
|
||||
}
|
||||
});
|
||||
|
||||
// Add join for process, but only for certain scenarios such as category or process
|
||||
if ($category || $process || $sort == 'APP_PRO_TITLE') {
|
||||
$query->join('PROCESS', function ($join) use ($category) {
|
||||
$join->on('APP_DELEGATION.PRO_ID', '=', 'PROCESS.PRO_ID');
|
||||
if ($category) {
|
||||
$join->where('PROCESS.PRO_CATEGORY', $category);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Add join for user, but only for certain scenarios as sorting
|
||||
if ($sort == 'APP_CURRENT_USER') {
|
||||
$query->join('USERS', function ($join) use ($userId) {
|
||||
$join->on('APP_DELEGATION.USR_ID', '=', 'USERS.USR_ID');
|
||||
});
|
||||
}
|
||||
|
||||
// Search for specified user
|
||||
if ($userId) {
|
||||
$query->where('APP_DELEGATION.USR_ID', $userId);
|
||||
}
|
||||
|
||||
// Search for specified process
|
||||
if ($process) {
|
||||
$query->where('APP_DELEGATION.PRO_ID', $process);
|
||||
}
|
||||
|
||||
// Search for an app/case number
|
||||
if ($filterBy == 'APP_NUMBER' && $search) {
|
||||
$query->where('APP_DELEGATION.APP_NUMBER', 'LIKE', "%${search}%");
|
||||
}
|
||||
|
||||
// Date range filter
|
||||
if (!empty($dateFrom)) {
|
||||
$query->where('APP_DELEGATION.DEL_DELEGATE_DATE', '>=', $dateFrom);
|
||||
}
|
||||
if (!empty($dateTo)) {
|
||||
$dateTo = $dateTo . " 23:59:59";
|
||||
// This is inclusive
|
||||
$query->where('APP_DELEGATION.DEL_DELEGATE_DATE', '<=', $dateTo);
|
||||
}
|
||||
|
||||
// Status Filter
|
||||
// This is tricky, the below behavior is combined with the application join behavior above
|
||||
switch ($status) {
|
||||
case 1: //DRAFT
|
||||
$query->where('APP_DELEGATION.DEL_THREAD_STATUS', 'OPEN');
|
||||
break;
|
||||
case 2: //TO_DO
|
||||
$query->where('APP_DELEGATION.DEL_THREAD_STATUS', 'OPEN');
|
||||
break;
|
||||
case 3: //COMPLETED
|
||||
$query->where('APP_DELEGATION.DEL_LAST_INDEX', 1);
|
||||
break;
|
||||
case 4: //CANCELLED
|
||||
$query->where('APP_DELEGATION.DEL_LAST_INDEX', 1);
|
||||
break;
|
||||
case "PAUSED":
|
||||
// Do nothing, as the app status check for TO_DO is performed in the join above
|
||||
break;
|
||||
default: //All statuses.
|
||||
$query->where(function ($query) {
|
||||
// Check to see if thread status is open
|
||||
$query->where('APP_DELEGATION.DEL_THREAD_STATUS', 'OPEN')
|
||||
->orWhere(function ($query) {
|
||||
// Or, we make sure if the thread is closed, and it's the last delegation, and if the app is completed or cancelled
|
||||
$query->where('APP_DELEGATION.DEL_THREAD_STATUS', 'CLOSED')
|
||||
->where('APP_DELEGATION.DEL_LAST_INDEX', 1)
|
||||
->whereIn('APPLICATION.APP_STATUS_ID', [3, 4]);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
// Add any sort if needed
|
||||
if($sort) {
|
||||
switch ($sort) {
|
||||
case 'APP_NUMBER':
|
||||
$query->orderBy('APP_DELEGATION.APP_NUMBER', $dir);
|
||||
break;
|
||||
case 'APP_PRO_TITLE':
|
||||
// We can do this because we joined the process table if sorting by it
|
||||
$query->orderBy('PROCESS.PRO_TITLE', $dir);
|
||||
break;
|
||||
case 'APP_TAS_TITLE':
|
||||
$query->orderBy('TASK.TAS_TITLE', $dir);
|
||||
break;
|
||||
case 'APP_CURRENT_USER':
|
||||
// We can do this because we joined the user table if sorting by it
|
||||
$query->orderBy('USERS.USR_LASTNAME', $dir);
|
||||
$query->orderBy('USERS.USR_FIRSTNAME', $dir);
|
||||
break;
|
||||
default:
|
||||
$query->orderBy($sort, $dir);
|
||||
}
|
||||
}
|
||||
|
||||
// Add pagination to the query
|
||||
$query = $query->offset($start)
|
||||
->limit($limit);
|
||||
|
||||
// Fetch results and transform to a laravel collection
|
||||
$results = $query->get();
|
||||
|
||||
// Transform with additional data
|
||||
$priorities = ['1' => 'VL', '2' => 'L', '3' => 'N', '4' => 'H', '5' => 'VH'];
|
||||
$results->transform(function ($item, $key) use ($priorities) {
|
||||
// Convert to an array as our results must be an array
|
||||
$item = json_decode(json_encode($item), true);
|
||||
// If it's assigned, fetch the user
|
||||
if($item['USR_ID']) {
|
||||
$user = User::where('USR_ID', $item['USR_ID'])->first();
|
||||
} else {
|
||||
$user = null;
|
||||
}
|
||||
$process = Process::where('PRO_ID', $item['PRO_ID'])->first();
|
||||
|
||||
// Rewrite priority string
|
||||
if ($item['DEL_PRIORITY']) {
|
||||
$item['DEL_PRIORITY'] = G::LoadTranslation("ID_PRIORITY_{$priorities[$item['DEL_PRIORITY']]}");
|
||||
}
|
||||
|
||||
// Merge in desired application data
|
||||
if ($item['APP_STATUS']) {
|
||||
$item['APP_STATUS_LABEL'] = G::LoadTranslation("ID_${item['APP_STATUS']}");
|
||||
} else {
|
||||
$item['APP_STATUS_LABEL'] = $item['APP_STATUS'];
|
||||
}
|
||||
|
||||
// Merge in desired process data
|
||||
// Handle situation where the process might not be in the system anymore
|
||||
$item['APP_PRO_TITLE'] = $process ? $process->PRO_TITLE : '';
|
||||
|
||||
// Merge in desired user data
|
||||
$item['USR_LASTNAME'] = $user ? $user->USR_LASTNAME : '';
|
||||
$item['USR_FIRSTNAME'] = $user ? $user->USR_FIRSTNAME : '';
|
||||
$item['USR_USERNAME'] = $user ? $user->USR_USERNAME : '';
|
||||
|
||||
//@todo: this section needs to use 'User Name Display Format', currently in the extJs is defined this
|
||||
$item["APP_CURRENT_USER"] = $item["USR_LASTNAME"] . ' ' . $item["USR_FIRSTNAME"];
|
||||
|
||||
$item["APPDELCR_APP_TAS_TITLE"] = '';
|
||||
|
||||
$item["USRCR_USR_UID"] = $item["USR_UID"];
|
||||
$item["USRCR_USR_FIRSTNAME"] = $item["USR_FIRSTNAME"];
|
||||
$item["USRCR_USR_LASTNAME"] = $item["USR_LASTNAME"];
|
||||
$item["USRCR_USR_USERNAME"] = $item["USR_USERNAME"];
|
||||
$item["APP_OVERDUE_PERCENTAGE"] = '';
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
// Remove any empty erroenous data
|
||||
$results = $results->filter();
|
||||
|
||||
// Bundle into response array
|
||||
$response = [
|
||||
// Fake totalCount to show pagination
|
||||
'totalCount' => $start + $limit + 1,
|
||||
'sql' => $query->toSql(),
|
||||
'bindings' => $query->getBindings(),
|
||||
'data' => $results->values()->toArray(),
|
||||
];
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participation information for a case
|
||||
*
|
||||
* @param string $appUid
|
||||
* @return array
|
||||
*
|
||||
* @see ProcessMaker\BusinessModel\Cases:getStatusInfo()
|
||||
*/
|
||||
public static function getParticipatedInfo($appUid)
|
||||
{
|
||||
// Build the query
|
||||
$query = Delegation::query()->select([
|
||||
'APP_UID',
|
||||
'DEL_INDEX',
|
||||
'PRO_UID'
|
||||
]);
|
||||
$query->appUid($appUid);
|
||||
$query->orderBy('DEL_INDEX', 'ASC');
|
||||
|
||||
// Fetch results
|
||||
$results = $query->get();
|
||||
|
||||
// Initialize the array to return
|
||||
$arrayData = [];
|
||||
|
||||
// If the collection have at least one item, build the main array to return
|
||||
if ($results->count() > 0) {
|
||||
// Get the first item
|
||||
$first = $results->first();
|
||||
|
||||
// Build the main array to return
|
||||
$arrayData = [
|
||||
'APP_STATUS' => 'PARTICIPATED', // Value hardcoded because we need to return the same structure previously sent
|
||||
'DEL_INDEX' => [], // Initialize this item like an array
|
||||
'PRO_UID' => $first->PRO_UID
|
||||
];
|
||||
|
||||
// Populate the DEL_INDEX key with the values of the items collected
|
||||
$results->each(function ($item) use (&$arrayData) {
|
||||
$arrayData['DEL_INDEX'][] = $item->DEL_INDEX;
|
||||
});
|
||||
}
|
||||
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
}
|
||||
64
workflow/engine/src/ProcessMaker/Model/Dynaform.php
Normal file
64
workflow/engine/src/ProcessMaker/Model/Dynaform.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Class Dynaform
|
||||
* @package ProcessMaker\Model
|
||||
*
|
||||
* Represents a dynaform object in the system.
|
||||
*/
|
||||
class Dynaform extends Model
|
||||
{
|
||||
protected $table = 'DYNAFORM';
|
||||
public $timestamps = false;
|
||||
|
||||
public function process()
|
||||
{
|
||||
return $this->belongsTo(Process::class, 'PRO_UID', 'PRO_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dynaforms by PRO_UID.
|
||||
* @param string $proUid
|
||||
* @return object
|
||||
*/
|
||||
public static function getByProUid($proUid)
|
||||
{
|
||||
return DB::table('DYNAFORM')
|
||||
->select()
|
||||
->where('DYNAFORM.PRO_UID', '=', $proUid)
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dynaform by DYN_UID.
|
||||
* @param string $dynUid
|
||||
* @return object
|
||||
*/
|
||||
public static function getByDynUid($dynUid)
|
||||
{
|
||||
return DB::table('DYNAFORM')
|
||||
->select()
|
||||
->where('DYNAFORM.DYN_UID', '=', $dynUid)
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dynaforms by PRO_UID except the DYN_UID specified in the second parameter.
|
||||
* @param string $proUid
|
||||
* @param string $dynUid
|
||||
* @return object
|
||||
*/
|
||||
public static function getByProUidExceptDynUid($proUid, $dynUid)
|
||||
{
|
||||
return DB::table('DYNAFORM')
|
||||
->select()
|
||||
->where('DYNAFORM.PRO_UID', '=', $proUid)
|
||||
->where('DYNAFORM.DYN_UID', '!=', $dynUid)
|
||||
->get();
|
||||
}
|
||||
}
|
||||
13
workflow/engine/src/ProcessMaker/Model/GroupUser.php
Normal file
13
workflow/engine/src/ProcessMaker/Model/GroupUser.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class GroupUser extends Model
|
||||
{
|
||||
protected $table = 'GROUP_USER';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
||||
14
workflow/engine/src/ProcessMaker/Model/Groupwf.php
Normal file
14
workflow/engine/src/ProcessMaker/Model/Groupwf.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Groupwf extends Model
|
||||
{
|
||||
protected $table = 'GROUPWF';
|
||||
protected $primaryKey = 'GRP_ID';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
||||
70
workflow/engine/src/ProcessMaker/Model/ListUnassigned.php
Normal file
70
workflow/engine/src/ProcessMaker/Model/ListUnassigned.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use ListUnassigned as PropelListUnassigned;
|
||||
|
||||
class ListUnassigned extends Model
|
||||
{
|
||||
protected $table = "LIST_UNASSIGNED";
|
||||
// No timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Returns the application this belongs to
|
||||
*/
|
||||
public function application()
|
||||
{
|
||||
return $this->belongsTo(Application::class, 'APP_UID', 'APP_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the process task this belongs to
|
||||
*/
|
||||
public function task()
|
||||
{
|
||||
return $this->belongsTo(Task::class, 'TAS_ID', 'TAS_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the process this belongs to
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
return $this->belongsTo(Process::class, 'PRO_ID', 'PRO_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get count
|
||||
*
|
||||
* @param string $userUid
|
||||
* @param array $filters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function doCount($userUid, $filters = [])
|
||||
{
|
||||
$list = new PropelListUnassigned();
|
||||
$result = $list->getCountList($userUid, $filters);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search data
|
||||
*
|
||||
* @param string $userUid
|
||||
* @param array $filters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function loadList($userUid, $filters = [])
|
||||
{
|
||||
$list = new PropelListUnassigned();
|
||||
$result = $list->loadList($userUid, $filters);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,29 @@ class Process extends Model
|
||||
{
|
||||
// Set our table name
|
||||
protected $table = 'PROCESS';
|
||||
// We do have a created at, but we don't store an updated at
|
||||
// Our custom timestamp columns
|
||||
const CREATED_AT = 'PRO_CREATE_DATE';
|
||||
const UPDATED_AT = null;
|
||||
const UPDATED_AT = 'PRO_UPDATE_DATE';
|
||||
/**
|
||||
* Retrieve all applications that belong to this process
|
||||
*/
|
||||
public function applications()
|
||||
{
|
||||
return $this->hasMany(Application::class, 'PRO_ID', 'PRO_ID');
|
||||
}
|
||||
|
||||
}
|
||||
public function tasks()
|
||||
{
|
||||
return $this->hasMany(Task::class, 'PRO_UID', 'PRO_UID');
|
||||
}
|
||||
|
||||
public function creator()
|
||||
{
|
||||
return $this->hasOne(User::class, 'PRO_CREATE_USER', 'USR_UID');
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->hasOne(ProcessCategory::class, 'PRO_CATEGORY', 'CATEGORY_UID');
|
||||
}
|
||||
}
|
||||
|
||||
19
workflow/engine/src/ProcessMaker/Model/ProcessCategory.php
Normal file
19
workflow/engine/src/ProcessMaker/Model/ProcessCategory.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class ProcessCategory
|
||||
* @package ProcessMaker\Model
|
||||
*
|
||||
* Represents a process category object in the system.
|
||||
*/
|
||||
class ProcessCategory extends Model
|
||||
{
|
||||
// Set our table name
|
||||
protected $table = 'PROCESS_CATEGORY';
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
||||
19
workflow/engine/src/ProcessMaker/Model/Route.php
Normal file
19
workflow/engine/src/ProcessMaker/Model/Route.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Process
|
||||
* @package ProcessMaker\Model
|
||||
*
|
||||
* Represents a business process object in the system.
|
||||
*/
|
||||
class Route extends Model
|
||||
{
|
||||
// Set our table name
|
||||
protected $table = 'ROUTE';
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
||||
23
workflow/engine/src/ProcessMaker/Model/Task.php
Normal file
23
workflow/engine/src/ProcessMaker/Model/Task.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Task extends Model
|
||||
{
|
||||
protected $table = 'TASK';
|
||||
protected $primaryKey = 'TAS_ID';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
|
||||
public function process()
|
||||
{
|
||||
return $this->belongsTo(Process::class, 'PRO_UID', 'PRO_UID');
|
||||
}
|
||||
|
||||
public function delegations()
|
||||
{
|
||||
return $this->hasMany(Delegation::class, 'TAS_ID', 'TAS_ID');
|
||||
}
|
||||
}
|
||||
12
workflow/engine/src/ProcessMaker/Model/TaskUser.php
Normal file
12
workflow/engine/src/ProcessMaker/Model/TaskUser.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TaskUser extends Model
|
||||
{
|
||||
protected $table = 'TASK_USER';
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
||||
21
workflow/engine/src/ProcessMaker/Model/User.php
Normal file
21
workflow/engine/src/ProcessMaker/Model/User.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
protected $table = "USERS";
|
||||
// Our custom timestamp columns
|
||||
const CREATED_AT = 'USR_CREATE_DATE';
|
||||
const UPDATED_AT = 'USR_UPDATE_DATE';
|
||||
|
||||
/**
|
||||
* Returns the delegations this user has (all of them)
|
||||
*/
|
||||
public function delegations()
|
||||
{
|
||||
return $this->hasMany(Delegation::class, 'USR_ID', 'USR_ID');
|
||||
}
|
||||
}
|
||||
@@ -485,6 +485,33 @@ function csrfToken()
|
||||
return isset($_SESSION['USR_CSRF_TOKEN']) ? $_SESSION['USR_CSRF_TOKEN'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is a valid HTML code
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @see G::replaceDataField()
|
||||
*/
|
||||
function stringIsValidHtml($string)
|
||||
{
|
||||
// To validate we use the DOMDocument class
|
||||
$doc = new DOMDocument('1.0', 'UTF-8');
|
||||
|
||||
// Clean previous errors
|
||||
libxml_clear_errors();
|
||||
|
||||
// This line have to be silenced because if the string is not an HTML a Warning is displayed
|
||||
@$doc->loadHTML($string);
|
||||
|
||||
// Get last error parsing the HTML
|
||||
$libXmlError = libxml_get_last_error();
|
||||
|
||||
// If the attribute "textContent" is empty or exists libxml errors, is not a valid HTML
|
||||
return $doc->textContent !== '' && empty($libXmlError);
|
||||
}
|
||||
|
||||
// Methods deleted in PHP 7.x, added in this file in order to keep compatibility with old libraries included/used in ProcessMaker
|
||||
if (!function_exists('set_magic_quotes_runtime')) {
|
||||
function set_magic_quotes_runtime($value) {
|
||||
|
||||
Reference in New Issue
Block a user