diff --git a/db/changes/10250-curfew/00-travelDetail.sql b/db/changes/10250-curfew/00-travelDetail.sql
new file mode 100644
index 000000000..673044b9e
--- /dev/null
+++ b/db/changes/10250-curfew/00-travelDetail.sql
@@ -0,0 +1,94 @@
+drop procedure `vn2008`.travelDetail;
+
+create definer = root@`%` procedure `vn2008`.travelDetail__()
+BEGIN
+
+ DECLARE vDateFrom DATE DEFAULT TIMESTAMPADD(WEEK,-12,CURDATE());
+
+ SELECT IFNULL(CONCAT(" ",Entrada),travel) travelAndEntry,
+ travel,
+ Entrada,
+ IsTravel,
+ Agencia,
+ ref,
+ shipment,
+ OrigenCajas,
+ landing,
+ Destino,
+ Etiquetas,
+ Notas_Eva,
+ kg,
+ loadedKg,
+ volumeKg,
+ loadPriority,
+ Notas,
+ Carguera
+ FROM(SELECT
+ 1 as IsTravel,
+ tr.id as travel,
+ NULL as Entrada,
+ ag.Agencia,
+ tr.ref,
+ tr.shipment,
+ wo.name as OrigenCajas,
+ tr.landing,
+ w.name as Destino,
+ sum(c.Etiquetas) as Etiquetas,
+ NULL as Notas_Eva,
+ kg,
+ cast(sum(a.density * c.Etiquetas * IF(cb.Volumen, cb.Volumen, cb.X * cb.Y * cb.Z) / 1000000 ) as DECIMAL(10,0)) as loadedKg,
+ cast(sum(167.5 * c.Etiquetas * IF(cb.Volumen, cb.Volumen, cb.X * cb.Y * cb.Z) / 1000000 ) as DECIMAL(10,0)) as volumeKg,
+ NULL as loadPriority,
+ NULL as Notas,
+ pc.Alias as Carguera
+ FROM travel tr
+ LEFT JOIN Proveedores pc ON pc.Id_Proveedor = tr.cargoSupplierFk
+ LEFT JOIN Entradas e ON e.travel_id = tr.id
+ LEFT JOIN Compres c ON c.Id_Entrada = e.Id_Entrada
+ LEFT JOIN Cubos cb ON cb.Id_Cubo = c.Id_Cubo
+ LEFT JOIN Articles a ON a.Id_Article = c.Id_Article
+ LEFT JOIN Tipos tp ON tp.tipo_id = a.tipo_id
+ JOIN warehouse w ON w.id = tr.warehouse_id
+ JOIN warehouse wo ON wo.id = tr.warehouse_id_out
+ JOIN Agencias ag ON ag.Id_Agencia = tr.agency_id
+ WHERE tr.landing >= vDateFrom AND (wo.name="Colombia" OR wo.name="Ecuador")
+ GROUP BY tr.id
+
+ UNION ALL
+
+ SELECT
+ 0 as IsTravel,
+ e.travel_id as travel,
+ e.Id_Entrada,
+ p.Proveedor,
+ e.Referencia,
+ tr.shipment,
+ wo.name as OrigenCajas,
+ tr.landing,
+ w.name as Destino,
+ sum(Etiquetas) as Etiquetas,
+ e.Notas_Eva,
+ NULL as kg,
+ cast(sum(a.density * c.Etiquetas * IF(cb.Volumen, cb.Volumen, cb.X * cb.Y * cb.Z) / 1000000 ) as DECIMAL(10,0)) as loadedkg,
+ cast(sum(167.5 * c.Etiquetas * IF(cb.Volumen, cb.Volumen, cb.X * cb.Y * cb.Z) / 1000000 ) as DECIMAL(10,0)) as volumeKg,
+ loadPriority,
+ e.Notas,
+ pc.Alias as carguera
+
+ FROM Entradas e
+ JOIN Compres c ON c.Id_Entrada = e.Id_Entrada
+ JOIN Cubos cb ON cb.Id_Cubo = c.Id_Cubo
+ JOIN Articles a ON a.Id_Article = c.Id_Article
+ JOIN Tipos tp ON tp.tipo_id = a.tipo_id
+ JOIN Proveedores p ON p.Id_Proveedor = e.Id_Proveedor
+ JOIN travel tr ON tr.id = e.travel_id
+ LEFT JOIN Proveedores pc ON pc.Id_Proveedor = tr.cargoSupplierFk
+ JOIN warehouse w ON w.id = tr.warehouse_id
+ JOIN warehouse wo ON wo.id = tr.warehouse_id_out
+ WHERE tr.landing >= vDateFrom AND (wo.name="Colombia" OR wo.name="Ecuador")
+ GROUP BY e.Id_Entrada
+ ) sub
+ ORDER BY landing ASC, shipment ASC,travel, IsTravel DESC, (loadPriority > 0) DESC,loadPriority, Agencia, Notas_Eva ;
+
+END;
+
diff --git a/front/core/components/table/style.scss b/front/core/components/table/style.scss
index 7dd69d89f..8d35c374c 100644
--- a/front/core/components/table/style.scss
+++ b/front/core/components/table/style.scss
@@ -22,28 +22,7 @@ vn-table {
& > * > vn-th[field] {
position: relative;
overflow: visible;
- cursor: pointer;
-
- &.active > :after {
- color: $color-font;
- opacity: 1;
- }
- &.desc > :after {
- content: 'arrow_drop_down';
- }
- &.asc > :after {
- content: 'arrow_drop_up';
- }
- & > :after {
- font-family: 'Material Icons';
- content: 'arrow_drop_down';
- position: absolute;
- color: $color-spacer;
- opacity: 0;
- }
- &:hover > :after {
- opacity: 1;
- }
+ cursor: pointer
}
}
& > vn-tbody,
diff --git a/front/core/components/th/index.html b/front/core/components/th/index.html
index 28d80695d..281c6866c 100644
--- a/front/core/components/th/index.html
+++ b/front/core/components/th/index.html
@@ -1,3 +1 @@
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/front/core/components/th/index.js b/front/core/components/th/index.js
index b8260bd74..838431714 100644
--- a/front/core/components/th/index.js
+++ b/front/core/components/th/index.js
@@ -1,10 +1,19 @@
import ngModule from '../../module';
+import Component from '../../lib/component';
+import './style.scss';
+
+export default class Th extends Component {
+ constructor($element, $, $transclude) {
+ super($element, $);
-export default class Th {
- constructor($element) {
this._order = 'ASC';
this.column = $element[0];
$element.on('click', () => this.onToggleOrder());
+
+ $transclude($clone => {
+ const text = this.$t($clone.text()); // Not updating translations
+ $element.append(text ? text : $clone);
+ });
}
/**
@@ -54,7 +63,6 @@ export default class Th {
else
this.table.setOrder(this.field, this.order);
-
this.updateArrow();
this.table.applyOrder(this.field, this.order);
@@ -73,10 +81,9 @@ export default class Th {
}
}
-Th.$inject = ['$element'];
+Th.$inject = ['$element', '$scope', '$transclude'];
ngModule.vnComponent('vnTh', {
- template: require('./index.html'),
transclude: true,
controller: Th,
bindings: {
diff --git a/front/core/components/th/style.scss b/front/core/components/th/style.scss
new file mode 100644
index 000000000..6f575a02e
--- /dev/null
+++ b/front/core/components/th/style.scss
@@ -0,0 +1,33 @@
+@import "effects";
+@import "variables";
+
+vn-th {
+ font-weight: normal;
+}
+
+vn-th[field] {
+ &.active:after {
+ color: $color-font;
+ opacity: 1;
+ }
+ &.desc:after {
+ content: 'arrow_drop_down';
+ }
+ &.asc:after {
+ content: 'arrow_drop_up';
+ }
+
+ &:after {
+ font-family: 'Material Icons';
+ content: 'arrow_drop_down';
+ position: absolute;
+ color: $color-spacer;
+ font-size: 1.5em;
+ margin-top: -2px;
+ opacity: 0
+
+ }
+ &:hover:after {
+ opacity: 1;
+ }
+}
\ No newline at end of file
diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json
index 56f1eef4f..65bf15fa4 100644
--- a/modules/entry/back/models/buy.json
+++ b/modules/entry/back/models/buy.json
@@ -34,9 +34,6 @@
"stickers": {
"type": "number"
},
- "packageFk": {
- "type": "number"
- },
"groupingMode": {
"type": "number"
},
@@ -68,6 +65,11 @@
"model": "Item",
"foreignKey": "itemFk",
"required": true
- }
+ },
+ "package": {
+ "type": "belongsTo",
+ "model": "Packaging",
+ "foreignKey": "packageFk"
+ }
}
}
\ No newline at end of file
diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js
new file mode 100644
index 000000000..5b095328b
--- /dev/null
+++ b/modules/travel/back/methods/travel/extraCommunityFilter.js
@@ -0,0 +1,227 @@
+
+const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
+const buildFilter = require('vn-loopback/util/filter').buildFilter;
+const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
+
+module.exports = Self => {
+ Self.remoteMethodCtx('extraCommunityFilter', {
+ description: 'Find all instances of the model matched by filter from the data source.',
+ accessType: 'READ',
+ accepts: [
+ {
+ arg: 'filter',
+ type: 'Object',
+ description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
+ http: {source: 'query'}
+ }, {
+ arg: 'search',
+ type: 'String',
+ description: 'Searchs the travel by id',
+ http: {source: 'query'}
+ }, {
+ arg: 'id',
+ type: 'Integer',
+ description: 'The travel id',
+ http: {source: 'query'}
+ }, {
+ arg: 'shippedFrom',
+ type: 'Date',
+ description: 'The shipped from date filter',
+ http: {source: 'query'}
+ }, {
+ arg: 'shippedTo',
+ type: 'Date',
+ description: 'The shipped to date filter',
+ http: {source: 'query'}
+ }, {
+ arg: 'landedFrom',
+ type: 'Date',
+ description: 'The landed from date filter',
+ http: {source: 'query'}
+ }, {
+ arg: 'landedTo',
+ type: 'Date',
+ description: 'The landed to date filter',
+ http: {source: 'query'}
+ }, {
+ arg: 'agencyFk',
+ type: 'Number',
+ description: 'The agencyModeFk id',
+ http: {source: 'query'}
+ }, {
+ arg: 'warehouseOutFk',
+ type: 'Number',
+ description: 'The warehouseOutFk filter',
+ http: {source: 'query'}
+ }, {
+ arg: 'warehouseInFk',
+ type: 'Number',
+ description: 'The warehouseInFk filter',
+ http: {source: 'query'}
+ }, {
+ arg: 'totalEntries',
+ type: 'Number',
+ description: 'The totalEntries filter',
+ http: {source: 'query'}
+ }, {
+ arg: 'ref',
+ type: 'string',
+ description: 'The reference'
+ }
+ ],
+ returns: {
+ type: ['Object'],
+ root: true
+ },
+ http: {
+ path: `/extraCommunityFilter`,
+ verb: 'GET'
+ }
+ });
+
+ Self.extraCommunityFilter = async(ctx, filter) => {
+ let conn = Self.dataSource.connector;
+ let where = buildFilter(ctx.args, (param, value) => {
+ switch (param) {
+ case 'search':
+ return /^\d+$/.test(value)
+ ? {'t.id': value}
+ : {'t.ref': {like: `%${value}%`}};
+ case 'ref':
+ return {'t.ref': {like: `%${value}%`}};
+ case 'shippedFrom':
+ return {'t.shipped': {gte: value}};
+ case 'shippedTo':
+ return {'t.shipped': {lte: value}};
+ case 'landedFrom':
+ return {'t.landed': {gte: value}};
+ case 'landedTo':
+ return {'t.landed': {lte: value}};
+ case 'id':
+ case 'agencyFk':
+ case 'warehouseOutFk':
+ case 'warehouseInFk':
+ case 'totalEntries':
+ param = `t.${param}`;
+ return {[param]: value};
+ }
+ });
+
+ filter = mergeFilters(ctx.args.filter, {where});
+
+ let stmts = [];
+ let stmt;
+ stmt = new ParameterizedSQL(
+ `SELECT
+ tr.id,
+ tr.ref,
+ tr.shipped,
+ tr.landed,
+ tr.kg,
+ am.id AS agencyModeFk,
+ am.name AS agencyModeName,
+ wo.id AS warehouseOutFk,
+ wo.name AS warehouseOutName,
+ w.name AS warehouseInFk,
+ w.name AS warehouseInName,
+ SUM(b.stickers) AS stickers,
+ s.id AS supplierFk,
+ s.nickname AS supplierNickname
+ FROM travel tr
+ LEFT JOIN supplier s ON s.id = tr.cargoSupplierFk
+ LEFT JOIN entry e ON e.travelFk = tr.id
+ LEFT JOIN buy b ON b.entryFk = e.id
+ LEFT JOIN packaging p ON p.id = b.packageFk
+ LEFT JOIN item i ON i.id = b.itemFk
+ LEFT JOIN itemType it ON it.id = i.typeFk
+ JOIN warehouse w ON w.id = tr.warehouseInFk
+ JOIN warehouse wo ON wo.id = tr.warehouseOutFk
+ JOIN agencyMode am ON am.id = tr.agencyFk`
+ );
+
+ /* cast(sum(a.density * c.Etiquetas * IF(cb.Volumen, cb.Volumen, cb.X * cb.Y * cb.Z) / 1000000 ) as DECIMAL(10,0)) as loadedKg,
+ cast(sum(167.5 * c.Etiquetas * IF(cb.Volumen, cb.Volumen, cb.X * cb.Y * cb.Z) / 1000000 ) as DECIMAL(10,0)) as volumeKg,
+ pc.Alias as Carguera */
+
+ // WHERE tr.landing >= @vDateFrom AND (wo.name="Colombia" OR wo.name="Ecuador")
+
+ stmt.merge('GROUP BY tr.id');
+ // stmt.merge(conn.makeSuffix(filter));
+ const itemsIndex = stmts.push(stmt) - 1;
+
+ const sql = ParameterizedSQL.join(stmts, ';');
+ const result = await conn.executeStmt(sql);
+ return itemsIndex === 0 ? result : result[itemsIndex];
+
+ /*
+ SET @vDateFrom:= TIMESTAMPADD(WEEK,-12,CURDATE());
+
+ SELECT
+ 1 as IsTravel,
+ tr.id as travel,
+ NULL as Entrada,
+ ag.Agencia,
+ tr.ref,
+ tr.shipment,
+ wo.name as OrigenCajas,
+ tr.landing,
+ w.name as Destino,
+ sum(c.Etiquetas) as Etiquetas,
+ NULL as Notas_Eva,
+ kg,
+ cast(sum(a.density * c.Etiquetas * IF(cb.Volumen, cb.Volumen, cb.X * cb.Y * cb.Z) / 1000000 ) as DECIMAL(10,0)) as loadedKg,
+ cast(sum(167.5 * c.Etiquetas * IF(cb.Volumen, cb.Volumen, cb.X * cb.Y * cb.Z) / 1000000 ) as DECIMAL(10,0)) as volumeKg,
+ NULL as loadPriority,
+ NULL as Notas,
+ pc.Alias as Carguera
+ FROM travel tr
+ LEFT JOIN Proveedores pc ON pc.Id_Proveedor = tr.cargoSupplierFk
+ LEFT JOIN Entradas e ON e.travel_id = tr.id
+ LEFT JOIN Compres c ON c.Id_Entrada = e.Id_Entrada
+ LEFT JOIN Cubos cb ON cb.Id_Cubo = c.Id_Cubo
+ LEFT JOIN Articles a ON a.Id_Article = c.Id_Article
+ LEFT JOIN Tipos tp ON tp.tipo_id = a.tipo_id
+ JOIN warehouse w ON w.id = tr.warehouse_id
+ JOIN warehouse wo ON wo.id = tr.warehouse_id_out
+ JOIN Agencias ag ON ag.Id_Agencia = tr.agency_id
+ WHERE tr.landing >= @vDateFrom AND (wo.name="Colombia" OR wo.name="Ecuador")
+ GROUP BY tr.id
+
+ UNION ALL
+
+ SELECT
+ 0 as IsTravel,
+ e.travel_id as travel,
+ e.Id_Entrada,
+ p.Proveedor,
+ e.Referencia,
+ tr.shipment,
+ wo.name as OrigenCajas,
+ tr.landing,
+ w.name as Destino,
+ sum(Etiquetas) as Etiquetas,
+ e.Notas_Eva,
+ NULL as kg,
+ cast(sum(a.density * c.Etiquetas * IF(cb.Volumen, cb.Volumen, cb.X * cb.Y * cb.Z) / 1000000 ) as DECIMAL(10,0)) as loadedkg,
+ cast(sum(167.5 * c.Etiquetas * IF(cb.Volumen, cb.Volumen, cb.X * cb.Y * cb.Z) / 1000000 ) as DECIMAL(10,0)) as volumeKg,
+ loadPriority,
+ e.Notas,
+ pc.Alias as carguera
+
+ FROM Entradas e
+ JOIN Compres c ON c.Id_Entrada = e.Id_Entrada
+ JOIN Cubos cb ON cb.Id_Cubo = c.Id_Cubo
+ JOIN Articles a ON a.Id_Article = c.Id_Article
+ JOIN Tipos tp ON tp.tipo_id = a.tipo_id
+ JOIN Proveedores p ON p.Id_Proveedor = e.Id_Proveedor
+ JOIN travel tr ON tr.id = e.travel_id
+ LEFT JOIN Proveedores pc ON pc.Id_Proveedor = tr.cargoSupplierFk
+ JOIN warehouse w ON w.id = tr.warehouse_id
+ JOIN warehouse wo ON wo.id = tr.warehouse_id_out
+ WHERE tr.landing >= @vDateFrom AND (wo.name="Colombia" OR wo.name="Ecuador")
+ GROUP BY e.Id_Entrada
+ ) sub
+ ORDER BY landing ASC, shipment ASC,travel, IsTravel DESC, (loadPriority > 0) DESC,loadPriority, Agencia, Notas_Eva ; */
+ };
+};
+
diff --git a/modules/travel/back/models/travel.js b/modules/travel/back/models/travel.js
index b47742c26..b8a1a24b3 100644
--- a/modules/travel/back/models/travel.js
+++ b/modules/travel/back/models/travel.js
@@ -7,6 +7,7 @@ module.exports = Self => {
require('../methods/travel/createThermograph')(Self);
require('../methods/travel/deleteThermograph')(Self);
require('../methods/travel/updateThermograph')(Self);
+ require('../methods/travel/extraCommunityFilter')(Self);
Self.rewriteDbError(function(err) {
if (err.code === 'ER_DUP_ENTRY')
diff --git a/modules/travel/front/extra-community/index.html b/modules/travel/front/extra-community/index.html
index d363f0ce0..1007f223a 100644
--- a/modules/travel/front/extra-community/index.html
+++ b/modules/travel/front/extra-community/index.html
@@ -1,15 +1,32 @@
+ url="Travels/extraCommunityFilter"
+ data="travels">
+
+
+
+
-
diff --git a/modules/travel/front/extra-community/style.scss b/modules/travel/front/extra-community/style.scss
index 55a6eb2ef..5a929908c 100644
--- a/modules/travel/front/extra-community/style.scss
+++ b/modules/travel/front/extra-community/style.scss
@@ -1,6 +1,6 @@
@import "variables";
-vn-item-waste {
+vn-travel-extra-community {
.header {
margin-bottom: 16px;
text-transform: uppercase;
diff --git a/modules/travel/front/index.js b/modules/travel/front/index.js
index 28ec27693..410cbe219 100644
--- a/modules/travel/front/index.js
+++ b/modules/travel/front/index.js
@@ -13,3 +13,4 @@ import './thermograph/index/';
import './thermograph/create/';
import './thermograph/edit/';
import './descriptor-popover';
+import './extra-community';