diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index 068ced790..0cbbcad53 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -2018,11 +2018,13 @@ INSERT INTO `vn`.`thermograph`(`id`, `model`)
VALUES
('TMM190901395', 'TEMPMATE'),
('TL.BBA85422', 'TL30'),
- ('TZ1905012010', 'DISPOSABLE');
+ ('TZ1905012010', 'DISPOSABLE'),
+ ('138350-0', 'DISPOSABLE');
INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperature`, `result`, `dmsFk`)
VALUES
- ('TMM190901395', CURDATE(), 1, 1, 'WARM', 'Ok', NULL),
- ('TL.BBA85422', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL),
- ('TL.BBA85422', CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL),
- ('TZ1905012010', CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5);
\ No newline at end of file
+ ('TMM190901395', CURDATE(), 1, 1, 'WARM', 'Ok', NULL),
+ ('TL.BBA85422', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL),
+ ('TL.BBA85422', CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL),
+ ('TZ1905012010', CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5),
+ ('138350-0', CURDATE(), 1, NULL, 'WARM', NULL, 5);
\ No newline at end of file
diff --git a/modules/travel/back/methods/travel-thermograph/uploadFile.js b/modules/travel/back/methods/travel-thermograph/uploadFile.js
new file mode 100644
index 000000000..e5ea465cb
--- /dev/null
+++ b/modules/travel/back/methods/travel-thermograph/uploadFile.js
@@ -0,0 +1,76 @@
+module.exports = Self => {
+ Self.remoteMethodCtx('uploadFile', {
+ description: 'Upload and attach a document',
+ accessType: 'WRITE',
+ accepts: [{
+ arg: 'id',
+ type: 'Number',
+ description: 'The ticket id',
+ http: {source: 'path'}
+ }, {
+ arg: 'warehouseId',
+ type: 'Number',
+ description: 'The warehouse id',
+ required: true
+ }, {
+ arg: 'companyId',
+ type: 'Number',
+ description: 'The company id',
+ required: true
+ }, {
+ arg: 'dmsTypeId',
+ type: 'Number',
+ description: 'The dms type id',
+ required: true
+ }, {
+ arg: 'reference',
+ type: 'String',
+ required: true
+ }, {
+ arg: 'description',
+ type: 'String',
+ required: true
+ }, {
+ arg: 'hasFile',
+ type: 'Boolean',
+ description: 'True if has an attached file',
+ required: true
+ }],
+ returns: {
+ type: 'Object',
+ root: true
+ },
+ http: {
+ path: `/:id/uploadFile`,
+ verb: 'POST'
+ }
+ });
+
+ Self.uploadFile = async(ctx, id) => {
+ const models = Self.app.models;
+ const promises = [];
+ const tx = await Self.beginTransaction({});
+
+ try {
+ const options = {transaction: tx};
+
+ const uploadedFiles = await models.Dms.uploadFile(ctx, options);
+ uploadedFiles.forEach(dms => {
+ const newTicketDms = models.TicketDms.create({
+ ticketFk: id,
+ dmsFk: dms.id
+ }, options);
+
+ promises.push(newTicketDms);
+ });
+ const resolvedPromises = await Promise.all(promises);
+
+ await tx.commit();
+
+ return resolvedPromises;
+ } catch (err) {
+ await tx.rollback();
+ throw err;
+ }
+ };
+};
diff --git a/modules/travel/back/models/travel-thermograph.js b/modules/travel/back/models/travel-thermograph.js
new file mode 100644
index 000000000..8eab0ab7b
--- /dev/null
+++ b/modules/travel/back/models/travel-thermograph.js
@@ -0,0 +1,3 @@
+module.exports = Self => {
+ require('../methods/travel-thermograph/uploadFile')(Self);
+};
diff --git a/modules/travel/front/index.js b/modules/travel/front/index.js
index 4bf935a8c..1f5346e98 100644
--- a/modules/travel/front/index.js
+++ b/modules/travel/front/index.js
@@ -9,5 +9,6 @@ import './summary';
import './basic-data';
import './log';
import './create';
-import './thermograph';
+import './thermograph/index/';
+import './thermograph/create/';
diff --git a/modules/travel/front/locale/es.yml b/modules/travel/front/locale/es.yml
index 31e4e452b..931f79ab8 100644
--- a/modules/travel/front/locale/es.yml
+++ b/modules/travel/front/locale/es.yml
@@ -16,4 +16,4 @@ New travel: Nuevo envío
# Sections
Travels: Envíos
Log: Historial
-Thermographs: Termómetros
\ No newline at end of file
+Thermographs: Termógrafos
\ No newline at end of file
diff --git a/modules/travel/front/routes.json b/modules/travel/front/routes.json
index d7d5b52df..fcbe5b92f 100644
--- a/modules/travel/front/routes.json
+++ b/modules/travel/front/routes.json
@@ -11,7 +11,7 @@
"card": [
{"state": "travel.card.basicData", "icon": "settings"},
{"state": "travel.card.log", "icon": "history"},
- {"state": "travel.card.thermograph", "icon": "icon-thermometer"}
+ {"state": "travel.card.thermograph.index", "icon": "icon-thermometer"}
]
},
"routes": [
@@ -59,14 +59,28 @@
"component": "vn-travel-create",
"description": "New travel"
}, {
- "url" : "/thermograph",
+ "url": "/thermograph",
"state": "travel.card.thermograph",
- "component": "vn-travel-thermograph",
+ "abstract": true,
+ "component": "ui-view"
+ }, {
+ "url" : "/index",
+ "state": "travel.card.thermograph.index",
+ "component": "vn-travel-thermograph-index",
"description": "Thermographs",
"params": {
"travel": "$ctrl.travel"
},
"acl": ["buyer"]
+ }, {
+ "url" : "/create",
+ "state": "travel.card.thermograph.create",
+ "component": "vn-travel-thermograph-create",
+ "description": "Add thermograph",
+ "params": {
+ "travel": "$ctrl.travel"
+ },
+ "acl": ["buyer"]
}
]
}
\ No newline at end of file
diff --git a/modules/travel/front/thermograph/create/index.html b/modules/travel/front/thermograph/create/index.html
new file mode 100644
index 000000000..327c6e629
--- /dev/null
+++ b/modules/travel/front/thermograph/create/index.html
@@ -0,0 +1,80 @@
+