diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html
index 064a9d4f55..a39ecc56e1 100644
--- a/modules/claim/front/basic-data/index.html
+++ b/modules/claim/front/basic-data/index.html
@@ -28,10 +28,10 @@
{{firstName}} {{name}}
{{firstName}} {{name}}
diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js
index 035074210b..842565c3f1 100644
--- a/modules/client/back/models/client.js
+++ b/modules/client/back/models/client.js
@@ -8,7 +8,6 @@ const LoopBackContext = require('loopback-context');
module.exports = Self => {
// Methods
- require('../methods/client/activeWorkersWithRole')(Self);
require('../methods/client/getCard')(Self);
require('../methods/client/createWithUser')(Self);
require('../methods/client/listWorkers')(Self);
diff --git a/modules/client/front/basic-data/index.html b/modules/client/front/basic-data/index.html
index 6235ec9238..e4debac16e 100644
--- a/modules/client/front/basic-data/index.html
+++ b/modules/client/front/basic-data/index.html
@@ -54,11 +54,11 @@
diff --git a/modules/client/front/consumption-search-panel/index.html b/modules/client/front/consumption-search-panel/index.html
index fbcf24fade..28370537d7 100644
--- a/modules/client/front/consumption-search-panel/index.html
+++ b/modules/client/front/consumption-search-panel/index.html
@@ -17,10 +17,10 @@
{{nickname}}
diff --git a/modules/client/front/create/index.html b/modules/client/front/create/index.html
index d9759e3478..c5fa356587 100644
--- a/modules/client/front/create/index.html
+++ b/modules/client/front/create/index.html
@@ -18,10 +18,10 @@
+ where="{role: 'salesPerson'}">
{{firstName}} {{lastName}}
diff --git a/modules/client/front/search-panel/index.html b/modules/client/front/search-panel/index.html
index 7577676716..9caf4185bb 100644
--- a/modules/client/front/search-panel/index.html
+++ b/modules/client/front/search-panel/index.html
@@ -17,7 +17,7 @@
diff --git a/modules/item/front/fixed-price-search-panel/index.html b/modules/item/front/fixed-price-search-panel/index.html
index 5a1e7781e3..773862bf17 100644
--- a/modules/item/front/fixed-price-search-panel/index.html
+++ b/modules/item/front/fixed-price-search-panel/index.html
@@ -44,7 +44,7 @@
{{nickname}}
diff --git a/modules/item/front/search-panel/index.html b/modules/item/front/search-panel/index.html
index f30442ec61..545cffda0d 100644
--- a/modules/item/front/search-panel/index.html
+++ b/modules/item/front/search-panel/index.html
@@ -42,11 +42,11 @@
vn-one
disabled="false"
ng-model="filter.salesPersonFk"
- url="Clients/activeWorkersWithRole"
+ url="Workers/activeWithRole"
show-field="nickname"
search-function="{firstName: $search}"
value-field="id"
- where="{role: 'employee'}"
+ where="{role: 'buyer'}"
label="Buyer">
diff --git a/modules/order/front/search-panel/index.html b/modules/order/front/search-panel/index.html
index f9b214578d..c622dd1523 100644
--- a/modules/order/front/search-panel/index.html
+++ b/modules/order/front/search-panel/index.html
@@ -28,11 +28,11 @@
diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html
index 0a1734ff2a..d3ba25b110 100644
--- a/modules/route/front/basic-data/index.html
+++ b/modules/route/front/basic-data/index.html
@@ -11,7 +11,7 @@
diff --git a/modules/route/front/search-panel/index.html b/modules/route/front/search-panel/index.html
index 4c9dd3110f..6e3d30d306 100644
--- a/modules/route/front/search-panel/index.html
+++ b/modules/route/front/search-panel/index.html
@@ -13,7 +13,7 @@
{{nickname}}
diff --git a/modules/ticket/front/request/create/index.html b/modules/ticket/front/request/create/index.html
index 755e8cb513..f7280b2de3 100644
--- a/modules/ticket/front/request/create/index.html
+++ b/modules/ticket/front/request/create/index.html
@@ -18,7 +18,7 @@
diff --git a/modules/ticket/front/search-panel/index.html b/modules/ticket/front/search-panel/index.html
index 55611899b7..d0b77b9dea 100644
--- a/modules/ticket/front/search-panel/index.html
+++ b/modules/ticket/front/search-panel/index.html
@@ -60,7 +60,7 @@
{
- Self.remoteMethod('activeWorkersWithRole', {
- description: 'Returns actives workers with salesperson role',
- accessType: 'READ',
- accepts: [{
- arg: 'filter',
- type: 'Object',
- description: 'Filter defining where and paginated data',
- required: true
- }],
- returns: {
- type: 'Worker',
- root: true
- },
- http: {
- path: `/activeWorkersWithRole`,
- verb: 'get'
- }
- });
-
- Self.activeWorkersWithRole = async filter => {
+ Self.activeWorkers = async(query, filter) => {
let conn = Self.dataSource.connector;
if (filter.where && filter.where.and && Array.isArray(filter.where.and)) {
let where = {};
@@ -54,14 +35,8 @@ module.exports = Self => {
myFilter = mergeFilters(myFilter, clientFilter);
- let stmt = new ParameterizedSQL(
- `SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname
- FROM worker w
- JOIN account.user u ON u.id = w.userFk
- JOIN account.roleRole i ON i.role = u.role
- JOIN account.role r ON r.id = i.inheritsFrom`
- );
+ let stmt = new ParameterizedSQL(query);
stmt.merge(conn.makeSuffix(myFilter));
- return await conn.executeStmt(stmt);
+ return conn.executeStmt(stmt);
};
};
diff --git a/modules/worker/back/methods/worker/activeWithInheritedRole.js b/modules/worker/back/methods/worker/activeWithInheritedRole.js
new file mode 100644
index 0000000000..9536b0f29b
--- /dev/null
+++ b/modules/worker/back/methods/worker/activeWithInheritedRole.js
@@ -0,0 +1,32 @@
+
+module.exports = Self => {
+ Self.remoteMethod('activeWithInheritedRole', {
+ description: 'Returns active workers with a role',
+ accessType: 'READ',
+ accepts: [{
+ arg: 'filter',
+ type: 'Object',
+ description: 'Filter defining where and paginated data',
+ required: true
+ }],
+ returns: {
+ type: ['object'],
+ root: true
+ },
+ http: {
+ path: `/activeWithInheritedRole`,
+ verb: 'GET'
+ }
+ });
+
+ Self.activeWithInheritedRole = async filter => {
+ const query =
+ `SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname
+ FROM worker w
+ JOIN account.user u ON u.id = w.userFk
+ JOIN account.roleRole i ON i.role = u.role
+ JOIN account.role r ON r.id = i.inheritsFrom`;
+
+ return Self.activeWorkers(query, filter);
+ };
+};
diff --git a/modules/worker/back/methods/worker/activeWithRole.js b/modules/worker/back/methods/worker/activeWithRole.js
new file mode 100644
index 0000000000..3924164585
--- /dev/null
+++ b/modules/worker/back/methods/worker/activeWithRole.js
@@ -0,0 +1,31 @@
+
+module.exports = Self => {
+ Self.remoteMethod('activeWithRole', {
+ description: 'Returns active workers with an inherited role',
+ accessType: 'READ',
+ accepts: [{
+ arg: 'filter',
+ type: 'Object',
+ description: 'Filter defining where and paginated data',
+ required: true
+ }],
+ returns: {
+ type: ['object'],
+ root: true
+ },
+ http: {
+ path: `/activeWithRole`,
+ verb: 'GET'
+ }
+ });
+
+ Self.activeWithRole = async filter => {
+ const query =
+ `SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname
+ FROM worker w
+ JOIN account.user u ON u.id = w.id
+ JOIN account.role r ON r.id = u.role`;
+
+ return Self.activeWorkers(query, filter);
+ };
+};
diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js
index 0d94c788ec..9bfef52351 100644
--- a/modules/worker/back/models/worker.js
+++ b/modules/worker/back/models/worker.js
@@ -7,4 +7,7 @@ module.exports = Self => {
require('../methods/worker/createAbsence')(Self);
require('../methods/worker/deleteAbsence')(Self);
require('../methods/worker/updateAbsence')(Self);
+ require('../methods/worker/active')(Self);
+ require('../methods/worker/activeWithRole')(Self);
+ require('../methods/worker/activeWithInheritedRole')(Self);
};
diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html
index a767eccc4a..228ae39d41 100644
--- a/modules/worker/front/basic-data/index.html
+++ b/modules/worker/front/basic-data/index.html
@@ -30,13 +30,13 @@
rule>
+ disabled="false"
+ ng-model="$ctrl.worker.bossFk"
+ url="Clients/activeWorkersWithInheritRole"
+ show-field="nickname"
+ search-function="{firstName: $search}"
+ where="{role: 'employee'}"
+ label="Boss">