From 17f5e46497be140d68d3806a6a9d4a079328eee5 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 10 Apr 2019 09:45:45 +0200 Subject: [PATCH] #1284 Print - Informe zona --- db/dump/fixtures.sql | 16 ++++----- print/config/routes.json | 1 + print/report/rpt-route/assets/css/index.js | 7 ++++ print/report/rpt-route/assets/css/style.css | 9 ++++++ print/report/rpt-route/index.html | 15 +++++++++ print/report/rpt-route/index.js | 36 +++++++++++++++++++++ print/report/rpt-route/locale.js | 0 7 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 print/report/rpt-route/assets/css/index.js create mode 100644 print/report/rpt-route/assets/css/style.css create mode 100644 print/report/rpt-route/index.html create mode 100755 print/report/rpt-route/index.js create mode 100644 print/report/rpt-route/locale.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index a96820c05..4461087f0 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -355,15 +355,15 @@ INSERT INTO `vn`.`creditInsurance`(`id`, `creditClassification`, `credit`, `crea (2, 2 , 6000, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), NULL), (3, 3, 10000 , DATE_ADD(CURDATE(), INTERVAL -3 MONTH), NULL); -INSERT INTO `vn`.`route`(`id`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`) +INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`) VALUES - (1, 56, CURDATE(), 1, 1, 'first route', null, 10, CURDATE(), CURDATE()), - (2, 56, CURDATE(), 1, 1, 'second route', 4.2, 20, CURDATE(), CURDATE()), - (3, 56, CURDATE(), 2, 7, 'third route', 5.3, 30, CURDATE(), CURDATE()), - (4, 56, CURDATE(), 3, 7, 'fourth route', 6.4, 40, CURDATE(), CURDATE()), - (5, 56, CURDATE(), 4, 8, 'fifth route', 7.5, 50, CURDATE(), CURDATE()), - (6, 57, CURDATE(), 5, 8, 'sixth route', 8.6, 60, CURDATE(), CURDATE()), - (7, 57, CURDATE(), 6, null, 'seventh route', 9.7, 70, CURDATE(), CURDATE()); + (1, '1899-12-30 12:15:00', 56, CURDATE(), 1, 1, 'first route', null, 10, CURDATE(), CURDATE()), + (2, '1899-12-30 13:20:00', 56, CURDATE(), 1, 1, 'second route', 4.2, 20, CURDATE(), CURDATE()), + (3, '1899-12-30 14:30:00', 56, CURDATE(), 2, 7, 'third route', 5.3, 30, CURDATE(), CURDATE()), + (4, '1899-12-30 15:45:00', 56, CURDATE(), 3, 7, 'fourth route', 6.4, 40, CURDATE(), CURDATE()), + (5, '1899-12-30 16:00:00', 56, CURDATE(), 4, 8, 'fifth route', 7.5, 50, CURDATE(), CURDATE()), + (6, null, 57, CURDATE(), 5, 8, 'sixth route', 8.6, 60, CURDATE(), CURDATE()), + (7, null, 57, CURDATE(), 6, null, 'seventh route', 9.7, 70, CURDATE(), CURDATE()); INSERT INTO `vn2008`.`empresa_grupo`(`empresa_grupo_id`, `grupo`) VALUES diff --git a/print/config/routes.json b/print/config/routes.json index 88365b1d0..95e881f0a 100644 --- a/print/config/routes.json +++ b/print/config/routes.json @@ -12,6 +12,7 @@ {"type": "report", "name": "rpt-letter-debtor"}, {"type": "report", "name": "rpt-sepa-core"}, {"type": "report", "name": "rpt-receipt"}, + {"type": "report", "name": "rpt-route"}, {"type": "static", "name": "email-header"}, {"type": "static", "name": "email-footer"}, {"type": "static", "name": "report-header"}, diff --git a/print/report/rpt-route/assets/css/index.js b/print/report/rpt-route/assets/css/index.js new file mode 100644 index 000000000..06417fcee --- /dev/null +++ b/print/report/rpt-route/assets/css/index.js @@ -0,0 +1,7 @@ +const CssReader = require(`${appPath}/lib/cssReader`); + +module.exports = new CssReader([ + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/report/rpt-route/assets/css/style.css b/print/report/rpt-route/assets/css/style.css new file mode 100644 index 000000000..82e5c33f1 --- /dev/null +++ b/print/report/rpt-route/assets/css/style.css @@ -0,0 +1,9 @@ +section .text { + font-family: Tahoma; + font-weight: bold; + color: white; + font-size: 7.5em; + text-align: center; + background-color: black; + margin-bottom: 0.2em +} \ No newline at end of file diff --git a/print/report/rpt-route/index.html b/print/report/rpt-route/index.html new file mode 100644 index 000000000..727088c82 --- /dev/null +++ b/print/report/rpt-route/index.html @@ -0,0 +1,15 @@ + + + +
+
+ +
{{route.agencyName}}
+
{{route.id}}
+
{{route.plateNumber}} {{routeTime(route.time)}}
+
+ +
+
+ + \ No newline at end of file diff --git a/print/report/rpt-route/index.js b/print/report/rpt-route/index.js new file mode 100755 index 000000000..7048acc2a --- /dev/null +++ b/print/report/rpt-route/index.js @@ -0,0 +1,36 @@ +const strftime = require('strftime'); +const database = require(`${appPath}/lib/database`); +const UserException = require(`${appPath}/lib/exceptions/userException`); + +module.exports = { + name: 'rpt-route', + async asyncData(ctx, params) { + if (!params.routeFk) + throw new UserException('No route id specified'); + + let [[route]] = await this.methods.fetchRoute(params.routeFk); + + if (!route) + throw new UserException('Route not ready'); + + return {route}; + }, + methods: { + fetchRoute(routeFk) { + return database.pool.query( + `SELECT + r.id, + r.time, + am.name agencyName, + v.numberPlate plateNumber + FROM route r + JOIN agencyMode am ON am.id = r.agencyModeFk + JOIN vehicle v ON v.id = r.vehicleFk + WHERE r.id = ?`, [routeFk]); + }, + routeTime: routeTime => { + if (routeTime) + return strftime('%H:%M', routeTime); + }, + }, +}; diff --git a/print/report/rpt-route/locale.js b/print/report/rpt-route/locale.js new file mode 100644 index 000000000..e69de29bb