Updated Shipping Note

This commit is contained in:
Luca Haid
2025-01-21 09:23:10 +01:00
parent 38d5cd1861
commit f5e167d477
3 changed files with 90 additions and 11 deletions

View File

@@ -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

View File

@@ -1,7 +1,48 @@
// here we need to change window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"] to add actions and this conditions like this:
// <button v-if="window.TT_CONFIG['WAREHOUSE_ADMIN'] == true && status === 'new'" class="btn btn-warning" @click="changeStatus('in_progress')">In
// Bearbeitung
// </button>
// <button v-if="window.TT_CONFIG['WAREHOUSE_ADMIN'] == true && (status === 'new' || status === 'in_progress')" class="btn btn-success"
// @click="changeStatus('accepted')">Akzeptieren
// </button>
// <button v-if="window.TT_CONFIG['WAREHOUSE_ADMIN'] == true && status === 'accepted'" class="btn btn-info" @click="changeStatus('invoiced')">
// Verrechnet
// </button>
// <button class="btn btn-info" @click="$emit('open-signing-modal', id)">Unterschreiben</button>
// 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 }}</span>
</li>
<template v-for="entry in hoursEntries">
<li><span>{{ entry.hourCount }}h Arbeitszeit</span></li>
<li v-if="entry.carId">{{entry.kilometerCount}}km Anfahrt</li>
<li><span>{{ entry.hourCount }}h Arbeitszeit</span></li>
<li v-if="entry.carId">{{ entry.kilometerCount }}km Anfahrt</li>
</template>
</ul>
</div>
@@ -51,10 +92,12 @@ Vue.component('warehouse-shipping-note', {
//language=Vue
template: `
<tt-card>
<warehouse-shipping-note-modal v-if="shippingNoteModalId" :id="shippingNoteModalId" @close="shippingNoteModalId = null;$refs.table.$refs.table.refreshTable()"
<warehouse-shipping-note-modal v-if="shippingNoteModalId" :id="shippingNoteModalId"
@close="shippingNoteModalId = null;$refs.table.$refs.table.refreshTable()"
@open-signing-modal="signingShippingNoteId = $event"/>
<warehouse-history-modal :show.sync="historyModal" :id="historyModalId"/>
<warehouse-shipping-note-signature-pad v-if="signingShippingNoteId" :shipping-note-id="signingShippingNoteId" @close="signingShippingNoteId = null"/>
<warehouse-shipping-note-signature-pad v-if="signingShippingNoteId" :shipping-note-id="signingShippingNoteId"
@close="signingShippingNoteId = null"/>
<button @click="shippingNoteModalId = 'create'" class="btn btn-primary">Lieferschein erstellen</button>
@@ -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', {
</tt-card>
`, 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');
}
},
}
})

View File

@@ -29,7 +29,7 @@ Vue.component('tt-table-crud', {
<template v-slot:actions="{ row }">
<!-- calculate min width 1 + number of actions * 19 -->
<div style="display: flex; justify-content: space-around; align-items: center;"
:style="{minWidth: (1 + crudConfig?.additionalActions?.length || 0) * 19 + 'px'}">
:style="{minWidth: calculateMinActionsWidth(row)}">
<a style="cursor: pointer;" @click="openCrudModal(row)"><i class="far fa-edit text-primary"
title="Editieren"></i></a>
@@ -154,6 +154,22 @@ Vue.component('tt-table-crud', {
}
this.$set(this, 'crudModalColumnVisibility', crudModalColumnVisibility)
},
calculateMinActionsWidth(row) {
// Base width for the edit action
let minWidth = 19;
// Check additional actions
if (this.crudConfig && this.crudConfig.additionalActions) {
this.crudConfig.additionalActions.forEach(action => {
// Add width if action is visible (no condition or condition is true)
if (!action.condition || action.condition(row)) {
minWidth += 19;
}
});
}
return `${minWidth}px`;
}
}, computed: {
tableConfig() {