Send delivery note to client #1332

This commit is contained in:
Joan Sanchez 2019-09-06 11:06:44 +02:00
parent 178dc6f2e8
commit 7fad401624
10 changed files with 128 additions and 8 deletions

View File

@ -68,9 +68,6 @@ class Controller {
this.$scope.confirmPickupOrder.show();
}
confirmDeleteClaim() {
this.$scope.confirmDeleteClaim.show();
}
sendPickupOrder(response) {
if (response === 'ACCEPT') {
this.$http.post(`/api/email/claim-pickup-order`, {claimFk: this.claim.id}).then(
@ -78,6 +75,11 @@ class Controller {
);
}
}
confirmDeleteClaim() {
this.$scope.confirmDeleteClaim.show();
}
deleteClaim(response) {
if (response === 'ACCEPT') {
this.$http.delete(`/claim/api/Claims/${this.claim.id}`).then(() => {

View File

@ -204,3 +204,10 @@
<!-- SMS Dialog -->
<vn-client-sms vn-id="sms" sms="$ctrl.newSMS"></vn-client-sms>
<!-- SMS Dialog -->
<vn-confirm
vn-id="confirm-delivery-note"
on-response="$ctrl.sendDeliveryNote(response)"
question="Send Delivery Note"
message="Are you sure you want to send it?">
</vn-confirm>

View File

@ -11,6 +11,7 @@ class Controller {
this.moreOptions = [
{name: 'Add turn', callback: this.showAddTurnDialog},
{name: 'Show Delivery Note', callback: this.showDeliveryNote},
{name: 'Send Delivery Note', callback: this.confirmDeliveryNote},
{name: 'Delete ticket', callback: this.showDeleteTicketDialog},
{name: 'Change shipped hour', callback: this.showChangeShipped},
{name: 'Send SMS', callback: this.showSMSDialog},
@ -262,6 +263,18 @@ class Controller {
hasInvoice() {
return this.ticket.refFk !== null;
}
confirmDeliveryNote() {
this.$scope.confirmDeliveryNote.show();
}
sendDeliveryNote(response) {
if (response === 'ACCEPT') {
this.$http.post(`/api/email/delivery-note`, {ticketFk: this.ticket.id}).then(
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
);
}
}
}
Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate', 'aclService'];

View File

@ -7,7 +7,9 @@ Stowaways of the ticket: Polizones del ticket
Add stowaway: Añadir polizón
Remove stowaway: Borrar polizón
Are you sure you want to delete this stowaway?: ¿Seguro que quieres borrar este polizón?
Are you sure you want to send it?: ¿Seguro que quieres enviarlo?
Show Delivery Note: Ver albarán
Send Delivery Note: Enviar albarán
Show pallet report: Ver hoja de pallet
Change shipped hour: Cambiar hora de envío
Shipped hour: Hora de envío

View File

@ -8,6 +8,7 @@
{"type": "email", "name": "sepa-core"},
{"type": "email", "name": "client-lcr"},
{"type": "email", "name": "driver-route"},
{"type": "email", "name": "delivery-note"},
{"type": "report", "name": "rpt-delivery-note"},
{"type": "report", "name": "rpt-claim-pickup-order"},
{"type": "report", "name": "rpt-letter-debtor"},

View File

@ -0,0 +1,7 @@
const CssReader = require(`${appPath}/lib/cssReader`);
module.exports = new CssReader([
`${appPath}/common/css/layout.css`,
`${appPath}/common/css/email.css`,
`${appPath}/common/css/misc.css`])
.mergeStyles();

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="es">
<head>
<title>{{ $t('subject') }}</title>
</head>
<body>
<section class="container">
<!-- Header component -->
<email-header></email-header>
<!-- End header component -->
<section class="main">
<!-- Title block -->
<div class="title">
<h1>{{ $t('title') }}</h1>
</div>
<!-- Title block end -->
<p>{{$t('dearClient')}},</p>
<p v-html="$t('clientData')"></p>
<p v-html="$t('help')"></p>
</section>
<!-- Footer component -->
<email-footer :locale="locale"></email-footer>
<!-- End footer component -->
</section>
</body>
</html>

View File

@ -0,0 +1,50 @@
const database = require(`${appPath}/lib/database`);
const reportEngine = require(`${appPath}/lib/reportEngine.js`);
const UserException = require(`${appPath}/lib/exceptions/userException`);
module.exports = {
name: 'delivery-note',
async asyncData(ctx, params) {
const promises = [];
const data = {
isPreview: ctx.method === 'GET',
};
if (!params.ticketFk)
throw new UserException('No ticket id specified');
promises.push(reportEngine.toPdf('rpt-delivery-note', ctx));
promises.push(this.methods.fetchTicket(params.ticketFk));
return Promise.all(promises).then(result => {
const stream = result[0];
const [[ticket]] = result[1];
Object.assign(data, ticket);
Object.assign(data, {attachments: [{filename: 'rpt-delivery-note.pdf', content: stream}]});
return data;
});
},
created() {
if (this.locale)
this.$i18n.locale = this.locale;
},
methods: {
fetchTicket(ticketFk) {
return database.pool.query(`
SELECT
t.id,
u.lang locale,
c.email recipient
FROM ticket t
JOIN client c ON c.id = t.clientFk
JOIN account.user u ON u.id = c.id
WHERE t.id = ?`, [ticketFk]);
},
},
components: {
'email-header': require('../email-header'),
'email-footer': require('../email-footer'),
},
};

View File

@ -0,0 +1,11 @@
module.exports = {
messages: {
es: {
subject: 'Aquí tienes tu albarán',
title: '¡Este es tu albarán!',
dearClient: 'Estimado cliente',
clientData: `A continuación adjuntamos tu albarán.`,
help: 'Cualquier duda que te surja, no dudes en consultarla, <strong>¡estamos para atenderte!</strong>'
},
},
};

View File

@ -6,16 +6,16 @@ module.exports = {
sections: {
introduction: {
title: 'Estimado cliente',
description: `Le informamos que han cambiado las condiciones de pago de su cuenta.
<br/>A continuación le indicamos las nuevas condiciones`,
description: `Te informamos que han cambiado las condiciones de pago de tu cuenta.
<br/>A continuación te indicamos las nuevas condiciones`,
},
pay: {
method: 'Método de pago',
day: 'Día de pago',
dueDay: '{0} de cada mes',
cardImplicates: `Su modo de pago actual implica que deberá abonar el
cardImplicates: `Tu modo de pago actual implica que deberás abonar el
importe de los pedidos realizados en el mismo día para que se puedan enviar.`,
accountImplicates: `Su modo de pago actual implica que se le pasará un cargo a la
accountImplicates: `Tu modo de pago actual implica que se te pasará un cargo a la
cuenta terminada en <strong>"{0}"</strong> por el importe pendiente, al vencimiento establecido en las condiciones.`,
},
},