This commit is contained in:
Joan Sanchez 2017-05-31 14:56:51 +02:00
commit ce728c2224
3 changed files with 15 additions and 9 deletions

View File

@ -3,10 +3,12 @@ import {module} from '../module';
export const NAME = 'vnClientBillingData'; export const NAME = 'vnClientBillingData';
class billingData { class billingData {
constructor($scope, $http, $timeout) { constructor($scope, $http, $timeout, vnAppLogger, $translate) {
this.$ = $scope; this.$ = $scope;
this.http = $http; this.http = $http;
this.timeout = $timeout; this.timeout = $timeout;
this.logger = vnAppLogger;
this.translate = $translate;
this.payId = null; this.payId = null;
this.dueDay = null; this.dueDay = null;
this.copyData(); this.copyData();
@ -26,10 +28,9 @@ class billingData {
checkChanges() { checkChanges() {
let payId = this.client.payMethodFk || null; let payId = this.client.payMethodFk || null;
let dueDay = this.client.dueDay || null; let dueDay = this.client.dueDay || null;
let dialog = this.$.sendMail;
if (dialog && (this.payId !== payId || this.dueDay !== dueDay)) { if (this.payId !== payId || this.dueDay !== dueDay) {
dialog.show(); this.$.sendMail.show();
return false; return false;
} }
@ -37,16 +38,19 @@ class billingData {
} }
returnDialog(response) { returnDialog(response) {
if (response === 'ACCEPT') { if (response === 'ACCEPT') {
this.sendMail(); this.sendMail().then(
() => this.logger.showMessage(this.translate.instant('Notification sent!')),
() => this.logger.showMessage(this.translate.instant('Notification error'))
);
} }
this.timeout(() => this.$.watcher.submit()); this.timeout(() => this.$.watcher.submit());
} }
sendMail() { sendMail() {
this.http.post(`/mailer/manuscript/paymentUpdate`, {user: this.client.id}); return this.http.post(`/mailer/manuscript/paymentUpdate`, {user: this.client.id});
} }
} }
billingData.$inject = ['$scope', '$http', '$timeout']; billingData.$inject = ['$scope', '$http', '$timeout', 'vnAppLogger', '$translate'];
export const COMPONENT = { export const COMPONENT = {
template: require('./billing-data.html'), template: require('./billing-data.html'),

View File

@ -2,5 +2,7 @@
"Changed terms": "Has modificado las condiciones de pago", "Changed terms": "Has modificado las condiciones de pago",
"Notify customer?" : "¿Deseas notificar al cliente de dichos cambios?", "Notify customer?" : "¿Deseas notificar al cliente de dichos cambios?",
"No": "No", "No": "No",
"Yes, notify": "Sí, notificar" "Yes, notify": "Sí, notificar",
"Notification sent!": "¡Notificación enviada!",
"Notification error": "Error al enviar notificación"
} }