diff --git a/application/WarehouseShippingNote/WarehouseShippingNoteController.php b/application/WarehouseShippingNote/WarehouseShippingNoteController.php index fda2e9335..8b7913141 100644 --- a/application/WarehouseShippingNote/WarehouseShippingNoteController.php +++ b/application/WarehouseShippingNote/WarehouseShippingNoteController.php @@ -421,7 +421,13 @@ class WarehouseShippingNoteController extends TTCrud { $shippingNote['status'] = $status; WarehouseShippingNoteModel::update($shippingNote); - self::returnJson(['success' => true, 'message' => 'Status wurde geändert']); + $statusNiceText = [ + 'new' => 'Neu', + 'in_progress' => 'In Bearbeitung', + 'accepted' => 'Akzeptiert', + 'invoiced' => 'In Rechnung gestellt', + ]; + self::returnJson(['success' => true, 'message' => 'Status wurde auf ' . $statusNiceText[$status] . ' geändert']); } //TODO: either move this to TimerecordingCarController or make it better diff --git a/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js b/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js index 25f6e2309..e4e7c81b4 100644 --- a/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js +++ b/public/js/pages/WarehouseShippingNote/WarehouseShippingNote.js @@ -1,7 +1,48 @@ +// here we need to change window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"] to add actions and this conditions like this: +// +// +// +// + +// inside additionalActions each entry looks like { +// "key": "openHistory", +// "title": "Historie", +// "class": "fas fa-history text-primary" +// } but this is without the condition function + +window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"] = [ + ...window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"], + { + "key": "status_to_progress", + "title": "In Bearbeitung", + "class": "fas fa-cog text-warning", + "condition": (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.status === 'new', + }, + { + "key": "status_to_accepted", + "title": "Akzeptieren", + "class": "fas fa-check text-success", + "condition": (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && (row.status === 'new' || row.status === 'in_progress'), + }, + { + "key": "status_to_invoiced", + "title": "Verrechnet", + "class": "fas fa-file-invoice text-info", + "condition": (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.status === 'accepted', + }, +] + + Vue.component('warehouse-shipping-note-positions', { //language=Vue props: { - positions: Array, + positions: Array, hoursEntries: Array }, data() { return { @@ -20,8 +61,8 @@ Vue.component('warehouse-shipping-note-positions', { {{ position.article ? articleData[position.article]?.text : position.articlePacket ? articlePacketData[position.articlePacket]?.text : position.articleText }} @@ -51,10 +92,12 @@ Vue.component('warehouse-shipping-note', { //language=Vue template: ` - - + @@ -62,6 +105,9 @@ Vue.component('warehouse-shipping-note', { @openHistory="historyModal = true; historyModalId = $event.id" @print="window.open(window.TT_CONFIG['BASE_PATH'] + '/WarehouseShippingNote/createPDF?id=' + $event.id)" @printWithPrice="window.open(window.TT_CONFIG['BASE_PATH'] + '/WarehouseShippingNote/createPDF?id=' + $event.id + '&price=true')" + @status_to_progress="changeStatus($event.id, 'in_progress')" + @status_to_accepted="changeStatus($event.id, 'accepted')" + @status_to_invoiced="changeStatus($event.id, 'invoiced')" @edit="shippingNoteModalId = $event.id" ref="table"> @@ -73,10 +119,10 @@ Vue.component('warehouse-shipping-note', { `, data() { return { - window: window, - historyModal: false, - historyModalId: null, - shippingNoteModalId: null, + window: window, + historyModal: false, + historyModalId: null, + shippingNoteModalId: null, signingShippingNoteId: null } }, @@ -85,5 +131,16 @@ Vue.component('warehouse-shipping-note', { if (window.location.search.includes('doAction=createNew')) { this.shippingNoteModalId = 'create'; } + }, + methods: { + async changeStatus(id, status) { + const response = await axios.post(window.TT_CONFIG.BASE_PATH + '/WarehouseShippingNote/changeStatus', {id, status}); + if (response.data.success) { + this.window.notify('success', response.data.message || 'Erfolgreich aktualisiert'); + this.$refs.table.$refs.table.refreshTable(); + } else { + this.window.notify('error', response.data.message || 'Ein Fehler ist aufgetreten'); + } + }, } }) diff --git a/public/plugins/vue/tt-components/tt-table-crud.js b/public/plugins/vue/tt-components/tt-table-crud.js index 122a867c7..5feca4904 100644 --- a/public/plugins/vue/tt-components/tt-table-crud.js +++ b/public/plugins/vue/tt-components/tt-table-crud.js @@ -29,7 +29,7 @@ Vue.component('tt-table-crud', {