diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 3a5d5f8a6..694b3eb33 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -138,12 +138,28 @@ + ng-click="$ctrl.createTicket()"> New ticket without route + ng-click="selectRoute.show()"> New ticket with route - \ No newline at end of file + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 38d02f548..d80c8e812 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -26,6 +26,23 @@ class Controller extends Section { get totalChecked() { return this.checked.length; } + + createTicket(routeFk) { + const tomorrow = new Date(); + const params = { + clientId: this.ticket.clientFk, + landed: tomorrow.getDay() + 1, + addressId: this.ticket.addressFk, + agencyModeId: this.ticket.agencyModeFk, + warehouseId: this.ticket.warehouseFk + }; + const query = `Tickets/new`; + this.$http.post(query, params).then(res => { + if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); + this.vnApp.showSuccess(this.$t('Data saved!')); + this.$state.go('ticket.card.summary', {id: res.data.id}); + }); + } } ngModule.vnComponent('vnTicketExpedition', {