diff --git a/loopback/util/http.js b/loopback/util/http.js
new file mode 100644
index 000000000..59bfe38b0
--- /dev/null
+++ b/loopback/util/http.js
@@ -0,0 +1,16 @@
+/**
+ * Serializes an object to a query params
+ *
+ * @param {Object} obj The params object
+ * @return {String} Serialized params
+ */
+exports.httpParamSerializer = function(obj) {
+ let query = '';
+ for (let param in obj) {
+ if (query != '')
+ query += '&';
+ query += `${param}=${obj[param]}`;
+ }
+
+ return query;
+};
diff --git a/modules/claim/front/card/index.js b/modules/claim/front/card/index.js
index 7c0c348a9..0a641ce89 100644
--- a/modules/claim/front/card/index.js
+++ b/modules/claim/front/card/index.js
@@ -35,7 +35,7 @@ class Controller {
{
relation: 'client',
scope: {
- fields: ['salesPersonFk', 'name'],
+ fields: ['salesPersonFk', 'name', 'email'],
include: {
relation: 'salesPerson',
scope: {
diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js
index 0328d954c..7bc9c831a 100644
--- a/modules/claim/front/descriptor/index.js
+++ b/modules/claim/front/descriptor/index.js
@@ -1,13 +1,14 @@
import ngModule from '../module';
class Controller {
- constructor($scope, $state, $http, $translate, vnApp, aclService) {
+ constructor($scope, $state, $http, $translate, vnApp, aclService, $httpParamSerializer) {
this.$scope = $scope;
this.$state = $state;
this.$http = $http;
this.$translate = $translate;
this.vnApp = vnApp;
this.aclService = aclService;
+ this.$httpParamSerializer = $httpParamSerializer;
this.moreOptions = [
{callback: this.showPickupOrder, name: 'Show Pickup order'},
{callback: this.confirmPickupOrder, name: 'Send Pickup order'},
@@ -60,7 +61,12 @@ class Controller {
}
showPickupOrder() {
- let url = `report/rpt-claim-pickup-order?claimFk=${this.claim.id}`;
+ const params = {
+ clientId: this.claim.clientFk,
+ claimId: this.claim.id
+ };
+ const serializedParams = this.$httpParamSerializer(params);
+ let url = `api/report/claim-pickup-order?${serializedParams}`;
window.open(url);
}
@@ -70,7 +76,14 @@ class Controller {
sendPickupOrder(response) {
if (response === 'accept') {
- this.$http.post(`email/claim-pickup-order`, {claimFk: this.claim.id}).then(
+ const params = {
+ recipient: this.claim.client.email,
+ clientId: this.claim.clientFk,
+ claimId: this.claim.id
+ };
+ const serializedParams = this.$httpParamSerializer(params);
+ const url = `email/claim-pickup-order?${serializedParams}`;
+ this.$http.get(url).then(
() => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
);
}
@@ -90,7 +103,7 @@ class Controller {
}
}
-Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp', 'aclService'];
+Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp', 'aclService', '$httpParamSerializer'];
ngModule.component('vnClaimDescriptor', {
template: require('./index.html'),
diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js
index 58aac9ccd..73626b408 100644
--- a/modules/client/back/models/client.js
+++ b/modules/client/back/models/client.js
@@ -2,6 +2,8 @@ let request = require('request-promise-native');
let UserError = require('vn-loopback/util/user-error');
let getFinalState = require('vn-loopback/util/hook').getFinalState;
let isMultiple = require('vn-loopback/util/hook').isMultiple;
+const httpParamSerializer = require('vn-loopback/util/http').httpParamSerializer;
+const LoopBackContext = require('loopback-context');
module.exports = Self => {
// Methods
@@ -239,15 +241,18 @@ module.exports = Self => {
});
}
- const options = {
- method: 'POST',
- uri: 'http://127.0.0.1:3000/api/email/payment-update',
- body: {
- clientFk: instance.id
- },
- json: true
+ // Send email to client
+
+ if (!instance.email) return;
+ const loopBackContext = LoopBackContext.getCurrentContext();
+ const headers = loopBackContext.active.http.req.headers;
+ const params = {
+ clientId: instance.id,
+ recipient: instance.email
};
- await request(options);
+ const serializedParams = httpParamSerializer(params);
+ const query = `${headers.origin}/api/email/payment-update?${serializedParams}`;
+ await request.get(query);
}
});
diff --git a/modules/client/front/sample/create/index.html b/modules/client/front/sample/create/index.html
index dae61ce10..ba2ec55bb 100644
--- a/modules/client/front/sample/create/index.html
+++ b/modules/client/front/sample/create/index.html
@@ -44,5 +44,9 @@
-
+
+
+
+
+
diff --git a/modules/client/front/sample/create/index.js b/modules/client/front/sample/create/index.js
index 22adb3488..935909e25 100644
--- a/modules/client/front/sample/create/index.js
+++ b/modules/client/front/sample/create/index.js
@@ -2,13 +2,14 @@ import ngModule from '../../module';
import './style.scss';
class Controller {
- constructor($scope, $state, $http, vnApp, $translate, $httpParamSerializer) {
+ constructor($scope, $state, $http, vnApp, $translate, $httpParamSerializer, $window) {
this.$scope = $scope;
this.$state = $state;
this.$stateParams = $state.params;
this.$http = $http;
this.vnApp = vnApp;
this.$translate = $translate;
+ this.$window = $window;
this.$httpParamSerializer = $httpParamSerializer;
this.clientSample = {
clientFk: this.$stateParams.id
@@ -58,13 +59,12 @@ class Controller {
const serializedParams = this.$httpParamSerializer(params);
const query = `email/${sampleType.code}?${serializedParams}`;
this.$http.get(query).then(res => {
- let dialog = this.$scope.showPreview.element;
+ this.$scope.showPreview.show();
+ let dialog = document.body.querySelector('div.vn-dialog');
let body = dialog.querySelector('tpl-body');
let scroll = dialog.querySelector('div:first-child');
body.innerHTML = res.data;
- this.$scope.showPreview.show();
-
scroll.scrollTop = 0;
});
}
@@ -100,7 +100,7 @@ class Controller {
});
}
}
-Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate', '$httpParamSerializer'];
+Controller.$inject = ['$scope', '$state', '$http', 'vnApp', '$translate', '$httpParamSerializer', '$window'];
ngModule.component('vnClientSampleCreate', {
template: require('./index.html'),
diff --git a/modules/client/front/sample/create/style.scss b/modules/client/front/sample/create/style.scss
index a958e264b..3b4226ccb 100644
--- a/modules/client/front/sample/create/style.scss
+++ b/modules/client/front/sample/create/style.scss
@@ -1,36 +1,38 @@
-vn-client-sample-create {
- vn-dialog {
- & > div {
- padding: 0 !important
+div.vn-dialog {
+ & > div {
+ padding: 0 !important
+ }
+
+ tpl-body {
+ min-width: 800px;
+
+ .container, .container h1 {
+ font-family: "Roboto","Helvetica","Arial",sans-serif;
+ font-size: 1em !important;
+
+ h1 {
+ font-weight: bold;
+ margin: auto
+ }
+
+ p {
+ margin: 1em 0
+ }
+
+ footer p {
+ font-size: 10px !important;
+ line-height: 10px
+ }
}
- tpl-body {
- min-width: 800px;
+
+ .title h1 {
+ font-size: 2em !important;
+ margin: 0
+ }
- .container, .container h1 {
- font-family: "Roboto","Helvetica","Arial",sans-serif;
- font-size: 1em !important;
-
- h1 {
- font-weight: bold;
- margin: auto
- }
-
- p {
- margin: 1em 0
- }
-
- footer p {
- font-size: 10px !important;
- line-height: 10px
- }
- }
-
-
- .title h1 {
- font-size: 2em !important;
- margin: 0
- }
+ .loading {
+ text-align: center
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/route/front/card/index.js b/modules/route/front/card/index.js
index 2e3acb9c1..76471002a 100644
--- a/modules/route/front/card/index.js
+++ b/modules/route/front/card/index.js
@@ -42,6 +42,24 @@ export default class Controller {
scope: {
fields: ['id', 'name']
}
+ },
+ {
+ relation: 'worker',
+ scope: {
+ fields: ['userFk'],
+ include: {
+ relation: 'user',
+ scope: {
+ fields: ['id'],
+ include: {
+ relation: 'emailUser',
+ scope: {
+ fields: ['email']
+ }
+ }
+ }
+ }
+ }
}
]
};
diff --git a/modules/route/front/descriptor/index.js b/modules/route/front/descriptor/index.js
index 438a2dda9..402b9102f 100644
--- a/modules/route/front/descriptor/index.js
+++ b/modules/route/front/descriptor/index.js
@@ -1,12 +1,13 @@
import ngModule from '../module';
class Controller {
- constructor($, $http, vnApp, $translate, aclService) {
+ constructor($, $http, vnApp, $translate, aclService, $httpParamSerializer) {
this.$http = $http;
this.vnApp = vnApp;
this.$translate = $translate;
this.$ = $;
this.aclService = aclService;
+ this.$httpParamSerializer = $httpParamSerializer;
this.moreOptions = [
{callback: this.showRouteReport, name: 'Show route report'},
{callback: this.sendRouteReport, name: 'Send route report'},
@@ -36,13 +37,26 @@ class Controller {
}
showRouteReport() {
- let url = `report/rpt-route?routeFk=${this.route.id}`;
+ const user = this.route.worker.user;
+ const params = {
+ clientId: user.id,
+ routeId: this.route.id
+ };
+ const serializedParams = this.$httpParamSerializer(params);
+ let url = `api/report/driver-route?${serializedParams}`;
window.open(url);
}
sendRouteReport() {
- let url = `email/driver-route?routeFk=${this.route.id}`;
- this.$http.post(url).then(() => {
+ const user = this.route.worker.user;
+ const params = {
+ recipient: user.emailUser.email,
+ clientId: user.id,
+ routeId: this.route.id
+ };
+ const serializedParams = this.$httpParamSerializer(params);
+ const url = `email/driver-route?${serializedParams}`;
+ this.$http.get(url).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Report sent'));
});
}
@@ -62,7 +76,7 @@ class Controller {
}
}
-Controller.$inject = ['$scope', '$http', 'vnApp', '$translate', 'aclService'];
+Controller.$inject = ['$scope', '$http', 'vnApp', '$translate', 'aclService', '$httpParamSerializer'];
ngModule.component('vnRouteDescriptor', {
template: require('./index.html'),
diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js
index b05472bcb..b805c3803 100644
--- a/modules/ticket/front/card/index.js
+++ b/modules/ticket/front/card/index.js
@@ -15,7 +15,15 @@ class Controller {
{
relation: 'client',
scope: {
- fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked', 'credit'],
+ fields: [
+ 'salesPersonFk',
+ 'name',
+ 'isActive',
+ 'isFreezed',
+ 'isTaxDataChecked',
+ 'credit',
+ 'email'
+ ],
include: {
relation: 'salesPerson',
scope: {
diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js
index 4d8df2d1f..d419df5de 100644
--- a/modules/ticket/front/descriptor/index.js
+++ b/modules/ticket/front/descriptor/index.js
@@ -1,12 +1,13 @@
import ngModule from '../module';
class Controller {
- constructor($state, $scope, $http, vnApp, $translate, aclService) {
+ constructor($state, $scope, $http, vnApp, $translate, aclService, $httpParamSerializer) {
this.$scope = $scope;
this.$state = $state;
this.$http = $http;
this.vnApp = vnApp;
this.$translate = $translate;
+ this.$httpParamSerializer = $httpParamSerializer;
this.aclService = aclService;
this.moreOptions = [
{name: 'Add turn', callback: this.showAddTurnDialog},
@@ -201,10 +202,29 @@ class Controller {
}
showDeliveryNote() {
- let url = `report/rpt-delivery-note?ticketFk=${this.ticket.id}`;
+ const params = {
+ clientId: this.ticket.client.id,
+ ticketId: this.ticket.id
+ };
+ const serializedParams = this.$httpParamSerializer(params);
+ let url = `api/report/delivery-note?${serializedParams}`;
window.open(url);
}
+ sendDeliveryNote(response) {
+ if (response === 'accept') {
+ const params = {
+ recipient: this.ticket.client.email,
+ clientId: this.ticket.client.id,
+ ticketId: this.ticket.id
+ };
+ const serializedParams = this.$httpParamSerializer(params);
+ this.$http.get(`email/delivery-note?${serializedParams}`).then(
+ () => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
+ );
+ }
+ }
+
showSMSDialog() {
const address = this.ticket.address;
this.newSMS = {
@@ -275,17 +295,9 @@ class Controller {
confirmDeliveryNote() {
this.$scope.confirmDeliveryNote.show();
}
-
- sendDeliveryNote(response) {
- if (response === 'accept') {
- this.$http.post(`email/delivery-note`, {ticketFk: this.ticket.id}).then(
- () => this.vnApp.showMessage(this.$translate.instant('Notification sent!'))
- );
- }
- }
}
-Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate', 'aclService'];
+Controller.$inject = ['$state', '$scope', '$http', 'vnApp', '$translate', 'aclService', '$httpParamSerializer'];
ngModule.component('vnTicketDescriptor', {
template: require('./index.html'),
diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.html b/print/templates/email/claim-pickup-order/claim-pickup-order.html
index 7de22dd58..5b227438d 100644
--- a/print/templates/email/claim-pickup-order/claim-pickup-order.html
+++ b/print/templates/email/claim-pickup-order/claim-pickup-order.html
@@ -1,12 +1,15 @@
-
+
{{ $t('subject') }}
-
+
+
diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js
index 00dbd380c..cb49e548d 100755
--- a/print/templates/email/claim-pickup-order/claim-pickup-order.js
+++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js
@@ -2,38 +2,21 @@ const Component = require(`${appPath}/core/component`);
const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer');
const attachments = require('./attachments.json');
-const db = require(`${appPath}/core/database`);
module.exports = {
name: 'claim-pickup-order',
- /* async serverPrefetch() {
- this.client = await this.fetchClient(this.clientId);
- },*/
- created() {
- if (this.locale)
- this.$i18n.locale = this.locale;
- },
data() {
return {
attachments
};
},
- methods: {
- fetchClient(claimId) {
- return db.findOne(`
- SELECT
- c.id,
- u.lang locale,
- c.email recipient
- FROM claim cl
- JOIN client c ON c.id = cl.clientFk
- JOIN account.user u ON u.id = c.id
- WHERE cl.id = ?`, [claimId]);
- },
- },
components: {
'email-header': emailHeader.build(),
'email-footer': emailFooter.build()
},
- props: ['clientId', 'claimId', 'isPreview']
+ props: {
+ claimId: {
+ required: true
+ }
+ }
};
diff --git a/print/templates/email/client-welcome/client-welcome.html b/print/templates/email/client-welcome/client-welcome.html
index 00b38959a..9bc571d4e 100644
--- a/print/templates/email/client-welcome/client-welcome.html
+++ b/print/templates/email/client-welcome/client-welcome.html
@@ -1,12 +1,15 @@
-
+
{{ $t('subject') }}
diff --git a/print/templates/email/printer-setup/printer-setup.js b/print/templates/email/printer-setup/printer-setup.js
index 78def7aea..812492eba 100755
--- a/print/templates/email/printer-setup/printer-setup.js
+++ b/print/templates/email/printer-setup/printer-setup.js
@@ -1,7 +1,7 @@
-const db = require(`${appPath}/core/database`);
const Component = require(`${appPath}/core/component`);
const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer');
+const db = require(`${appPath}/core/database`);
module.exports = {
name: 'printer-setup',
diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.js b/print/templates/reports/claim-pickup-order/claim-pickup-order.js
index ed64081f5..2578443dd 100755
--- a/print/templates/reports/claim-pickup-order/claim-pickup-order.js
+++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.js
@@ -60,7 +60,6 @@ module.exports = {
},
props: {
claimId: {
- type: String,
required: true
}
}
diff --git a/print/templates/reports/route/assets/css/import.js b/print/templates/reports/driver-route/assets/css/import.js
similarity index 100%
rename from print/templates/reports/route/assets/css/import.js
rename to print/templates/reports/driver-route/assets/css/import.js
diff --git a/print/templates/reports/route/assets/css/style.css b/print/templates/reports/driver-route/assets/css/style.css
similarity index 100%
rename from print/templates/reports/route/assets/css/style.css
rename to print/templates/reports/driver-route/assets/css/style.css
diff --git a/print/templates/reports/route/route.html b/print/templates/reports/driver-route/driver-route.html
similarity index 100%
rename from print/templates/reports/route/route.html
rename to print/templates/reports/driver-route/driver-route.html
diff --git a/print/templates/reports/route/route.js b/print/templates/reports/driver-route/driver-route.js
similarity index 98%
rename from print/templates/reports/route/route.js
rename to print/templates/reports/driver-route/driver-route.js
index 858fd8407..5e9e617ad 100755
--- a/print/templates/reports/route/route.js
+++ b/print/templates/reports/driver-route/driver-route.js
@@ -4,7 +4,7 @@ const reportFooter = new Component('report-footer');
const db = require(`${appPath}/core/database`);
module.exports = {
- name: 'route',
+ name: 'driver-route',
async serverPrefetch() {
this.route = await this.fetchRoute(this.routeId);
this.tickets = await this.fetchTickets(this.routeId);
@@ -83,7 +83,6 @@ module.exports = {
},
props: {
routeId: {
- type: String,
required: true
}
}
diff --git a/print/templates/reports/route/locale/es.yml b/print/templates/reports/driver-route/locale/es.yml
similarity index 100%
rename from print/templates/reports/route/locale/es.yml
rename to print/templates/reports/driver-route/locale/es.yml
diff --git a/print/templates/reports/item-label/item-label.js b/print/templates/reports/item-label/item-label.js
index f98fcabf9..f5fd988f1 100755
--- a/print/templates/reports/item-label/item-label.js
+++ b/print/templates/reports/item-label/item-label.js
@@ -70,11 +70,9 @@ module.exports = {
},
props: {
itemId: {
- type: String,
required: true
},
warehouseId: {
- type: String,
required: true
},
labelNumber: {
diff --git a/print/templates/reports/letter-debtor/letter-debtor.js b/print/templates/reports/letter-debtor/letter-debtor.js
index 7e70c88d1..c7cd9bbfc 100755
--- a/print/templates/reports/letter-debtor/letter-debtor.js
+++ b/print/templates/reports/letter-debtor/letter-debtor.js
@@ -77,11 +77,9 @@ module.exports = {
},
props: {
clientId: {
- type: String,
required: true
},
companyId: {
- type: String,
required: true
}
}
diff --git a/print/templates/reports/receipt/receipt.js b/print/templates/reports/receipt/receipt.js
index 1aee32b18..4f6d0dda5 100755
--- a/print/templates/reports/receipt/receipt.js
+++ b/print/templates/reports/receipt/receipt.js
@@ -43,7 +43,6 @@ module.exports = {
},
props: {
receiptId: {
- type: String,
required: true
}
}
diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js
index f2d245536..417562015 100755
--- a/print/templates/reports/sepa-core/sepa-core.js
+++ b/print/templates/reports/sepa-core/sepa-core.js
@@ -68,11 +68,9 @@ const rptSepaCore = {
},
props: {
clientId: {
- type: String,
required: true
},
companyId: {
- type: String,
required: true
}
}
diff --git a/print/templates/reports/zone/zone.js b/print/templates/reports/zone/zone.js
index 0debd4ef4..458762563 100755
--- a/print/templates/reports/zone/zone.js
+++ b/print/templates/reports/zone/zone.js
@@ -24,7 +24,6 @@ module.exports = {
},
props: {
routeId: {
- type: String,
required: true
}
}