diff --git a/application/WarehouseOrderRequest/WarehouseOrderRequestController.php b/application/WarehouseOrderRequest/WarehouseOrderRequestController.php
index 92ac0dd6c..77f80c571 100644
--- a/application/WarehouseOrderRequest/WarehouseOrderRequestController.php
+++ b/application/WarehouseOrderRequest/WarehouseOrderRequestController.php
@@ -41,6 +41,7 @@ class WarehouseOrderRequestController extends TTCrud {
'table' => ['filter' => 'select'],
'modal' => ['type' => 'select', 'items' => []]],
['key' => 'warehouseLocation', 'text' => 'Lagerort', 'required' => false, 'type' => 'varchar'],
+ ['key' => 'canceled', 'text' => 'Storniert', 'required' => false, 'modal' => ['visible' => false, 'type' => 'select', 'items' => [['value' => 0, 'text' => 'Nein'], ['value' => 1, 'text' => 'Ja']]], 'table' => ['filter' => 'select']],
['key' => 'note', 'text' => 'Notiz', 'required' => false, 'type' => 'textarea'],
['key' => 'actions',
'text' => 'Aktionen',
@@ -133,6 +134,38 @@ class WarehouseOrderRequestController extends TTCrud {
$email->send();
}
+ protected function cancelAction() {
+ $id = $this->request->id;
+ $cancel = $this->request->cancel;
+
+ if (!is_numeric($id) || !is_numeric($cancel)) {
+ self::returnJson(['error' => 'Invalid request']);
+ }
+
+ $order = (array) WarehouseOrderRequestModel::get($id);
+
+ if (empty($order)) {
+ self::returnJson(['error' => 'Order not found']);
+ }
+
+ // $cancel is either 0 for uncancelling or 1 for cancelling
+
+ if ($cancel == 1) {
+ $order['canceled'] = 1;
+ } else {
+ $order['canceled'] = 0;
+ }
+
+ $order['id'] = $id;
+
+ if (!WarehouseOrderRequestModel::update($order)) {
+ self::returnJson(['error' => 'Error updating order']);
+ }
+
+ self::returnJson(['success' => true, 'message' => 'Order updated']);
+
+ }
+
protected function getHistoryAction() {
$this->prepareCrudConfig();
self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
diff --git a/application/WarehouseOrderRequest/WarehouseOrderRequestModel.php b/application/WarehouseOrderRequest/WarehouseOrderRequestModel.php
index 68a4654dc..880ab484a 100644
--- a/application/WarehouseOrderRequest/WarehouseOrderRequestModel.php
+++ b/application/WarehouseOrderRequest/WarehouseOrderRequestModel.php
@@ -15,5 +15,6 @@ class WarehouseOrderRequestModel extends TTCrudBaseModel {
public ?string $warehouseLocation;
public ?string $note;
+ public ?int $canceled;
}
diff --git a/db/migrations/20250128090000_warehouse_modify_9.php b/db/migrations/20250128090000_warehouse_modify_9.php
new file mode 100644
index 000000000..3c7b8c887
--- /dev/null
+++ b/db/migrations/20250128090000_warehouse_modify_9.php
@@ -0,0 +1,24 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("WarehouseOrderRequest");
+ $table->addColumn("canceled", "integer", ["null" => false, "default" => 0]);
+ $table->save();;
+ }
+ }
+
+ public function down(): void
+ {
+ if ($this->getEnvironment() == "thetool") {
+ $table = $this->table("WarehouseOrderRequest");
+ $table->removeColumn("canceled");
+ $table->save();;
+ }
+ }
+}
diff --git a/public/js/pages/WarehouseOrderRequest/WarehouseOrderRequest.js b/public/js/pages/WarehouseOrderRequest/WarehouseOrderRequest.js
index 5216621ba..a767a575c 100644
--- a/public/js/pages/WarehouseOrderRequest/WarehouseOrderRequest.js
+++ b/public/js/pages/WarehouseOrderRequest/WarehouseOrderRequest.js
@@ -1,21 +1,46 @@
window.localStorage.setItem('tt-table-WarehouseOrderRequest', JSON.stringify({
filters: {
- takeOverBy: null
+ takeOverBy: null,
+ canceled: 0
}
}));
+window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"] = [
+ ...window.TT_CONFIG["CRUD_CONFIG"]["additionalActions"],
+ {
+ "key": "cancel",
+ "title": "Bestellwunsch stornieren",
+ "class": "fas fa-times text-danger",
+ "condition": (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.canceled === 0,
+ },
+ {
+ "key": "uncancel",
+ "title": "Bestellwunsch wiederherstellen",
+ "class": "fas fa-check text-success",
+ "condition": (row) => window.TT_CONFIG['WAREHOUSE_ADMIN'] === '1' && row.canceled === 1,
+ },
+]
+
Vue.component('warehouse-order-request', {
//language=Vue
template: `
-
+
-
+
@@ -41,13 +66,14 @@ Vue.component('warehouse-order-request', {
`, data() {
return {
- window: window, historyModal: false, historyModalId: null, showHiddenRequests: false
+ window: window, historyModal: false, historyModalId: null, showHiddenRequests: false, showCanceledRequests: false
}
},
async mounted() {
if (this.window.TT_CONFIG.WAREHOUSE_ADMIN !== '1') return
this.$refs.crud.$watch('crudModal', (value) => {
+ return
if (value) {
// if id is not 'create' then check if order is set and if not set it to current date
// if order is set then check if takeover is set and if not set it to current date
@@ -70,10 +96,32 @@ Vue.component('warehouse-order-request', {
}
})
},
+ methods: {
+ // portected function cancelAction() {
+ // $id = $this->request->id;
+ // $cancel = $this->request->cancel;
+ async cancelOrderRequest(row, cancel) {
+ if (!window.confirm('Bestellwunsch wirklich stornieren?')) return
+
+ const response = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/WarehouseOrderRequest/cancel?id=' + row.id + '&cancel=' + cancel);
+ if (response.data.success) {
+ this.window.notify('success', response.data.message || 'Erfolgreich aktualisiert')
+ this.$refs.crud.$refs.table.refresh()
+ return
+ }
+ this.window.notify('error', response.data.message || 'Fehler beim aktualisieren')
+ }
+ },
watch: {
- showHiddenRequests(value) {
- // set filter data inside table takeOverBy to !NULL
+ async showHiddenRequests(value) {
+ this.showCanceledRequests = false
+ this.$refs.crud.$refs.table.$set(this.$refs.crud.$refs.table.filters, 'canceled', '')
this.$refs.crud.$refs.table.$set(this.$refs.crud.$refs.table.filters, 'takeOverBy', value ? '' : null)
+ },
+ async showCanceledRequests(value) {
+ this.showHiddenRequests = false
+ this.$refs.crud.$refs.table.$set(this.$refs.crud.$refs.table.filters, 'canceled', value ? '1' : '')
+ this.$refs.crud.$refs.table.$set(this.$refs.crud.$refs.table.filters, 'takeOverBy', '')
}
}
})
diff --git a/public/plugins/vue/tt-components/tt-table-crud.js b/public/plugins/vue/tt-components/tt-table-crud.js
index 5feca4904..0df34a368 100644
--- a/public/plugins/vue/tt-components/tt-table-crud.js
+++ b/public/plugins/vue/tt-components/tt-table-crud.js
@@ -20,10 +20,10 @@ Vue.component('tt-table-crud', {
:name="column.key.toLowerCase()" :row="row">
- {{column.modal.items.find(item => item.value == row[column.key]).text}}
+ {{column.modal.items.find(item => item.value == row[column.key]).text}}
Select not found for column {{column.key}} and value {{row[column.key]}}
+ >Select not found for column {{column.key}} and value {{row[column.key]}} {{typeof row[column.key]}}