Merge branch 'feature/PMCORE-3049' of https://bitbucket.org/colosa/processmaker into feature/PMCORE-3170

This commit is contained in:
Henry Jordan
2021-07-21 15:11:01 +00:00
12 changed files with 573 additions and 124 deletions

View File

@@ -43,7 +43,7 @@ import MyDocuments from "./MyDocuments";
import Todo from "./Inbox/Todo.vue";
import Paused from "./Paused/Paused.vue";
import Draft from "./Draft/Draft.vue";
import Unassigned from "./Unassigned";
import Unassigned from "./Unassigned/Unassigned.vue";
import BatchRouting from "./BatchRouting";
import CaseDetail from "./CaseDetail";
import XCase from "./XCase";

View File

@@ -8,8 +8,9 @@
@onRemoveFilter="onRemoveFilter"
@onUpdateFilters="onUpdateFilters"
/>
<multiview-header :data="dataMultiviewHeader" />
<v-server-table
:data="tableData"
v-if="typeView === 'GRID'"
:columns="columns"
:options="options"
ref="vueTable"
@@ -46,23 +47,140 @@
</div>
</div>
</v-server-table>
<VueCardView
v-if="typeView === 'CARD'"
:options="optionsVueList"
ref="vueCardView"
>
<div slot="detail" slot-scope="props">
<div class="v-pm-card-info" @click="openCaseDetail(props.item)">
<i class="fas fa-info-circle"></i>
</div>
</div>
<div slot="case_number" slot-scope="props" class="v-card-text">
<span class="v-card-text-highlight"
>{{ props["headings"][props.column] }} : {{ props["item"]["CASE_NUMBER"] }}</span
>
</div>
<div slot="case_title" slot-scope="props" class="v-card-text">
<span class="v-card-text-dark"
>{{ props["headings"][props.column] }} :</span
>
<span class="v-card-text-light"
>{{ props["item"]["CASE_TITLE"] }}
</span>
</div>
<div slot="process_name" slot-scope="props" class="v-card-text">
<span class="v-card-text-dark"
>{{ props["headings"][props.column] }} :</span
>
<span class="v-card-text-light"
>{{ props["item"]["PROCESS_NAME"] }}
</span>
</div>
<div slot="due_date" slot-scope="props" class="v-card-text">
<span class="v-card-text-dark"
>{{ props["headings"][props.column] }} :</span
>
<span class="v-card-text-light"
>{{ props["item"]["DUE_DATE"] }}
</span>
</div>
<div slot="delegation_date" slot-scope="props" class="v-card-text">
<span class="v-card-text-dark"
>{{ props["headings"][props.column] }} :</span
>
<span class="v-card-text-light"
>{{ props["item"]["DELEGATION_DATE"] }}
</span>
</div>
<div slot="task" slot-scope="props" class="v-card-text">
<span class="v-card-text-dark"
>{{ props["headings"][props.column] }} :</span
>
<span class="v-card-text-light">
<TaskCell :data="props.item.TASK" />
</span>
</div>
</VueCardView>
<VueListView
v-if="typeView === 'LIST'"
:options="optionsVueList"
ref="vueListView"
>
<div slot="detail" slot-scope="props">
<div class="v-pm-card-info" @click="openCaseDetail(props.item)">
<i class="fas fa-info-circle"></i>
</div>
</div>
<div slot="case_number" slot-scope="props" class="v-card-text">
<span class="v-card-text-highlight"
>{{ props["headings"][props.column] }} : {{ props["item"]["CASE_NUMBER"] }}</span
>
</div>
<div slot="case_title" slot-scope="props" class="v-card-text">
<span class="v-card-text-dark"
>{{ props["headings"][props.column] }} :</span
>
<span class="v-card-text-light"
>{{ props["item"]["CASE_TITLE"] }}
</span>
</div>
<div slot="process_name" slot-scope="props" class="v-card-text">
<span class="v-card-text-dark"
>{{ props["headings"][props.column] }} :</span
>
<span class="v-card-text-light"
>{{ props["item"]["PROCESS_NAME"] }}
</span>
</div>
<div slot="due_date" slot-scope="props" class="v-card-text">
<span class="v-card-text-dark"
>{{ props["headings"][props.column] }} :</span
>
<span class="v-card-text-light"
>{{ props["item"]["DUE_DATE"] }}
</span>
</div>
<div slot="delegation_date" slot-scope="props" class="v-card-text">
<span class="v-card-text-dark"
>{{ props["headings"][props.column] }} :</span
>
<span class="v-card-text-light"
>{{ props["item"]["DELEGATION_DATE"] }}
</span>
</div>
<div slot="task" slot-scope="props" class="v-card-text">
<span class="v-card-text-dark"
>{{ props["headings"][props.column] }} :</span
>
<span class="v-card-text-light">
<TaskCell :data="props.item.TASK" />
</span>
</div>
</VueListView>
<ModalClaimCase ref="modal-claim-case"></ModalClaimCase>
</div>
</template>
<script>
import HeaderCounter from "../components/home/HeaderCounter.vue";
import ButtonFleft from "../components/home/ButtonFleft.vue";
import ModalNewRequest from "./ModalNewRequest.vue";
import TaskCell from "../components/vuetable/TaskCell.vue";
import CasesFilter from "../components/search/CasesFilter";
import ModalClaimCase from "./modal/ModalClaimCase.vue";
import api from "./../api/index";
import utils from "./../utils/utils";
import Ellipsis from '../components/utils/ellipsis.vue';
import HeaderCounter from "../../components/home/HeaderCounter.vue";
import ButtonFleft from "../../components/home/ButtonFleft.vue";
import ModalNewRequest from "../ModalNewRequest.vue";
import TaskCell from "../../components/vuetable/TaskCell.vue";
import CasesFilter from "../../components/search/CasesFilter";
import ModalClaimCase from "../modal/ModalClaimCase.vue";
import api from "../../api/index";
import utils from "../../utils/utils";
import Ellipsis from '../../components/utils/ellipsis.vue';
import MultiviewHeader from "../../components/headers/MultiviewHeader.vue";
import VueCardView from "../../components/dataViews/vueCardView/VueCardView.vue";
import VueListView from "../../components/dataViews/vueListView/VueListView.vue";
import defaultMixins from "./defaultMixins";
export default {
name: "Unassigned",
mixins: [defaultMixins],
components: {
HeaderCounter,
ButtonFleft,
@@ -71,6 +189,9 @@ export default {
ModalClaimCase,
CasesFilter,
Ellipsis,
MultiviewHeader,
VueCardView,
VueListView
},
props: ["defaultOption", "filters"],
data() {
@@ -93,10 +214,8 @@ export default {
"priority",
"actions",
],
tableData: [],
options: {
filterable: false,
sendInitialRequest: false,
headings: {
case_number: this.$i18n.t("ID_MYCASE_NUMBER"),
case_title: this.$i18n.t("ID_CASE_TITLE"),
@@ -327,7 +446,15 @@ export default {
}
if (data.refresh) {
this.$nextTick(() => {
if (this.typeView === "GRID") {
this.$refs["vueTable"].getData();
}
if (this.typeView === "CARD") {
this.$refs["vueCardView"].getData();
}
if (this.typeView === "LIST") {
this.$refs["vueListView"].getData();
}
});
}
},

View File

@@ -0,0 +1,136 @@
import api from "../../api/index";
export default {
data() {
let that = this;
return {
typeView: "GRID",
dataMultiviewHeader: {
actions: [
{
id: "view-grid",
title: "Grid",
onClick(action) {
that.typeView = "GRID";
},
icon: "fas fa-table",
},
{
id: "view-list",
title: "List",
onClick(action) {
that.typeView = "LIST";
},
icon: "fas fa-list",
},
{
id: "view-card",
title: "Card",
onClick(action) {
that.typeView = "CARD";
},
icon: "fas fa-th",
},
],
},
optionsVueList: {
limit: 10,
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"),
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"
],
requestFunction(data) {
return that.getCases(data);
},
requestFunctionViewMore(data) {
return that.getCasesViewMore(data);
}
}
}
},
created: function () {
},
methods: {
/**
* Get cases for Vue Card View
*/
getCases(data) {
let that = this,
dt,
start = 0,
limit = data.limit,
filters = {};
filters = {
paged: "0," + limit,
};
_.forIn(this.filters, function (item, key) {
filters[item.filterVar] = item.value;
});
return new Promise((resolutionFunc, rejectionFunc) => {
api.cases
.unassigned(filters)
.then((response) => {
dt = that.formatDataResponse(response.data.data);
resolutionFunc({
data: dt,
count: response.data.total,
});
})
.catch((e) => {
rejectionFunc(e);
});
});
},
/**
* Get cases for Vue Card View
*/
getCasesViewMore(data) {
let that = this,
dt,
paged,
limit = data.limit,
start = data.page === 1 ? 0 : limit * (data.page - 1),
filters = {};
paged = start + "," + limit;
filters = {
paged: paged,
};
_.forIn(this.filters, function (item, key) {
filters[item.filterVar] = item.value;
});
return new Promise((resolutionFunc, rejectionFunc) => {
api.cases
.unassigned(filters)
.then((response) => {
dt = that.formatDataResponse(response.data.data);
resolutionFunc({
data: dt,
count: response.data.total,
});
})
.catch((e) => {
rejectionFunc(e);
});
});
},
}
}

View File

@@ -21,6 +21,22 @@ class AbstractCasesTest extends TestCase
{
use DatabaseTransactions;
/**
* This check the getter and setter related to the category
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCategoryId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCategoryId()
* @test
*/
public function it_return_set_get_category()
{
$category = factory(ProcessCategory::class)->create();
$absCases = new AbstractCases();
$absCases->setCategoryId($category->CATEGORY_ID);
$actual = $absCases->getCategoryId();
$this->assertEquals($category->CATEGORY_ID, $actual);
}
/**
* This check the getter and setter related to the category
*
@@ -28,7 +44,7 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCategoryUid()
* @test
*/
public function it_return_set_get_category()
public function it_return_set_get_category_uid()
{
$category = factory(ProcessCategory::class)->create();
$absCases = new AbstractCases();
@@ -95,6 +111,38 @@ class AbstractCasesTest extends TestCase
$this->assertEquals($users->USR_ID, $actual);
}
/**
* This check the getter and setter related to the user completed
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserCompletedId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserCompletedId()
* @test
*/
public function it_return_set_get_user_completed()
{
$users = factory(User::class)->create();
$absCases = new AbstractCases();
$absCases->setUserCompletedId($users->USR_ID);
$actual = $absCases->getUserCompletedId();
$this->assertEquals($users->USR_ID, $actual);
}
/**
* This check the getter and setter related to the user started
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserStartedId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserStartedId()
* @test
*/
public function it_return_set_get_user_started()
{
$users = factory(User::class)->create();
$absCases = new AbstractCases();
$absCases->setUserStartedId($users->USR_ID);
$actual = $absCases->getUserStartedId();
$this->assertEquals($users->USR_ID, $actual);
}
/**
* This check the getter and setter related to the priority
*
@@ -580,7 +628,7 @@ class AbstractCasesTest extends TestCase
}
/**
* This check the getter and setter related to the oldest than date
* This check the getter and setter related to the order by column
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOrderByColumn()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOrderByColumn()
@@ -593,6 +641,20 @@ class AbstractCasesTest extends TestCase
$absCases->setOrderByColumn($text);
$actual = $absCases->getOrderByColumn();
$this->assertEquals($text, $actual);
}
/**
* This test the exception setOrderByColumn
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOrderByColumn()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOrderByColumn()
* @test
*/
public function it_return_exception_order_by_column()
{
$this->expectException(Exception::class);
$absCases = new AbstractCases();
$absCases->setOrderByColumn('INVALID');
}
/**
@@ -711,39 +773,8 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumber()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseTitle()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getProcessId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getTaskId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseNumber()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseTitle()
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setParticipatedStatus()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatus()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setStartCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setStartCaseTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishCaseTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getParticipatedStatus()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseStatus()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getStartCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getStartCaseTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFinishCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFinishCaseTo()
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFilterCases()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatuses()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProperties()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDelegateFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDelegateTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDueFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDueTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFilterCases()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseStatuses()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDelegateFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDelegateTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDueFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDueTo()
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCasesNumbers()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setRangeCasesFromTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseUid()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCasesUids()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOrderByColumn()
@@ -751,6 +782,14 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setPaged()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOffset()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setLimit()
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getProcessId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getTaskId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseNumber()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseTitle()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCasesNumbers()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getRangeCasesFromTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseUid()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCasesUids()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOrderByColumn()
@@ -764,23 +803,13 @@ class AbstractCasesTest extends TestCase
{
$absCases = new AbstractCases();
$properties = [
// Tasks - Cases
// Filters that works for all list
'process' => rand(),
'task' => rand(),
'user' => rand(),
'caseNumber' => rand(),
'caseTitle' => G::generateUniqueID(),
// Home - Search
'caseStatuses' => ['TO_DO','DRAFT'],
'filterCases'=> '1,3-5,8,10-15',
// Home - My cases
'filter'=> 'STARTED',
'caseStatus' => 'TO_DO',
'startCaseFrom' => date('Y-m-d'),
'startCaseTo' => date('Y-m-d'),
'finishCaseFrom' => date('Y-m-d'),
'finishCaseTo' => date('Y-m-d'),
// Other
'caseLink' => G::generateUniqueID(),
'appUidCheck' => [G::generateUniqueID()],
'sort' => 'APP_NUMBER',
@@ -801,37 +830,10 @@ class AbstractCasesTest extends TestCase
$this->assertEquals($properties['caseNumber'], $actual);
$actual = $absCases->getCaseTitle();
$this->assertEquals($properties['caseTitle'], $actual);
// Home - Search
$actual = $absCases->getCaseStatuses();
$this->assertNotEmpty($actual);
$actual = $absCases->getFilterCases();
$this->assertEmpty($actual);
$actual = $absCases->getCasesNumbers();
$this->assertEmpty($actual);
$this->assertNotEmpty($actual);
$actual = $absCases->getRangeCasesFromTo();
$this->assertEmpty($actual);
$actual = $absCases->getStartCaseFrom();
$this->assertEmpty($actual);
$actual = $absCases->getStartCaseTo();
$this->assertEmpty($actual);
$actual = $absCases->getFinishCaseFrom();
$this->assertEmpty($actual);
$actual = $absCases->getFinishCaseTo();
$this->assertEmpty($actual);
// Home - My cases
$actual = $absCases->getParticipatedStatus();
$this->assertEmpty($actual);
$actual = $absCases->getCaseStatus();
$this->assertEmpty($actual);
$actual = $absCases->getStartCaseFrom();
$this->assertEmpty($actual);
$actual = $absCases->getStartCaseTo();
$this->assertEmpty($actual);
$actual = $absCases->getFinishCaseFrom();
$this->assertEmpty($actual);
$actual = $absCases->getFinishCaseTo();
$this->assertEmpty($actual);
// Other
$this->assertNotEmpty($actual);
$actual = $absCases->getCaseUid();
$this->assertEquals($properties['caseLink'], $actual);
$actual = $absCases->getCasesUids();
@@ -858,8 +860,15 @@ class AbstractCasesTest extends TestCase
{
$absCases = new AbstractCases();
$dueDate = date('Y-m-d');
// Review overdue
$result = $absCases->getTaskColor($dueDate);
$this->assertNotEmpty($result);
$absCases = new AbstractCases();
$dueDate = date('Y-m-d');
// Review on-time
$result = $absCases->getTaskColor($dueDate,'' ,'2000-01-01');
$this->assertNotEmpty($result);
}
/**

View File

@@ -263,9 +263,6 @@ class DraftTest extends TestCase
'APP_NUMBER',
'DEL_TITLE',
'PRO_TITLE',
'TAS_TITLE',
'DEL_TASK_DUE_DATE',
'DEL_DELEGATE_DATE'
];
$index = array_rand($columnsView);
// Create new Inbox object

View File

@@ -256,9 +256,6 @@ class InboxTest extends TestCase
'APP_NUMBER',
'DEL_TITLE',
'PRO_TITLE',
'TAS_TITLE',
'DEL_TASK_DUE_DATE',
'DEL_DELEGATE_DATE'
];
$index = array_rand($columnsView);
// Create new Inbox object

View File

@@ -675,9 +675,6 @@ class SupervisingTest extends TestCase
'APP_NUMBER',
'DEL_TITLE',
'PRO_TITLE',
'TAS_TITLE',
'APP_CREATE_DATE',
'APP_FINISH_DATE'
];
$index = array_rand($columnsView);
// Instance the Supervising object

View File

@@ -463,6 +463,20 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->positiveCases()->get());
}
/**
* This test scopeCasesOrRangeOfCases
*
* @covers \ProcessMaker\Model\Delegation::scopeCasesOrRangeOfCases()
* @test
*/
public function it_return_scope_cases_and_range_of_cases()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$cases = [$table->APP_NUMBER];
$rangeCases = [$table->APP_NUMBER.'-'.$table->APP_NUMBER];
$this->assertCount(1, $table->casesOrRangeOfCases($cases, $rangeCases)->get());
}
/**
* This test scopeRangeOfCases
*
@@ -549,6 +563,18 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->processId($table->PRO_ID)->get());
}
/**
* This test scopeTask
*
* @covers \ProcessMaker\Model\Delegation::scopeTask()
* @test
*/
public function it_return_scope_task_id()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->task($table->TAS_ID)->get());
}
/**
* This test scopeTask
*
@@ -639,6 +665,18 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->processInList([$table->PRO_ID])->get());
}
/**
* This test scopeParticipated
*
* @covers \ProcessMaker\Model\Delegation::scopeParticipated()
* @test
*/
public function it_return_scope_participated()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->participated($table->USR_ID)->get());
}
/**
* This test scopeJoinCategoryProcess
*
@@ -3208,4 +3246,30 @@ class DelegationTest extends TestCase
// Assert the result is true
$this->assertTrue($res);
}
/**
* This check the return cases completed by specific user
*
* @covers \ProcessMaker\Model\Delegation::casesCompletedBy()
* @test
*/
public function it_get_cases_completed_by_specific_user()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::casesCompletedBy($delegation->USR_ID);
$this->assertEmpty($result);
}
/**
* This check the return cases completed by specific user
*
* @covers \ProcessMaker\Model\Delegation::casesStartedBy()
* @test
*/
public function it_get_cases_started_by_specific_user()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::casesStartedBy($delegation->USR_ID);
$this->assertNotEmpty($result);
}
}

View File

@@ -58,6 +58,12 @@ class AbstractCases implements CasesInterface
// Filter by user using the Id field
private $userId = 0;
// Filter by user who completed using the Id field
private $userCompleted = 0;
// Filter by user who started using the Id field
private $userStarted = 0;
// Value to search, can be a text or an application number, know as "$search" in the old lists classes
private $valueToSearch = '';
@@ -282,6 +288,46 @@ class AbstractCases implements CasesInterface
return $this->userId;
}
/**
* Set User Id value
*
* @param int $userId
*/
public function setUserCompletedId(int $userId)
{
$this->userCompleted = $userId;
}
/**
* Get User Id value
*
* @return int
*/
public function getUserCompletedId()
{
return $this->userCompleted;
}
/**
* Set User Id value
*
* @param int $userId
*/
public function setUserStartedId(int $userId)
{
$this->userStarted = $userId;
}
/**
* Get User Id value
*
* @return int
*/
public function getUserStartedId()
{
return $this->userStarted;
}
/**
* Set value to search
*
@@ -1294,6 +1340,34 @@ class AbstractCases implements CasesInterface
if (!empty($properties['caseTitle'])) {
$this->setCaseTitle($properties['caseTitle']);
}
// Filter by case uid
if (!empty($properties['caseLink'])) {
$this->setCaseUid($properties['caseLink']);
}
// Filter by array of case uids
if (!empty($properties['appUidCheck'])) {
$this->setCasesUids($properties['appUidCheck']);
}
// Sort column
if (!empty($properties['sort'])) {
$this->setOrderByColumn($properties['sort']);
}
// Direction column
if (!empty($properties['dir'])) {
$this->setOrderDirection($properties['dir']);
}
// Paged
if (!empty($properties['paged'])) {
$this->setPaged($properties['paged']);
}
// Start
if (!empty($properties['start'])) {
$this->setOffset($properties['start']);
}
// Limit
if (!empty($properties['limit'])) {
$this->setLimit($properties['limit']);
}
/** Apply filters related to INBOX */
// Filter date related to delegate from
if (get_class($this) === Inbox::class && !empty($properties['delegateFrom'])) {
@@ -1372,33 +1446,13 @@ class AbstractCases implements CasesInterface
if (get_class($this) === Search::class && !empty($properties['finishCaseTo'])) {
$this->setFinishCaseTo($properties['finishCaseTo']);
}
// Filter by case uid
if (!empty($properties['caseLink'])) {
$this->setCaseUid($properties['caseLink']);
// Filter date related to user who started
if (get_class($this) === Search::class && !empty($properties['userCompleted'])) {
$this->setUserCompletedId($properties['userCompleted']);
}
// Filter by array of case uids
if (!empty($properties['appUidCheck'])) {
$this->setCasesUids($properties['appUidCheck']);
}
// Sort column
if (!empty($properties['sort'])) {
$this->setOrderByColumn($properties['sort']);
}
// Direction column
if (!empty($properties['dir'])) {
$this->setOrderDirection($properties['dir']);
}
// Paged
if (!empty($properties['paged'])) {
$this->setPaged($properties['paged']);
}
// Start
if (!empty($properties['start'])) {
$this->setOffset($properties['start']);
}
// Limit
if (!empty($properties['limit'])) {
$this->setLimit($properties['limit']);
// Filter date related to user who completed
if (get_class($this) === Search::class && !empty($properties['userStarted'])) {
$this->setUserStartedId($properties['userStarted']);
}
}

View File

@@ -88,6 +88,18 @@ class Search extends AbstractCases
// Get only the open threads related to the user
$query->where('APP_DELEGATION.DEL_THREAD_STATUS', '=', 'OPEN');
}
// Filter by user who started
if ($this->getUserStartedId()) {
// Get the case numbers related to this filter
$result = Delegation::casesStartedBy($this->getUserStartedId(), $this->getOffset(), $this->getLimit());
$query->specificCases($result);
}
// Filter by user who completed
if ($this->getUserCompletedId()) {
// Get the case numbers related to this filter
$result = Delegation::casesCompletedBy($this->getUserCompletedId(), $this->getOffset(), $this->getLimit());
$query->specificCases($result);
}
// Filter by task
if ($this->getTaskId()) {
// Join with delegation

View File

@@ -2051,4 +2051,54 @@ class Delegation extends Model
}
return false;
}
/**
* Get cases completed by specific user
*
* @param int $userId
* @param int $offset
* @param int $limit
*
* @return array
*/
public static function casesCompletedBy(int $userId, int $offset = 0, int $limit = 15)
{
// Get the case numbers related to this filter
$query = Delegation::query()->select(['APP_NUMBER']);
// Filter the user
$query->participated($userId);
// Filter the last thread
$query->lastThread();
// Apply the limit
$query->offset($offset)->limit($limit);
// Get the result
$results = $query->get();
return $results->values()->toArray();
}
/**
* Get cases started by specific user
*
* @param int $userId
* @param int $offset
* @param int $limit
*
* @return array
*/
public static function casesStartedBy(int $userId, int $offset = 0, int $limit = 15)
{
// Get the case numbers related to this filter
$query = Delegation::query()->select(['APP_NUMBER']);
// Filter the user
$query->participated($userId);
// Filter the first thread
$query->caseStarted();
// Apply the limit
$query->offset($offset)->limit($limit);
// Get the result
$results = $query->get();
return $results->values()->toArray();
}
}

View File

@@ -464,6 +464,8 @@ class Home extends Api
* @param int $process
* @param int $task
* @param int $user
* @param int $userCompleted
* @param int $userStarted
* @param string $caseTitle
* @param string $caseStatuses
* @param string $filterCases
@@ -487,6 +489,8 @@ class Home extends Api
int $process = 0,
int $task = 0,
int $user = 0,
int $userCompleted = 0,
int $userStarted = 0,
string $caseTitle = '',
string $caseStatuses = '',
string $filterCases = '',
@@ -507,6 +511,8 @@ class Home extends Api
$properties['process'] = $process;
$properties['task'] = $task;
$properties['user'] = $user;
$properties['userCompleted'] = $userCompleted;
$properties['userStarted'] = $userStarted;
$properties['caseStatuses'] = explode(',', $caseStatuses);
$properties['filterCases'] = $filterCases;
$properties['startCaseFrom'] = $startCaseFrom;