diff --git a/modules/order/back/model-config.json b/modules/order/back/model-config.json index ed0b39e8d..389c97e46 100644 --- a/modules/order/back/model-config.json +++ b/modules/order/back/model-config.json @@ -4,5 +4,8 @@ }, "OrderRow": { "dataSource": "vn" + }, + "OrderTicket": { + "dataSource": "vn" } } diff --git a/modules/order/back/models/order-ticket.json b/modules/order/back/models/order-ticket.json new file mode 100644 index 000000000..2875ebdfc --- /dev/null +++ b/modules/order/back/models/order-ticket.json @@ -0,0 +1,31 @@ +{ + "name": "OrderTicket", + "base": "VnModel", + "options": { + "mysql": { + "table": "orderTicket" + } + }, + "properties": { + "orderFk": { + "id": true, + "type": "Number" + }, + "ticketFk": { + "id": true, + "type": "Number" + } + }, + "relations": { + "ticket": { + "type": "belongsTo", + "model": "Ticket", + "foreignKey": "ticketFk" + }, + "order": { + "type": "belongsTo", + "model": "Order", + "foreignKey": "orderFk" + } + } +} diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index e21993733..4e165f123 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -117,7 +117,7 @@ module.exports = Self => { let orderTickets = []; if (ctx.args && ctx.args.orderFk) { - let ticketsToSearch = await Self.app.models.OrderTickets.find({where: {orderFk: filter.orderFk}}); + let ticketsToSearch = await Self.app.models.OrderTicket.find({where: {orderFk: ctx.args.orderFk}}); ticketsToSearch.forEach(ticket => { orderTickets.push(ticket.ticketFk); }); diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index f52b2591b..878f05b79 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -2,32 +2,37 @@ import ngModule from '../module'; import './style.scss'; export default class Controller { - constructor($scope, $state) { + constructor($scope, $state, $stateparams) { this.$ = $scope; + this.$stateparams = $stateparams; this.$state = $state; this.selectedTicket = null; this.moreOptions = [ {callback: this.goToTurns, name: 'Turns', always: true}, ]; - let today = new Date(); - let offset = today.getTimezoneOffset() * 60000; - today.setHours(0, 0, 0, 0); - today.setTime(today.getTime() - offset); + if (!$state && !$stateparams) { + let today = new Date(); + let offset = today.getTimezoneOffset() * 60000; + today.setHours(0, 0, 0, 0); + today.setTime(today.getTime() - offset); - let tomorrow = new Date(today); - tomorrow.setHours(23, 59, 59, 999); - tomorrow.setTime(tomorrow.getTime() - offset); + let tomorrow = new Date(today); + tomorrow.setHours(23, 59, 59, 999); + tomorrow.setTime(tomorrow.getTime() - offset); - let sixDays = new Date(today); - sixDays.setDate(today.getDate() + 6); - sixDays.setHours(23, 59, 59, 999); - sixDays.setTime(sixDays.getTime() - offset); - this.filter = {mine: true, from: today, to: sixDays}; + let sixDays = new Date(today); + sixDays.setDate(today.getDate() + 6); + sixDays.setHours(23, 59, 59, 999); + sixDays.setTime(sixDays.getTime() - offset); + + this.filter = {mine: true, from: today, to: sixDays}; + } } $postLink() { - this.onSearch(this.filter); + if (this.filter) + this.onSearch(this.filter); } onSearch(params) {