fixed creating csv

This commit is contained in:
2024-09-27 12:27:54 +02:00
parent bbc34bcfc0
commit 8a2b8c0b20
2 changed files with 19 additions and 2 deletions

View File

@@ -144,7 +144,21 @@ class WarehouseEShopOrderController extends TTCrud {
$rows = [];
foreach ($orders as $order) {
$orderItems = $ordersItems[$order['id']];
$realOrderItems = null;
foreach ($ordersItems as $orderId => $items) {
if ($orderId == $order['id']) {
$realOrderItems = $items;
break;
}
}
// if it is still null, die with order id:
if ($realOrderItems === null) {
self::returnJson(['success' => false, 'message' => 'Bestellung mit ID ' . $order['id'] . ' hat keine Artikel. Bitte überprüfen.']);
die();
}
$orderItems = $realOrderItems;
$orderItemsStr = join('; ', array_map(function ($item) {
$articleTitle = $item['articleTitle'] ?? $item['articlePacketTitle'];
$quantity = $item['quantity'];
@@ -177,7 +191,10 @@ class WarehouseEShopOrderController extends TTCrud {
return Helper::arrayToCsv($rows);
}
die(json_encode($rows));
self::returnJson($rows);
return;
}
protected function getAllOrderItemsPerOrder(): array {

View File

@@ -98,7 +98,7 @@ Vue.component('warehouse-e-shop-order', {
const response = await axios.post(`${window['TT_CONFIG']['BASE_PATH']}/WarehouseEShopOrder/CSVExportNewOrdersMarkAccepted`);
if (response.data.message) {
window.notify('success', response.data.message);
window.notify(response.data.success === true ? 'success' : 'error', response.data.message);
return;
}