diff --git a/modules/route/back/methods/route/sendSms.js b/modules/route/back/methods/route/sendSms.js
index 9a93b040e..fe881abd5 100644
--- a/modules/route/back/methods/route/sendSms.js
+++ b/modules/route/back/methods/route/sendSms.js
@@ -4,35 +4,29 @@ module.exports = Self => {
Self.remoteMethodCtx('sendSms', {
description: 'Sends a SMS to each client of the routes, each client only recieves the SMS once',
accessType: 'WRITE',
- accepts: [{
- arg: 'id',
- type: 'string',
- required: true,
- description: 'The routes Ids, is separated by commas',
- http: {source: 'path'}
- },
- {
- arg: 'destination',
- type: 'string',
- description: 'A comma separated string of destinations',
- required: true,
- },
- {
- arg: 'message',
- type: 'string',
- required: true,
- }],
+ accepts: [
+ {
+ arg: 'destination',
+ type: 'string',
+ description: 'A comma separated string of destinations',
+ required: true,
+ },
+ {
+ arg: 'message',
+ type: 'string',
+ required: true,
+ }],
returns: {
type: 'object',
root: true
},
http: {
- path: `/:id/sendSms`,
+ path: `/sendSms`,
verb: 'POST'
}
});
- Self.sendSms = async(ctx, id, destination, message) => {
+ Self.sendSms = async(ctx, destination, message) => {
const targetClients = destination.split(',');
const allSms = [];
diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html
index e9785d958..7a64a9aff 100644
--- a/modules/route/front/index/index.html
+++ b/modules/route/front/index/index.html
@@ -7,6 +7,29 @@
model="model"
options="$ctrl.smartTableOptions"
expr-builder="$ctrl.exprBuilder(param, value)">
+
+
+
@@ -160,42 +183,6 @@
-
-
-
-
-
e === ticket.clientFk).length > 0)
- clientsFk.push(ticket.clientFk);
- }
-
- for (let client of clientsFk) {
- let currentClient = await this.$http.get(`Clients/${client}`);
- clients.push(currentClient.data);
- }
-
- let destination = '';
- let destinationFk = '';
- let routesId = '';
-
- for (let client of clients) {
- if (destination !== '')
- destination = destination + ',';
- if (destinationFk !== '')
- destinationFk = destinationFk + ',';
- destination = destination + client.phone;
- destinationFk = destinationFk + client.id;
- }
-
- for (let route of routes) {
- if (routesId !== '')
- routesId = routesId + ',';
- routesId = routesId + route;
- }
- this.newSMS = Object.assign({
- routesId: routesId,
- destinationFk: destinationFk,
- destination: destination
- });
-
- this.$.sms.open();
- return true;
- } catch (e) {
- this.vnApp.showError(this.$t(e.message));
- return false;
- }
- }
}
Controller.$inject = ['$element', '$scope', 'vnReport'];
diff --git a/modules/route/front/sms/index.html b/modules/route/front/sms/index.html
index 4f86b346f..0d7dd7c11 100644
--- a/modules/route/front/sms/index.html
+++ b/modules/route/front/sms/index.html
@@ -1,19 +1,10 @@
+ message="Send SMS to the selected tickets">
-
-
+
{
+ this.$http.post(`Routes/sendSms`, this.sms).then(res => {
this.vnApp.showMessage(this.$t('SMS sent!'));
if (res.data) this.emit('send', {response: res.data});
diff --git a/modules/route/front/sms/locale/es.yml b/modules/route/front/sms/locale/es.yml
index 4d6022921..0168a6eb6 100644
--- a/modules/route/front/sms/locale/es.yml
+++ b/modules/route/front/sms/locale/es.yml
@@ -1,4 +1,4 @@
-Send SMS: Enviar SMS
+Send SMS to the selected tickets: Enviar SMS a los tickets seleccionados
Routes to notify: Rutas a notificar
Message: Mensaje
SMS sent!: ¡SMS enviado!
diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html
index 1f91276e7..29f5cd861 100644
--- a/modules/route/front/tickets/index.html
+++ b/modules/route/front/tickets/index.html
@@ -29,13 +29,18 @@
disabled="!$ctrl.isChecked"
ng-click="$ctrl.deletePriority()"
vn-tooltip="Delete priority"
- icon="filter_alt_off">
+ icon="filter_alt">
+
+
@@ -149,19 +154,29 @@
route="$ctrl.$params"
parent-reload="$ctrl.$.model.refresh()">
-
-
-
+
-
\ No newline at end of file
+
+
+
+
\ No newline at end of file
diff --git a/modules/route/front/tickets/index.js b/modules/route/front/tickets/index.js
index e78d9b8b7..80f8ad4f4 100644
--- a/modules/route/front/tickets/index.js
+++ b/modules/route/front/tickets/index.js
@@ -161,6 +161,37 @@ class Controller extends Section {
throw error;
});
}
+
+ async sendSms() {
+ try {
+ const clientsFk = [];
+ const clientsName = [];
+ const clients = [];
+
+ const selectedTickets = this.getSelectedItems(this.$.$ctrl.tickets);
+
+ for (let ticket of selectedTickets) {
+ clientsFk.push(ticket.clientFk);
+ let userContact = await this.$http.get(`Clients/${ticket.clientFk}`);
+ clientsName.push(userContact.data.name);
+ clients.push(userContact.data.phone);
+ }
+
+ const destinationFk = String(clientsFk);
+ const destination = String(clients);
+
+ this.newSMS = Object.assign({
+ destinationFk: destinationFk,
+ destination: destination
+ });
+
+ this.$.sms.open();
+ return true;
+ } catch (e) {
+ this.vnApp.showError(this.$t(e.message));
+ return false;
+ }
+ }
}
ngModule.vnComponent('vnRouteTickets', {