PMCORE-1176
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
parent
7eeda4ef57
commit
0d32551ca5
@@ -5,21 +5,21 @@ use Faker\Generator as Faker;
|
||||
$factory->define(\ProcessMaker\Model\Application::class, function(Faker $faker) {
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
$appNumber = $faker->unique()->numberBetween(1000);
|
||||
|
||||
// APP_TITLE field is used in 'MYSQL: MATCH() AGAINST()' function, string size should not be less than 3.
|
||||
$appTitle = $faker->lexify(str_repeat('?', rand(3, 5)) . ' ' . str_repeat('?', rand(3, 5)));
|
||||
|
||||
//APP_STATUS must start in TO_DO because all tests require this state.
|
||||
|
||||
return [
|
||||
'APP_UID' => G::generateUniqueID(),
|
||||
'APP_TITLE' => $appTitle,
|
||||
'APP_DESCRIPTION' => $faker->text,
|
||||
'APP_NUMBER' => $appNumber,
|
||||
'APP_STATUS' => 'TO_DO',
|
||||
'APP_STATUS_ID' => 2,
|
||||
'PRO_UID' => function() {
|
||||
return factory(\ProcessMaker\Model\Process::class)->create()->PRO_UID;
|
||||
},
|
||||
'APP_PROC_STATUS' => '',
|
||||
'APP_PROC_CODE' => '',
|
||||
'APP_PARALLEL' => 'N',
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID,
|
||||
@@ -41,15 +41,19 @@ $factory->state(\ProcessMaker\Model\Application::class, 'foreign_keys', function
|
||||
// APP_TITLE field is used in 'MYSQL: MATCH() AGAINST()' function, string size should not be less than 3.
|
||||
$appTitle = $faker->lexify(str_repeat('?', rand(3, 5)) . ' ' . str_repeat('?', rand(3, 5)));
|
||||
|
||||
//APP_STATUS must start in TO_DO because all tests require this state.
|
||||
$statuses = ['DRAFT', 'TO_DO', 'COMPLETED', 'CANCELLED'];
|
||||
$status = $faker->randomElement($statuses);
|
||||
$statusId = array_search($status, $statuses) + 1;
|
||||
|
||||
return [
|
||||
'APP_UID' => G::generateUniqueID(),
|
||||
'APP_TITLE' => $appTitle,
|
||||
'APP_NUMBER' => $appNumber,
|
||||
'APP_STATUS' => 'TO_DO',
|
||||
'APP_STATUS_ID' => 2,
|
||||
'APP_STATUS' => $status,
|
||||
'APP_STATUS_ID' => $statusId,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_PROC_STATUS' => '',
|
||||
'APP_PROC_CODE' => '',
|
||||
'APP_PARALLEL' => 'N',
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID,
|
||||
|
||||
@@ -18,3 +18,4 @@ $factory->define(\ProcessMaker\Model\BpmnProcess::class, function(Faker $faker)
|
||||
'PRO_IS_SUBPROCESS' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
@@ -3,17 +3,22 @@
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\BpmnProject::class, function (Faker $faker) {
|
||||
// Create user
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
// Create process
|
||||
$process = factory(\ProcessMaker\Model\Process::class)->create();
|
||||
|
||||
return [
|
||||
'PRJ_UID' => G::generateUniqueID(),
|
||||
'PRJ_NAME' => '',
|
||||
'PRJ_NAME' => $faker->sentence(5),
|
||||
'PRJ_DESCRIPTION' => $faker->text,
|
||||
'PRJ_EXPRESION_LANGUAGE' => '',
|
||||
'PRJ_TYPE_LANGUAGE' => '',
|
||||
'PRJ_EXPORTER' => '',
|
||||
'PRJ_EXPORTER_VERSION' => '',
|
||||
'PRJ_CREATE_DATE' => new \Carbon\Carbon(2030, 1, 1),
|
||||
'PRJ_UPDATE_DATE' => new \Carbon\Carbon(2030, 1, 1),
|
||||
'PRJ_AUTHOR' => '',
|
||||
'PRJ_CREATE_DATE' => $faker->dateTime(),
|
||||
'PRJ_UPDATE_DATE' => $faker->dateTime(),
|
||||
'PRJ_AUTHOR' => $user->USR_UID,
|
||||
'PRJ_AUTHOR_VERSION' => '',
|
||||
'PRJ_ORIGINAL_SOURCE' => '',
|
||||
];
|
||||
|
||||
@@ -5,20 +5,25 @@
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\Process::class, function(Faker $faker) {
|
||||
// Return with default values
|
||||
//The incremental fields of the tables must not be specified in the creation list.
|
||||
|
||||
return [
|
||||
'PRO_UID' => G::generateUniqueID(),
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1000),
|
||||
'PRO_TITLE' => $faker->sentence(3),
|
||||
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
||||
'PRO_CREATE_USER' => '00000000000000000000000000000001',
|
||||
'PRO_DYNAFORMS' => '',
|
||||
'PRO_ITEE' => 1,
|
||||
'PRO_PARENT' => G::generateUniqueID(),
|
||||
'PRO_STATUS' => 'ACTIVE',
|
||||
'PRO_STATUS_ID' => 1,
|
||||
'PRO_TYPE' => 'NORMAL',
|
||||
'PRO_ASSIGNMENT' => 'FALSE',
|
||||
'PRO_TYPE_PROCESS' => 'PUBLIC',
|
||||
'PRO_UPDATE_DATE' => $faker->dateTime(),
|
||||
'PRO_CREATE_DATE' => $faker->dateTime(),
|
||||
'PRO_CREATE_USER' => '00000000000000000000000000000001',
|
||||
'PRO_DEBUG' => 0,
|
||||
'PRO_DYNAFORMS' => serialize([]),
|
||||
'PRO_ITEE' => 1,
|
||||
'PRO_ACTION_DONE' => serialize([]),
|
||||
'PRO_CATEGORY' => function() {
|
||||
return factory(\ProcessMaker\Model\ProcessCategory::class)->create()->CATEGORY_UID;
|
||||
},
|
||||
@@ -27,44 +32,29 @@ $factory->define(\ProcessMaker\Model\Process::class, function(Faker $faker) {
|
||||
|
||||
// Create a process with the foreign keys
|
||||
$factory->state(\ProcessMaker\Model\Process::class, 'foreign_keys', function (Faker $faker) {
|
||||
// Create user
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
|
||||
return [
|
||||
'PRO_UID' => G::generateUniqueID(),
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1000),
|
||||
'PRO_TITLE' => $faker->sentence(3),
|
||||
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
||||
'PRO_CREATE_USER' => $user->USR_UID,
|
||||
'PRO_DYNAFORMS' => '',
|
||||
'PRO_ITEE' => 1,
|
||||
'PRO_PARENT' => G::generateUniqueID(),
|
||||
'PRO_STATUS' => 'ACTIVE',
|
||||
'PRO_STATUS_ID' => 1,
|
||||
'PRO_TYPE' => 'NORMAL',
|
||||
'PRO_ASSIGNMENT' => 'FALSE',
|
||||
'PRO_TYPE_PROCESS' => 'PUBLIC',
|
||||
'PRO_UPDATE_DATE' => $faker->dateTime(),
|
||||
'PRO_CREATE_DATE' => $faker->dateTime(),
|
||||
'PRO_CATEGORY' => '',
|
||||
];
|
||||
});
|
||||
|
||||
// Create a process related to the flow designer
|
||||
$factory->state(\ProcessMaker\Model\Process::class, 'flow', function (Faker $faker) {
|
||||
// Create values in the foreign key relations
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
$process = [
|
||||
'PRO_UID' => G::generateUniqueID(),
|
||||
'PRO_TITLE' => $faker->sentence(3),
|
||||
'PRO_DESCRIPTION' => $faker->paragraph(3),
|
||||
'PRO_CREATE_USER' => $user->USR_UID,
|
||||
'PRO_DYNAFORMS' => '',
|
||||
'PRO_DEBUG' => 0,
|
||||
'PRO_DYNAFORMS' => serialize([]),
|
||||
'PRO_ITEE' => 1,
|
||||
'PRO_STATUS' => 'ACTIVE',
|
||||
'PRO_STATUS_ID' => 1,
|
||||
'PRO_TYPE_PROCESS' => 'PUBLIC',
|
||||
'PRO_UPDATE_DATE' => $faker->dateTime(),
|
||||
'PRO_CREATE_DATE' => $faker->dateTime(),
|
||||
'PRO_CATEGORY' => '',
|
||||
'PRO_ACTION_DONE' => serialize([]),
|
||||
'PRO_CATEGORY' => function() {
|
||||
return factory(\ProcessMaker\Model\ProcessCategory::class)->create()->CATEGORY_UID;
|
||||
},
|
||||
];
|
||||
// Create a task related to this process
|
||||
$task = factory(\ProcessMaker\Model\Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -17,6 +17,15 @@ class ProcessTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Call the setUp parent method
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Process::query()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test belongs to PRO_ID
|
||||
*
|
||||
@@ -242,4 +251,92 @@ class ProcessTest extends TestCase
|
||||
// This asserts the process was converted from private to public
|
||||
$this->assertEquals('PUBLIC', $p[0]->PRO_TYPE_PROCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the process list
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Process::getProcessesFilter()
|
||||
* @covers \ProcessMaker\Model\Process::scopeNoStatus()
|
||||
* @covers \ProcessMaker\Model\Process::scopeSubProcess()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_process_without_filter()
|
||||
{
|
||||
$process = factory(Process::class)->create();
|
||||
$result = Process::getProcessesFilter(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$process->PRO_CREATE_USER
|
||||
);
|
||||
$this->assertEquals($process->PRO_CREATE_USER, $result[0]['USR_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the process list with specific category
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Process::getProcessesFilter()
|
||||
* @covers \ProcessMaker\Model\Process::scopeCategory()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_process_with_category_filter()
|
||||
{
|
||||
$process = factory(Process::class)->create([
|
||||
'PRO_CATEGORY' => function () {
|
||||
return factory(ProcessCategory::class)->create()->CATEGORY_UID;
|
||||
}
|
||||
]);
|
||||
$result = Process::getProcessesFilter(
|
||||
$process->PRO_CATEGORY
|
||||
);
|
||||
$this->assertEquals($process->PRO_CATEGORY, $result[0]['PRO_CATEGORY']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the process list with specific process
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Process::getProcessesFilter()
|
||||
* @covers \ProcessMaker\Model\Process::scopeProcess()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_process_with_process_filter()
|
||||
{
|
||||
$process = factory(Process::class)->create();
|
||||
$result = Process::getProcessesFilter(
|
||||
null,
|
||||
$process->PRO_UID
|
||||
);
|
||||
$this->assertEquals($process->PRO_UID, $result[0]['PRO_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the process list with specific process title
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Process::getProcessesFilter()
|
||||
* @covers \ProcessMaker\Model\Process::scopeTitle()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_process_with_title_filter()
|
||||
{
|
||||
$process = factory(Process::class)->create();
|
||||
$result = Process::getProcessesFilter(
|
||||
null,
|
||||
null,
|
||||
$process->PRO_TITLE
|
||||
);
|
||||
$this->assertEquals($process->PRO_TITLE, $result[0]['PRO_TITLE']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the count process
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Process::getCounter()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_count_process()
|
||||
{
|
||||
$process = factory(Process::class)->create();
|
||||
$total = Process::getCounter($process->PRO_CREATE_USER);
|
||||
$this->assertEquals(1, $total);
|
||||
}
|
||||
}
|
||||
@@ -22085,6 +22085,12 @@ msgstr "The report table '{0}' is related to a process not present in the worksp
|
||||
msgid "[LABEL/ID_PROCESS_NO_CATEGORY] No Category"
|
||||
msgstr "No Category"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_PROCESS_NONE_CATEGORY
|
||||
#: LABEL/ID_PROCESS_NONE_CATEGORY
|
||||
msgid "- No Category -"
|
||||
msgstr "- No Category -"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_PROCESS_NO_EXIST
|
||||
#: LABEL/ID_PROCESS_NO_EXIST
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use ProcessMaker\Model\ProcessCategory as ModelCategories;
|
||||
|
||||
class ProcessProxy extends HttpProxyController
|
||||
{
|
||||
|
||||
@@ -9,15 +11,29 @@ class ProcessProxy extends HttpProxyController
|
||||
$RBAC->allows(basename(__FILE__), $name);
|
||||
parent::call($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* get Process Categories List with defailt value (empty option) and -All- aoption
|
||||
* Get Categories list with default values
|
||||
*
|
||||
* @link https://wiki.processmaker.com/3.2/Processes#Designer_Menu
|
||||
*/
|
||||
public function categoriesList()
|
||||
{
|
||||
$data = $this->getCategoriesList();
|
||||
$defaultOption[] = Array ('CATEGORY_UID' => '<reset>','CATEGORY_NAME' => G::LoadTranslation( 'ID_ALL' ));
|
||||
$defaultOption = [];
|
||||
// Add the option All categories
|
||||
$defaultOption[] = [
|
||||
'CATEGORY_UID' => '',
|
||||
'CATEGORY_NAME' => G::LoadTranslation('ID_ALL')
|
||||
];
|
||||
// Add the option Without categories
|
||||
$defaultOption[] = [
|
||||
'CATEGORY_UID' => 'NONE',
|
||||
'CATEGORY_NAME' => G::LoadTranslation('ID_PROCESS_NO_CATEGORY')
|
||||
];
|
||||
|
||||
return array_merge( $defaultOption, $data );
|
||||
$listCategories = ModelCategories::getCategories();
|
||||
|
||||
return array_merge($defaultOption, $listCategories);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60577,6 +60577,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
||||
( 'LABEL','ID_PROCESS_NOCATEGORY','en','No Category','2014-01-15') ,
|
||||
( 'LABEL','ID_PROCESS_NOT_EXIST','en','The report table ''{0}'' is related to a process not present in the workspace, import the related process first. To relate the report table to other process, open the process in the designer and import from there. The report table can''t be imported.','2016-03-08') ,
|
||||
( 'LABEL','ID_PROCESS_NO_CATEGORY','en','No Category','2014-01-15') ,
|
||||
( 'LABEL','ID_PROCESS_NONE_CATEGORY','en','- No Category -','2020-10-23') ,
|
||||
( 'LABEL','ID_PROCESS_NO_EXIST','en','Process doesn''t exist!','2014-01-15') ,
|
||||
( 'LABEL','ID_PROCESS_PERMISSIONS','en','Process Permissions','2014-01-15') ,
|
||||
( 'LABEL','ID_PROCESS_PERMISSIONS_CREATE','en','Process Permission created successfully','2014-01-15') ,
|
||||
|
||||
@@ -1,63 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* processesList.php
|
||||
*
|
||||
* Get an overview information about the all the processes
|
||||
*
|
||||
* @link https://wiki.processmaker.com/3.2/Processes
|
||||
*/
|
||||
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Util\DateTime;
|
||||
|
||||
require_once 'classes/model/Process.php';
|
||||
|
||||
$start = isset($_POST['start']) ? $_POST['start'] : 0;
|
||||
$limit = isset($_POST['limit']) ? $_POST['limit'] : '';
|
||||
$limit = isset($_POST['limit']) ? $_POST['limit'] : 25;
|
||||
$dir = isset($_POST['dir']) ? $_POST['dir'] : 'ASC';
|
||||
$sort = isset($_POST['sort']) ? $_POST['sort'] : '';
|
||||
|
||||
$oProcess = new Process();
|
||||
$oProcess->dir = $dir;
|
||||
$oProcess->sort = $sort;
|
||||
|
||||
$memkey = 'no memcache';
|
||||
$memcacheUsed = 'not used';
|
||||
$sort = isset($_POST['sort']) ? $_POST['sort'] : 'PRO_CREATE_DATE';
|
||||
switch ($sort) {
|
||||
case 'PRO_DEBUG_LABEL':
|
||||
$sort = 'PRO_DEBUG';
|
||||
break;
|
||||
case 'PRO_CREATE_USER_LABEL':
|
||||
$sort = 'USR_UID';
|
||||
break;
|
||||
case 'PRO_STATUS_LABEL':
|
||||
$sort = 'PRO_STATUS';
|
||||
break;
|
||||
case 'PROJECT_TYPE':
|
||||
$sort = 'PRO_TYPE';
|
||||
break;
|
||||
case 'PRO_CATEGORY_LABEL':
|
||||
$sort = 'PRO_CATEGORY';
|
||||
break;
|
||||
default:
|
||||
// keep the sort value
|
||||
}
|
||||
$totalCount = 0;
|
||||
if (isset($_POST['category']) && $_POST['category'] !== '<reset>') {
|
||||
if (isset($_POST['processName'])) {
|
||||
$proData = $oProcess->getAllProcesses($start, $limit, $_POST['category'], $_POST['processName'], true, false, $_SESSION["USER_LOGGED"]);
|
||||
} else {
|
||||
$proData = $oProcess->getAllProcesses($start, $limit, $_POST['category'], null, true, false, $_SESSION["USER_LOGGED"]);
|
||||
}
|
||||
} else {
|
||||
if (isset($_POST['processName'])) {
|
||||
$memkey = 'processList-' . $start . '-' . $limit . '-' . $_POST['processName'];
|
||||
$memcacheUsed = 'yes';
|
||||
$proData = $memcache->get($memkey);
|
||||
if ($proData === false) {
|
||||
$proData = $oProcess->getAllProcesses($start, $limit, null, $_POST['processName'], true, false, $_SESSION["USER_LOGGED"]);
|
||||
$memcache->set($memkey, $proData, PMmemcached::ONE_HOUR);
|
||||
$totalCount = count($proData);
|
||||
$proData = array_splice($proData, $start, $limit);
|
||||
$memcacheUsed = 'no';
|
||||
} else {
|
||||
$proData = $oProcess->orderMemcache($proData, $start, $limit);
|
||||
$totalCount = $proData->totalCount;
|
||||
$proData = $proData->dataMemcache;
|
||||
}
|
||||
} else {
|
||||
$memkey = 'processList-allProcesses-' . $start . '-' . $limit;
|
||||
$memkeyTotal = $memkey . '-total';
|
||||
$memcacheUsed = 'yes';
|
||||
if (($proData = $memcache->get($memkey)) === false || ($totalCount = $memcache->get($memkeyTotal)) === false) {
|
||||
$proData = $oProcess->getAllProcesses($start, $limit, null, null, true, false, $_SESSION["USER_LOGGED"]);
|
||||
$totalCount = count($proData);
|
||||
$proData = array_splice($proData, $start, $limit);
|
||||
$memcache->set($memkey, $proData, PMmemcached::ONE_HOUR);
|
||||
$memcache->set($memkeyTotal, $totalCount, PMmemcached::ONE_HOUR);
|
||||
$memcacheUsed = 'no';
|
||||
} else {
|
||||
$proData = $oProcess->orderMemcache($proData, $start, $limit);
|
||||
$totalCount = $proData->totalCount;
|
||||
$proData = $proData->dataMemcache;
|
||||
}
|
||||
}
|
||||
}
|
||||
$r = new stdclass();
|
||||
$r->memkey = htmlspecialchars($memkey);
|
||||
$r->memcache = $memcacheUsed;
|
||||
$r->data = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($proData);
|
||||
$r->totalCount = $totalCount;
|
||||
|
||||
echo G::json_encode($r);
|
||||
// Get the category uid to search
|
||||
$catUid = !empty($_POST['category']) ? $_POST['category'] : null;
|
||||
|
||||
// Get the process name to search
|
||||
$process = !empty($_POST['processName']) ? $_POST['processName'] : null;
|
||||
$usrUid = $_SESSION["USER_LOGGED"];
|
||||
$proData = Process::getProcessesFilter(
|
||||
$catUid,
|
||||
null,
|
||||
$process,
|
||||
$usrUid,
|
||||
$start,
|
||||
$limit,
|
||||
$dir,
|
||||
$sort
|
||||
);
|
||||
|
||||
$response = new stdclass();
|
||||
$response->data = DateTime::convertUtcToTimeZone($proData);
|
||||
$response->totalCount = Process::getCounter($usrUid);
|
||||
|
||||
echo G::json_encode($response);
|
||||
|
||||
|
||||
@@ -28,6 +28,19 @@ class Application extends Model
|
||||
return $this->belongsTo(User::class, 'APP_INIT_USER', 'USR_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for query to get the positive cases
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopePositivesCases($query)
|
||||
{
|
||||
$result = $query->where('APP_NUMBER', '>', 0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for query to get the application by APP_UID.
|
||||
*
|
||||
@@ -42,6 +55,20 @@ class Application extends Model
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for query to get the application by status Id
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param integer $status
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeStatusId($query, int $status)
|
||||
{
|
||||
$result = $query->where('APP_STATUS_ID', '=', $status);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for query to get the applications by PRO_UID.
|
||||
*
|
||||
@@ -111,4 +138,24 @@ class Application extends Model
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Applications by PRO_UID, ordered by APP_NUMBER.
|
||||
*
|
||||
* @param string $proUid
|
||||
* @param int $status
|
||||
*
|
||||
* @return object
|
||||
* @see ReportTables->populateTable()
|
||||
*/
|
||||
public static function getCountByProUid(string $proUid, $status = 2)
|
||||
{
|
||||
$query = Application::query()
|
||||
->select()
|
||||
->proUid($proUid)
|
||||
->statusId($status)
|
||||
->positivesCases();
|
||||
|
||||
return $query->get()->count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,20 @@ class BpmnProject extends Model
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Check is the Process is BPMN.
|
||||
*
|
||||
* @param string $proUid
|
||||
*
|
||||
* @return int 1 if is BPMN process or 0 if a Normal process
|
||||
*/
|
||||
public static function isBpmnProcess(string $proUid)
|
||||
{
|
||||
$query = BpmnProject::query()
|
||||
->select()
|
||||
->where('PRJ_UID', '=', $proUid);
|
||||
$result = $query->get()->values()->toArray();
|
||||
|
||||
return empty($result) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Configurations;
|
||||
use Exception;
|
||||
use G;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use RbacUsers;
|
||||
use RBAC;
|
||||
|
||||
/**
|
||||
@@ -20,22 +22,164 @@ class Process extends Model
|
||||
// Our custom timestamp columns
|
||||
const CREATED_AT = 'PRO_CREATE_DATE';
|
||||
const UPDATED_AT = 'PRO_UPDATE_DATE';
|
||||
// Columns to see in the process list
|
||||
public $listColumns = [
|
||||
'PRO_UID',
|
||||
'PRO_TITLE',
|
||||
'PRO_DESCRIPTION',
|
||||
'PRO_PARENT',
|
||||
'PRO_STATUS',
|
||||
'PRO_TYPE',
|
||||
'PRO_CATEGORY',
|
||||
'PRO_UPDATE_DATE',
|
||||
'PRO_CREATE_DATE',
|
||||
'PRO_CREATE_USER',
|
||||
'PRO_DEBUG',
|
||||
'PRO_TYPE_PROCESS',
|
||||
'USR_UID',
|
||||
'USR_USERNAME',
|
||||
'USR_FIRSTNAME',
|
||||
'USR_LASTNAME',
|
||||
'CATEGORY_UID',
|
||||
'CATEGORY_NAME'
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the columns related to the process list
|
||||
* @return array
|
||||
*/
|
||||
public function getListColumns()
|
||||
{
|
||||
return $this->listColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the task related to the process belongs to
|
||||
*/
|
||||
public function tasks()
|
||||
{
|
||||
return $this->belongsTo(Task::class, 'PRO_ID', 'PRO_ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user creator belongs to
|
||||
*/
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'PRO_CREATE_USER', 'USR_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the category related to the process belongs to
|
||||
*/
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(ProcessCategory::class, 'PRO_CATEGORY', 'CATEGORY_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to specific process
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $proUid
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcess($query, $proUid)
|
||||
{
|
||||
return $query->where('PRO_UID', '=', $proUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to specific title
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $title
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeTitle($query, $title)
|
||||
{
|
||||
return $query->where('PRO_TITLE', 'LIKE', "%{$title}%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to exclude a specific status
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $status
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeNoStatus($query, $status = 'DISABLED')
|
||||
{
|
||||
return $query->where('PRO_STATUS', '!=', $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to include subprocess
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeSubProcess($query)
|
||||
{
|
||||
return $query->where('PRO_SUBPROCESS', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to include a specific process category
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $category
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCategory($query, $category)
|
||||
{
|
||||
return $query->where('PROCESS.PRO_CATEGORY', $category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to include the user owner or public process
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $userUid
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopePerUser($query, string $userUid)
|
||||
{
|
||||
$query->where(function ($query) use ($userUid) {
|
||||
$query->orWhere('PRO_CREATE_USER', $userUid);
|
||||
$query->orWhere('PRO_TYPE_PROCESS', 'PUBLIC');
|
||||
});
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to include the process related to the specific user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeJoinUsers($query)
|
||||
{
|
||||
$query->join('USERS', function ($join) {
|
||||
$join->on('PROCESS.PRO_CREATE_USER', '=', 'USERS.USR_UID');
|
||||
});
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to join with categories
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeJoinCategory($query)
|
||||
{
|
||||
$query->leftJoin('PROCESS_CATEGORY', function ($join) {
|
||||
$join->on('PROCESS.PRO_CATEGORY', '=', 'PROCESS_CATEGORY.CATEGORY_UID');
|
||||
});
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the process list for an specific user and/or for the specific category
|
||||
*
|
||||
@@ -93,4 +237,157 @@ class Process extends Model
|
||||
Process::where('PRO_CREATE_USER', $userUid)
|
||||
->update(['PRO_CREATE_USER' => $admin]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the process list applying some extra filters
|
||||
*
|
||||
* @param string $catUid
|
||||
* @param string $proUid
|
||||
* @param string $title
|
||||
* @param string $userUid
|
||||
* @param int $start
|
||||
* @param int $limit
|
||||
* @param string $dir
|
||||
* @param string $sort
|
||||
* @param boolean $counterByProcess
|
||||
* @param boolean $subProcess
|
||||
*
|
||||
* @return array
|
||||
* @throw Exception
|
||||
*/
|
||||
public static function getProcessesFilter(
|
||||
$catUid = null,
|
||||
$proUid = null,
|
||||
$title = null,
|
||||
$userUid = null,
|
||||
$start = 0,
|
||||
$limit = 25,
|
||||
$dir = 'ASC',
|
||||
$sort = 'PRO_CREATE_DATE',
|
||||
$counterByProcess = true,
|
||||
$subProcess = false
|
||||
) {
|
||||
$process = new Process();
|
||||
$rows = $process->getListColumns();
|
||||
if (!in_array($sort, $rows)) {
|
||||
throw new Exception('The column ' . $sort . ' does not exist');
|
||||
}
|
||||
// Select rows
|
||||
$query = Process::query()->select($rows)->noStatus();
|
||||
|
||||
// Join with users
|
||||
$query->joinUsers();
|
||||
|
||||
// Join with category
|
||||
$query->joinCategory();
|
||||
|
||||
// Check if the owner is the user logged or if the process is PUBLIC
|
||||
if (!empty($userUid)) {
|
||||
//Only process PRO_TYPE_PROCESS = "PUBLIC" or related user owner
|
||||
$query->perUser($userUid);
|
||||
}
|
||||
|
||||
// Check if we can list only the sub-process
|
||||
if ($subProcess) {
|
||||
$query->subProcess();
|
||||
}
|
||||
|
||||
// Specific process
|
||||
if ($proUid) {
|
||||
$query->process($proUid);
|
||||
}
|
||||
|
||||
// Specific process title
|
||||
if ($title) {
|
||||
$query->title($title);
|
||||
}
|
||||
|
||||
// Search a specific category
|
||||
if (!empty($catUid)) {
|
||||
if ($catUid == 'NONE') {
|
||||
// Processes without category
|
||||
$query->category('');
|
||||
} else {
|
||||
// Processes with the category $catUid
|
||||
$query->category($catUid);
|
||||
}
|
||||
}
|
||||
|
||||
// Order the data
|
||||
$query->orderBy($sort, $dir);
|
||||
|
||||
// Define the pagination
|
||||
$query->offset($start)->limit($limit);
|
||||
|
||||
// Get the results
|
||||
$results = $query->get();
|
||||
|
||||
// Define the class for get workspace configurations
|
||||
$systemConf = new Configurations();
|
||||
$systemConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
|
||||
$mask = isset($systemConf->aConfig['dateFormat']) ? $systemConf->aConfig['dateFormat'] : '';
|
||||
|
||||
// Prepare the final result
|
||||
$results->transform(function ($item, $key) use ($counterByProcess, $systemConf, $mask){
|
||||
// Get the counter related to the status
|
||||
// todo: those counters needs to remove when the PMCORE-2314 was implemented
|
||||
$item['CASES_COUNT_DRAFT'] = $counterByProcess ? Application::getCountByProUid($item['PRO_UID'], 1) : 0;
|
||||
$item['CASES_COUNT_TO_DO'] = $counterByProcess ? Application::getCountByProUid($item['PRO_UID'], 2) : 0;
|
||||
$item['CASES_COUNT_COMPLETED'] = $counterByProcess ? Application::getCountByProUid($item['PRO_UID'], 3) : 0;
|
||||
$item['CASES_COUNT_CANCELLED'] = $counterByProcess ? Application::getCountByProUid($item['PRO_UID'], 4) : 0;
|
||||
$item['CASES_COUNT'] = $item['CASES_COUNT_DRAFT'] + $item['CASES_COUNT_TO_DO'] + $item['CASES_COUNT_COMPLETED'] + $item['CASES_COUNT_CANCELLED'];
|
||||
|
||||
// Get the description
|
||||
// todo: we will to remove htmlspecialchars but frontEnd needs to add application wide XSS prevention measures
|
||||
$item['PRO_DESCRIPTION'] = empty($item['PRO_DESCRIPTION']) ? '' : htmlspecialchars($item['PRO_DESCRIPTION']);
|
||||
|
||||
// Get the type: bpmn or classic
|
||||
$bpmnProcess = BpmnProject::isBpmnProcess($item['PRO_UID']);
|
||||
$item['PROJECT_TYPE'] = ($bpmnProcess) ? 'bpmn' : 'classic';
|
||||
|
||||
// Get the process type: PUBLIC or PRIVATE
|
||||
$item['PRO_TYPE_PROCESS'] = ($item['PRO_TYPE_PROCESS'] == 'PUBLIC') ? G::LoadTranslation("ID_PUBLIC") : G::LoadTranslation("ID_PRIVATE");;
|
||||
|
||||
// Get information about the owner, with the format defined
|
||||
$creatorOwner = $systemConf->usersNameFormat($item['USR_USERNAME'], $item['USR_FIRSTNAME'], $item['USR_LASTNAME']);
|
||||
$item['PRO_CREATE_USER_LABEL'] = empty($creatorOwner) ? $item['USR_FIRSTNAME'] . ' ' . $item['USR_LASTNAME'] : $creatorOwner;
|
||||
|
||||
// Get debug label
|
||||
$item['PRO_DEBUG_LABEL'] = ($item['PRO_DEBUG'] == '1') ? G::LoadTranslation('ID_ON') : G::LoadTranslation('ID_OFF');
|
||||
|
||||
// Get status label
|
||||
$item['PRO_STATUS_LABEL'] = $item['PRO_STATUS'] == 'ACTIVE' ? G::LoadTranslation('ID_ACTIVE') : G::LoadTranslation('ID_INACTIVE');
|
||||
|
||||
// Get category label
|
||||
$item['PRO_CATEGORY_LABEL'] = trim($item['PRO_CATEGORY']) != '' ? $item['CATEGORY_NAME'] : G::LoadTranslation('ID_PROCESS_NONE_CATEGORY');
|
||||
|
||||
// Apply the date format defined in environment
|
||||
if (!empty($mask)) {
|
||||
$item['PRO_CREATE_DATE_LABEL'] = $item['PRO_CREATE_DATE']->format($mask);
|
||||
$item['PRO_UPDATE_DATE_LABEL'] = $item['PRO_UPDATE_DATE']->format($mask);
|
||||
}
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
return $results->values()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of rows corresponding to the process
|
||||
*
|
||||
* @param string $userUid
|
||||
* @return integer
|
||||
*/
|
||||
public static function getCounter($userUid = '')
|
||||
{
|
||||
$query = Process::query()->select();
|
||||
$query->noStatus();
|
||||
if (!empty($userUid)) {
|
||||
//Only process PRO_TYPE_PROCESS = "PUBLIC" or related user owner
|
||||
$query->perUser($userUid);
|
||||
}
|
||||
|
||||
return $query->count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,26 @@ class ProcessCategory extends Model
|
||||
protected $table = 'PROCESS_CATEGORY';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the categories
|
||||
*
|
||||
* @param string $dir
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @see ProcessProxy::categoriesList()
|
||||
* @link https://wiki.processmaker.com/3.0/Process_Categories
|
||||
*/
|
||||
public static function getCategories( $dir = 'ASC')
|
||||
{
|
||||
$query = ProcessCategory::query()
|
||||
->select([
|
||||
'CATEGORY_UID',
|
||||
'CATEGORY_NAME'
|
||||
])
|
||||
->orderBy('CATEGORY_NAME', $dir);
|
||||
|
||||
return $query->get()->values()->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,6 @@ Ext.onReady(function(){
|
||||
Ext.QuickTips.init();
|
||||
|
||||
store = new Ext.data.GroupingStore( {
|
||||
//var store = new Ext.data.Store( {
|
||||
remoteSort: true,
|
||||
proxy : new Ext.data.HttpProxy({
|
||||
url: 'processesList'
|
||||
@@ -168,9 +167,6 @@ Ext.onReady(function(){
|
||||
]
|
||||
}),
|
||||
|
||||
//sortInfo:{field: 'PRO_TITLE', direction: "ASC"}
|
||||
//groupField:'PRO_CATEGORY_LABEL'
|
||||
|
||||
listeners: {
|
||||
load: function (store) {
|
||||
Ext.ComponentMgr.get("export").setDisabled(true);
|
||||
@@ -225,44 +221,6 @@ Ext.onReady(function(){
|
||||
store.load({params: {category: filter, start: 0, limit: 25}});
|
||||
}}
|
||||
})
|
||||
/* storePageSize = new Ext.data.SimpleStore({
|
||||
fields: ['size'],
|
||||
data: [['20'],['30'],['40'],['50'],['100']],
|
||||
autoLoad: true
|
||||
});
|
||||
|
||||
var comboPageSize = new Ext.form.ComboBox({
|
||||
typeAhead : false,
|
||||
mode : 'local',
|
||||
triggerAction : 'all',
|
||||
store: storePageSize,
|
||||
valueField: 'size',
|
||||
displayField: 'size',
|
||||
width: 50,
|
||||
editable: false,
|
||||
listeners:{
|
||||
select: function(c,d,i){
|
||||
//UpdatePageConfig(d.data['size']);
|
||||
bbar.pageSize = parseInt(d.data['size']);
|
||||
bbar.moveFirst();
|
||||
|
||||
//Ext.getCmp('bbar').setPageSize(comboPageSize.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
comboPageSize.setValue(pageSize);
|
||||
|
||||
|
||||
var bbar = new Ext.PagingToolbar({
|
||||
id: 'bbar',
|
||||
pageSize: '15',
|
||||
store: store,
|
||||
displayInfo: true,
|
||||
displayMsg: 'Displaying Processes {0} - {1} of {2}',
|
||||
emptyMsg: "",
|
||||
items:[_('ID_PAGE_SIZE')+':',comboPageSize]
|
||||
}) */
|
||||
|
||||
var mnuNewBpmnProject = {
|
||||
text: _("ID_NEW_BPMN_PROJECT"),
|
||||
@@ -453,11 +411,11 @@ Ext.onReady(function(){
|
||||
}}
|
||||
,{header: _('ID_OWNER'), dataIndex: 'PRO_CREATE_USER_LABEL', width: 90}
|
||||
,{header: _('ID_PRO_CREATE_DATE'), dataIndex: 'PRO_CREATE_DATE', width: 90}
|
||||
,{header: _('ID_INBOX'), dataIndex: 'CASES_COUNT_TO_DO', width: 50, align:'right'}
|
||||
,{header: _('ID_DRAFT'), dataIndex: 'CASES_COUNT_DRAFT', width: 50, align:'right'}
|
||||
,{header: _('ID_COMPLETED'), dataIndex: 'CASES_COUNT_COMPLETED', width: 50, align:'right'}
|
||||
,{header: _('ID_CANCELLED'), dataIndex: 'CASES_COUNT_CANCELLED', width: 50, align:'right'}
|
||||
,{header: _('ID_TOTAL_CASES'), dataIndex: 'CASES_COUNT', width: 70, renderer:function(v){return "<b>"+v+"</b>";}, align:'right'}
|
||||
,{header: _('ID_INBOX'), dataIndex: 'CASES_COUNT_TO_DO', width: 50, align:'right', sortable: false}
|
||||
,{header: _('ID_DRAFT'), dataIndex: 'CASES_COUNT_DRAFT', width: 50, align:'right', sortable: false}
|
||||
,{header: _('ID_COMPLETED'), dataIndex: 'CASES_COUNT_COMPLETED', width: 50, align:'right', sortable: false}
|
||||
,{header: _('ID_CANCELLED'), dataIndex: 'CASES_COUNT_CANCELLED', width: 50, align:'right', sortable: false}
|
||||
,{header: _('ID_TOTAL_CASES'), dataIndex: 'CASES_COUNT', width: 70, renderer:function(v){return "<b>"+v+"</b>";}, align:'right', sortable: false}
|
||||
,{header: _('ID_PRO_DEBUG'), dataIndex: 'PRO_DEBUG_LABEL', width: 30}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
,{header: _("ID_TYPE_PROCESS"), dataIndex: "PRO_TYPE_PROCESS", width: 70}
|
||||
@@ -468,25 +426,14 @@ Ext.onReady(function(){
|
||||
sm: proSelModel,
|
||||
store: store,
|
||||
tbar:[
|
||||
newTypeProcess,/*
|
||||
{
|
||||
text: _('ID_NEW'),
|
||||
iconCls: 'button_menu_ext ss_sprite ss_add',
|
||||
//icon: '/images/addc.png',
|
||||
handler: newProcess
|
||||
},*/
|
||||
newTypeProcess,
|
||||
'-'
|
||||
,{
|
||||
text: _('ID_EDIT'),
|
||||
iconCls: 'button_menu_ext',
|
||||
icon: '/images/pencil.png',
|
||||
handler: editProcess
|
||||
},/*{
|
||||
text: 'Edit (New Editor)',
|
||||
iconCls: 'button_menu_ext',
|
||||
icon: '/images/pencil_beta.png',
|
||||
handler: editNewProcess
|
||||
},*/{
|
||||
},{
|
||||
text: _('ID_STATUS'),
|
||||
id:'activator',
|
||||
icon: '',
|
||||
@@ -541,12 +488,9 @@ Ext.onReady(function(){
|
||||
text:'X',
|
||||
ctCls:'pm_search_x_button_des',
|
||||
handler: function(){
|
||||
//store.setBaseParam( 'category', '<reset>');
|
||||
store.setBaseParam('processName', '');
|
||||
store.load({params: {start: 0, limit: 25}});
|
||||
Ext.getCmp('searchTxt').setValue('');
|
||||
//comboCategory.setValue('');
|
||||
//store.reload();
|
||||
}
|
||||
},{
|
||||
text: _('ID_SEARCH'),
|
||||
@@ -882,8 +826,6 @@ function saveProcess()
|
||||
}
|
||||
|
||||
function doSearch() {
|
||||
if(comboCategory.getValue() == '')
|
||||
store.setBaseParam( 'category', '<reset>');
|
||||
filter = Ext.getCmp('searchTxt').getValue();
|
||||
store.setBaseParam('processName', filter);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user