diff --git a/modules/claim/back/methods/claim/claimPickupEmail.js b/modules/claim/back/methods/claim/claimPickupEmail.js index b946353d6..4d64cc66e 100644 --- a/modules/claim/back/methods/claim/claimPickupEmail.js +++ b/modules/claim/back/methods/claim/claimPickupEmail.js @@ -1,8 +1,9 @@ -const {Report, Email, smtp} = require('vn-print'); +const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('claimPickupEmail', { description: 'Sends the the claim pickup order email with an attached PDF', + accessType: 'WRITE', accepts: [ { arg: 'id', @@ -40,7 +41,7 @@ module.exports = Self => { } }); - Self.claimPickupEmail = async(ctx, id) => { + Self.claimPickupEmail = async ctx => { const args = Object.assign({}, ctx.args); const params = { recipient: args.recipient, diff --git a/modules/client/back/methods/client/consumptionSendQueued.js b/modules/client/back/methods/client/consumptionSendQueued.js index 3f551d3d2..77e0e34f2 100644 --- a/modules/client/back/methods/client/consumptionSendQueued.js +++ b/modules/client/back/methods/client/consumptionSendQueued.js @@ -18,46 +18,46 @@ module.exports = Self => { Self.consumptionSendQueued = async() => { const queues = await Self.rawSql(` SELECT - ccq.id, - c.id AS clientFk, - c.email AS clientEmail, - eu.email salesPersonEmail, - REPLACE(json_extract(params, '$.from'), '"', '') AS fromDate, - REPLACE(json_extract(params, '$.to'), '"', '') AS toDate - FROM clientConsumptionQueue ccq - JOIN client c ON ( - JSON_SEARCH( - JSON_ARRAY( - json_extract(params, '$.clients') - ) - , 'all', c.id) IS NOT NULL) - JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk - JOIN ticket t ON t.clientFk = c.id - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk - WHERE status = '' - AND it.isPackaging = FALSE - AND DATE(t.shipped) BETWEEN - REPLACE(json_extract(params, '$.from'), '"', '') AND - REPLACE(json_extract(params, '$.to'), '"', '') - GROUP BY c.id`); + id, + params + FROM clientConsumptionQueue + WHERE status = ''`); for (const queue of queues) { try { - const args = { - id: queue.clientFk, - recipient: queue.clientEmail, - replyTo: queue.salesPersonEmail, - from: queue.fromDate, - to: queue.toDate - }; + const params = JSON.parse(queue.params); - const email = new Email('campaign-metrics', args); - await email.send(); + const clients = await Self.rawSql(` + SELECT + c.id AS clientFk, + c.email AS clientEmail, + eu.email salesPersonEmail + FROM client c + JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk + JOIN ticket t ON t.clientFk = c.id + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + WHERE c.id IN(?) + AND it.isPackaging = FALSE + AND DATE(t.shipped) BETWEEN ? AND ? + GROUP BY c.id`, [params.clients, params.from, params.to]); + + for (const client of clients) { + const args = { + id: client.clientFk, + recipient: client.clientEmail, + replyTo: client.salesPersonEmail, + from: params.from, + to: params.to + }; + + const email = new Email('campaign-metrics', args); + await email.send(); + } await Self.rawSql(` - UPDATE clientConsumptionQueue + UPDATE clientConsumptionQueue SET status = 'printed', printed = ? WHERE id = ?`, @@ -69,7 +69,7 @@ module.exports = Self => { WHERE id = ?`, [error.message, queue.id]); - throw e; + throw error; } } diff --git a/modules/client/front/notification/index.js b/modules/client/front/notification/index.js index e70af12b2..faa062b25 100644 --- a/modules/client/front/notification/index.js +++ b/modules/client/front/notification/index.js @@ -77,15 +77,16 @@ export default class Controller extends Section { onSendClientConsumption() { const clientIds = this.checked.map(client => client.id); - const params = { + const data = { clients: clientIds, from: this.campaign.from, to: this.campaign.to }; + const params = JSON.stringify(data); this.$http.post('ClientConsumptionQueues', {params}) .then(() => this.$.filters.hide()) - .then(() => this.vnApp.showSuccess(this.$t('Notifications sent!'))); + .then(() => this.vnApp.showSuccess(this.$t('Notification sent!'))); } exprBuilder(param, value) { diff --git a/modules/client/front/notification/index.spec.js b/modules/client/front/notification/index.spec.js index ea082c403..4e754f6ad 100644 --- a/modules/client/front/notification/index.spec.js +++ b/modules/client/front/notification/index.spec.js @@ -69,15 +69,16 @@ describe('Client notification', () => { data[0].$checked = true; data[1].$checked = true; - const params = Object.assign({ + const args = Object.assign({ clients: [1101, 1102] }, controller.campaign); + const params = JSON.stringify(args); $httpBackend.expect('POST', `ClientConsumptionQueues`, {params}).respond(200, params); controller.onSendClientConsumption(); $httpBackend.flush(); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Notifications sent!'); + expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Notification sent!'); }); }); diff --git a/modules/route/back/methods/route/driverRouteEmail.js b/modules/route/back/methods/route/driverRouteEmail.js index 81d770360..4d5279d2d 100644 --- a/modules/route/back/methods/route/driverRouteEmail.js +++ b/modules/route/back/methods/route/driverRouteEmail.js @@ -3,6 +3,7 @@ const {Email} = require('vn-print'); module.exports = Self => { Self.remoteMethodCtx('driverRouteEmail', { description: 'Sends the driver route email with an attached PDF', + accessType: 'WRITE', accepts: [ { arg: 'id', diff --git a/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js b/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js index fd6af2f82..0655c7bba 100644 --- a/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js +++ b/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js @@ -29,7 +29,7 @@ module.exports = Self => { Object.assign(myOptions, options); const query = - `SELECT DISTINCT u.nickname + `SELECT DISTINCT u.id, u.nickname FROM itemType it JOIN worker w ON w.id = it.workerFk JOIN account.user u ON u.id = w.id`; diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 4f3813eb8..5e81e3827 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -18,6 +18,7 @@ module.exports = Self => { Self.closeAll = async() => { const toDate = new Date(); + toDate.setHours(0, 0, 0, 0); toDate.setDate(toDate.getDate() - 1); const todayMinDate = new Date(); diff --git a/modules/travel/front/extra-community/index.html b/modules/travel/front/extra-community/index.html index f19ab592e..fbf982b68 100644 --- a/modules/travel/front/extra-community/index.html +++ b/modules/travel/front/extra-community/index.html @@ -42,10 +42,10 @@ Id - + Supplier - + Agency @@ -100,7 +100,7 @@ {{::travel.id}} - + @@ -110,22 +110,23 @@ {{::travel.agencyModeName}} - {{::travel.stickers}} - {{::entry.ref}} + {{::entry.ref}} {{::entry.stickers}} {{::entry.loadedkg}} diff --git a/modules/travel/front/extra-community/style.scss b/modules/travel/front/extra-community/style.scss index 532a3056a..4b0dd6b22 100644 --- a/modules/travel/front/extra-community/style.scss +++ b/modules/travel/front/extra-community/style.scss @@ -3,7 +3,7 @@ vn-travel-extra-community { .header { margin-bottom: 16px; - font-size: 1.25rem; + font-size: 1.1rem; line-height: 1; padding: 7px; padding-bottom: 7px; @@ -29,10 +29,10 @@ vn-travel-extra-community { outline: 0; height: 65px; pointer-events: fill; - user-select:all; + user-select: all; } - tr[draggable] *::selection{ + tr[draggable] *::selection { background-color: transparent; } @@ -43,16 +43,19 @@ vn-travel-extra-community { tr[draggable].dragging { background-color: $color-primary-light; color: $color-font-light; - font-weight:bold; + font-weight: bold; } - .td-editable{ - input{ - font-size: 1.25rem!important; - } + .td-editable { + max-width: 200px; } - .number *{ - text-align: right; + vn-input-number.number { + min-width: 100px; + padding-right: 10px; + } + + .number * { + text-align: center; } }