This commit is contained in:
parent
2263da2e05
commit
8110325af8
|
@ -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');
|
|
@ -34,3 +34,5 @@ import './sample/index';
|
|||
import './sample/create';
|
||||
import './web-payment';
|
||||
import './log';
|
||||
import './sms';
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<vn-dialog
|
||||
vn-id="SMSDialog"
|
||||
on-response="$ctrl.onResponse(response)">
|
||||
<tpl-body>
|
||||
<h5 pad-small-v translate>Send SMS</h5>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one
|
||||
label="Recipient"
|
||||
model="$ctrl.sms.recipient">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal >
|
||||
<vn-textarea vn-one
|
||||
label="Message"
|
||||
field="$ctrl.sms.message">
|
||||
</vn-textarea>
|
||||
</vn-horizontal>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
<input type="button" response="CANCEL" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="ACCEPT" translate>Send</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
|
@ -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: '<',
|
||||
}
|
||||
});
|
|
@ -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('<vn-dialog></vn-dialog>');
|
||||
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!');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,4 @@
|
|||
Send SMS: Enviar SMS
|
||||
Recipient: Destinatario
|
||||
Message: Mensaje
|
||||
SMS sent!: ¡SMS enviado!
|
|
@ -0,0 +1,7 @@
|
|||
@import "variables";
|
||||
|
||||
vn-client-sms {
|
||||
textarea {
|
||||
height: 8em
|
||||
}
|
||||
}
|
|
@ -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'},
|
||||
|
|
|
@ -178,3 +178,7 @@
|
|||
<button response="ACCEPT" translate>Save</button>
|
||||
</tpl-buttons>
|
||||
</vn-dialog>
|
||||
|
||||
<!-- SMS Dialog -->
|
||||
<vn-client-sms vn-id="sms" sms="$ctrl.newSMS"></vn-client-sms>
|
||||
<!-- SMS Dialog -->
|
|
@ -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'];
|
||||
|
|
|
@ -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.
|
|
@ -10,3 +10,6 @@ Are you sure you want to delete this stowaway?: ¿Estas seguro de que quieres bo
|
|||
Show Delivery Note: Ver albarán
|
||||
Change shipped hour: Cambiar hora de envío
|
||||
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.
|
|
@ -285,6 +285,10 @@
|
|||
</vn-horizontal>
|
||||
</div>
|
||||
</vn-popover>
|
||||
|
||||
<!-- SMS Dialog -->
|
||||
<vn-client-sms vn-id="sms" sms="$ctrl.newSMS"></vn-client-sms>
|
||||
<!-- SMS Dialog -->
|
||||
</vn-vertical>
|
||||
<vn-confirm
|
||||
vn-id="delete-lines"
|
||||
|
|
|
@ -15,7 +15,8 @@ class Controller {
|
|||
{callback: this.markAsReserved, name: 'Mark as reserved'},
|
||||
{callback: this.unmarkAsReserved, name: 'Unmark as reserved'},
|
||||
{callback: this.showEditDialog, name: 'Update discount'},
|
||||
{callback: this.createClaim, name: 'Add claim'}
|
||||
{callback: this.createClaim, name: 'Add claim'},
|
||||
{callback: this.showSMSDialog, name: 'Send SMS'}
|
||||
];
|
||||
|
||||
this.imagesPath = '//verdnatura.es/vn-image-data/catalog';
|
||||
|
@ -315,6 +316,26 @@ class Controller {
|
|||
this.vnApp.showSuccess(this.$translate.instant('Order created'));
|
||||
});
|
||||
}
|
||||
|
||||
showSMSDialog() {
|
||||
const address = this.ticket.address;
|
||||
const lines = this.getCheckedLines();
|
||||
const items = lines.map(line => {
|
||||
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'];
|
||||
|
|
|
@ -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('');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
SMSAvailability: >-
|
||||
Verdnatura communicates: Your order {{ticketFk}} created on {{created | date: "dd/MM/yyyy"}}.
|
||||
{{notAvailables}} not available. Sorry for the inconvenience.
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue