diff --git a/db/install/changes/00-smsConfig.sql b/db/install/changes/00-smsConfig.sql
deleted file mode 100644
index 7d2c6e1b7..000000000
--- a/db/install/changes/00-smsConfig.sql
+++ /dev/null
@@ -1 +0,0 @@
-INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `user`, `password`, `title`) VALUES ('1', 'https://websms.xtratelecom.es/api_php/server.wsdl', 'FERRERTORIBIO', 'HERMANOS', 'Verdnatura');
diff --git a/modules/client/front/index.js b/modules/client/front/index.js
index cf72ee0b2..b4166676b 100644
--- a/modules/client/front/index.js
+++ b/modules/client/front/index.js
@@ -34,3 +34,5 @@ import './sample/index';
import './sample/create';
import './web-payment';
import './log';
+import './sms';
+
diff --git a/modules/client/front/sms/index.html b/modules/client/front/sms/index.html
new file mode 100644
index 000000000..30bf2dcc8
--- /dev/null
+++ b/modules/client/front/sms/index.html
@@ -0,0 +1,23 @@
+
+
+ Send SMS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/client/front/sms/index.js b/modules/client/front/sms/index.js
new file mode 100644
index 000000000..03bafdec0
--- /dev/null
+++ b/modules/client/front/sms/index.js
@@ -0,0 +1,42 @@
+import ngModule from '../module';
+import Component from 'core/lib/component';
+import './style.scss';
+
+class Controller extends Component {
+ constructor($element, $scope, $http, $translate, vnApp) {
+ super($element, $scope);
+
+ this.$scope = $scope;
+ this.$http = $http;
+ this.$translate = $translate;
+ this.vnApp = vnApp;
+ }
+
+ open() {
+ this.$scope.SMSDialog.show();
+ }
+
+ onResponse(response) {
+ if (response === 'ACCEPT') {
+ let params = {
+ recipient: this.sms.recipient,
+ message: this.sms.message
+ };
+ this.$http.post(`/client/api/Sms/send`, params).then(res => {
+ this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
+
+ if (res.data) this.emit('send', {response: res.data});
+ });
+ }
+ }
+}
+
+Controller.$inject = ['$element', '$scope', '$http', '$translate', 'vnApp'];
+
+ngModule.component('vnClientSms', {
+ template: require('./index.html'),
+ controller: Controller,
+ bindings: {
+ sms: '<',
+ }
+});
diff --git a/modules/client/front/sms/index.spec.js b/modules/client/front/sms/index.spec.js
new file mode 100644
index 000000000..e8f530025
--- /dev/null
+++ b/modules/client/front/sms/index.spec.js
@@ -0,0 +1,34 @@
+import './index';
+
+describe('Client', () => {
+ describe('Component vnClientSms', () => {
+ let controller;
+ let $httpBackend;
+ let $element;
+
+ beforeEach(ngModule('client'));
+
+ beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
+ $httpBackend = _$httpBackend_;
+ $element = angular.element('');
+ controller = $componentController('vnClientSms', {$element});
+ controller.client = {id: 101};
+ }));
+
+ describe('onResponse()', () => {
+ it('should perform a POST query and show a success snackbar', () => {
+ let params = {recipient: 111111111, message: 'My SMS'};
+ controller.sms = {recipient: 111111111, message: 'My SMS'};
+
+ spyOn(controller.vnApp, 'showMessage');
+ $httpBackend.when('POST', `/client/api/Sms/send`, params).respond(200, params);
+ $httpBackend.expect('POST', `/client/api/Sms/send`, params).respond(params);
+
+ controller.onResponse('ACCEPT');
+ $httpBackend.flush();
+
+ expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
+ });
+ });
+ });
+});
diff --git a/modules/client/front/sms/locale/es.yml b/modules/client/front/sms/locale/es.yml
new file mode 100644
index 000000000..28933f774
--- /dev/null
+++ b/modules/client/front/sms/locale/es.yml
@@ -0,0 +1,4 @@
+Send SMS: Enviar SMS
+Recipient: Destinatario
+Message: Mensaje
+SMS sent!: ¡SMS enviado!
\ No newline at end of file
diff --git a/modules/client/front/sms/style.scss b/modules/client/front/sms/style.scss
new file mode 100644
index 000000000..60a625880
--- /dev/null
+++ b/modules/client/front/sms/style.scss
@@ -0,0 +1,7 @@
+@import "variables";
+
+vn-client-sms {
+ textarea {
+ height: 8em
+ }
+}
\ No newline at end of file
diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js
index 776b450ca..9c1e45e78 100644
--- a/modules/ticket/front/card/index.js
+++ b/modules/ticket/front/card/index.js
@@ -7,6 +7,7 @@ class Controller {
this.filter = {
include: [
{relation: 'warehouse', scope: {fields: ['name']}},
+ {relation: 'address'},
{relation: 'ship'},
{relation: 'agencyMode', scope: {fields: ['name']}},
{relation: 'stowaway'},
diff --git a/modules/ticket/front/descriptor/index.html b/modules/ticket/front/descriptor/index.html
index 4521deb9d..41bcfec8b 100644
--- a/modules/ticket/front/descriptor/index.html
+++ b/modules/ticket/front/descriptor/index.html
@@ -177,4 +177,8 @@
-
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js
index e85ed702b..a58d84c2a 100644
--- a/modules/ticket/front/descriptor/index.js
+++ b/modules/ticket/front/descriptor/index.js
@@ -13,7 +13,8 @@ class Controller {
{callback: this.showRemoveStowaway, name: 'Remove stowaway', show: () => this.shouldShowRemoveStowaway()},
{callback: this.showDeliveryNote, name: 'Show Delivery Note', show: true},
{callback: this.showDeleteTicketDialog, name: 'Delete ticket', show: true},
- {callback: this.showChangeShipped, name: 'Change shipped hour', show: true}
+ {callback: this.showChangeShipped, name: 'Change shipped hour', show: true},
+ {callback: this.showSMSDialog, name: 'Send SMS', show: true}
];
}
@@ -163,6 +164,15 @@ class Controller {
let url = `/api/report/rpt-delivery-note?ticketFk=${this.ticket.id}`;
window.open(url);
}
+
+ showSMSDialog() {
+ const address = this.ticket.address;
+ this.newSMS = {
+ recipient: address.mobile || null,
+ message: this.$translate.instant('SMSPayment')
+ };
+ this.$scope.sms.open();
+ }
}
Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate'];
diff --git a/modules/ticket/front/descriptor/locale/en.yml b/modules/ticket/front/descriptor/locale/en.yml
new file mode 100644
index 000000000..4dca75a51
--- /dev/null
+++ b/modules/ticket/front/descriptor/locale/en.yml
@@ -0,0 +1,3 @@
+SMSPayment: >-
+ Verdnatura communicates: Your order is pending of payment.
+ Please, enter the web page and make the payment with card. Thank you.
\ No newline at end of file
diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml
index 953d75cbb..bf2a121eb 100644
--- a/modules/ticket/front/descriptor/locale/es.yml
+++ b/modules/ticket/front/descriptor/locale/es.yml
@@ -9,4 +9,7 @@ Remove stowaway: Borrar polizón
Are you sure you want to delete this stowaway?: ¿Estas seguro de que quieres borrar este polizón?
Show Delivery Note: Ver albarán
Change shipped hour: Cambiar hora de envío
-Shipped hour: Hora de envío
\ No newline at end of file
+Shipped hour: Hora de envío
+SMSPayment: >-
+ Verdnatura le comunica: Su pedido está pendiente de pago.
+ Por favor, entre en la página web y efectue el pago con tarjeta. Muchas gracias.
\ No newline at end of file
diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html
index 479ac8f09..8ec48fa36 100644
--- a/modules/ticket/front/sale/index.html
+++ b/modules/ticket/front/sale/index.html
@@ -285,6 +285,10 @@
+
+
+
+
{
+ const instance = this.sales[line.instance];
+ return `${instance.quantity} ${instance.concept}`;
+ });
+ const notAvailables = items.join(', ');
+ const params = {
+ ticketFk: this.ticket.id,
+ created: this.ticket.created,
+ notAvailables
+ };
+ this.newSMS = {
+ recipient: address.mobile || null,
+ message: this.$translate.instant('SMSAvailability', params)
+ };
+ this.$scope.sms.open();
+ }
}
Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate'];
diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js
index fea921a14..113e29c80 100644
--- a/modules/ticket/front/sale/index.spec.js
+++ b/modules/ticket/front/sale/index.spec.js
@@ -11,16 +11,20 @@ describe('Ticket', () => {
id: 1,
clientFk: 1,
shipped: 1,
- client: {salesPersonFk: 1}
+ created: new Date(),
+ client: {salesPersonFk: 1},
+ address: {mobile: 111111111}
};
let sales = [
{
id: 1,
+ concept: 'Item 1',
quantity: 5,
price: 23.5,
discount: 0
}, {
id: 4,
+ concept: 'Item 2',
quantity: 20,
price: 5.5,
discount: 0
@@ -30,6 +34,7 @@ describe('Ticket', () => {
beforeEach(() => {
ngModule('item');
ngModule('ticket');
+ ngModule('client');
});
beforeEach(angular.mock.inject(($compile, $rootScope, $state, _$httpBackend_) => {
@@ -166,5 +171,18 @@ describe('Ticket', () => {
$httpBackend.flush();
});
});
+
+ describe('showSMSDialog()', () => {
+ it('should open an SMS dialog with specified data', () => {
+ spyOn(controller.$scope.sms, 'open');
+
+ controller.sales[1].checked = true;
+ controller.showSMSDialog();
+
+ expect(controller.$scope.sms.open).toHaveBeenCalledWith();
+ expect(controller.newSMS.recipient).toEqual(111111111);
+ expect(controller.newSMS.message).not.toEqual('');
+ });
+ });
});
});
diff --git a/modules/ticket/front/sale/locale/en.yml b/modules/ticket/front/sale/locale/en.yml
new file mode 100644
index 000000000..469e2a04e
--- /dev/null
+++ b/modules/ticket/front/sale/locale/en.yml
@@ -0,0 +1,3 @@
+SMSAvailability: >-
+ Verdnatura communicates: Your order {{ticketFk}} created on {{created | date: "dd/MM/yyyy"}}.
+ {{notAvailables}} not available. Sorry for the inconvenience.
\ No newline at end of file
diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml
index bbb08957f..3b6406d9e 100644
--- a/modules/ticket/front/sale/locale/es.yml
+++ b/modules/ticket/front/sale/locale/es.yml
@@ -28,3 +28,6 @@ Claim: Reclamación
Transfer lines: Transferir líneas
Change ticket state to 'Ok': Cambiar estado del ticket a 'Ok'
Reserved: Reservado
+SMSAvailability: >-
+ Verdnatura le comunica: Pedido {{ticketFk}} día {{created | date: "dd/MM/yyyy"}}.
+ {{notAvailables}} no disponible/s. Disculpe las molestias.