-
-
-
+
+
+ {{ props["headings"][props.column] }} :
+
+
+
+
@@ -183,6 +221,7 @@ import VueListView from "../../components/dataViews/vueListView/VueListView.vue"
import defaultMixins from "./defaultMixins";
import ModalPauseCase from '../modal/ModalPauseCase.vue';
import { Event } from 'vue-tables-2';
+import CurrentUserCell from "../../components/vuetable/CurrentUserCell.vue";
export default {
name: "Unassigned",
@@ -199,6 +238,7 @@ export default {
VueCardView,
VueListView,
ModalPauseCase,
+ CurrentUserCell,
},
props: ["defaultOption", "settings"],
data() {
@@ -242,6 +282,7 @@ export default {
case_title: this.$i18n.t("ID_CASE_TITLE"),
process_name: this.$i18n.t("ID_PROCESS_NAME"),
task: this.$i18n.t("ID_TASK"),
+ send_by: this.$i18n.t("ID_SEND_BY"),
due_date: this.$i18n.t("ID_DUE_DATE"),
delegation_date: this.$i18n.t("ID_DELEGATION_DATE"),
priority: this.$i18n.t("ID_PRIORITY"),
@@ -440,6 +481,7 @@ export default {
this.$i18n.t("ID_DELAYED") + ":" : this.statusTitle[v.TAS_STATUS],
DELAYED_MSG: v.TAS_STATUS === "OVERDUE" ? v.DELAY : ""
}],
+ USER_DATA: this.formatUser(v.SEND_BY_INFO),
DUE_DATE: v.DEL_TASK_DUE_DATE_LABEL,
DELEGATION_DATE: v.DEL_DELEGATE_DATE_LABEL,
PRIORITY: v.DEL_PRIORITY_LABEL,
@@ -451,6 +493,30 @@ export default {
});
return data;
},
+ /**
+ * Set the format to show user's information
+ * @return {array} dataFormat
+ */
+ formatUser(data) {
+ var dataFormat = [],
+ userDataFormat;
+ userDataFormat = utils.userNameDisplayFormat({
+ userName: data.user_tooltip.usr_firstname,
+ firstName: data.user_tooltip.usr_lastname,
+ lastName: data.user_tooltip.usr_username,
+ format: window.config.FORMATS.format || null
+ });
+ dataFormat.push({
+ USERNAME_DISPLAY_FORMAT: userDataFormat,
+ EMAIL: data.user_tooltip.usr_email,
+ POSITION: data.user_tooltip.usr_position,
+ AVATAR: userDataFormat !== "" ? window.config.SYS_SERVER_AJAX +
+ window.config.SYS_URI +
+ `users/users_ViewPhotoGrid?pUID=${data.user_tooltip.usr_id}` : "",
+ UNASSIGNED: userDataFormat !== "" ? true : false
+ });
+ return dataFormat;
+ },
/**
* Claim case
*
diff --git a/resources/assets/js/home/Unassigned/defaultMixins.js b/resources/assets/js/home/Unassigned/defaultMixins.js
index 0c29c1abe..cdfc5873d 100644
--- a/resources/assets/js/home/Unassigned/defaultMixins.js
+++ b/resources/assets/js/home/Unassigned/defaultMixins.js
@@ -39,25 +39,25 @@ export default {
this.openCase(item);
},
headings: {
- detail: "",
case_number: this.$i18n.t("ID_MYCASE_NUMBER"),
case_title: this.$i18n.t("ID_CASE_TITLE"),
process_name: this.$i18n.t("ID_PROCESS_NAME"),
task: this.$i18n.t("ID_TASK"),
+ send_by: this.$i18n.t("ID_SEND_BY"),
current_user: this.$i18n.t("ID_CURRENT_USER"),
due_date: this.$i18n.t("ID_DUE_DATE"),
delegation_date: this.$i18n.t("ID_DELEGATION_DATE"),
priority: this.$i18n.t("ID_PRIORITY")
},
columns: [
- "detail",
"case_number",
"case_title",
"process_name",
"due_date",
"delegation_date",
"priority",
- "task"
+ "task",
+ "send_by",
],
requestFunction(data) {
return that.getCases(data);
diff --git a/tests/unit/workflow/engine/methods/emailServer/EmailServerAjaxTest.php b/tests/unit/workflow/engine/methods/emailServer/EmailServerAjaxTest.php
index abfb01505..1613fc400 100644
--- a/tests/unit/workflow/engine/methods/emailServer/EmailServerAjaxTest.php
+++ b/tests/unit/workflow/engine/methods/emailServer/EmailServerAjaxTest.php
@@ -90,7 +90,7 @@ class EmailServerAjaxTest extends TestCase
$content = $this->requireOnceForEmailServerAjax();
$data = json_decode($content, JSON_OBJECT_AS_ARRAY);
- $this->assertContains(200, $data);
+ $this->assertContains(500, $data);
}
/**
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php
index 41238d060..8b60300ab 100644
--- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php
+++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php
@@ -5,7 +5,9 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Draft;
+use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\Application;
+use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\User;
@@ -354,6 +356,7 @@ class DraftTest extends TestCase
* It tests the getCountersByProcesses() method with the category filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCountersByProcesses()
+ * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_category()
@@ -643,6 +646,7 @@ class DraftTest extends TestCase
* It tests the getCountersByRange() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCountersByRange()
+ * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_range_method()
@@ -717,4 +721,49 @@ class DraftTest extends TestCase
$res = $draft->getCountersByRange(null, '2021-05-20', '2021-05-22');
$this->assertCount(3, $res);
}
+
+ /**
+ * This tests the getCustomListCount() method.
+ * @covers \ProcessMaker\BusinessModel\Cases\Draft::getCustomListCount()
+ * @test
+ */
+ public function it_should_test_getCustomListCount_method()
+ {
+ $cases = $this->createManyDraft(3);
+
+ $additionalTables = factory(AdditionalTables::class)->create();
+ $query = ""
+ . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
+ . "`APP_UID` varchar(32) NOT NULL,"
+ . "`APP_NUMBER` int(11) NOT NULL,"
+ . "`APP_STATUS` varchar(10) NOT NULL,"
+ . "`VAR1` varchar(255) DEFAULT NULL,"
+ . "`VAR2` varchar(255) DEFAULT NULL,"
+ . "`VAR3` varchar(255) DEFAULT NULL,"
+ . "PRIMARY KEY (`APP_UID`),"
+ . "KEY `indexTable` (`APP_UID`))";
+ DB::statement($query);
+
+ $caseList = factory(CaseList::class)->create([
+ 'CAL_TYPE' => 'draft',
+ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
+ 'USR_ID' => $cases->USR_ID
+ ]);
+
+ $draft = new Draft();
+ $draft->setUserId($cases->USR_ID);
+ $draft->setUserUid($cases->USR_UID);
+
+ $res = $draft->getCustomListCount($caseList->CAL_ID, 'draft');
+
+ //assertions
+ $this->assertArrayHasKey('label', $res);
+ $this->assertArrayHasKey('name', $res);
+ $this->assertArrayHasKey('description', $res);
+ $this->assertArrayHasKey('tableName', $res);
+ $this->assertArrayHasKey('total', $res);
+
+ $this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
+ $this->assertEquals(3, $res['total']);
+ }
}
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php
index d606af43c..84fe7cd68 100644
--- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php
+++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php
@@ -5,7 +5,9 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Inbox;
+use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\Application;
+use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
@@ -199,6 +201,7 @@ class InboxTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
+ * @covers \ProcessMaker\Model\Delegation::scopeTask()
* @test
*/
public function it_filter_by_task()
@@ -611,4 +614,49 @@ class InboxTest extends TestCase
$res = $inbox->getCountersByRange(null, '2021-05-20', '2021-05-23');
$this->assertCount(1, $res);
}
+
+ /**
+ * This tests the getCustomListCount() method.
+ * @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCustomListCount()
+ * @test
+ */
+ public function it_should_test_getCustomListCounts_method()
+ {
+ $cases = $this->createMultipleInbox(3);
+
+ $additionalTables = factory(AdditionalTables::class)->create();
+ $query = ""
+ . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
+ . "`APP_UID` varchar(32) NOT NULL,"
+ . "`APP_NUMBER` int(11) NOT NULL,"
+ . "`APP_STATUS` varchar(10) NOT NULL,"
+ . "`VAR1` varchar(255) DEFAULT NULL,"
+ . "`VAR2` varchar(255) DEFAULT NULL,"
+ . "`VAR3` varchar(255) DEFAULT NULL,"
+ . "PRIMARY KEY (`APP_UID`),"
+ . "KEY `indexTable` (`APP_UID`))";
+ DB::statement($query);
+
+ $caseList = factory(CaseList::class)->create([
+ 'CAL_TYPE' => 'inbox',
+ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
+ 'USR_ID' => $cases->USR_ID
+ ]);
+
+ $inbox = new Inbox();
+ $inbox->setUserId($cases->USR_ID);
+ $inbox->setUserUid($cases->USR_UID);
+
+ $res = $inbox->getCustomListCount($caseList->CAL_ID, 'inbox');
+
+ //assertions
+ $this->assertArrayHasKey('label', $res);
+ $this->assertArrayHasKey('name', $res);
+ $this->assertArrayHasKey('description', $res);
+ $this->assertArrayHasKey('tableName', $res);
+ $this->assertArrayHasKey('total', $res);
+
+ $this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
+ $this->assertEquals(3, $res['total']);
+ }
}
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php
index 4db7f0ef9..a4f00b49c 100644
--- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php
+++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php
@@ -5,6 +5,7 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Participated;
+use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
@@ -26,7 +27,7 @@ class ParticipatedTest extends TestCase
}
/**
- * Create participated cases factories
+ * Create participated cases factories when the case is TO_DO
*
* @param string
*
@@ -37,8 +38,9 @@ class ParticipatedTest extends TestCase
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_INDEX' => 1,
+ 'DEL_LAST_INDEX' => 0,
]);
- $delegation2 = factory(Delegation::class)->states('last_thread')->create([
+ $delegation = factory(Delegation::class)->states('last_thread')->create([
'APP_NUMBER' => $delegation->APP_NUMBER,
'TAS_ID' => $delegation->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
@@ -46,9 +48,41 @@ class ParticipatedTest extends TestCase
'USR_ID' => $delegation->USR_ID,
'PRO_ID' => $delegation->PRO_ID,
'DEL_INDEX' => 2,
+ 'DEL_LAST_INDEX' => 1,
]);
- return $delegation2;
+ return $delegation;
+ }
+
+ /**
+ * Create participated cases factories when the case is COMPLETED
+ *
+ * @param string
+ *
+ * @return array
+ */
+ public function createParticipatedCompleted()
+ {
+ $application = factory(Application::class)->states('completed')->create();
+ $delegation = factory(Delegation::class)->states('first_thread')->create([
+ 'APP_NUMBER' => $application->APP_NUMBER,
+ 'APP_UID' => $application->APP_UID,
+ 'DEL_THREAD_STATUS' => 'CLOSED',
+ 'DEL_INDEX' => 1,
+ 'DEL_LAST_INDEX' => 0,
+ ]);
+ $delegation = factory(Delegation::class)->states('last_thread')->create([
+ 'APP_NUMBER' => $application->APP_NUMBER,
+ 'APP_UID' => $application->APP_UID,
+ 'DEL_THREAD_STATUS' => 'CLOSED',
+ 'USR_UID' => $delegation->USR_UID,
+ 'USR_ID' => $delegation->USR_ID,
+ 'PRO_ID' => $delegation->PRO_ID,
+ 'DEL_INDEX' => 2,
+ 'DEL_LAST_INDEX' => 1,
+ ]);
+
+ return $delegation;
}
/**
@@ -67,6 +101,7 @@ class ParticipatedTest extends TestCase
'DEL_INDEX' => 1,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
+ 'DEL_LAST_INDEX' => 0,
]);
factory(Delegation::class)->states('last_thread')->create([
'APP_UID' => $delegation->APP_UID,
@@ -77,6 +112,7 @@ class ParticipatedTest extends TestCase
'USR_ID' => $delegation->USR_ID,
'PRO_ID' => $delegation->PRO_ID,
'DEL_INDEX' => 2,
+ 'DEL_LAST_INDEX' => 1,
]);
}
return $user;
@@ -105,9 +141,9 @@ class ParticipatedTest extends TestCase
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_NUMBER');
// Get the data
- $res = $participated->getData();
- // This assert that the expected numbers of results are returned
- $this->assertEquals(2, count($res));
+ $result = $participated->getData();
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -137,9 +173,9 @@ class ParticipatedTest extends TestCase
// Set the filter STARTED
$participated->setParticipatedStatus('STARTED');
// Get the data
- $res = $participated->getData();
- // This assert that the expected numbers of results are returned
- $this->assertEquals(1, count($res));
+ $result = $participated->getData();
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -156,7 +192,7 @@ class ParticipatedTest extends TestCase
public function it_filter_by_completed_by_me()
{
// Create factories related to the participated cases
- $cases = $this->createParticipated();
+ $cases = $this->createParticipatedCompleted();
// Create new Participated object
$participated = new Participated();
// Set the user UID
@@ -166,9 +202,9 @@ class ParticipatedTest extends TestCase
// Set the filter COMPLETED
$participated->setParticipatedStatus('COMPLETED');
// Get the data
- $res = $participated->getData();
- // This assert that the expected numbers of results are returned
- $this->assertEquals(0, count($res));
+ $result = $participated->getData();
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -198,9 +234,9 @@ class ParticipatedTest extends TestCase
// Set the process
$participated->setProcessId($cases['PRO_ID']);
// Get the data
- $res = $participated->getData();
- // This assert that the expected numbers of results are returned
- $this->assertEquals(2, count($res));
+ $result = $participated->getData();
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -227,9 +263,9 @@ class ParticipatedTest extends TestCase
// Set the case numbers
$participated->setCasesNumbers([$cases['APP_NUMBER']]);
// Get the data
- $res = $participated->getData();
- // This assert that the expected numbers of results are returned
- $this->assertEquals(2, count($res));
+ $result = $participated->getData();
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -257,9 +293,9 @@ class ParticipatedTest extends TestCase
$rangeOfCases = $cases['APP_NUMBER'] . "-" . $cases['APP_NUMBER'];
$participated->setRangeCasesFromTo([$rangeOfCases]);
// Get the data
- $res = $participated->getData();
- // This assert that the expected numbers of results are returned
- $this->assertEquals(2, count($res));
+ $result = $participated->getData();
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -291,9 +327,9 @@ class ParticipatedTest extends TestCase
// Set the title
$participated->setCaseTitle($cases->DEL_TITLE);
// Get the data
- $res = $participated->getData();
- // Asserts
- $this->assertCount(1, $res);
+ $result = $participated->getData();
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -324,7 +360,7 @@ class ParticipatedTest extends TestCase
$participated->setCaseStatus('TO_DO');
// Get the data
$result = $participated->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertNotEmpty($result);
}
@@ -359,7 +395,7 @@ class ParticipatedTest extends TestCase
$participated->setStartCaseTo($date);
// Get the data
$result = $participated->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertEmpty($result);
}
@@ -394,7 +430,7 @@ class ParticipatedTest extends TestCase
$participated->setFinishCaseTo($date);
// Get the data
$result = $participated->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertEmpty($result);
}
@@ -419,11 +455,39 @@ class ParticipatedTest extends TestCase
$participated->setUserId($cases->USR_ID);
// Set participated status
$participated->setParticipatedStatus('IN_PROGRESS');
- // Get result
+ // Get the data
$result = $participated->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertNotEmpty($result);
}
+
+ /**
+ * It tests the specific filter setParticipatedStatus = STARTED
+ *
+ * @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
+ * @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
+ * @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
+ * @covers \ProcessMaker\BusinessModel\Cases\Participated::setParticipatedStatus()
+ * @test
+ */
+ public function it_get_status_started()
+ {
+ // Create factories related to the participated cases
+ $cases = $this->createParticipated();
+ // Create new Participated object
+ $participated = new Participated();
+ // Set the user UID
+ $participated->setUserUid($cases->USR_UID);
+ // Set the user ID
+ $participated->setUserId($cases->USR_ID);
+ // Set participated status
+ $participated->setParticipatedStatus('STARTED');
+ // Get the data
+ $result = $participated->getData();
+ // Asserts with the result
+ $this->assertNotEmpty($result);
+ }
+
/**
* It tests the specific filter setParticipatedStatus = COMPLETED
*
@@ -436,7 +500,7 @@ class ParticipatedTest extends TestCase
public function it_get_status_completed()
{
// Create factories related to the participated cases
- $cases = $this->createParticipated();
+ $cases = $this->createParticipatedCompleted();
// Create new Participated object
$participated = new Participated();
// Set the user UID
@@ -445,10 +509,10 @@ class ParticipatedTest extends TestCase
$participated->setUserId($cases->USR_ID);
// Set participated status
$participated->setParticipatedStatus('COMPLETED');
- // Get result
+ // Get the data
$result = $participated->getData();
- // This assert that the expected numbers of results are returned
- $this->assertEmpty($result);
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -460,7 +524,22 @@ class ParticipatedTest extends TestCase
*/
public function it_get_counter()
{
- // Create factories related to the participated cases
+ // Create factories related to the in started cases
+ $cases = $this->createParticipated();
+ // Create new Participated object
+ $participated = new Participated();
+ // Set the user UID
+ $participated->setUserUid($cases->USR_UID);
+ // Set the user ID
+ $participated->setUserId($cases->USR_ID);
+ // Set participated status
+ $participated->setParticipatedStatus('STARTED');
+ // Get the data
+ $result = $participated->getCounter();
+ // Asserts with the result
+ $this->assertTrue($result > 0);
+
+ // Create factories related to the in progress cases
$cases = $this->createParticipated();
// Create new Participated object
$participated = new Participated();
@@ -470,10 +549,25 @@ class ParticipatedTest extends TestCase
$participated->setUserId($cases->USR_ID);
// Set participated status
$participated->setParticipatedStatus('IN_PROGRESS');
- // Get result
- $res = $participated->getCounter();
- // Assert the result of getCounter method
- $this->assertEquals(1, $res);
+ // Get the data
+ $result = $participated->getCounter();
+ // Asserts with the result
+ $this->assertTrue($result > 0);
+
+ // Create factories related to the complete cases
+ $cases = $this->createParticipatedCompleted();
+ // Create new Participated object
+ $participated = new Participated();
+ // Set the user UID
+ $participated->setUserUid($cases->USR_UID);
+ // Set the user ID
+ $participated->setUserId($cases->USR_ID);
+ // Set participated status
+ $participated->setParticipatedStatus('COMPLETED');
+ // Get the data
+ $result = $participated->getCounter();
+ // Asserts with the result
+ $this->assertTrue($result > 0);
}
/**
@@ -485,20 +579,40 @@ class ParticipatedTest extends TestCase
*/
public function it_should_test_get_paging_counters_method()
{
- $cases = $this->createMultipleParticipated(3);
+ // Create factories related to the in started cases
+ $cases = $this->createParticipated();
$participated = new Participated();
$participated->setUserId($cases->USR_ID);
$participated->setUserUid($cases->USR_UID);
+ $participated->setCaseUid($cases->APP_UID);
$participated->setParticipatedStatus('STARTED');
- $res = $participated->getPagingCounters();
- $this->assertEquals(3, $res);
+ // Get the data
+ $result = $participated->getPagingCounters();
+ // Asserts with the result
+ $this->assertTrue($result >= 0);
- $delegation = Delegation::select()->where('USR_ID', $cases->USR_ID)->first();
- $participated->setCaseNumber($delegation->APP_NUMBER);
- $participated->setProcessId($delegation->PRO_ID);
- $participated->setTaskId($delegation->TAS_ID);
- $participated->setCaseUid($delegation->APP_UID);
- $res = $participated->getPagingCounters();
- $this->assertEquals(1, $res);
+ // Create factories related to the in progress cases
+ $cases = $this->createParticipated();
+ $participated = new Participated();
+ $participated->setUserId($cases->USR_ID);
+ $participated->setUserUid($cases->USR_UID);
+ $participated->setCaseUid($cases->APP_UID);
+ $participated->setParticipatedStatus('IN_PROGRESS');
+ // Get the data
+ $result = $participated->getPagingCounters();
+ // Asserts with the result
+ $this->assertTrue($result >= 0);
+
+ // Create factories related to the complete cases
+ $cases = $this->createParticipatedCompleted();
+ $participated = new Participated();
+ $participated->setUserId($cases->USR_ID);
+ $participated->setUserUid($cases->USR_UID);
+ $participated->setCaseUid($cases->APP_UID);
+ $participated->setParticipatedStatus('COMPLETED');
+ // Get the data
+ $result = $participated->getPagingCounters();
+ // Asserts with the result
+ $this->assertTrue($result >= 0);
}
}
\ No newline at end of file
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php
index 85873a905..65f05310c 100644
--- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php
+++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php
@@ -5,8 +5,10 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Paused;
+use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\AppDelay;
+use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
@@ -606,4 +608,49 @@ class PausedTest extends TestCase
$res = $paused->getCountersByRange(null, '2021-05-20', '2021-05-23');
$this->assertCount(1, $res);
}
+
+ /**
+ * This tests the getCustomListCount() method.
+ * @covers \ProcessMaker\BusinessModel\Cases\Paused::getCustomListCount()
+ * @test
+ */
+ public function it_should_test_getCustomListCounts_method()
+ {
+ $cases = $this->createMultiplePaused(3);
+
+ $additionalTables = factory(AdditionalTables::class)->create();
+ $query = ""
+ . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
+ . "`APP_UID` varchar(32) NOT NULL,"
+ . "`APP_NUMBER` int(11) NOT NULL,"
+ . "`APP_STATUS` varchar(10) NOT NULL,"
+ . "`VAR1` varchar(255) DEFAULT NULL,"
+ . "`VAR2` varchar(255) DEFAULT NULL,"
+ . "`VAR3` varchar(255) DEFAULT NULL,"
+ . "PRIMARY KEY (`APP_UID`),"
+ . "KEY `indexTable` (`APP_UID`))";
+ DB::statement($query);
+
+ $caseList = factory(CaseList::class)->create([
+ 'CAL_TYPE' => 'paused',
+ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
+ 'USR_ID' => $cases->USR_ID
+ ]);
+
+ $paused = new Paused();
+ $paused->setUserId($cases->USR_ID);
+ $paused->setUserUid($cases->USR_UID);
+
+ $res = $paused->getCustomListCount($caseList->CAL_ID, 'paused');
+
+ //assertions
+ $this->assertArrayHasKey('label', $res);
+ $this->assertArrayHasKey('name', $res);
+ $this->assertArrayHasKey('description', $res);
+ $this->assertArrayHasKey('tableName', $res);
+ $this->assertArrayHasKey('total', $res);
+
+ $this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
+ $this->assertEquals(3, $res['total']);
+ }
}
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php
index 4f32d0d4a..010ddebef 100644
--- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php
+++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php
@@ -56,7 +56,7 @@ class SearchTest extends TestCase
// Create new Search object
$search = new Search();
$result = $search->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertNotEmpty($result);
}
@@ -67,7 +67,6 @@ class SearchTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setCaseNumber()
- * @covers \ProcessMaker\BusinessModel\Cases\Search::setOrderByColumn()
* @test
*/
public function it_filter_by_app_number()
@@ -77,10 +76,8 @@ class SearchTest extends TestCase
// Create new Search object
$search = new Search();
$search->setCaseNumber($cases[0]->APP_NUMBER);
- // Set order by column value
- $search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertEquals($cases[0]->APP_NUMBER, $result[0]['APP_NUMBER']);
}
@@ -101,7 +98,7 @@ class SearchTest extends TestCase
$search = new Search();
$search->setCasesNumbers([$cases[0]->APP_NUMBER]);
$result = $search->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertEquals($cases[0]->APP_NUMBER, $result[0]['APP_NUMBER']);
}
@@ -123,7 +120,31 @@ class SearchTest extends TestCase
$rangeOfCases = $cases[0]->APP_NUMBER . "-" . $cases[0]->APP_NUMBER;
$search->setRangeCasesFromTo([$rangeOfCases]);
$result = $search->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
+ $this->assertNotEmpty($result);
+ }
+
+ /**
+ * Tests the specific filter setCasesNumbers and setRangeCasesFromTo
+ *
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::setCasesNumbers()
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::setRangeCasesFromTo()
+ * @test
+ */
+ public function it_filter_by_cases_and_range_cases()
+ {
+ // Create factories related to the delegation cases
+ $cases = $this->createSearch();
+ // Create new Search object
+ $search = new Search();
+ $search->setCasesNumbers([$cases[0]->APP_NUMBER]);
+ $rangeOfCases = $cases[0]->APP_NUMBER . "-" . $cases[0]->APP_NUMBER;
+ $search->setRangeCasesFromTo([$rangeOfCases]);
+ $result = $search->getData();
+ // Asserts with the result
$this->assertNotEmpty($result);
}
@@ -144,7 +165,7 @@ class SearchTest extends TestCase
$search = new Search();
$search->setProcessId($cases[0]->PRO_ID);
$result = $search->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertNotEmpty($result);
}
@@ -165,7 +186,7 @@ class SearchTest extends TestCase
$search = new Search();
$search->setTaskId($cases[0]->TAS_ID);
$result = $search->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertNotEmpty($result);
}
@@ -195,6 +216,27 @@ class SearchTest extends TestCase
$this->assertNotEmpty($res);
}
+ /**
+ * It tests the getData with setCategoryId
+ *
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::setCategoryId()
+ * @test
+ */
+ public function it_filter_by_category()
+ {
+ // Create factories related to the delegation cases
+ $cases = $this->createSearch();
+ // Create new Search object
+ $search = new Search();
+ $search->setCategoryId(12);
+ $result = $search->getData();
+ // Asserts with the result
+ $this->assertEmpty($result);
+ }
+
/**
* It tests the getData with user
*
@@ -212,12 +254,12 @@ class SearchTest extends TestCase
$search = new Search();
$search->setUserId($cases[0]->USR_ID);
$result = $search->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertNotEmpty($result);
}
/**
- * It tests the getData with user
+ * It tests the getData with setStartCaseFrom and setStartCaseTo
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
@@ -236,7 +278,31 @@ class SearchTest extends TestCase
$search->setStartCaseFrom($date);
$search->setStartCaseTo($date);
$result = $search->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
+ $this->assertEmpty($result);
+ }
+
+ /**
+ * It tests the getData with setFinishCaseFrom and setFinishCaseTo
+ *
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::setFinishCaseFrom()
+ * @covers \ProcessMaker\BusinessModel\Cases\Search::setFinishCaseTo()
+ * @test
+ */
+ public function it_filter_by_finish_date()
+ {
+ // Create factories related to the delegation cases
+ $cases = $this->createSearch();
+ // Create new Search object
+ $search = new Search();
+ $date = date('Y-m-d');
+ $search->setFinishCaseFrom($date);
+ $search->setFinishCaseTo($date);
+ $result = $search->getData();
+ // Asserts with the result
$this->assertEmpty($result);
}
@@ -257,7 +323,7 @@ class SearchTest extends TestCase
$search = new Search();
$search->setCaseStatuses(['TO_DO']);
$result = $search->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertNotEmpty($result);
}
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php
index 1a75830ae..250f9570b 100644
--- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php
+++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php
@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Supervising;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
+use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessUser;
use ProcessMaker\Model\Task;
@@ -30,19 +31,26 @@ class SupervisingTest extends TestCase
/**
* Create supervising cases factories
+ * This function define a specific user in the supervisors list
*
- * @param string
+ * @param int $cases
*
* @return array
*/
- public function createSupervising()
+ public function createSupervising(int $cases = 2)
{
// Create process
$process = factory(Process::class)->create();
-
// Create user
$user = factory(User::class)->create();
-
+ // Define this user like process supervisor
+ factory(ProcessUser::class)->create(
+ [
+ 'PRO_UID' => $process->PRO_UID,
+ 'USR_UID' => $user->USR_UID,
+ 'PU_TYPE' => 'SUPERVISOR'
+ ]
+ );
// Create a task
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'NORMAL',
@@ -54,246 +62,112 @@ class SupervisingTest extends TestCase
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
-
- // Create 3 cases
- $app1 = factory(Application::class)->states('todo')->create([
- 'APP_STATUS' => 'TO_DO',
- 'APP_STATUS_ID' => 2,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_INIT_USER' => $user->USR_UID,
- 'APP_CUR_USER' => $user->USR_UID,
- ]);
- $app2 = factory(Application::class)->states('todo')->create([
- 'APP_STATUS' => 'TO_DO',
- 'APP_STATUS_ID' => 2,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_INIT_USER' => $user->USR_UID,
- 'APP_CUR_USER' => $user->USR_UID,
- ]);
- $app3 = factory(Application::class)->states('todo')->create([
- 'APP_STATUS' => 'TO_DO',
- 'APP_STATUS_ID' => 2,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_INIT_USER' => $user->USR_UID,
- 'APP_CUR_USER' => $user->USR_UID,
- ]);
-
- // Create the registers in delegation
- factory(Delegation::class)->create([
- "APP_UID" => $app1['APP_UID'],
- 'TAS_ID' => $task->TAS_ID,
- 'TAS_UID' => $task->TAS_UID,
- 'DEL_THREAD_STATUS' => 'CLOSED',
- 'USR_UID' => $user->USR_UID,
- 'USR_ID' => $user->USR_ID,
- 'PRO_ID' => $process->PRO_ID,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app1['APP_NUMBER'],
- 'DEL_INDEX' => 1,
- 'DEL_PREVIOUS' => 0
- ]);
- factory(Delegation::class, 1)->create([
- "APP_UID" => $app1['APP_UID'],
- 'TAS_ID' => $task2->TAS_ID,
- 'TAS_UID' => $task2->TAS_UID,
- 'DEL_THREAD_STATUS' => 'OPEN',
- 'USR_UID' => $user->USR_UID,
- 'USR_ID' => $user->USR_ID,
- 'PRO_ID' => $process->PRO_ID,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app1['APP_NUMBER'],
- 'DEL_INDEX' => 2,
- 'DEL_PREVIOUS' => 1
- ]);
-
- factory(Delegation::class, 1)->create([
- "APP_UID" => $app2['APP_UID'],
- 'TAS_ID' => $task->TAS_ID,
- 'TAS_UID' => $task->TAS_UID,
- 'DEL_THREAD_STATUS' => 'CLOSED',
- 'USR_UID' => $user->USR_UID,
- 'USR_ID' => $user->USR_ID,
- 'PRO_ID' => $process->PRO_ID,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app2['APP_NUMBER'],
- 'DEL_INDEX' => 1,
- 'DEL_PREVIOUS' => 0
- ]);
- factory(Delegation::class, 1)->create([
- "APP_UID" => $app2['APP_UID'],
- 'TAS_ID' => $task2->TAS_ID,
- 'TAS_UID' => $task2->TAS_UID,
- 'DEL_THREAD_STATUS' => 'OPEN',
- 'USR_UID' => $user->USR_UID,
- 'USR_ID' => $user->USR_ID,
- 'PRO_ID' => $process->PRO_ID,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app2['APP_NUMBER'],
- 'DEL_INDEX' => 2,
- 'DEL_PREVIOUS' => 1
- ]);
-
- factory(Delegation::class, 1)->create([
- "APP_UID" => $app3['APP_UID'],
- 'TAS_ID' => $task->TAS_ID,
- 'TAS_UID' => $task->TAS_UID,
- 'DEL_THREAD_STATUS' => 'CLOSED',
- 'USR_UID' => $user->USR_UID,
- 'USR_ID' => $user->USR_ID,
- 'PRO_ID' => $process->PRO_ID,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app3['APP_NUMBER'],
- 'DEL_INDEX' => 1,
- 'DEL_PREVIOUS' => 0
- ]);
- $delegation = factory(Delegation::class)->create([
- "APP_UID" => $app3['APP_UID'],
- 'TAS_ID' => $task2->TAS_ID,
- 'TAS_UID' => $task2->TAS_UID,
- 'DEL_THREAD_STATUS' => 'OPEN',
- 'USR_UID' => $user->USR_UID,
- 'USR_ID' => $user->USR_ID,
- 'PRO_ID' => $process->PRO_ID,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app3['APP_NUMBER'],
- 'DEL_INDEX' => 2,
- 'DEL_PREVIOUS' => 1
- ]);
-
- // Create the register in the ProcessUser table
- factory(ProcessUser::class)->create(
- [
+ // Create n cases related to the process
+ $delegation = [];
+ for ($i = 0; $i < $cases; $i = $i + 1) {
+ // Create case
+ $app = factory(Application::class)->states('todo')->create([
'PRO_UID' => $process->PRO_UID,
+ 'APP_INIT_USER' => $user->USR_UID,
+ 'APP_CUR_USER' => $user->USR_UID,
+ ]);
+ // Create two threads
+ $delegation = factory(Delegation::class)->create([
+ 'APP_UID' => $app['APP_UID'],
+ 'TAS_ID' => $task->TAS_ID,
+ 'TAS_UID' => $task->TAS_UID,
+ 'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
- 'PU_TYPE' => 'SUPERVISOR'
- ]
- );
+ 'USR_ID' => $user->USR_ID,
+ 'PRO_ID' => $process->PRO_ID,
+ 'PRO_UID' => $process->PRO_UID,
+ 'APP_NUMBER' => $app['APP_NUMBER'],
+ 'DEL_INDEX' => 1,
+ 'DEL_PREVIOUS' => 0,
+ 'DEL_LAST_INDEX' => 0
+ ]);
+ $delegation = factory(Delegation::class)->create([
+ 'APP_UID' => $app['APP_UID'],
+ 'TAS_ID' => $task2->TAS_ID,
+ 'TAS_UID' => $task2->TAS_UID,
+ 'DEL_THREAD_STATUS' => 'OPEN',
+ 'USR_UID' => $user->USR_UID,
+ 'USR_ID' => $user->USR_ID,
+ 'PRO_ID' => $process->PRO_ID,
+ 'PRO_UID' => $process->PRO_UID,
+ 'APP_NUMBER' => $app['APP_NUMBER'],
+ 'DEL_INDEX' => 2,
+ 'DEL_PREVIOUS' => 1,
+ 'DEL_LAST_INDEX' => 1
+ ]);
+ }
return $delegation;
}
/**
- * Create many supervising cases for one user
- *
- * @param int
- * @return object
+ * Create supervising cases factories
+ * This function define a group user in the supervisors list
+ *
+ * @param int $cases
+ *
+ * @return array
*/
- public function createMultipleSupervising($cases)
+ public function createGroupSupervising(int $cases = 2)
{
- $user = factory(\ProcessMaker\Model\User::class)->create();
-
+ // Create process
+ $process = factory(Process::class)->create();
+ // Create user
+ $user = factory(User::class)->create();
+ // Create group
+ $group = factory(GroupUser::class)->create([
+ 'USR_UID' => $user->USR_UID,
+ ]);
+ // Define this group like process supervisor
+ factory(ProcessUser::class)->create(
+ [
+ 'PRO_UID' => $process->PRO_UID,
+ 'USR_UID' => $group->GRP_UID,
+ 'PU_TYPE' => 'GROUP_SUPERVISOR'
+ ]
+ );
+ // Create a task
+ $task = factory(Task::class)->create([
+ 'TAS_ASSIGN_TYPE' => 'NORMAL',
+ 'TAS_GROUP_VARIABLE' => '',
+ 'PRO_UID' => $process->PRO_UID,
+ ]);
+ $task2 = factory(Task::class)->create([
+ 'TAS_ASSIGN_TYPE' => 'NORMAL',
+ 'TAS_GROUP_VARIABLE' => '',
+ 'PRO_UID' => $process->PRO_UID,
+ ]);
+ // Create n cases related to the process
+ $delegation = [];
for ($i = 0; $i < $cases; $i = $i + 1) {
- // Create process
- $process = factory(Process::class)->create();
-
- // Create user
- $user = factory(User::class)->create();
-
- // Create a task
- $task = factory(Task::class)->create([
- 'TAS_ASSIGN_TYPE' => 'NORMAL',
- 'TAS_GROUP_VARIABLE' => '',
- 'PRO_UID' => $process->PRO_UID,
- ]);
- $task2 = factory(Task::class)->create([
- 'TAS_ASSIGN_TYPE' => 'NORMAL',
- 'TAS_GROUP_VARIABLE' => '',
- 'PRO_UID' => $process->PRO_UID,
- ]);
-
- // Create 3 cases
- $app1 = factory(Application::class)->states('todo')->create([
- 'APP_STATUS' => 'TO_DO',
- 'APP_STATUS_ID' => 2,
+ // Create case
+ $app = factory(Application::class)->states('todo')->create([
'PRO_UID' => $process->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
- $app2 = factory(Application::class)->states('todo')->create([
- 'APP_STATUS' => 'TO_DO',
- 'APP_STATUS_ID' => 2,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_INIT_USER' => $user->USR_UID,
- 'APP_CUR_USER' => $user->USR_UID,
- ]);
- $app3 = factory(Application::class)->states('todo')->create([
- 'APP_STATUS' => 'TO_DO',
- 'APP_STATUS_ID' => 2,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_INIT_USER' => $user->USR_UID,
- 'APP_CUR_USER' => $user->USR_UID,
- ]);
-
- // Create the registers in delegation
- factory(Delegation::class)->create([
- "APP_UID" => $app1['APP_UID'],
+ // Create two threads
+ $delegation = factory(Delegation::class)->create([
+ 'APP_UID' => $app['APP_UID'],
'TAS_ID' => $task->TAS_ID,
'TAS_UID' => $task->TAS_UID,
- 'DEL_THREAD_STATUS' => 'CLOSED',
- 'USR_UID' => $user->USR_UID,
- 'USR_ID' => $user->USR_ID,
- 'PRO_ID' => $process->PRO_ID,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app1['APP_NUMBER'],
- 'DEL_INDEX' => 1,
- 'DEL_PREVIOUS' => 0
- ]);
- factory(Delegation::class, 1)->create([
- "APP_UID" => $app1['APP_UID'],
- 'TAS_ID' => $task2->TAS_ID,
- 'TAS_UID' => $task2->TAS_UID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app1['APP_NUMBER'],
- 'DEL_INDEX' => 2,
- 'DEL_PREVIOUS' => 1
- ]);
-
- factory(Delegation::class, 1)->create([
- "APP_UID" => $app2['APP_UID'],
- 'TAS_ID' => $task->TAS_ID,
- 'TAS_UID' => $task->TAS_UID,
- 'DEL_THREAD_STATUS' => 'CLOSED',
- 'USR_UID' => $user->USR_UID,
- 'USR_ID' => $user->USR_ID,
- 'PRO_ID' => $process->PRO_ID,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app2['APP_NUMBER'],
+ 'APP_NUMBER' => $app['APP_NUMBER'],
'DEL_INDEX' => 1,
- 'DEL_PREVIOUS' => 0
- ]);
- factory(Delegation::class, 1)->create([
- "APP_UID" => $app2['APP_UID'],
- 'TAS_ID' => $task2->TAS_ID,
- 'TAS_UID' => $task2->TAS_UID,
- 'DEL_THREAD_STATUS' => 'OPEN',
- 'USR_UID' => $user->USR_UID,
- 'USR_ID' => $user->USR_ID,
- 'PRO_ID' => $process->PRO_ID,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app2['APP_NUMBER'],
- 'DEL_INDEX' => 2,
- 'DEL_PREVIOUS' => 1
- ]);
-
- factory(Delegation::class, 1)->create([
- "APP_UID" => $app3['APP_UID'],
- 'TAS_ID' => $task->TAS_ID,
- 'TAS_UID' => $task->TAS_UID,
- 'DEL_THREAD_STATUS' => 'CLOSED',
- 'USR_UID' => $user->USR_UID,
- 'USR_ID' => $user->USR_ID,
- 'PRO_ID' => $process->PRO_ID,
- 'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app3['APP_NUMBER'],
- 'DEL_INDEX' => 1,
- 'DEL_PREVIOUS' => 0
+ 'DEL_PREVIOUS' => 0,
+ 'DEL_LAST_INDEX' => 0
]);
$delegation = factory(Delegation::class)->create([
- "APP_UID" => $app3['APP_UID'],
+ 'APP_UID' => $app['APP_UID'],
'TAS_ID' => $task2->TAS_ID,
'TAS_UID' => $task2->TAS_UID,
'DEL_THREAD_STATUS' => 'OPEN',
@@ -301,21 +175,14 @@ class SupervisingTest extends TestCase
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
- 'APP_NUMBER' => $app3['APP_NUMBER'],
+ 'APP_NUMBER' => $app['APP_NUMBER'],
'DEL_INDEX' => 2,
- 'DEL_PREVIOUS' => 1
+ 'DEL_PREVIOUS' => 1,
+ 'DEL_LAST_INDEX' => 1
]);
-
- // Create the register in the ProcessUser table
- factory(ProcessUser::class)->create(
- [
- 'PRO_UID' => $process->PRO_UID,
- 'USR_UID' => $user->USR_UID,
- 'PU_TYPE' => 'SUPERVISOR'
- ]
- );
}
- return $user;
+
+ return $delegation;
}
/**
@@ -337,8 +204,8 @@ class SupervisingTest extends TestCase
$supervising->setUserId($cases->USR_ID);
// Get the data
$result = $supervising->getData();
- // Asserts the result contains 3 registers
- $this->assertCount(3, $result);
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -360,8 +227,8 @@ class SupervisingTest extends TestCase
$supervising->setUserId($cases->USR_ID);
// Get the data
$result = $supervising->getData();
- // Asserts the result contains 3 registers
- $this->assertCount(3, $result);
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -384,7 +251,7 @@ class SupervisingTest extends TestCase
$supervising->setUserId($user->USR_ID);
// Get the data
$result = $supervising->getData();
- // Asserts the result
+ // Asserts with the result
$this->assertEmpty($result);
}
@@ -412,10 +279,8 @@ class SupervisingTest extends TestCase
$supervising->setCaseNumber($cases->APP_NUMBER);
// Get the data
$result = $supervising->getData();
- // Asserts the result contains 3 registers
- $this->assertCount(1, $result);
- // Asserts that the result contains the app number searched
- $this->assertContains($cases->APP_NUMBER, $result[0]);
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -442,10 +307,8 @@ class SupervisingTest extends TestCase
$supervising->setCasesNumbers([$cases->APP_NUMBER]);
// Get the data
$result = $supervising->getData();
- // Asserts the result contains 3 registers
- $this->assertCount(1, $result);
- // Asserts that the result contains the app number searched
- $this->assertContains($cases->APP_NUMBER, $result[0]);
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -473,10 +336,39 @@ class SupervisingTest extends TestCase
$supervising->setRangeCasesFromTo([$rangeOfCases]);
// Get the data
$result = $supervising->getData();
- // Asserts the result contains 3 registers
- $this->assertCount(1, $result);
- // Asserts that the result contains the app number searched
- $this->assertContains($cases->APP_NUMBER, $result[0]);
+ // Asserts with the result
+ $this->assertNotEmpty($result);
+ }
+
+ /**
+ * Tests the specific filter setCasesNumbers and setRangeCasesFromTo
+ *
+ * @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
+ * @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
+ * @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
+ * @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserUid()
+ * @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserId()
+ * @covers \ProcessMaker\BusinessModel\Cases\Supervising::setCasesNumbers()
+ * @covers \ProcessMaker\BusinessModel\Cases\Supervising::setRangeCasesFromTo()
+ * @test
+ */
+ public function it_filter_by_cases_and_range_cases()
+ {
+ $cases = $this->createSupervising();
+ // Instance the Supervising object
+ $supervising = new Supervising();
+ // Set the user UID
+ $supervising->setUserUid($cases->USR_UID);
+ // Set the user ID
+ $supervising->setUserId($cases->USR_ID);
+ // Set the range of case numbers
+ $rangeOfCases = $cases->APP_NUMBER . "-" . $cases->APP_NUMBER;
+ $supervising->setCasesNumbers([$cases->APP_NUMBER]);
+ $supervising->setRangeCasesFromTo([$rangeOfCases]);
+ // Get the data
+ $result = $supervising->getData();
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -509,8 +401,8 @@ class SupervisingTest extends TestCase
$supervising->setCaseTitle($title);
// Get the data
$result = $supervising->getData();
- // Asserts
- $this->assertCount(1, $result);
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -537,7 +429,8 @@ class SupervisingTest extends TestCase
$supervising->setProcessId($cases['PRO_ID']);
// Get the data
$result = $supervising->getData();
- $this->assertCount(3, $result);
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -564,7 +457,8 @@ class SupervisingTest extends TestCase
$supervising->setTaskId($cases['TAS_ID']);
// Get the data
$result = $supervising->getData();
- $this->assertCount(3, $result);
+ // Asserts with the result
+ $this->assertNotEmpty($result);
}
/**
@@ -591,6 +485,7 @@ class SupervisingTest extends TestCase
$supervising->setCaseStatus('TO_DO');
// Get the data
$result = $supervising->getData();
+ // Asserts with the result
$this->assertNotEmpty($result);
}
@@ -621,7 +516,7 @@ class SupervisingTest extends TestCase
$supervising->setStartCaseTo($date);
// Get the data
$result = $supervising->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertEmpty($result);
}
@@ -652,7 +547,7 @@ class SupervisingTest extends TestCase
$supervising->setFinishCaseTo($date);
// Get the data
$result = $supervising->getData();
- // This assert that the expected numbers of results are returned
+ // Asserts with the result
$this->assertEmpty($result);
}
@@ -687,6 +582,7 @@ class SupervisingTest extends TestCase
$supervising->setOrderByColumn($columnsView[$index]);
// Get the data
$result = $supervising->getData();
+ // Asserts with the result
$this->assertNotEmpty($result);
}
@@ -709,24 +605,27 @@ class SupervisingTest extends TestCase
$supervising->setUserId($cases->USR_ID);
// Get the data
$result = $supervising->getCounter();
- // Assert the counter
- $this->assertEquals(3, $result);
+ // Asserts with the result
+ $this->assertTrue($result > 0 );
}
/**
* It tests the getPagingCounters() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getPagingCounters()
+ * @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test
*/
public function it_should_test_get_paging_counters_method()
{
- $cases = $this->createMultipleSupervising(3);
+ $cases = $this->createSupervising(3);
$supervising = new Supervising();
$supervising->setUserId($cases->USR_ID);
$supervising->setUserUid($cases->USR_UID);
+ $supervising->setCaseUid($cases->APP_UID);
// Get the count
$result = $supervising->getPagingCounters();
- $this->assertEquals(3, $result);
+ // Asserts with the result
+ $this->assertTrue($result > 0 );
}
}
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php
index 6b78560ab..5f940b329 100644
--- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php
+++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php
@@ -5,9 +5,11 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Unassigned;
+use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\AppAssignSelfServiceValue;
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
use ProcessMaker\Model\Application;
+use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf;
@@ -657,4 +659,68 @@ class UnassignedTest extends TestCase
$res = $unassigned->getCountersByRange(null, '2021-05-20', '2021-05-23');
$this->assertCount(1, $res);
}
+
+ /**
+ * It tests the getCustomListCount() method
+ * @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCustomListCount()
+ * @test
+ */
+ public function it_should_test_getCustomListCount_method()
+ {
+ $cases = $this->createMultipleUnassigned(0);
+
+ $additionalTables = factory(AdditionalTables::class)->create();
+ $query = ""
+ . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
+ . "`APP_UID` varchar(32) NOT NULL,"
+ . "`APP_NUMBER` int(11) NOT NULL,"
+ . "`APP_STATUS` varchar(10) NOT NULL,"
+ . "`VAR1` varchar(255) DEFAULT NULL,"
+ . "`VAR2` varchar(255) DEFAULT NULL,"
+ . "`VAR3` varchar(255) DEFAULT NULL,"
+ . "PRIMARY KEY (`APP_UID`),"
+ . "KEY `indexTable` (`APP_UID`))";
+ DB::statement($query);
+
+ $caseList = factory(CaseList::class)->create([
+ 'CAL_TYPE' => 'unassigned',
+ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
+ 'USR_ID' => $cases->USR_ID
+ ]);
+
+ $unassigned = new Unassigned();
+ $unassigned->setUserId($cases->USR_ID);
+ $unassigned->setUserUid($cases->USR_UID);
+
+ $res = $unassigned->getCustomListCount($caseList->CAL_ID, 'unassigned');
+
+ //assertions
+ $this->assertArrayHasKey('label', $res);
+ $this->assertArrayHasKey('name', $res);
+ $this->assertArrayHasKey('description', $res);
+ $this->assertArrayHasKey('tableName', $res);
+ $this->assertArrayHasKey('total', $res);
+
+ $this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
+ $this->assertEquals(0, $res['total']);
+
+ //for user or group
+ $cases = $this->createSelfServiceUserOrGroup();
+
+ $unassigned = new Unassigned();
+ $unassigned->setUserUid($cases['taskUser']->USR_UID);
+ $unassigned->setUserId($cases['delegation']->USR_ID);
+
+ $res = $unassigned->getCustomListCount($caseList->CAL_ID, 'unassigned');
+
+ //assertions
+ $this->assertArrayHasKey('label', $res);
+ $this->assertArrayHasKey('name', $res);
+ $this->assertArrayHasKey('description', $res);
+ $this->assertArrayHasKey('tableName', $res);
+ $this->assertArrayHasKey('total', $res);
+
+ $this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
+ $this->assertEquals(0, $res['total']);
+ }
}
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php
index c479aaa36..ba0e97d7e 100644
--- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php
+++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php
@@ -5,6 +5,7 @@ namespace ProcessMaker\BusinessModel;
use Exception;
use G;
use Illuminate\Support\Facades\DB;
+use ProcessMaker\Model\AppDelay;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Documents;
@@ -380,4 +381,45 @@ class CasesTest extends TestCase
// Get DynaForms assigned as steps for the second task when the application status is COMPLETED
self::assertCount(1, Cases::dynaFormsByApplication($application->APP_UID, $task2->TAS_UID, '', 'COMPLETED'));
}
+
+ /**
+ * It test the case info used in the PMFCaseLink
+ *
+ * @covers \ProcessMaker\BusinessModel\Cases::getStatusInfo()
+ * @covers \ProcessMaker\Model\AppDelay::getPaused()
+ * @test
+ */
+ public function it_should_test_case_status_info()
+ {
+ // Get status info when the case is PAUSED
+ $table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
+ $cases = new Cases();
+ $result = $cases->getStatusInfo($table->APP_UID, $table->APP_DEL_INDEX, $table->APP_DELEGATION_USER);
+ $this->assertNotEmpty($result);
+ $this->assertArrayHasKey('APP_STATUS', $result);
+ $this->assertArrayHasKey('DEL_INDEX', $result);
+ $this->assertArrayHasKey('PRO_UID', $result);
+ // Get status info when the case is UNASSIGNED
+ // Get status info when the case is TO_DO
+ $table = factory(Delegation::class)->states('foreign_keys')->create();
+ $cases = new Cases();
+ $result = $cases->getStatusInfo($table->APP_UID, $table->DEL_INDEX, $table->USR_UID);
+ $this->assertNotEmpty($result);
+ $this->assertArrayHasKey('APP_STATUS', $result);
+ $this->assertArrayHasKey('DEL_INDEX', $result);
+ $this->assertArrayHasKey('PRO_UID', $result);
+ // Get status info when the case is COMPLETED
+ $table = factory(Application::class)->states('completed')->create();
+ $table = factory(Delegation::class)->states('foreign_keys')->create([
+ 'APP_NUMBER' => $table->APP_NUMBER,
+ 'APP_UID' => $table->APP_UID,
+ ]);
+ $cases = new Cases();
+ $result = $cases->getStatusInfo($table->APP_UID, $table->DEL_INDEX, $table->USR_UID);
+ $this->assertNotEmpty($result);
+ $this->assertArrayHasKey('APP_STATUS', $result);
+ $this->assertArrayHasKey('DEL_INDEX', $result);
+ $this->assertArrayHasKey('PRO_UID', $result);
+ }
+
}
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/TableTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/TableTest.php
new file mode 100644
index 000000000..1344dafca
--- /dev/null
+++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/TableTest.php
@@ -0,0 +1,56 @@
+create();
+
+ $proUid = $additionalTables->PRO_UID;
+ $search = $additionalTables->ADD_TAB_NAME;
+
+ $table = new Table();
+ $result = $table->getTables($proUid, true, false, $search);
+
+ //assertions
+ $this->assertNotEmpty($result);
+ $this->assertEquals($additionalTables->ADD_TAB_NAME, $result[0]['rep_tab_name']);
+
+ $search = '';
+ $table = new Table();
+ $result = $table->getTables($proUid, true, false, $search);
+
+ //assertions
+ $this->assertNotEmpty($result);
+ $this->assertEquals($additionalTables->ADD_TAB_NAME, $result[0]['rep_tab_name']);
+ }
+}
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppDelayTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppDelayTest.php
new file mode 100644
index 000000000..b703b5bc3
--- /dev/null
+++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppDelayTest.php
@@ -0,0 +1,102 @@
+states('paused_foreign_keys')->create();
+ $this->assertCount(1, $table->type('PAUSE')->get());
+ }
+
+ /**
+ * This test scopeNotDisabled
+ *
+ * @covers \ProcessMaker\Model\AppDelay::scopeNotDisabled()
+ * @test
+ */
+ public function it_return_scope_not_action_disable()
+ {
+ $table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
+ $this->assertCount(1, $table->notDisabled()->get());
+ }
+
+ /**
+ * This test scopeCase
+ *
+ * @covers \ProcessMaker\Model\AppDelay::scopeCase()
+ * @test
+ */
+ public function it_return_scope_case()
+ {
+ $table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
+ $this->assertCount(1, $table->case($table->APP_NUMBER)->get());
+ }
+
+ /**
+ * This test scopeIndex
+ *
+ * @covers \ProcessMaker\Model\AppDelay::scopeIndex()
+ * @test
+ */
+ public function it_return_scope_index()
+ {
+ $table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
+ $this->assertCount(1, $table->index($table->APP_DEL_INDEX)->get());
+ }
+
+ /**
+ * This test scopeDelegateUser
+ *
+ * @covers \ProcessMaker\Model\AppDelay::scopeDelegateUser()
+ * @test
+ */
+ public function it_return_scope_delegate_user()
+ {
+ $table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
+ $this->assertCount(1, $table->delegateUser($table->APP_DELEGATION_USER)->get());
+ }
+
+ /**
+ * This test getPaused
+ *
+ * @covers \ProcessMaker\Model\AppDelay::getPaused()
+ * @covers \ProcessMaker\Model\AppDelay::scopeCase()
+ * @covers \ProcessMaker\Model\AppDelay::scopeIndex()
+ * @covers \ProcessMaker\Model\AppDelay::scopeDelegateUser()
+ * @test
+ */
+ public function it_return_paused_threads()
+ {
+ $table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
+ $result = AppDelay::getPaused($table->APP_NUMBER, $table->APP_DEL_INDEX, $table->APP_DELEGATION_USER);
+ $this->assertNotEmpty($result);
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php
index 2c86e17ae..ae8b1edca 100644
--- a/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php
+++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php
@@ -170,7 +170,7 @@ class DelegationTest extends TestCase
*/
public function it_return_scope_case_started()
{
- $table = factory(Delegation::class)->states('foreign_keys')->create();
+ $table = factory(Delegation::class)->states('first_thread')->create();
$this->assertCount(1, $table->caseStarted($table->DEL_INDEX)->get());
}
@@ -426,6 +426,42 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->dueTo($table->DEL_TASK_DUE_DATE)->get());
}
+ /**
+ * This test scopeOnTime
+ *
+ * @covers \ProcessMaker\Model\Delegation::scopeOnTime()
+ * @test
+ */
+ public function it_return_scope_on_time()
+ {
+ $table = factory(Delegation::class)->states('closed')->create();
+ $this->assertCount(1, $table->onTime($table->DEL_DELEGATE_DATE)->get());
+ }
+
+ /**
+ * This test scopeAtRisk
+ *
+ * @covers \ProcessMaker\Model\Delegation::scopeAtRisk()
+ * @test
+ */
+ public function it_return_scope_at_risk()
+ {
+ $table = factory(Delegation::class)->states('closed')->create();
+ $this->assertCount(1, $table->atRisk($table->DEL_DELEGATE_DATE)->get());
+ }
+
+ /**
+ * This test scopeOverdue
+ *
+ * @covers \ProcessMaker\Model\Delegation::scopeOverdue()
+ * @test
+ */
+ public function it_return_scope_overdue()
+ {
+ $table = factory(Delegation::class)->states('closed')->create();
+ $this->assertCount(1, $table->overdue($table->DEL_DELEGATE_DATE)->get());
+ }
+
/**
* This test scopeCase
*
@@ -496,7 +532,7 @@ class DelegationTest extends TestCase
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$cases = [$table->APP_NUMBER];
- $rangeCases = [$table->APP_NUMBER.'-'.$table->APP_NUMBER];
+ $rangeCases = [$table->APP_NUMBER . '-' . $table->APP_NUMBER];
$this->assertCount(1, $table->casesOrRangeOfCases($cases, $rangeCases)->get());
}
@@ -2114,6 +2150,8 @@ class DelegationTest extends TestCase
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
+ $result = Delegation::getSelfService($user->USR_UID, ['APP_DELEGATION.APP_NUMBER', 'APP_DELEGATION.DEL_INDEX'], null, null,null, null, null, 0, 15);
+ $this->assertEquals(15, count($result));
}
/**
@@ -3196,6 +3234,28 @@ class DelegationTest extends TestCase
$this->assertNotEmpty($result);
}
+ /**
+ * This check the return of thread info
+ *
+ * @covers \ProcessMaker\Model\Delegation::getDatesFromThread()
+ * @test
+ */
+ public function it_get_thread_dates()
+ {
+ $delegation = factory(Delegation::class)->states('foreign_keys')->create();
+ $task = new Task();
+ $taskInfo = $task->load($delegation->TAS_UID);
+ $taskInfo = head($taskInfo);
+ $taskType = $taskInfo['TAS_TYPE'];
+ $result = Delegation::getDatesFromThread(
+ $delegation->APP_UID,
+ $delegation->DEL_INDEX,
+ $delegation->TAS_UID,
+ $taskType
+ );
+ $this->assertNotEmpty($result);
+ }
+
/**
* This check the return of pending threads
*
@@ -3207,6 +3267,8 @@ class DelegationTest extends TestCase
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::getPendingThreads($delegation->APP_NUMBER);
$this->assertNotEmpty($result);
+ $result = Delegation::getPendingThreads($delegation->APP_NUMBER, false);
+ $this->assertNotEmpty($result);
}
/**
@@ -3283,9 +3345,9 @@ class DelegationTest extends TestCase
]);
$res = Delegation::hasActiveParentsCases($parents);
-
- // Assert the result is true
$this->assertTrue($res);
+ $res = Delegation::hasActiveParentsCases([]);
+ $this->assertFalse($res);
}
/**
@@ -3296,9 +3358,9 @@ class DelegationTest extends TestCase
*/
public function it_get_cases_completed_by_specific_user()
{
- $delegation = factory(Delegation::class)->states('foreign_keys')->create();
+ $delegation = factory(Delegation::class)->states('last_thread')->create();
$result = Delegation::casesCompletedBy($delegation->USR_ID);
- $this->assertEmpty($result);
+ $this->assertNotEmpty($result);
}
/**
@@ -3309,7 +3371,7 @@ class DelegationTest extends TestCase
*/
public function it_get_cases_started_by_specific_user()
{
- $delegation = factory(Delegation::class)->states('foreign_keys')->create();
+ $delegation = factory(Delegation::class)->states('first_thread')->create();
$result = Delegation::casesStartedBy($delegation->USR_ID);
$this->assertNotEmpty($result);
}
diff --git a/workflow/engine/classes/Calendar.php b/workflow/engine/classes/Calendar.php
index 91f257418..9a22631fd 100644
--- a/workflow/engine/classes/Calendar.php
+++ b/workflow/engine/classes/Calendar.php
@@ -799,41 +799,45 @@ class Calendar extends CalendarDefinition
return $return;
}
+ /**
+ * Calculate date adding a duration, will considerate the calendar
+ *
+ * @param string $initialDate
+ * @param string $duration
+ * @param string $formatDuration
+ * @param array $calendarData
+ *
+ * @return string
+ */
+ public function dashCalculateDate($initialDate, $duration, $formatDuration, $calendarData = [])
+ {
+ if (G::toUpper($formatDuration) == 'DAYS') {
+ $duration = $duration * $calendarData['HOURS_FOR_DAY'];
+ }
+ if (G::toUpper($formatDuration) == 'MINUTES') {
+ $duration = $duration / 60;
+ }
+ $hoursDuration = (float)$duration;
+ $newDate = $initialDate;
-
-
-
- /**************SLA classes***************/
- public function dashCalculateDate ($iniDate, $duration, $formatDuration, $calendarData = array())
- {
- if ( G::toUpper($formatDuration) == 'DAYS' ) {
- $duration = $duration*$calendarData['HOURS_FOR_DAY'];
- }
- if ( G::toUpper($formatDuration) == 'MINUTES' ) {
- $duration = $duration/60;
- }
- $hoursDuration = (float)$duration;
- $newDate = $iniDate;
-
- while ($hoursDuration > 0) {
- $newDate = $this->dashGetIniDate($newDate, $calendarData);
-
- $rangeWorkHour = $this->dashGetRangeWorkHours($newDate, $calendarData['BUSINESS_DAY']);
- $onlyDate = (date('Y-m-d',strtotime($newDate))) . ' ' . $rangeWorkHour['END'];
-
- if ( (((float)$hoursDuration) >= ((float)$rangeWorkHour['TOTAL'])) ||
- ((strtotime($onlyDate) - strtotime($newDate)) < (((float)$hoursDuration)*3600))
- ) {
- $secondRes = (float)(strtotime($onlyDate) - strtotime($newDate));
- $newDate = $onlyDate;
- $hoursDuration -= (float)($secondRes/3600);
- } else {
- $newDate = date('Y-m-d H:i:s', strtotime('+' . round((((float)$hoursDuration)*3600), 5) . ' seconds', strtotime($newDate)));
- $hoursDuration = 0;
- }
- }
- return $newDate;
- }
+ while ($hoursDuration > 0) {
+ $newDate = $this->dashGetIniDate($newDate, $calendarData);
+ $rangeWorkHour = $this->dashGetRangeWorkHours($newDate, $calendarData['BUSINESS_DAY']);
+ $onlyDate = (date('Y-m-d', strtotime($newDate))) . ' ' . $rangeWorkHour['END'];
+ $rangeWorkHourTotal = (float)$rangeWorkHour['TOTAL'];
+ if ($hoursDuration >= $rangeWorkHourTotal ||
+ ((strtotime($onlyDate) - strtotime($newDate)) < (($hoursDuration) * 3600))
+ ) {
+ $secondRes = (float)(strtotime($onlyDate) - strtotime($newDate));
+ $newDate = $onlyDate;
+ $hoursDuration -= (float)($secondRes / 3600);
+ } else {
+ $newDate = date('Y-m-d H:i:s', strtotime('+' . round((($hoursDuration) * 3600), 5) . ' seconds', strtotime($newDate)));
+ $hoursDuration = 0;
+ }
+ }
+ return $newDate;
+ }
//Calculate the duration betwen two dates with a calendar
public function dashCalculateDurationWithCalendar ($iniDate, $finDate = null, $calendarData = array())
diff --git a/workflow/engine/classes/model/AppDelegation.php b/workflow/engine/classes/model/AppDelegation.php
index 531066a6f..42f3a276c 100644
--- a/workflow/engine/classes/model/AppDelegation.php
+++ b/workflow/engine/classes/model/AppDelegation.php
@@ -41,6 +41,22 @@ use ProcessMaker\Plugins\PluginRegistry;
*/
class AppDelegation extends BaseAppDelegation
{
+ /**
+ * Get the risk value
+ *
+ * @return double
+ */
+ public function getRisk()
+ {
+ try {
+ $risk = 2;
+
+ return $risk;
+ } catch (Exception $e) {
+ throw $e;
+ }
+ }
+
/**
* Get previous delegation (Valid Task)
*
@@ -91,42 +107,59 @@ class AppDelegation extends BaseAppDelegation
}
/**
- * create an application delegation
+ * Create an application delegation
*
- * @param $sProUid process Uid
- * @param $sAppUid Application Uid
- * @param $sTasUid Task Uid
- * @param $sUsrUid User Uid
- * @param $iPriority delegation priority
- * @param $isSubprocess is a subprocess inside a process?
- * @return delegation index of the application delegation.
+ * @param string $proUid process Uid
+ * @param string $appUid Application Uid
+ * @param string $tasUid Task Uid
+ * @param string $usrUid User Uid
+ * @param int $priority delegation priority
+ * @param bool $isSubprocess is a subprocess inside a process?
+ *
+ * @return int index of the application delegation.
*/
- public function createAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null, $flagControl = false, $flagControlMulInstance = false, $delPrevious = 0, $appNumber = 0, $taskId = 0, $userId = 0, $proId = 0)
- {
- if (! isset($sProUid) || strlen($sProUid) == 0) {
- throw (new Exception('Column "PRO_UID" cannot be null.'));
+ public function createAppDelegation(
+ $proUid,
+ $appUid,
+ $tasUid,
+ $usrUid,
+ $sAppThread,
+ $priority = 3,
+ $isSubprocess = false,
+ $previous = -1,
+ $nextTasParam = null,
+ $flagControl = false,
+ $flagControlMulInstance = false,
+ $delPrevious = 0,
+ $appNumber = 0,
+ $taskId = 0,
+ $userId = 0,
+ $proId = 0
+ ){
+ if (! isset($proUid) || strlen($proUid) == 0) {
+ throw new Exception('Column "PRO_UID" cannot be null.');
}
- if (! isset($sAppUid) || strlen($sAppUid) == 0) {
- throw (new Exception('Column "APP_UID" cannot be null.'));
+ if (! isset($appUid) || strlen($appUid) == 0) {
+ throw new Exception('Column "APP_UID" cannot be null.');
}
- if (! isset($sTasUid) || strlen($sTasUid) == 0) {
- throw (new Exception('Column "TAS_UID" cannot be null.'));
+ if (! isset($tasUid) || strlen($tasUid) == 0) {
+ throw new Exception('Column "TAS_UID" cannot be null.');
}
- if (! isset($sUsrUid) /*|| strlen($sUsrUid ) == 0*/) {
- throw (new Exception('Column "USR_UID" cannot be null.'));
+ if (! isset($usrUid)) {
+ throw new Exception('Column "USR_UID" cannot be null.');
}
if (! isset($sAppThread) || strlen($sAppThread) == 0) {
- throw (new Exception('Column "APP_THREAD" cannot be null.'));
+ throw new Exception('Column "APP_THREAD" cannot be null.');
}
$this->delegation_id = null;
- //Get max DEL_INDEX
+ // Get max DEL_INDEX
$criteria = new Criteria("workflow");
- $criteria->add(AppDelegationPeer::APP_UID, $sAppUid);
+ $criteria->add(AppDelegationPeer::APP_UID, $appUid);
$criteria->add(AppDelegationPeer::DEL_LAST_INDEX, 1);
$criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
@@ -136,8 +169,8 @@ class AppDelegation extends BaseAppDelegation
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$delIndex = 1;
- $delPreviusUsrUid = $sUsrUid;
- $delPreviousFather = $sPrevious;
+ $delPreviusUsrUid = $usrUid;
+ $delPreviousFather = $previous;
if ($rs->next()) {
$row = $rs->getRow();
@@ -149,7 +182,7 @@ class AppDelegation extends BaseAppDelegation
$criteriaDelIndex->addSelectColumn(AppDelegationPeer::DEL_INDEX);
$criteriaDelIndex->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
- $criteriaDelIndex->add(AppDelegationPeer::APP_UID, $sAppUid);
+ $criteriaDelIndex->add(AppDelegationPeer::APP_UID, $appUid);
$criteriaDelIndex->addDescendingOrderByColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
$rsCriteriaDelIndex = AppDelegationPeer::doSelectRS($criteriaDelIndex);
@@ -161,23 +194,23 @@ class AppDelegation extends BaseAppDelegation
$delIndex = (isset($row["DEL_INDEX"]))? $row["DEL_INDEX"] + 1 : 1;
}
}
- //Verify successors: parrallel submit in the same time
+ // Verify successors: parallel submit in the same time
if ($flagControl) {
- $nextTaskUid = $sTasUid;
- $index = $this->getAllTasksBeforeSecJoin($nextTaskUid, $sAppUid, $delPreviousFather);
- if ($this->createThread($index, $sAppUid)) {
+ $nextTaskUid = $tasUid;
+ $index = $this->getAllTasksBeforeSecJoin($nextTaskUid, $appUid, $delPreviousFather);
+ if ($this->createThread($index, $appUid)) {
return 0;
}
}
if ($flagControlMulInstance) {
- $nextTaskUid = $sTasUid;
- $index = $this->getAllTheardMultipleInstance($delPreviousFather, $sAppUid);
- if ($this->createThread($index, $sAppUid, $sUsrUid)) {
+ $nextTaskUid = $tasUid;
+ $index = $this->getAllTheardMultipleInstance($delPreviousFather, $appUid);
+ if ($this->createThread($index, $appUid, $usrUid)) {
return 0;
}
}
- //Update set
+ // Update set
$criteriaUpdate = new Criteria('workflow');
$criteriaUpdate->add(AppDelegationPeer::DEL_LAST_INDEX, 0);
BasePeer::doUpdate($criteria, $criteriaUpdate, Propel::getConnection('workflow'));
@@ -185,15 +218,15 @@ class AppDelegation extends BaseAppDelegation
// Define the status of the thread, if is subprocess we need to CLOSED the thread
$theadStatus = !$isSubprocess ? 'OPEN' : 'CLOSED';
- $this->setAppUid($sAppUid);
- $this->setProUid($sProUid);
- $this->setTasUid($sTasUid);
+ $this->setAppUid($appUid);
+ $this->setProUid($proUid);
+ $this->setTasUid($tasUid);
$this->setDelIndex($delIndex);
$this->setDelLastIndex(1);
- $this->setDelPrevious($sPrevious == - 1 ? 0 : $sPrevious);
- $this->setUsrUid($sUsrUid);
+ $this->setDelPrevious($previous == - 1 ? 0 : $previous);
+ $this->setUsrUid($usrUid);
$this->setDelType('NORMAL');
- $this->setDelPriority(($iPriority != '' ? $iPriority : '3'));
+ $this->setDelPriority(($priority != '' ? $priority : '3'));
$this->setDelThread($sAppThread);
$this->setDelThreadStatus($theadStatus);
$this->setDelThreadStatusId(Delegation::$thread_status[$theadStatus]);
@@ -203,24 +236,22 @@ class AppDelegation extends BaseAppDelegation
$this->setUsrId($userId);
$this->setProId($proId);
- //The function return an array now. By JHL
- $delTaskDueDate = $this->calculateDueDate($sNextTasParam);
- $delRiskDate = $this->calculateRiskDate($sNextTasParam, $this->getRisk());
-
- //$this->setDelTaskDueDate( $delTaskDueDate['DUE_DATE'] ); // Due date formatted
+ // The function return an array now. By JHL
+ $delTaskDueDate = $this->calculateDueDate($nextTasParam);
+ $delRiskDate = $this->calculateRiskDate($nextTasParam, $this->getRisk());
$this->setDelTaskDueDate($delTaskDueDate);
$this->setDelRiskDate($delRiskDate);
if ((defined("DEBUG_CALENDAR_LOG")) && (DEBUG_CALENDAR_LOG)) {
- //$this->setDelData( $delTaskDueDate['DUE_DATE_LOG'] ); // Log of actions made by Calendar Engine
+ // Log of actions made by Calendar Engine
$this->setDelData($delTaskDueDate);
} else {
$this->setDelData('');
}
- // this condition assures that an internal delegation like a subprocess dont have an initial date setted
+ // This condition assures that an internal delegation like a subprocess don't have an initial date set
if ($delIndex == 1 && ! $isSubprocess) {
- //the first delegation, init date this should be now for draft applications, in other cases, should be null.
+ // The first delegation, init date this should be now for draft applications, in other cases, should be null.
$this->setDelInitDate('now');
}
@@ -247,16 +278,16 @@ class AppDelegation extends BaseAppDelegation
$bpmn = new \ProcessMaker\Project\Bpmn();
$flagActionsByEmail = true;
- $arrayAppDelegationPrevious = $this->getPreviousDelegationValidTask($sAppUid, $delIndex);
+ $arrayAppDelegationPrevious = $this->getPreviousDelegationValidTask($appUid, $delIndex);
$data = new stdclass();
- $data->TAS_UID = $sTasUid;
- $data->APP_UID = $sAppUid;
+ $data->TAS_UID = $tasUid;
+ $data->APP_UID = $appUid;
$data->DEL_INDEX = $delIndex;
- $data->USR_UID = $sUsrUid;
+ $data->USR_UID = $usrUid;
$data->PREVIOUS_USR_UID = ($arrayAppDelegationPrevious !== false)? $arrayAppDelegationPrevious['USR_UID'] : $delPreviusUsrUid;
- if ($bpmn->exists($sProUid)) {
+ if ($bpmn->exists($proUid)) {
/*----------------------------------********---------------------------------*/
// this section evaluates the actions by email trigger execution please
// modify this section carefully, the if evaluation checks if the license has been
@@ -265,8 +296,8 @@ class AppDelegation extends BaseAppDelegation
::getSingleton()
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=')) {
$criteriaAbe = new Criteria();
- $criteriaAbe->add(AbeConfigurationPeer::PRO_UID, $sProUid);
- $criteriaAbe->add(AbeConfigurationPeer::TAS_UID, $sTasUid);
+ $criteriaAbe->add(AbeConfigurationPeer::PRO_UID, $proUid);
+ $criteriaAbe->add(AbeConfigurationPeer::TAS_UID, $tasUid);
$resultAbe = AbeConfigurationPeer::doSelectRS($criteriaAbe);
$resultAbe->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($resultAbe->next()) {
@@ -289,7 +320,7 @@ class AppDelegation extends BaseAppDelegation
$pmGoogle = new PmGoogleApi();
if ($pmGoogle->getServiceGmailStatus()) {
$Pmgmail = new \ProcessMaker\BusinessModel\Pmgmail();
- $Pmgmail->gmailsForRouting($sUsrUid, $sTasUid, $sAppUid, $delIndex, $isSubprocess);
+ $Pmgmail->gmailsForRouting($usrUid, $tasUid, $appUid, $delIndex, $isSubprocess);
}
} catch (Exception $oError) {
error_log($oError->getMessage());
@@ -299,8 +330,8 @@ class AppDelegation extends BaseAppDelegation
}
if ($flagActionsByEmail) {
- $oPluginRegistry = PluginRegistry::loadSingleton();
- $oPluginRegistry->executeTriggers(PM_CREATE_NEW_DELEGATION, $data);
+ $pluginRegistry = PluginRegistry::loadSingleton();
+ $pluginRegistry->executeTriggers(PM_CREATE_NEW_DELEGATION, $data);
}
}
@@ -474,30 +505,38 @@ class AppDelegation extends BaseAppDelegation
//Calendar - Use the dates class to calculate dates
$calendar = new Calendar();
- $arrayCalendarData = $calendar->getCalendarData($aCalendarUID);
+ $calendarData = $calendar->getCalendarData($aCalendarUID);
if ($calendar->pmCalendarUid == "") {
$calendar->getCalendar(null, $this->getProUid(), $this->getTasUid());
- $arrayCalendarData = $calendar->getCalendarData();
+ $calendarData = $calendar->getCalendarData();
}
//Due date
$initDate = $this->getDelDelegateDate();
$timeZone = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($initDate);
- $dueDate = $calendar->dashCalculateDate($timeZone, $aData["TAS_DURATION"], $aData["TAS_TIMEUNIT"], $arrayCalendarData);
+ $dueDate = $calendar->dashCalculateDate($timeZone, $aData["TAS_DURATION"], $aData["TAS_TIMEUNIT"], $calendarData);
$dueDate = \ProcessMaker\Util\DateTime::convertDataToUtc($dueDate);
return $dueDate;
}
- public function calculateRiskDate($dueDate, $risk)
+ /**
+ * Calculate the risk date
+ *
+ * @param array $nextTask
+ * @param double $risk
+ *
+ * @return string
+ */
+ public function calculateRiskDate($nextTask, $risk)
{
try {
- $data = array();
- if (isset($sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY']) && $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true') {
- $data['TAS_DURATION'] = $sNextTasParam['NEXT_TASK']['TAS_DURATION'];
- $data['TAS_TIMEUNIT'] = $sNextTasParam['NEXT_TASK']['TAS_TIMEUNIT'];
+ $data = [];
+ if (isset($nextTask['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY']) && $nextTask['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true') {
+ $data['TAS_DURATION'] = $nextTask['NEXT_TASK']['TAS_DURATION'];
+ $data['TAS_TIMEUNIT'] = $nextTask['NEXT_TASK']['TAS_TIMEUNIT'];
} else {
$task = TaskPeer::retrieveByPK($this->getTasUid());
$data['TAS_DURATION'] = $task->getTasDuration();
@@ -506,19 +545,21 @@ class AppDelegation extends BaseAppDelegation
$riskTime = $data['TAS_DURATION'] - ($data['TAS_DURATION'] * $risk);
- //Calendar - Use the dates class to calculate dates
+ // Calendar - Use the dates class to calculate dates
$calendar = new Calendar();
-
- $arrayCalendarData = array();
-
- if ($calendar->pmCalendarUid == "") {
+ $calendarData = [];
+ if (empty($calendar->pmCalendarUid)) {
$calendar->getCalendar(null, $this->getProUid(), $this->getTasUid());
-
- $arrayCalendarData = $calendar->getCalendarData();
+ $calendarData = $calendar->getCalendarData();
}
- //Risk date
- $riskDate = $calendar->dashCalculateDate($this->getDelDelegateDate(), $riskTime, $data['TAS_TIMEUNIT'], $arrayCalendarData);
+ // Risk date
+ $riskDate = $calendar->dashCalculateDate(
+ $this->getDelDelegateDate(),
+ $riskTime,
+ $data['TAS_TIMEUNIT'],
+ $calendarData
+ );
return $riskDate;
} catch (Exception $e) {
@@ -526,12 +567,6 @@ class AppDelegation extends BaseAppDelegation
}
}
- public function getDiffDate($date1, $date2)
- {
- return ($date1 - $date2) / (24 * 60 * 60); //days
- return ($date1 - $date2) / 3600;
- }
-
//usually this function is called when routing in the flow, so by default cron =0
public function calculateDuration($cron = 0)
{
@@ -799,8 +834,10 @@ class AppDelegation extends BaseAppDelegation
/**
* This function get the current user related to the specific case and index
+ *
* @param string $appUid, Uid related to the case
* @param integer $index, Index to review
+ *
* @return array
*/
public static function getCurrentUsers($appUid, $index)
@@ -820,7 +857,8 @@ class AppDelegation extends BaseAppDelegation
/**
* Verify if the current case is already routed.
*
- * @param string $AppUid the uid of the application
+ * @param string $appUid the uid of the application
+ *
* @return array $Fields the fields
*/
@@ -841,18 +879,6 @@ class AppDelegation extends BaseAppDelegation
}
}
- public function getRisk()
- {
- try {
- $risk = 0.2;
-
- //Return
- return $risk;
- } catch (Exception $e) {
- throw $e;
- }
- }
-
/**
* Get all task before Join Threads
*
diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po
index 32c5fc237..8d825507e 100755
--- a/workflow/engine/content/translations/english/processmaker.en.po
+++ b/workflow/engine/content/translations/english/processmaker.en.po
@@ -4493,6 +4493,12 @@ msgstr "City"
msgid "Claim"
msgstr "Claim"
+# TRANSLATION
+# LABEL/ID_CLAIM_THIS_CASE
+#: LABEL/ID_CLAIM_THIS_CASE
+msgid "Claim this case"
+msgstr "Claim this case"
+
# TRANSLATION
# LABEL/ID_CLASSIC_EDITOR
#: LABEL/ID_CLASSIC_EDITOR
@@ -24671,6 +24677,12 @@ msgstr "An error has occurred, please verify on which server \"SendMail\" has be
msgid "send at"
msgstr "send at"
+# TRANSLATION
+# LABEL/ID_SEND_BY
+#: LABEL/ID_SEND_BY
+msgid "Send By"
+msgstr "Send By"
+
# TRANSLATION
# LABEL/ID_SEND_EMAIL_CASE_PARTICIPANTS
#: LABEL/ID_SEND_EMAIL_CASE_PARTICIPANTS
diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql
index c711385dc..b40a740d7 100755
--- a/workflow/engine/data/mysql/insert.sql
+++ b/workflow/engine/data/mysql/insert.sql
@@ -57561,6 +57561,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_CITY','en','City','2020-12-15') ,
( 'LABEL','ID_CHOOSE_TIME','en','Choose a time','2014-08-27') ,
( 'LABEL','ID_CLAIM','en','Claim','2014-01-15') ,
+( 'LABEL','ID_CLAIM_THIS_CASE','en','Claim this case','2021-08-03') ,
( 'LABEL','ID_CLASSIC_EDITOR','en','Classic Editor','2014-01-15') ,
( 'LABEL','ID_CLASS_ALREADY_EXISTS','en','Class already exists','2014-01-15') ,
( 'LABEL','ID_CLASS_TABLE_DOESNT_EXIST','en','This Class Table doesn''t exist!','2014-01-15') ,
@@ -61026,6 +61027,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_SENDING_REQUEST_SALES_DEPARTMENT','en','Sending request to ProcessMaker Sales Department, please wait...','2014-09-18') ,
( 'LABEL','ID_SENDMAIL_NOT_INSTALLED','en','An error has occured, please verify on which server "SendMail" has been installed or any other mail service, and if it has been configured correctly.','2014-01-15') ,
( 'LABEL','ID_SEND_AT','en','send at','2014-01-15') ,
+( 'LABEL','ID_SEND_BY','en','Send By','2021-08-02') ,
( 'LABEL','ID_SEND_EMAIL_CASE_PARTICIPANTS','en','Send Email (Case Participants)','2014-01-15') ,
( 'LABEL','ID_SEND_EMAIL_TO_PARTICIPANTS','en','Send email to participants','2020-12-01') ,
( 'LABEL','ID_SENT','en','Participated','2016-07-11') ,
diff --git a/workflow/engine/methods/cases/casesListSetup.php b/workflow/engine/methods/cases/casesListSetup.php
index 729189c9d..ef6c541c8 100644
--- a/workflow/engine/methods/cases/casesListSetup.php
+++ b/workflow/engine/methods/cases/casesListSetup.php
@@ -6,6 +6,8 @@ use ProcessMaker\Core\System;
global $translation;
global $RBAC;
+$conf = new Configurations();
+
if ($RBAC->userCanAccess("PM_SETUP") != 1 || $RBAC->userCanAccess("PM_SETUP_ADVANCE") != 1) {
G::SendTemporalMessage("ID_USER_HAVENT_RIGHTS_PAGE", "error", "labels");
exit(0);
@@ -30,4 +32,5 @@ ScriptVariables::add('SYS_WORKSPACE', config("system.workspace"));
ScriptVariables::add('SYS_URI', SYS_URI);
ScriptVariables::add('SYS_LANG', SYS_LANG);
ScriptVariables::add('TRANSLATIONS', $translation);
+ScriptVariables::add('FORMATS', $conf->getFormats());
echo View::make('Views::admin.settings.customCasesList', compact("userCanAccess"))->render();
\ No newline at end of file
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php
index 2d00d45b0..b4270196b 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php
@@ -46,6 +46,7 @@ use ProcessMaker\BusinessModel\User as BmUser;
use ProcessMaker\Core\System;
use ProcessMaker\Exception\UploadException;
use ProcessMaker\Exception\CaseNoteUploadFile;
+use ProcessMaker\Model\AppDelay as Delay;
use ProcessMaker\Model\Application as ModelApplication;
use ProcessMaker\Model\AppNotes as Notes;
use ProcessMaker\Model\AppTimeoutAction;
@@ -2456,33 +2457,25 @@ class Cases
/**
* This function get the status information
*
- * @param object $rsCriteria
+ * @param array $result
+ * @param string $status
*
* @return array
* @throws Exception
*/
- private function getStatusInfoDataByRsCriteria($rsCriteria)
+ private function getStatusInfoFormatted(array $result, string $status = '')
{
try {
- $arrayData = [];
-
- if ($rsCriteria->next()) {
- $record = $rsCriteria->getRow();
-
- $arrayData = [
- 'APP_STATUS' => $record['APP_STATUS'],
- 'DEL_INDEX' => [],
- 'PRO_UID' => $record['PRO_UID']
- ];
+ $record = head($result);
+ $arrayData = [
+ 'APP_STATUS' => empty($status) ? $record['APP_STATUS'] : $status,
+ 'DEL_INDEX' => [],
+ 'PRO_UID' => $record['PRO_UID']
+ ];
+ $arrayData['DEL_INDEX'][] = $record['DEL_INDEX'];
+ foreach ($result as $record) {
$arrayData['DEL_INDEX'][] = $record['DEL_INDEX'];
-
- while ($rsCriteria->next()) {
- $record = $rsCriteria->getRow();
-
- $arrayData['DEL_INDEX'][] = $record['DEL_INDEX'];
- }
}
-
//Return
return $arrayData;
} catch (Exception $e) {
@@ -2493,8 +2486,8 @@ class Cases
/**
* Get status info Case
*
- * @param string $applicationUid Unique id of Case
- * @param int $delIndex Delegation index
+ * @param string $appUid Unique id of Case
+ * @param int $index Delegation index
* @param string $userUid Unique id of User
*
* @return array Return an array with status info Case, array empty otherwise
@@ -2502,179 +2495,120 @@ class Cases
*
* @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()
+ * @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 = "")
+ public function getStatusInfo(string $appUid, int $index = 0, string $userUid = "")
{
try {
- //Verify data
- $this->throwExceptionIfNotExistsCase($applicationUid, $delIndex,
- $this->getFieldNameByFormatFieldName("APP_UID"));
-
- //Get data
- //Status is PAUSED
- $delimiter = DBAdapter::getStringDelimiter();
-
- $criteria = new Criteria("workflow");
-
- $criteria->setDistinct();
- $criteria->addSelectColumn($delimiter . 'PAUSED' . $delimiter . ' AS APP_STATUS');
- $criteria->addSelectColumn(AppDelayPeer::APP_DEL_INDEX . " AS DEL_INDEX");
- $criteria->addSelectColumn(AppDelayPeer::PRO_UID);
-
- $criteria->add(AppDelayPeer::APP_UID, $applicationUid, Criteria::EQUAL);
- $criteria->add(AppDelayPeer::APP_TYPE, "PAUSE", Criteria::EQUAL);
- $criteria->add(
- $criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)->addOr(
- $criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL))
- );
-
- if ($delIndex != 0) {
- $criteria->add(AppDelayPeer::APP_DEL_INDEX, $delIndex, Criteria::EQUAL);
+ $arrayData = [];
+ // Verify data
+ $this->throwExceptionIfNotExistsCase($appUid, $index, $this->getFieldNameByFormatFieldName("APP_UID"));
+ // Get the case number
+ $caseNumber = ModelApplication::getCaseNumber($appUid);
+ // Status is PAUSED
+ $result = Delay::getPaused($caseNumber, $index, $userUid);
+ if (!empty($result)) {
+ $arrayData = $this->getStatusInfoFormatted($result, 'PAUSED');
+ return $arrayData;
}
- if ($userUid != "") {
- $criteria->add(AppDelayPeer::APP_DELEGATION_USER, $userUid, Criteria::EQUAL);
+ // Status is UNASSIGNED
+ $query = Delegation::query()->select([
+ 'APP_DELEGATION.APP_NUMBER',
+ 'APP_DELEGATION.DEL_INDEX',
+ 'APP_DELEGATION.PRO_UID'
+ ]);
+ $query->taskAssignType('SELF_SERVICE');
+ $query->threadOpen()->withoutUserId();
+ // Filter specific user
+ if (!empty($userUid)) {
+ $delegation = new Delegation();
+ $delegation->casesUnassigned($query, $userUid);
+ }
+ // Filter specific case
+ $query->case($caseNumber);
+ // Filter specific index
+ if (is_int($index)) {
+ $query->index($index);
+ }
+ $results = $query->get();
+ $arrayData = $results->values()->toArray();
+ if (!empty($arrayData)) {
+ $arrayData = $this->getStatusInfoFormatted($arrayData, 'UNASSIGNED');
+ return $arrayData;
}
- $rsCriteria = AppDelayPeer::doSelectRS($criteria);
- $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ // Status is TO_DO, DRAFT
+ $query = Delegation::query()->select([
+ 'APPLICATION.APP_STATUS',
+ 'APP_DELEGATION.APP_NUMBER',
+ 'APP_DELEGATION.DEL_INDEX',
+ 'APP_DELEGATION.PRO_UID'
+ ]);
+ $query->joinApplication();
+ // Filter the status TO_DO and DRAFT
+ $query->casesInProgress([1, 2]);
+ // Filter the OPEN thread
+ $query->threadOpen();
+ // Filter specific case
+ $query->case($caseNumber);
+ // Filter specific index
+ if ($index > 0) {
+ $query->index($index);
+ }
+ // Filter specific user
+ if (!empty($userUid)) {
+ $userId = !empty($userUid) ? User::getId($userUid) : 0;
+ $query->userId($userId);
+ }
+ $results = $query->get();
+ $arrayData = $results->values()->toArray();
- $arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
+ if (!empty($arrayData)) {
+ $arrayData = $this->getStatusInfoFormatted($arrayData);
+ return $arrayData;
+ }
+ // Status is CANCELLED, COMPLETED
+ $query = Delegation::query()->select([
+ 'APPLICATION.APP_STATUS',
+ 'APP_DELEGATION.APP_NUMBER',
+ 'APP_DELEGATION.DEL_INDEX',
+ 'APP_DELEGATION.PRO_UID'
+ ]);
+ $query->joinApplication();
+ // Filter the status COMPLETED and CANCELLED
+ $query->casesDone([3, 4]);
+ // Filter specific case
+ $query->case($caseNumber);
+ // Filter specific index
+ if ($index > 0) {
+ $query->index($index);
+ }
+ // Filter specific user
+ if (!empty($userUid)) {
+ $userId = !empty($userUid) ? User::getId($userUid) : 0;
+ $query->userId($userId);
+ }
+ $query->lastThread();
+ $results = $query->get();
+ $arrayData = $results->values()->toArray();
+ if (!empty($arrayData)) {
+ $arrayData = $this->getStatusInfoFormatted($arrayData);
+ return $arrayData;
+ }
+
+ // Status is PARTICIPATED
+ $arrayData = Delegation::getParticipatedInfo($appUid);
if (!empty($arrayData)) {
return $arrayData;
}
- //Status is UNASSIGNED
- if ($userUid != '') {
- $appCacheView = new AppCacheView();
-
- $criteria = $appCacheView->getUnassignedListCriteria($userUid);
- } else {
- $criteria = new Criteria('workflow');
-
- $criteria->add(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
- $criteria->add(AppCacheViewPeer::USR_UID, '', Criteria::EQUAL);
- }
-
- $criteria->setDistinct();
- $criteria->clearSelectColumns();
- $criteria->addSelectColumn($delimiter . 'UNASSIGNED' . $delimiter . ' AS APP_STATUS');
- $criteria->addSelectColumn(AppCacheViewPeer::DEL_INDEX);
- $criteria->addSelectColumn(AppCacheViewPeer::PRO_UID);
-
- $criteria->add(AppCacheViewPeer::APP_UID, $applicationUid, Criteria::EQUAL);
-
- if ($delIndex != 0) {
- $criteria->add(AppCacheViewPeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
- }
-
- $rsCriteria = AppCacheViewPeer::doSelectRS($criteria);
- $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
-
- $arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
-
- if (!empty($arrayData)) {
- return $arrayData;
- }
-
- //Status is TO_DO, DRAFT
- $criteria = new Criteria("workflow");
-
- $criteria->setDistinct();
- $criteria->addSelectColumn(ApplicationPeer::APP_STATUS);
- $criteria->addSelectColumn(ApplicationPeer::PRO_UID);
- $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
-
- $arrayCondition = array();
- $arrayCondition[] = array(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::EQUAL);
- $arrayCondition[] = array(
- ApplicationPeer::APP_UID,
- $delimiter . $applicationUid . $delimiter,
- Criteria::EQUAL
- );
- $criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
-
- $criteria->add(
- $criteria->getNewCriterion(ApplicationPeer::APP_STATUS, "TO_DO", Criteria::EQUAL)->addAnd(
- $criteria->getNewCriterion(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL))->addAnd(
- $criteria->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"))
- )->addOr(
- $criteria->getNewCriterion(ApplicationPeer::APP_STATUS, "DRAFT", Criteria::EQUAL)->addAnd(
- $criteria->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"))
- );
-
- if ($delIndex != 0) {
- $criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
- }
-
- if ($userUid != "") {
- $criteria->add(AppDelegationPeer::USR_UID, $userUid, Criteria::EQUAL);
- }
-
- $rsCriteria = ApplicationPeer::doSelectRS($criteria);
- $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
-
- $arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria);
-
- if (!empty($arrayData)) {
- return $arrayData;
- }
-
- //Status is CANCELLED, COMPLETED
- $criteria = new Criteria("workflow");
-
- $criteria->addSelectColumn(ApplicationPeer::APP_STATUS);
- $criteria->addSelectColumn(ApplicationPeer::PRO_UID);
- $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
-
- $arrayCondition = array();
- $arrayCondition[] = array(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::EQUAL);
- $arrayCondition[] = array(
- ApplicationPeer::APP_UID,
- $delimiter . $applicationUid . $delimiter,
- Criteria::EQUAL
- );
- $criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
-
- if ($delIndex != 0) {
- $criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
- }
-
- if ($userUid != "") {
- $criteria->add(AppDelegationPeer::USR_UID, $userUid, Criteria::EQUAL);
- }
-
- $criteria2 = clone $criteria;
-
- $criteria2->setDistinct();
-
- $criteria2->add(ApplicationPeer::APP_STATUS, ['CANCELLED', 'COMPLETED'], Criteria::IN);
- $criteria2->add(AppDelegationPeer::DEL_LAST_INDEX, 1, Criteria::EQUAL);
-
- $rsCriteria2 = ApplicationPeer::doSelectRS($criteria2);
- $rsCriteria2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
-
- $arrayData = $this->getStatusInfoDataByRsCriteria($rsCriteria2);
-
- if (!empty($arrayData)) {
- return $arrayData;
- }
-
- //Status is PARTICIPATED
- $arrayData = Delegation::getParticipatedInfo($applicationUid);
-
- if (!empty($arrayData)) {
- return $arrayData;
- }
-
- //Return
- return array();
+ return $arrayData;
} catch (Exception $e) {
throw $e;
}
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php
index 5886f9265..cc9d47f4d 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php
@@ -1492,8 +1492,7 @@ class AbstractCases implements CasesInterface
/**
* Count how many cases has each process
- *
- * @param string $list
+ *
* @param int $category
* @param bool $topTen
* @param array $processes
@@ -1528,7 +1527,7 @@ class AbstractCases implements CasesInterface
$query->topTen('TOTAL', 'DESC');
}
if (!empty($processes)) {
- $query->inProcesses($processes);
+ $query->processInList($processes);
}
return $query->get()->values()->toArray();
}
@@ -1574,7 +1573,7 @@ class AbstractCases implements CasesInterface
}
$query->joinProcess();
if (!is_null($processId)) {
- $query->inProcesses([$processId]);
+ $query->processInList([$processId]);
}
if (!is_null($dateFrom)) {
$query->where('APP_DELEGATION.DEL_DELEGATE_DATE', '>=', $dateFrom);
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php
index 9ce4c1989..dc560506c 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php
@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel\Cases;
use G;
use ProcessMaker\Model\Application;
+use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\User;
@@ -166,4 +167,44 @@ class Draft extends AbstractCases
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
+
+ /**
+ * Returns the total cases of the custom draft list.
+ * @param int $id
+ * @param string $type
+ * @return array
+ */
+ public function getCustomListCount(int $id, string $type): array
+ {
+ $caseList = CaseList::where('CAL_ID', '=', $id)
+ ->where('CAL_TYPE', '=', $type)
+ ->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
+ ->select([
+ 'CASE_LIST.*',
+ 'ADDITIONAL_TABLES.ADD_TAB_NAME'
+ ])
+ ->get()
+ ->first();
+
+ $query = Delegation::query()->select();
+ $query->draft($this->getUserId());
+
+ $name = '';
+ $description = '';
+ $tableName = '';
+ if (!is_null($caseList)) {
+ $name = $caseList->CAL_NAME;
+ $description = $caseList->CAL_DESCRIPTION;
+ $tableName = $caseList->ADD_TAB_NAME;
+ $query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
+ }
+ $count = $query->count(['APP_DELEGATION.APP_NUMBER']);
+ return [
+ 'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_DRAFT') . $count,
+ 'name' => $name,
+ 'description' => $description,
+ 'tableName' => $tableName,
+ 'total' => $count
+ ];
+ }
}
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php
index 67d6754d5..f31a5eb63 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Inbox.php
@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel\Cases;
use G;
use ProcessMaker\Model\Application;
+use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\User;
@@ -179,4 +180,44 @@ class Inbox extends AbstractCases
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
+
+ /**
+ * Returns the total cases of the custom inbox list.
+ * @param int $id
+ * @param string $type
+ * @return array
+ */
+ public function getCustomListCount(int $id, string $type): array
+ {
+ $caseList = CaseList::where('CAL_ID', '=', $id)
+ ->where('CAL_TYPE', '=', $type)
+ ->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
+ ->select([
+ 'CASE_LIST.*',
+ 'ADDITIONAL_TABLES.ADD_TAB_NAME'
+ ])
+ ->get()
+ ->first();
+
+ $query = Delegation::query()->select();
+ $query->inbox($this->getUserId());
+
+ $name = '';
+ $description = '';
+ $tableName = '';
+ if (!is_null($caseList)) {
+ $name = $caseList->CAL_NAME;
+ $description = $caseList->CAL_DESCRIPTION;
+ $tableName = $caseList->ADD_TAB_NAME;
+ $query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
+ }
+ $count = $query->count(['APP_DELEGATION.APP_NUMBER']);
+ return [
+ 'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_INBOX') . $count,
+ 'name' => $name,
+ 'description' => $description,
+ 'tableName' => $tableName,
+ 'total' => $count
+ ];
+ }
}
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php
index 9cdbb0d85..1b920bb3f 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Paused.php
@@ -3,6 +3,7 @@
namespace ProcessMaker\BusinessModel\Cases;
use G;
+use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\User;
@@ -173,4 +174,44 @@ class Paused extends AbstractCases
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
+
+ /**
+ * Returns the total cases of the custom paused list.
+ * @param int $id
+ * @param string $type
+ * @return array
+ */
+ public function getCustomListCount(int $id, string $type): array
+ {
+ $caseList = CaseList::where('CAL_ID', '=', $id)
+ ->where('CAL_TYPE', '=', $type)
+ ->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
+ ->select([
+ 'CASE_LIST.*',
+ 'ADDITIONAL_TABLES.ADD_TAB_NAME'
+ ])
+ ->get()
+ ->first();
+
+ $query = Delegation::query()->select();
+ $query->paused($this->getUserId());
+
+ $name = '';
+ $description = '';
+ $tableName = '';
+ if (!is_null($caseList)) {
+ $name = $caseList->CAL_NAME;
+ $description = $caseList->CAL_DESCRIPTION;
+ $tableName = $caseList->ADD_TAB_NAME;
+ $query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
+ }
+ $count = $query->count(['APP_DELEGATION.APP_NUMBER']);
+ return [
+ 'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_PAUSED') . $count,
+ 'name' => $name,
+ 'description' => $description,
+ 'tableName' => $tableName,
+ 'total' => $count
+ ];
+ }
}
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php
index bab220af2..5c86ea9c1 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Unassigned.php
@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel\Cases;
use G;
use ProcessMaker\Model\Application;
+use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\User;
@@ -181,4 +182,44 @@ class Unassigned extends AbstractCases
// Return the number of rows
return $query->count(['APP_DELEGATION.APP_NUMBER']);
}
+
+ /**
+ * Returns the total cases of the custom unassigned list.
+ * @param int $id
+ * @param string $type
+ * @return array
+ */
+ public function getCustomListCount(int $id, string $type): array
+ {
+ $caseList = CaseList::where('CAL_ID', '=', $id)
+ ->where('CAL_TYPE', '=', $type)
+ ->leftJoin('ADDITIONAL_TABLES', 'ADDITIONAL_TABLES.ADD_TAB_UID', '=', 'CASE_LIST.ADD_TAB_UID')
+ ->select([
+ 'CASE_LIST.*',
+ 'ADDITIONAL_TABLES.ADD_TAB_NAME'
+ ])
+ ->get()
+ ->first();
+
+ $query = Delegation::query()->select();
+ $query->selfService($this->getUserId());
+
+ $name = '';
+ $description = '';
+ $tableName = '';
+ if (!is_null($caseList)) {
+ $name = $caseList->CAL_NAME;
+ $description = $caseList->CAL_DESCRIPTION;
+ $tableName = $caseList->ADD_TAB_NAME;
+ $query->leftJoin($caseList->ADD_TAB_NAME, $caseList->ADD_TAB_NAME . '.APP_UID', '=', 'APP_DELEGATION.APP_UID');
+ }
+ $count = $query->count(['APP_DELEGATION.APP_NUMBER']);
+ return [
+ 'label' => G::LoadTranslation('ID_NUMBER_OF_CASES_UNASSIGNED') . $count,
+ 'name' => $name,
+ 'description' => $description,
+ 'tableName' => $tableName,
+ 'total' => $count
+ ];
+ }
}
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Table.php b/workflow/engine/src/ProcessMaker/BusinessModel/Table.php
index b2d504532..6f155f7e1 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/Table.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Table.php
@@ -8,6 +8,7 @@ use Fields;
use G;
use PmTable;
use ProcessMaker\BusinessModel\ReportTable as BusinessModelRpt;
+use ProcessMaker\Model\AdditionalTables as ModelAdditionalTables;
use stdClass;
class Table
@@ -23,34 +24,25 @@ class Table
'or','throw','protected','public','static','switch','xor','try','use','var','while'];
/**
- * List of Tables in process
- * @var string $pro_uid. Uid for process
- * @var string $reportFlag. If is report table
- *
- * @author Brayan Pereyra (Cochalo)
- * @copyright Colosa - Bolivia
- *
+ * List of Tables in process.
+ * @param string $proUid
+ * @param bool $reportFlag
+ * @param bool $offline
+ * @param string $search
* @return array
*/
- public function getTables($pro_uid = '', $reportFlag = false, $offline = false)
+ public function getTables(string $proUid = '', bool $reportFlag = false, bool $offline = false, string $search = ''): array
{
- //VALIDATION
if ($reportFlag) {
- $pro_uid = $this->validateProUid($pro_uid);
+ $proUid = $this->validateProUid($proUid);
}
-
- $reportTables = array();
- $oCriteria = new \Criteria('workflow');
- $oCriteria->addSelectColumn(\AdditionalTablesPeer::ADD_TAB_UID);
- $oCriteria->add(\AdditionalTablesPeer::PRO_UID, $pro_uid, \Criteria::EQUAL);
- $oDataset = \AdditionalTablesPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
- while ($oDataset->next()) {
- $row = $oDataset->getRow();
- $reportTables[] = $this->getTable($row['ADD_TAB_UID'], $pro_uid, $reportFlag, false);
- }
-
- return $reportTables;
+ $additionalTables = ModelAdditionalTables::where('PRO_UID', '=', $proUid)
+ ->where('ADD_TAB_NAME', 'LIKE', "%{$search}%")
+ ->get();
+ $additionalTables->transform(function ($object) use ($proUid, $reportFlag) {
+ return $this->getTable($object->ADD_TAB_UID, $proUid, $reportFlag, false);
+ });
+ return $additionalTables->toArray();
}
/**
diff --git a/workflow/engine/src/ProcessMaker/Model/AppDelay.php b/workflow/engine/src/ProcessMaker/Model/AppDelay.php
index aaef99c09..20018aaeb 100644
--- a/workflow/engine/src/ProcessMaker/Model/AppDelay.php
+++ b/workflow/engine/src/ProcessMaker/Model/AppDelay.php
@@ -30,4 +30,94 @@ class AppDelay extends Model
'APP_ENABLE_ACTION_DATE',
'APP_DISABLE_ACTION_DATE',
];
+
+ /**
+ * Scope a query to filter a specific type
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param string $type
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function scopeType($query, string $type = 'PAUSE')
+ {
+ return $query->where('APP_DELAY.APP_TYPE', $type);
+ }
+ /**
+ * Scope a query to filter a specific disable action
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function scopeNotDisabled($query)
+ {
+ return $query->where('APP_DELAY.APP_DISABLE_ACTION_USER', 0);
+ }
+
+ /**
+ * Scope a query to filter a specific case
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param int $appNumber
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function scopeCase($query, int $appNumber)
+ {
+ return $query->where('APP_DELAY.APP_NUMBER', $appNumber);
+ }
+
+ /**
+ * Scope a query to filter a specific index
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param int $index
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function scopeIndex($query, int $index)
+ {
+ return $query->where('APP_DELAY.APP_DEL_INDEX', $index);
+ }
+
+ /**
+ * Scope a query to filter a specific user
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param string $user
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function scopeDelegateUser($query, string $user)
+ {
+ return $query->where('APP_DELAY.APP_DELEGATION_USER', $user);
+ }
+
+ /**
+ * Get the thread paused
+ *
+ * @param int $appNumber
+ * @param int $index
+ * @param string $userUid
+ *
+ * @return array
+ */
+ public static function getPaused(int $appNumber, int $index, string $userUid = '')
+ {
+ $query = AppDelay::query()->select([
+ 'APP_NUMBER',
+ 'APP_DEL_INDEX AS DEL_INDEX',
+ 'PRO_UID'
+ ]);
+ $query->type('PAUSE')->notDisabled();
+ $query->case($appNumber);
+ // Filter specific index
+ if ($index > 0) {
+ $query->index($index);
+ }
+ // Filter specific delegate user
+ if (!empty($userUid)) {
+ $query->delegateUser($userUid);
+ }
+ // Get the result
+ $results = $query->get();
+
+ return $results->values()->toArray();
+ }
}
diff --git a/workflow/engine/src/ProcessMaker/Model/CaseList.php b/workflow/engine/src/ProcessMaker/Model/CaseList.php
index 1e1f30f50..ae67f7bcd 100644
--- a/workflow/engine/src/ProcessMaker/Model/CaseList.php
+++ b/workflow/engine/src/ProcessMaker/Model/CaseList.php
@@ -173,9 +173,10 @@ class CaseList extends Model
* @param string $search
* @param int $offset
* @param int $limit
+ * @param bool $paged
* @return array
*/
- public static function getSetting(string $type, string $search, int $offset, int $limit): array
+ public static function getSetting(string $type, string $search, int $offset, int $limit, bool $paged = true): array
{
$order = 'asc';
$model = CaseList::where('CAL_TYPE', '=', $type)
@@ -198,7 +199,11 @@ class CaseList extends Model
$count = $model->count();
- $data = $model->offset($offset)->limit($limit)->get();
+ if ($paged === true) {
+ $model->offset($offset)->limit($limit);
+ }
+ $data = $model->get();
+
$data->transform(function ($item, $key) {
if (is_null($item->CAL_COLUMNS)) {
$item->CAL_COLUMNS = '[]';
diff --git a/workflow/engine/src/ProcessMaker/Model/Delegation.php b/workflow/engine/src/ProcessMaker/Model/Delegation.php
index 0b9a0cc15..95a65027b 100644
--- a/workflow/engine/src/ProcessMaker/Model/Delegation.php
+++ b/workflow/engine/src/ProcessMaker/Model/Delegation.php
@@ -173,18 +173,6 @@ class Delegation extends Model
return $query->where('DEL_INDEX', '=', 1);
}
- /**
- * Scope a query to get the in-progress
- *
- * @param \Illuminate\Database\Eloquent\Builder $query
- *
- * @return \Illuminate\Database\Eloquent\Builder
- */
- public function scopeCaseInProgress($query)
- {
- return $query->statusIds([Application::STATUS_DRAFT, Application::STATUS_TODO]);
- }
-
/**
* Scope a query to get the to_do cases
*
@@ -381,36 +369,39 @@ class Delegation extends Model
* Scope a query to get only the date on time
*
* @param \Illuminate\Database\Eloquent\Builder $query
+ * @param string $now
*
* @return \Illuminate\Database\Eloquent\Builder
*/
- public function scopeOnTime($query)
+ public function scopeOnTime($query, $now)
{
- return $query->whereRaw('TIMEDIFF(DEL_RISK_DATE, NOW()) > 0');
+ return $query->where('DEL_RISK_DATE', '>', $now);
}
/**
* Scope a query to get only the date at risk
*
* @param \Illuminate\Database\Eloquent\Builder $query
+ * @param string $now
*
* @return \Illuminate\Database\Eloquent\Builder
*/
- public function scopeAtRisk($query)
+ public function scopeAtRisk($query, $now)
{
- return $query->whereRaw('TIMEDIFF(DEL_RISK_DATE, NOW()) < 0 AND TIMEDIFF(DEL_TASK_DUE_DATE, NOW()) > 0');
+ return $query->where('DEL_RISK_DATE', '>=', $now)->where('DEL_TASK_DUE_DATE', '>=', $now);
}
/**
* Scope a query to get only the date overdue
*
* @param \Illuminate\Database\Eloquent\Builder $query
+ * @param string $now
*
* @return \Illuminate\Database\Eloquent\Builder
*/
- public function scopeOverdue($query)
+ public function scopeOverdue($query, $now)
{
- return $query->whereRaw('TIMEDIFF(DEL_TASK_DUE_DATE, NOW()) < 0');
+ return $query->where('DEL_TASK_DUE_DATE', '>', $now);
}
/**
@@ -774,19 +765,6 @@ class Delegation extends Model
return $query->whereIn('APP_DELEGATION.PRO_ID', $processes);
}
- /**
- * Scope where in processes
- *
- * @param \Illuminate\Database\Eloquent\Builder $query
- * @param array $processes
- *
- * @return \Illuminate\Database\Eloquent\Builder
- */
- public function scopeInProcesses($query, array $processes)
- {
- return $query->whereIn('PROCESS.PRO_ID', $processes);
- }
-
/**
* Scope the Inbox cases
*
@@ -809,26 +787,6 @@ class Delegation extends Model
return $query;
}
- /**
- * Scope the Inbox cases
- *
- * @param \Illuminate\Database\Eloquent\Builder $query
- *
- * @return \Illuminate\Database\Eloquent\Builder
- */
- public function scopeInboxWithoutUser($query)
- {
- // This scope is for the join with the APP_DELEGATION table
- $query->joinApplication();
- $query->status(Application::STATUS_TODO);
- // Scope for the restriction of the task that must not be searched for
- $query->excludeTaskTypes(Task::DUMMY_TASKS);
- // Scope that establish that the DEL_THREAD_STATUS must be OPEN
- $query->threadOpen();
-
- return $query;
- }
-
/**
* Scope a self service cases
*
@@ -1414,7 +1372,7 @@ class Delegation extends Model
* @param string $appUid
* @return array
*
- * @see \ProcessMaker\BusinessModel\Cases:getStatusInfo()
+ * @see \ProcessMaker\BusinessModel\Cases::getStatusInfo()
*/
public static function getParticipatedInfo($appUid)
{
diff --git a/workflow/engine/src/ProcessMaker/Model/User.php b/workflow/engine/src/ProcessMaker/Model/User.php
index 752d1f2a4..44add6a7d 100644
--- a/workflow/engine/src/ProcessMaker/Model/User.php
+++ b/workflow/engine/src/ProcessMaker/Model/User.php
@@ -215,6 +215,7 @@ class User extends Model
public static function getInformation(int $usrId)
{
$query = User::query()->select([
+ 'USR_ID',
'USR_USERNAME',
'USR_FIRSTNAME',
'USR_LASTNAME',
@@ -226,6 +227,7 @@ class User extends Model
$results = $query->get();
$info = [];
$results->each(function ($item) use (&$info) {
+ $info['usr_id'] = $item->USR_ID;
$info['usr_username'] = $item->USR_USERNAME;
$info['usr_firstname'] = $item->USR_FIRSTNAME;
$info['usr_lastname'] = $item->USR_LASTNAME;
diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Home.php b/workflow/engine/src/ProcessMaker/Services/Api/Home.php
index 597ec65ab..e2c87f706 100644
--- a/workflow/engine/src/ProcessMaker/Services/Api/Home.php
+++ b/workflow/engine/src/ProcessMaker/Services/Api/Home.php
@@ -14,6 +14,7 @@ use ProcessMaker\BusinessModel\Cases\Paused;
use ProcessMaker\BusinessModel\Cases\Search;
use ProcessMaker\BusinessModel\Cases\Supervising;
use ProcessMaker\BusinessModel\Cases\Unassigned;
+use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessCategory;
@@ -609,6 +610,30 @@ class Home extends Api
if ($menuInstance->Id[$i] === 'ID_CASE_ARCHIVE_SEARCH') {
$option->icon = "fas fa-archive";
}
+ //custom cases list
+ if (in_array($menuInstance->Id[$i], $optionsWithCounter)) {
+ $mapKeys = [
+ 'CASES_INBOX' => 'inbox',
+ 'CASES_DRAFT' => 'draft',
+ 'CASES_SELFSERVICE' => 'unassigned',
+ 'CASES_PAUSED' => 'paused'
+ ];
+ $option->customCasesList = [];
+ $result = CaseList::getSetting($mapKeys[$menuInstance->Id[$i]], '', 0, 10, false);
+ foreach ($result['data'] as $value) {
+ $option->customCasesList[] = [
+ "href" => "casesListExtJs?action=" . $mapKeys[$menuInstance->Id[$i]],
+ "id" => $value['id'],
+ "title" => $value['name'],
+ "description" => $value['description'],
+ "icon" => $value['iconList'],
+ "badge" => [
+ "text" => "0",
+ "class" => "badge-custom"
+ ]
+ ];
+ }
+ }
// Add option to the menu
$menuHome[] = $option;
}
@@ -727,10 +752,48 @@ class Home extends Api
$result = [];
$result['label'] = $text . $count;
$result['total'] = $count;
-
return $result;
}
+ /**
+ * Get task counters for inbox, draft, paused, and unassigned for custom case lists.
+ * @url GET /:task/counter/caseList/:id
+ * @param string $task
+ * @param int $id
+ * @return array
+ * @access protected
+ * @class AccessControl {@permission PM_CASES}
+ */
+ public function getCustomCaseListCounter(string $task, int $id)
+ {
+ try {
+ $usrUid = $this->getUserId();
+ $usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
+ switch ($task) {
+ case 'inbox':
+ $taskList = new Inbox();
+ break;
+ case 'draft':
+ $taskList = new Draft();
+ break;
+ case 'paused':
+ $taskList = new Paused();
+ break;
+ case 'unassigned':
+ $taskList = new Unassigned();
+ break;
+ default:
+ return [];
+ }
+ $taskList->setUserUid($usrUid);
+ $taskList->setUserId($usrId);
+ $result = $taskList->getCustomListCount($id, $task);
+ return $result;
+ } catch (Exception $e) {
+ throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
+ }
+ }
+
/**
* Get the tasks counters for todo, draft, paused and unassigned
*
diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project/ReportTable.php b/workflow/engine/src/ProcessMaker/Services/Api/Project/ReportTable.php
index 004afda62..63bc90253 100644
--- a/workflow/engine/src/ProcessMaker/Services/Api/Project/ReportTable.php
+++ b/workflow/engine/src/ProcessMaker/Services/Api/Project/ReportTable.php
@@ -1,33 +1,29 @@
- * @copyright Colosa - Bolivia
- *
* @protected
*/
class ReportTable extends Api
{
/**
- * @param string $prj_uid {@min 1} {@max 32}
- *
- * @author Brayan Pereyra (Cochalo)
- * @copyright Colosa - Bolivia
+ * Get list of the report tables by project.
+ * @url GET /:proUid/report-tables
+ * @param string $proUid {@min 1} {@max 32}
+ * @param string $search
* @return array
- *
- * @url GET /:prj_uid/report-tables
+ * @throws RestException
*/
- public function doGetReportTables($prj_uid)
+ public function doGetReportTables(string $proUid, string $search = '')
{
try {
- $oReportTable = new \ProcessMaker\BusinessModel\Table();
- $response = $oReportTable->getTables($prj_uid, true);
+ $reportTable = new Table();
+ $response = $reportTable->getTables($proUid, true, false, $search);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
@@ -38,9 +34,6 @@ class ReportTable extends Api
* @param string $prj_uid {@min 1} {@max 32}
* @param string $rep_uid {@min 1} {@max 32}
* @return array
- * @author Brayan Pereyra (Cochalo)
- * @copyright Colosa - Bolivia
- *
* @url GET /:prj_uid/report-table/:rep_uid
*/
public function doGetReportTable($prj_uid, $rep_uid)
@@ -58,9 +51,6 @@ class ReportTable extends Api
* @param string $prj_uid {@min 1} {@max 32}
* @param string $rep_uid {@min 1} {@max 32}
* @return array
- * @author Brayan Pereyra (Cochalo)
- * @copyright Colosa - Bolivia
- *
* @url GET /:prj_uid/report-table/:rep_uid/populate
*/
public function doGetPopulateReportTable($prj_uid, $rep_uid)
@@ -78,9 +68,6 @@ class ReportTable extends Api
* @param string $prj_uid {@min 1} {@max 32}
* @param string $rep_uid {@min 1} {@max 32}
* @return array
- * @author Brayan Pereyra (Cochalo)
- * @copyright Colosa - Bolivia
- *
* @url GET /:prj_uid/report-table/:rep_uid/data
*/
public function doGetReportTableData($prj_uid, $rep_uid)
diff --git a/workflow/engine/templates/cases/open.js b/workflow/engine/templates/cases/open.js
index 14f117908..adca3bdf9 100644
--- a/workflow/engine/templates/cases/open.js
+++ b/workflow/engine/templates/cases/open.js
@@ -416,7 +416,7 @@ Ext.onReady(function(){
buttonCancel = new Ext.Button({
buttonAlign: 'center',
- text: 'Cancel',
+ text: _("ID_CANCEL"),
handler: redirectHistory,
cls: 'cancelSummary',
width: '100px',
@@ -427,7 +427,7 @@ Ext.onReady(function(){
buttonClaimCase = new Ext.Button({
buttonAlign: 'center',
ui: 'round',
- text: 'Claim this case',
+ text: _("ID_CLAIM_THIS_CASE"),
handler: claimCase,
cls: 'claimCaseSummary',
width: '120px',