diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js
index a3c17ecc4..5fea43fbd 100644
--- a/modules/ticket/back/methods/ticket/filter.js
+++ b/modules/ticket/back/methods/ticket/filter.js
@@ -63,6 +63,10 @@ module.exports = Self => {
arg: 'myTeam',
type: 'Boolean',
description: `Whether to show only tickets for the current logged user team (For now it shows only the current user tickets)`
+ }, {
+ arg: 'problems',
+ type: 'Boolean',
+ description: `Whether to show only tickets with problems`
}, {
arg: 'mine',
type: 'Boolean',
@@ -239,6 +243,38 @@ module.exports = Self => {
FROM tmp.filter f
LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = f.id
LEFT JOIN tmp.ticketTotal tt ON tt.ticketFk = f.id`);
+
+
+ let condition;
+ let hasProblem;
+ let range;
+ let hasWhere;
+ switch (ctx.args.problems) {
+ case true:
+ condition = `or`;
+ hasProblem = true;
+ range = 0;
+ hasWhere = true;
+ break;
+
+ case false:
+ condition = `and`;
+ hasProblem = null;
+ range = null;
+ hasWhere = true;
+ break;
+ }
+
+ let problems = {[condition]: [
+ {'tp.isFreezed': hasProblem},
+ {'tp.risk': hasProblem},
+ {'tp.hasTicketRequest': hasProblem},
+ {'tp.isAvailable': range}
+ ]};
+
+ if (hasWhere)
+ stmt.merge(conn.makeWhere(problems));
+
stmt.merge(conn.makeOrderBy(filter.order));
let ticketsIndex = stmts.push(stmt);
diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js
index 357ef2bdb..7e5e1c126 100644
--- a/modules/ticket/back/methods/ticket/specs/filter.spec.js
+++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js
@@ -10,4 +10,31 @@ describe('ticket filter()', () => {
expect(ticketId).toEqual(24);
});
+
+ it('should return the tickets matching the problems on true', async() => {
+ let ctx = {req: {accessToken: {userId: 9}}, args: {problems: true}};
+
+ let filter = {};
+ let result = await app.models.Ticket.filter(ctx, filter);
+
+ expect(result.length).toEqual(4);
+ });
+
+ it('should return the tickets matching the problems on false', async() => {
+ let ctx = {req: {accessToken: {userId: 9}}, args: {problems: false}};
+
+ let filter = {};
+ let result = await app.models.Ticket.filter(ctx, filter);
+
+ expect(result.length).toEqual(20);
+ });
+
+ it('should return the tickets matching the problems on null', async() => {
+ let ctx = {req: {accessToken: {userId: 9}}, args: {problems: null}};
+
+ let filter = {};
+ let result = await app.models.Ticket.filter(ctx, filter);
+
+ expect(result.length).toEqual(24);
+ });
});
diff --git a/modules/ticket/front/search-panel/index.html b/modules/ticket/front/search-panel/index.html
index 27b8cbe99..ae5e152c6 100644
--- a/modules/ticket/front/search-panel/index.html
+++ b/modules/ticket/front/search-panel/index.html
@@ -91,12 +91,6 @@
-
-
+
+
+
+
+
+
diff --git a/modules/worker/back/methods/holiday/getByWarehouse.js b/modules/worker/back/methods/holiday/getByWarehouse.js
index a56b5166e..8a7fd8be3 100644
--- a/modules/worker/back/methods/holiday/getByWarehouse.js
+++ b/modules/worker/back/methods/holiday/getByWarehouse.js
@@ -23,11 +23,11 @@ module.exports = Self => {
beginningYear.setHours(0, 0, 0, 0);
let holidays = await Self.rawSql(
- `SELECT lh.dated, lhl.description, lht.name, w.id
+ `SELECT lh.dated, chn.name, cht.name, w.id
FROM vn.holiday lh
JOIN vn.workCenter w ON w.id = lh.workcenterFk
- LEFT JOIN vn.holidayDetail lhl ON lhl.id = lh.holidayDetailFk
- LEFT JOIN vn.holidayType lht ON lht.id = lh.holidayTypeFk
+ LEFT JOIN vn.calendarHolidaysName chn ON chn.id = lh.holidayDetailFk
+ LEFT JOIN vn.calendarHolidaysType cht ON cht.id = lh.holidayTypeFk
WHERE w.warehouseFk = ? AND lh.dated >= ?`, [warehouseFk, beginningYear]);
return holidays.map(holiday => {