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' && ['new', 'on_hold'].includes(row.status), }, { "key": "status_to_accepted", "title": "Akzeptieren", "class": "fas fa-check text-success", "condition": (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && ['new', 'in_progress', 'on_hold'].includes(row.status), }, { "key": "status_to_invoiced", "title": "Verrechnet", "class": "fas fa-file-invoice text-info", "condition": (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && ['in_progress', 'accepted', 'on_hold'].includes(row.status), }, { "key": "status_to_on_hold", "title": "On Hold", "class": "fas fa-pause text-warning", "condition": (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && ['accepted', 'new', 'in_progress'].includes(row.status), }, { "key": "status_to_cancelled", "title": "Storniert", "class": "fas fa-ban text-danger", "condition": (row) => (window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && ['new', 'in_progress', 'accepted'].includes(row.status)) || (row.status === 'new' && row.signature === null), }, { "key": "status_to_new", "title": "Lieferschein wiedereröffnen", "class": "fas fa-redo-alt text-success", "condition": (row) => (window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.status === 'cancelled'), }, { "key": "add_log", "title": "Log Eintrag hinzufügen", "class": "fas fa-plus text-primary", }, { "key": "print", "title": "Drucken", "class": "fas fa-print text-primary", } ] // normal regie 50% 100% window.TT_CONFIG["CRUD_CONFIG"]["editCondition"] = (row) => row.status === 'new' && row.signature === null || window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1'; Vue.component('warehouse-shipping-note-positions', { //language=Vue props: { positions: Array, hoursEntries: Array }, data() { return { articleData: {}, loading: false, articlePacketData: {}, userData: {} } }, template: `
`, async mounted() { this.loading = true; for (const position of this.positions) { if (position.article) { const response = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/WarehouseArticle/autoComplete?searchedID=' + position.article); this.$set(this.articleData, position.article, response.data[0]); } else if (position.articlePacket) { const response = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/WarehouseArticlePacket/autoComplete?searchedID=' + position.articlePacket); this.$set(this.articlePacketData, position.articlePacket, response.data[0]); } } for (const entry of this.hoursEntries) { if (entry.userId) { const response = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/WarehouseShippingNote/userAutoComplete?searchedID=' + entry.userId); this.$set(this.userData, entry.userId, response.data[0]); } } this.loading = false; } }) Vue.component('add-log-modal-sn', { props: { shippingNoteId: {type: Number, required: true}, }, data() { return { window: window, note: '', file: null, uploadedFiles: [], submitLoading: false }; }, methods: { async handleFileUpload(event) { const files = event.target.files; if (!files.length) return; for (let i = 0; i < files.length; i++) { const file = files[i]; const formData = new FormData(); formData.append('file', file); try { const response = await axios.post(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseShippingNote/uploadFile`, formData, { headers: { 'Content-Type': 'multipart/form-data' } }); if (response.data.success) { this.uploadedFiles.push({ id: response.data.fileId, name: file.name }); window.notify('success', `File "${file.name}" uploaded successfully`); } else { window.notify('error', `File "${file.name}" upload failed: ${response.data.error || 'Unknown error'}`); } } catch (error) { window.notify('error', `Error uploading file "${file.name}"`); } } // Clear the file input event.target.value = ''; }, removeFile: index => this.uploadedFiles.splice(index, 1), async submit() { this.submitLoading = true; const fileIds = this.uploadedFiles.map(file => file.id); const response = await axios.post(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseShippingNote/createNewLogAction`, { shippingNoteId: this.shippingNoteId, note: this.note, fileIds: JSON.stringify(fileIds), }); if (response.data.success) { this.$emit('close'); window.notify('success', response.data.message ?? 'Log Eintrag erfolgreich erstellt'); } else { window.notify('error', response.data.errors ? Object.values(response.data.errors).join('
') : response.data.message || 'Ein Fehler ist aufgetreten'); } this.submitLoading = false; }, }, template: ` ` }) Vue.component('tt-file', { props: ['id'], data: () => ({file: null}), async mounted() { const response = await axios.get(`${window.TT_CONFIG.BASE_PATH}/File/getById`, {params: {id: this.id}}); this.file = response.data; }, template: `
{{ file.filename }}
` }) Vue.component('warehouse-shipping-note-logs', { props: { shippingNoteId: {type: Number, required: true}, }, data() { return { logs: [], loading: false, }; }, //language=Vue template: `
{{ formatDate(log.create) }} ({{ getUserName(log.createBy) }}) | {{ log.message }}
`, async mounted() { this.loading = true; const response = await axios.get(window.TT_CONFIG.BASE_PATH + '/WarehouseShippingNote/getLog', {params: {shippingNoteId: this.shippingNoteId}}); this.logs = response.data; this.loading = false; }, methods: { formatDate: date => window.moment(date * 1000).format('DD.MM.YYYY HH:mm'), getUserName: id => window.TT_CONFIG.CRUD_CONFIG.columns.find(col => col.key === 'createBy')?.modal.items.find(u => u.value === id)?.text } }) Vue.component('warehouse-shipping-note-see-through', { props: ['wantedState'], //language=Vue template: ` `, data() { return { logModalKey: 0, currentPage: 1, perPage: 1, rows: [], activeTab: 'Editieren', window: window } }, computed: { currentRow() { return this.rows[0]; } }, methods: { tabStyle(tab) { return { padding: '10px 20px', cursor: 'pointer', backgroundColor: this.activeTab === tab ? '#005384' : '#f7c423', color: 'white', border: 'none', borderRadius: '5px', marginRight: '10px' }; }, previousNote() { if (this.currentPage > 1) { this.currentPage--; this.fetchData(); } }, nextNote() { if (this.currentPage) { this.currentPage++; this.fetchData(); } }, async changeStatus(action, row) { this.$emit(action, row); await new Promise(resolve => setTimeout(resolve, 50)); await this.fetchData(); }, async fetchData() { this.loading = true; this.rows = []; const response = await axios.post(window.TT_CONFIG.BASE_PATH + '/WarehouseShippingNote/get', { pagination: {page: this.currentPage, per_page: this.perPage}, filters: {status: this.wantedState}, }) this.rows = response.data.rows; if (this.rows.length === 0) { this.$emit('close'); this.window.notify('info', 'Keine Lieferscheine mit diesem Status gefunden'); } this.loading = false; }, async saveAndSetToProgress() { await this.$refs.modal.submit('in_progress'); await new Promise(resolve => setTimeout(resolve, 50)); await this.fetchData(); } }, mounted() { this.fetchData(); } }); // noinspection JSUnusedLocalSymbols Vue.component('warehouse-shipping-note', { //language=Vue template: ` `, data() { return { window: window, historyModal: false, historyModalId: null, shippingNoteModalId: null, signingShippingNoteId: null, addLogModalId: null, shippingNoteSeeThrough: false } }, mounted() { // check if get parameter doAction = createNew is set, if so open the modal with 'create' as id 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'); } }, } }) window.addEventListener('DOMContentLoaded', () => { if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/WarehouseShippingNote/sw', { scope: '/' }) .then(registration => { console.log('Patching PWA Service Worker registered with scope:', registration.scope); }) .catch(error => { console.error('Patching PWA Service Worker registration failed:', error); }); } })